/* Four Hands.
 *
 * A card room at night: a deep ink-blue table with a faint woven texture, cream cards with a thin
 * inner rule, crimson and near-black inks, and four band colours that are warm and slightly muted.
 * Serif for the title, the rank indices and the verdict; a clean sans for everything read in
 * passing. Dark only, like Clock Out and Cellar: the table is the brand.
 *
 * Every size on the table derives from one number, --cw (a card's width), which the table view
 * computes from the space available. A phone, a sideways phone and the itch frame are the same code.
 *
 * Motion budget, as everywhere in this family: transforms and opacity only, nothing loops, every
 * duration a multiple of --beat, which Full / Fast / Instant set, and reduced motion is honoured.
 */

:root {
  color-scheme: dark;

  --table: #0f1a26;
  --table-hi: #19304a;
  --table-edge: #08111a;
  --panel: #142233;
  --panel-2: #1a2c42;
  --line: rgba(233, 226, 211, 0.14);
  --line-2: rgba(233, 226, 211, 0.26);

  --ink: #ece5d6;
  --ink-2: #bdb5a4;
  --ink-3: #a49d89;          /* 6.4:1 on the table, 4.9:1 under its lit centre: the faintest text allowed */

  --card: #f5eddc;
  --card-hi: #fffaf0;
  --card-lo: #ebdfc6;
  --card-edge: #cdbd9c;
  --card-rule: rgba(140, 108, 58, 0.34);
  --red: #b3202d;
  --black: #1a1c23;
  --gold: #b48a33;

  /* The four bands, easiest to hardest. Warm, a little muted, never toy-bright. */
  --band-0: #e2b84a;
  --band-1: #7db36f;
  --band-2: #6597d8;
  --band-3: #a882d6;
  --band-ink: #18150f;

  --pick: #ffd56e;
  --bad: #ef8a78;
  --good: #9fd38e;
  --good-paper: #3c7434;     /* the same green, dark enough to read on the cream of the end card */
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M1.8 6.4l2.7 2.7 5.7-6' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;

  --beat: 170ms;
  --ease: cubic-bezier(.2, .8, .25, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  /* Springs, for the moments something lands. --spring overshoots about 9% and settles back, the
     way a card dropped on felt has weight; --spring-soft overshoots about 3%, for a sheet arriving
     or a card flying a long way. Both are a damped spring with a push at the start, sampled into
     linear() so they move from the first frame instead of easing in. A spring needs longer than a
     curve to say anything, so --t-spring is three beats - and still nothing when Motion is Instant
     or reduced. Browsers before linear() get the nearest cubic-bezier. Same values in every game in
     the family. */
  --spring: cubic-bezier(.3, 1.35, .5, 1);
  --spring-soft: cubic-bezier(.25, 1.1, .4, 1);
  --t-spring: calc(var(--beat) * 3);

  --cw: 90px;
  --ch: calc(var(--cw) * 1.4);
  --gap: calc(var(--cw) * 0.1);
}

@supports (animation-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.229 3.3%, 0.433 6.7%, 0.606 10%, 0.749 13.3%, 0.862 16.7%, 0.948 20%, 1.01 23.3%, 1.067 28.3%, 1.092 33.3%, 1.089 41.7%, 1.015 66.7%, 0.996 86.7%, 1);
    --spring-soft: linear(0, 0.203 3.3%, 0.375 6.7%, 0.518 10%, 0.636 13.3%, 0.732 16.7%, 0.841 21.7%, 0.916 26.7%, 0.978 33.3%, 1.015 41.7%, 1.028 55%, 1);
  }
}

html[data-motion="fast"] { --beat: 85ms; }
html[data-motion="instant"] { --beat: 0ms; }
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) { --beat: 0ms; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--table-edge);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  /* The felt: a pool of light over the table and a fine cross-weave, gradients only. */
  background:
    radial-gradient(120% 80% at 50% 28%, var(--table-hi) 0%, var(--table) 58%, var(--table-edge) 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px);
}

#app {
  position: relative;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px max(14px, env(safe-area-inset-bottom));
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

/* --- Head ------------------------------------------------------------------------------------ */

.head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.brand {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: 0.005em;
  line-height: 1;
  white-space: nowrap;
}

.brand-suits { display: inline-flex; gap: 2px; }
.brand-suits svg { width: 13px; height: 13px; }
.brand-suits .red { fill: #d9545c; }
.brand-suits .black { fill: var(--ink-2); }

.dealline {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dealline b { color: var(--ink); font-weight: 600; }
.dealline .tier { color: var(--pick); }

.tools { display: flex; gap: 6px; }

.tools button, .actions button, .wide, .end-actions button, .segmented button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--beat) var(--ease), border-color var(--beat) var(--ease),
              translate var(--beat) var(--ease), scale var(--t-spring) var(--spring);
}
.tools .round { width: 38px; padding: 0; font-family: var(--serif); font-weight: 700; font-size: 17px; }

@media (hover: hover) {
  .tools button:hover, .actions button:hover, .wide:hover, .end-actions button:hover, .segmented button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(233, 226, 211, 0.4);
  }
}
/* Everything a finger presses gives a little under it and springs back when it lets go: the press
   is quick, the release is the spring. Its own translate and scale, so the ready nudge on Submit
   (an animation on scale) never fights it. */
.tools button:active, .actions button:active, .wide:active, .end-actions button:active, .segmented button:active,
.big-choice:active, .picker button:active {
  translate: 0 1px;
  scale: 0.95;
  transition-duration: var(--beat);
}

:focus-visible { outline: 2px solid var(--pick); outline-offset: 2px; }

/* --- The four hands to find, and the mistakes ------------------------------------------------- */

.goals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pills {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pills li { display: contents; }
.pill {
  font: inherit;
  background: transparent;
  cursor: help;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background-color calc(var(--beat) * 2) var(--ease), color calc(var(--beat) * 2) var(--ease), border-color calc(var(--beat) * 2) var(--ease),
              scale var(--t-spring) var(--spring);
}
.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.6;
}
@media (hover: hover) { .pill:not(.is-found):hover { border-color: rgba(233, 226, 211, 0.45); color: var(--ink); } }
.pill:active { scale: 0.95; transition-duration: var(--beat); }
.pill.is-found { color: var(--band-ink); border-color: transparent; }
.pill.is-found .dot { background: var(--band-ink); border-color: var(--band-ink); opacity: 0.8; }
.pill.is-found.band-0 { background: var(--band-0); }
.pill.is-found.band-1 { background: var(--band-1); }
.pill.is-found.band-2 { background: var(--band-2); }
.pill.is-found.band-3 { background: var(--band-3); }
/* The hand just found fills its pill and pops: small, a touch too big, settled. The spring makes
   the overshoot, so the keyframes only say where it starts. */
.pill.just-found { animation: pill-pop var(--t-spring) var(--spring); }

@keyframes pill-pop {
  from { scale: 0.8; }
}

.mistakes { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.mistakes-label { font-size: 12px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.chips { display: inline-flex; gap: 5px; }

/* A mistake left is a poker chip; a mistake spent is the empty ring where it was. */
.chip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #d9545c 0 38%, transparent 39%),
    conic-gradient(from 0deg, #f1e7d4 0 12.5%, #c43b45 0 25%, #f1e7d4 0 37.5%, #c43b45 0 50%, #f1e7d4 0 62.5%, #c43b45 0 75%, #f1e7d4 0 87.5%, #c43b45 0);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  transition: transform calc(var(--beat) * 2) var(--ease), opacity calc(var(--beat) * 2) var(--ease);
}
.chip.is-spent {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line-2);
  transform: scale(0.8);
}
.chip.just-spent { animation: chip-lose calc(var(--beat) * 3) var(--ease); }
@keyframes chip-lose {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.25) rotate(-12deg); opacity: 0.9; }
  100% { transform: scale(0.8); opacity: 1; }
}

/* --- The table ------------------------------------------------------------------------------- */

.table {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}

/* --cw is set here and on the help chart, so everything derived from it has to be derived here
   too: a custom property computed on :root would keep :root's card width. */
.felt, .mini-hand { --ch: calc(var(--cw) * 1.4); --gap: calc(var(--cw) * 0.1); }

.felt {
  position: relative;
  width: calc(var(--cw) * 5 + var(--gap) * 4);
  height: calc(var(--ch) * 4 + var(--gap) * 3);
}

.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform-origin: 0 0;
  transform: translate(var(--x, 0px), var(--y, 0px)) scale(var(--s, 1));
  /* A card flying into its band, or closing up beneath it, comes to rest on the soft spring: the
     flight can cross the whole table, so the bigger spring's overshoot would read as a miss. */
  transition: transform var(--t-spring) var(--spring-soft);
  -webkit-appearance: none;
  appearance: none;
  z-index: 1;
}
.card:focus-visible { outline: none; }
.card:focus-visible .face { box-shadow: 0 0 0 3px var(--table), 0 0 0 5px var(--pick), 0 8px 18px rgba(0, 0, 0, 0.4); }
.card.is-locked { cursor: default; z-index: 2; }
.card.is-moving { z-index: 5; }

.face {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: calc(var(--cw) * 0.09);
  background: linear-gradient(168deg, var(--card-hi) 0%, var(--card) 48%, var(--card-lo) 100%);
  box-shadow:
    inset 0 0 0 calc(var(--cw) * 0.045) transparent,
    inset 0 0 0 calc(var(--cw) * 0.052) var(--card-rule),
    0 1.5px 0 var(--card-edge),
    0 calc(var(--cw) * 0.06) calc(var(--cw) * 0.14) rgba(0, 0, 0, 0.42);
  color: var(--black);
  overflow: hidden;
  translate: 0 0;
  transition: translate var(--t-spring) var(--spring), box-shadow calc(var(--beat) * 1.4) var(--ease);
}
.face.red { color: var(--red); }
.face.court {
  box-shadow:
    inset 0 0 0 calc(var(--cw) * 0.045) transparent,
    inset 0 0 0 calc(var(--cw) * 0.056) rgba(180, 138, 51, 0.75),
    0 1.5px 0 var(--card-edge),
    0 calc(var(--cw) * 0.06) calc(var(--cw) * 0.14) rgba(0, 0, 0, 0.42);
}

.index {
  position: absolute;
  left: 7%;
  top: 5%;
  width: 36%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--cw) * 0.02);
}
.rank {
  font-family: var(--serif);
  font-weight: 700;
  font-size: calc(var(--cw) * 0.37);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums;
}
.ten .rank { font-size: calc(var(--cw) * 0.3); letter-spacing: -0.07em; margin-left: -0.07em; }
.pip { width: calc(var(--cw) * 0.2); height: calc(var(--cw) * 0.2); fill: currentColor; }

.mark {
  position: absolute;
  right: 7%;
  bottom: 6%;
  width: 54%;
  height: 54%;
  aspect-ratio: 1;
  fill: currentColor;
}

.ace .mark { width: 44%; height: 44%; right: auto; bottom: auto; left: 50%; top: 56%; translate: -50% -50%; }
.ace .ring {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 74%;
  height: 74%;
  translate: -50% -50%;
  fill: currentColor;
  opacity: 0.22;
}
.court .crown {
  position: absolute;
  right: 18%;
  bottom: 55%;
  width: 34%;
  height: 34%;
  fill: var(--gold);
}
.court .mark { width: 46%; height: 46%; right: 12%; bottom: 8%; }

/* Picked: the card rises and takes the one warm ring on the table. The lift is on the spring, so a
   picked card hops up a touch past its height and settles, and drops back the same way. */
.card.is-selected .face {
  translate: 0 calc(var(--ch) * -0.07);
  box-shadow:
    0 0 0 calc(2px + var(--cw) * 0.015) var(--pick),
    0 1.5px 0 var(--card-edge),
    0 calc(var(--cw) * 0.16) calc(var(--cw) * 0.26) rgba(0, 0, 0, 0.5);
}

@media (hover: hover) {
  .card:not(.is-locked):not(.is-selected):hover .face { translate: 0 calc(var(--ch) * -0.025); }
}
.card:not(.is-locked):active .face { translate: 0 calc(var(--ch) * -0.01); }

.card.is-locked .face {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 3px 8px rgba(0, 0, 0, 0.25);
}

/* A wrong submit: the five shake, once. Lives on the face so it composes with the lift. */
.card.is-wrong .face { animation: wrong calc(var(--beat) * 2.6) var(--ease); }
@keyframes wrong {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-7%); }
  38% { transform: translateX(6%); }
  58% { transform: translateX(-4%); }
  78% { transform: translateX(2%); }
}

/* A free refusal: one small nod, so it reads as "not that" rather than "wrong". */
.card.is-refused .face { animation: refused calc(var(--beat) * 2) var(--ease); }
@keyframes refused {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(4%); }
}

/* A locked hand becomes a band: its colour, its name, and the five cards set into it. */
.band {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--ch);
  transform: translateY(var(--y, 0px));
  border-radius: calc(var(--cw) * 0.12);
  color: var(--band-ink);
  display: flex;
  align-items: center;
  padding: 0 calc(var(--cw) * 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.12), 0 6px 18px rgba(0, 0, 0, 0.35);
  animation: band-in var(--t-spring) var(--spring) both;
  animation-delay: calc(var(--beat) * 1.6);
  z-index: 1;
}
.band-0 { background: linear-gradient(180deg, #ecc75e, var(--band-0)); }
.band-1 { background: linear-gradient(180deg, #8ec280, var(--band-1)); }
.band-2 { background: linear-gradient(180deg, #78a6e2, var(--band-2)); }
.band-3 { background: linear-gradient(180deg, #b795e0, var(--band-3)); }

.band-label { width: calc(var(--cw) * 1.62); display: flex; flex-direction: column; gap: 3px; }
.band-name {
  font-size: max(11px, calc(var(--cw) * 0.15));
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.band-what {
  font-family: var(--serif);
  font-style: italic;
  font-size: max(12px, calc(var(--cw) * 0.16));
  line-height: 1.2;
}

.band.is-revealed { filter: saturate(0.55) brightness(0.92); }

/* The hand locks: its band is pressed onto the felt under the cards flying in, a little short and
   a little narrow, and springs out to fit. Scale is its own property, so the row's translateY is
   never touched. */
@keyframes band-in {
  from { opacity: 0; scale: 0.92 0.7; }
  30% { opacity: 1; }
  to { opacity: 1; scale: 1; }
}

.band.is-cheer { animation: band-cheer calc(var(--beat) * 3) var(--ease-out) both; animation-delay: var(--delay, 0ms); }
@keyframes band-cheer {
  0% { transform: translateY(var(--y, 0px)) scale(1); }
  45% { transform: translateY(var(--y, 0px)) scale(1.025); }
  100% { transform: translateY(var(--y, 0px)) scale(1); }
}

/* --- Under the table ------------------------------------------------------------------------- */

.readout {
  margin: 0;
  /* Two lines held open, so a longer line (a coaching line, a refusal) never resizes the cards. */
  min-height: 2.8em;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.4;
}
.readout b { color: var(--ink); font-weight: 600; }
.readout[data-tone="ready"] { color: var(--ink); }
.readout[data-tone="ready"] b { color: var(--pick); }
.readout[data-tone="bad"] { color: var(--bad); }
.readout[data-tone="good"] { color: var(--good); }
.readout[data-tone="away"] { color: var(--pick); font-weight: 600; }
.readout.pulse { animation: readout-pulse calc(var(--beat) * 2.4) var(--ease-out); }
@keyframes readout-pulse {
  0% { transform: scale(0.96); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

.actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.actions button { min-height: 46px; padding: 0 20px; font-size: 15px; }
.actions .quiet { color: var(--ink-2); }
.actions .primary, .end-actions .primary {
  min-width: 140px;
  background: var(--card);
  border-color: var(--card);
  color: var(--black);
  font-weight: 700;
  letter-spacing: 0.02em;
}
@media (hover: hover) {
  .actions .primary:hover, .end-actions .primary:hover { background: var(--card-hi); border-color: var(--card-hi); }
}
.actions .primary[aria-disabled="true"] {
  background: transparent;
  border-color: var(--line-2);
  color: var(--ink-3);
  cursor: default;
}
.actions .primary.is-ready { animation: ready var(--t-spring) var(--spring); }
@keyframes ready {
  from { scale: 0.9; }
}

/* --- Sheets ---------------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(4, 9, 14, 0.62);
  animation: fade calc(var(--beat) * 2) var(--ease) both;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100% - 8px);
  overflow: auto;
  padding: 24px 26px 0;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  animation: rise var(--t-spring) var(--spring-soft) both;
}
/* A sheet arrives from just below and settles, a shade past its place and back. */
@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  30% { opacity: 1; }
  to { opacity: 1; transform: none; }
}

.sheet h2 { margin: 0 0 10px; font-family: var(--serif); font-size: 26px; font-weight: 600; }
.sheet h3 {
  margin: 20px 0 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.sheet h3 .aside { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.sheet p { margin: 0 0 10px; line-height: 1.5; color: var(--ink-2); font-size: 15px; }
.sheet p b { color: var(--ink); }
.sheet .lede { color: var(--ink); font-size: 16px; }
.sheet .small { font-size: 13px; }
.sheet .keys { color: var(--ink-3); }

.wide {
  position: sticky;
  bottom: 0;
  display: block;
  width: calc(100% + 52px);
  margin: 18px -26px 0;
  min-height: 54px;
  border-radius: 0 0 17px 17px;
  border-width: 1px 0 0;
  background: var(--panel-2);
  font-size: 15px;
  font-weight: 600;
}
.wide:active { translate: none; scale: none; }  /* a full-width footer: shrinking it would show its edges */

.rules { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0; }
.rules dt { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: 15px; }
.rules dd { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.rules dd b { color: var(--ink); }

/* The poker chart in the help: each hand drawn with real cards. */
.chart { display: grid; gap: 10px; margin: 14px 0 6px; }
.chart-row { display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center; }
.chart-name { font-weight: 700; font-size: 14px; }
.chart-name small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.mini-hand { display: flex; gap: 4px; --cw: 36px; }
.mini-hand .face { position: relative; width: var(--cw); height: var(--ch); flex: none; }

/* The menu */
.menu-today, .menu-practice { display: flex; gap: 8px; flex-wrap: wrap; }
.big-choice {
  flex: 1 1 200px;
  min-height: 64px;
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--beat) var(--ease), translate var(--beat) var(--ease), scale var(--t-spring) var(--spring);
}
.big-choice b { display: block; font-size: 16px; }
.big-choice span { color: var(--ink-2); font-size: 13px; }
.big-choice.is-current { border-color: var(--pick); }
/* Today's, finished: the same tick the end card's days-running line wears. */
.big-choice.is-done b::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 8px;
  vertical-align: -1px;
  background: var(--good);
  -webkit-mask: var(--tick) center / contain no-repeat;
  mask: var(--tick) center / contain no-repeat;
}
@media (hover: hover) { .big-choice:hover { background: rgba(255, 255, 255, 0.07); } }
/* A missed weekday that would join the run up again: one small line under today's, a link rather
   than a second big button, so it reads as an offer and not a chore. */
.menu-today .catch-up {
  flex: 1 1 100%;
  min-height: 36px;
  margin-top: -4px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 13px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
  max-height: 168px;
  overflow: auto;
  padding: 2px;
}
.picker button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  position: relative;
  transition: translate var(--beat) var(--ease), scale var(--t-spring) var(--spring);
}
.picker button.won { background: rgba(159, 211, 142, 0.16); border-color: rgba(159, 211, 142, 0.5); }
.picker button.flawless { background: rgba(226, 184, 74, 0.2); border-color: rgba(226, 184, 74, 0.7); }
.picker button.lost { background: rgba(239, 138, 120, 0.12); border-color: rgba(239, 138, 120, 0.45); }
.picker button.started::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pick);
}
.picker p { grid-column: 1 / -1; margin: 0; }
.picker button.is-current { outline: 2px solid var(--pick); outline-offset: 1px; }

.segmented { display: inline-flex; gap: 4px; }
.segmented button[aria-checked="true"] { background: var(--card); color: var(--black); border-color: var(--card); }

/* Records */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 14px; }
.stat { text-align: center; }
.stat b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); }
.bars { display: grid; gap: 5px; }
.bar-row { display: grid; grid-template-columns: 112px 1fr; gap: 10px; align-items: center; font-size: 13px; color: var(--ink-2); }
.bar { height: 20px; min-width: 22px; border-radius: 5px; background: rgba(233, 226, 211, 0.16); color: var(--ink); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: flex-end; padding: 0 7px; font-variant-numeric: tabular-nums; }
.bar.is-last { background: var(--pick); color: var(--black); }

/* The end card: paper on the felt. */
.sheet.paper {
  max-width: 440px;
  padding: 26px 28px 18px;
  text-align: center;
  color: var(--black);
  border-color: var(--card-edge);
  background:
    linear-gradient(168deg, var(--card-hi), var(--card) 55%, var(--card-lo));
  box-shadow: inset 0 0 0 7px transparent, inset 0 0 0 8px var(--card-rule), 0 30px 80px rgba(0, 0, 0, 0.6);
}
.paper p { color: #4b463c; }
.end-kicker { margin: 0 0 4px !important; font-size: 12px !important; letter-spacing: 0.14em; text-transform: uppercase; color: #7a705e !important; }
.end-title {
  margin: 0 0 6px !important;
  font-family: var(--serif);
  font-size: 46px !important;
  font-weight: 700 !important;
  line-height: 1;
  color: var(--black);
  animation: settle calc(var(--t-spring) * 1.15) var(--spring) both;
  animation-delay: calc(var(--beat) * 1.2);
}
.end-title.is-lost { color: var(--red); }
/* The verdict is set down on the card from above it: big, then through its size a little and back,
   the thump of a word printed hard. */
@keyframes settle {
  from { opacity: 0; translate: 0 -10px; scale: 1.35; }
  25% { opacity: 1; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}
.end-line { font-family: var(--serif); font-style: italic; font-size: 16px !important; }

.grid { display: inline-grid; gap: 4px; margin: 6px auto 12px; }
.grid-row { display: flex; gap: 4px; }
.sq { width: 22px; height: 22px; border-radius: 5px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12); }
.sq.b0 { background: var(--band-0); }
.sq.b1 { background: var(--band-1); }
.sq.b2 { background: var(--band-2); }
.sq.b3 { background: var(--band-3); }
/* The grid fills a row at a time, each dealt down onto the card and settling, like the hands did. */
.grid-row { animation: row-in var(--t-spring) var(--spring) both; animation-delay: calc(var(--beat) * (3 + var(--i, 0))); }
@keyframes row-in {
  from { opacity: 0; translate: 0 -6px; scale: 0.6; }
  30% { opacity: 1; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}

.end-stats { font-size: 13px !important; color: #6b6352 !important; }
/* After today's deal: the days running and when the next is dealt. Written on the card like the
   stats above it, under a short rule, a fact about tomorrow rather than a banner. */
.comeback {
  display: table;
  margin: -2px auto 12px !important;
  padding-top: 8px;
  border-top: 1px solid var(--card-rule);
  font-size: 13.5px !important;
  line-height: 1.4 !important;
  color: #4b463c;
  font-variant-numeric: tabular-nums;
  animation: rise calc(var(--beat) * 2) var(--ease-out) both;
  animation-delay: calc(var(--beat) * 6);
}
.comeback[hidden] { display: none; }
.paper .comeback b { color: var(--black); font-weight: 700; }
.comeback::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  vertical-align: -1px;
  background: var(--good-paper);
  -webkit-mask: var(--tick) center / contain no-repeat;
  mask: var(--tick) center / contain no-repeat;
}
/* The week under it: seven small marks ending today, each with its initial. Inked for a day played,
   a faint hollow for a weekend left alone, an empty outline for a weekday missed; today wears a
   ring, inked once it is played. It rises just after the line above, on the soft spring. */
.comeback:has(+ .end-week:not([hidden])) { margin-bottom: 8px !important; }
/* A missed day that can still be played sits beside the marks, pointing at the gap, and drops under
   them only when the row has no room. */
.end-week { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 14px; margin: 0 0 12px; }
.end-week[hidden] { display: none; }
.week {
  display: inline-flex;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
  animation: rise var(--t-spring) var(--spring-soft) both;
  animation-delay: calc(var(--beat) * 7);
}
.week li { display: grid; justify-items: center; gap: 3px; }
.week i {
  box-sizing: border-box;
  width: 13px;
  height: 13px;
  border: 1.5px solid #7a705e;
  border-radius: 4px;
}
.week [data-state="played"] i { background: var(--black); border-color: var(--black); }
.week [data-state="weekend"] i { border-color: rgba(122, 112, 94, 0.3); }
.week li:last-child i { outline: 1.5px solid var(--black); outline-offset: 2px; border-radius: 50%; }
.week span { font-size: 10px; line-height: 1; color: #7a705e; margin-top: 2px; }
.week [data-state="weekend"] span { opacity: 0.6; }
.end-week .catch-up { margin: -2px 0 0; min-height: 32px; padding: 0 2px; color: #4b463c; }
.end-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.end-actions button { min-height: 46px; color: var(--black); border-color: rgba(26, 28, 35, 0.3); background: transparent; }
.end-actions .primary { background: var(--black); border-color: var(--black); color: var(--card); }
/* The way on to today's deal, after any other: drawn as the way forward. */
.end-actions #end-next.is-today { border-color: var(--black); font-weight: 600; }
.end-actions #end-next.is-today::after { content: "\a0\2192"; }
@media (hover: hover) {
  .end-actions button:hover { background: rgba(26, 28, 35, 0.06); border-color: rgba(26, 28, 35, 0.5); }
  .end-actions .primary:hover { background: #2a2d36; border-color: #2a2d36; }
}
.share-note { min-height: 1.3em; margin: 8px 0 0 !important; font-size: 13px !important; }
.share-note:empty { min-height: 0; margin: 0 !important; }
.share-text {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  resize: none;
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--black);
  font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace;
}
.also { margin-top: 12px; font-size: 13px; color: #6b6352; }
.also .also-today { margin: 0; }
.also a { color: var(--black); text-underline-offset: 2px; }
.link {
  margin-top: 10px;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: #6b6352;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* --- Phones ---------------------------------------------------------------------------------- */

@media (max-width: 620px) {
  #app { gap: 8px; padding: 8px 10px max(10px, env(safe-area-inset-bottom)); }
  .head { grid-template-columns: 1fr auto; row-gap: 2px; }
  .brand { font-size: 23px; gap: 7px; }
  .brand-suits svg { width: 10px; height: 10px; }
  .dealline { grid-column: 1 / -1; grid-row: 2; font-size: 12px; }
  .tools { grid-column: 2; grid-row: 1; }
  .tools button { min-height: 40px; padding: 0 12px; font-size: 13px; }
  .tools .round { width: 40px; }
  .goals { flex-wrap: wrap; gap: 6px 10px; }
  .pills { gap: 4px; }
  .pill { height: 28px; padding: 0 9px 0 8px; font-size: 12px; gap: 5px; }
  .pill .dot { width: 7px; height: 7px; }
  .mistakes-label { display: none; }
  .chip { width: 16px; height: 16px; }
  .readout { font-size: 14px; min-height: 2.8em; display: grid; place-items: center; }
  .actions { gap: 6px; }
  .actions button { flex: 1 1 0; min-height: 48px; padding: 0 8px; font-size: 14px; }
  .actions .primary { flex: 1.5 1 0; min-width: 0; }
  .sheet { padding: 20px 18px 0; border-radius: 16px; }
  .wide { width: calc(100% + 36px); margin: 16px -18px 0; }
  .chart-row { grid-template-columns: 88px 1fr; }
  .mini-hand { --cw: 30px; gap: 3px; }
  .rules { grid-template-columns: 1fr; gap: 2px; }
  .rules dd { margin-bottom: 8px; }
  .end-title { font-size: 40px !important; }
  .sheet.paper { padding: 22px 18px 14px; }
}

/* A short phone: the end card gives up a little air so the week fits with the card still whole. */
@media (max-width: 620px) and (max-height: 660px) {
  .sheet.paper { padding-top: 18px; }
  .grid { margin-bottom: 8px; }
  .comeback { padding-top: 6px; }
  .end-week { margin-bottom: 8px; }
  .also { margin-top: 8px; }
  .paper .link { margin-top: 2px; }
}

@media (max-width: 380px) {
  .brand { font-size: 21px; }
  .brand-suits { display: none; }
  .tools { gap: 4px; }
  .tools button { padding: 0 11px; }
  .pill { padding: 0 7px 0 6px; font-size: 11px; }
  .pill .dot { display: none; }
}

/* A phone on its side: everything but the table moves into a column beside it. */
@media (orientation: landscape) and (max-height: 520px) {
  #app {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(200px, 250px) 1fr;
    grid-template-rows: auto auto 1fr auto;
    gap: 8px 14px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  }
  .head { grid-column: 1; grid-row: 1; grid-template-columns: 1fr auto; row-gap: 2px; }
  .brand { font-size: 20px; }
  .dealline { grid-column: 1 / -1; grid-row: 2; font-size: 12px; }
  .tools { grid-column: 2; grid-row: 1; }
  .tools button { min-height: 36px; padding: 0 10px; font-size: 12px; }
  .tools .round { width: 36px; }
  .goals { grid-column: 1; grid-row: 2; flex-direction: column; align-items: stretch; gap: 8px; }
  .pills { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .pill { height: 28px; font-size: 12px; justify-content: center; }
  .mistakes { justify-content: center; }
  .readout { grid-column: 1; grid-row: 3; align-self: end; font-size: 13px; min-height: 3.2em; text-align: left; }
  .actions { grid-column: 1; grid-row: 4; flex-wrap: wrap; }
  .actions button { flex: 1 1 40%; min-height: 40px; padding: 0 8px; font-size: 13px; }
  .actions .primary, #see-result { flex-basis: 100%; }
  .table { grid-column: 2; grid-row: 1 / -1; }
  /* The end card turns sideways too: the grid on the left, the words and buttons beside it, so
     the whole card, buttons included, fits the short screen without scrolling inside it. */
  .sheet.paper {
    max-width: 620px;
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 24px;
    align-items: center;
    padding: 16px 22px 8px;
  }
  .sheet.paper > * { grid-column: 2; min-width: 0; }
  .sheet.paper > .grid { grid-column: 1; grid-row: 1 / span 8; margin: 0; }
  .end-title { font-size: 34px !important; }
  .end-line { font-size: 15px !important; margin-bottom: 6px !important; }
  .end-stats { margin-bottom: 8px !important; }
  .comeback { margin-bottom: 8px !important; padding-top: 6px; }
  .comeback:has(+ .end-week:not([hidden])) { margin-bottom: 6px !important; }
  .end-week { margin-bottom: 8px; }
  .end-actions button { min-height: 42px; }
  .also { margin-top: 8px; }
  .also .also-today { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .link { margin-top: 2px; min-height: 34px; }
}

/* Placing a whole table at once (a new deal, a resize, a reload) must not animate. */
.felt.no-anim .card, .felt.no-anim .face, .felt.no-anim .band { transition: none !important; }
.also a { display: inline-block; padding: 11px 2px; margin: -11px 0; }
