/* ============================================================================
 * Endplay client styles — the warm "sticker" skin (A12 front-end redesign).
 *
 * Design system reconciled from docs/design/DESIGN_HANDOFF.md + the reference
 * build (docs/design/Endplay.dc.html). Accessibility is a requirement, not
 * polish (audience: older adults on a phone):
 *   - All copy/UI type in rem, root font-size never pinned -> honours the OS
 *     text-size setting AND the in-app Text size control. (Chips are fixed
 *     graphical tokens >= 44px; their dark digit passes WCAG AA on every fill.)
 *   - Suit carried by SHAPE as well as colour, always on, everywhere suit shows.
 *   - Touch targets >= 44px. prefers-reduced-motion respected.
 *   - Theme is three-state: light (bare :root), dark (media + [data-theme]).
 * ========================================================================== */

/* ---- self-hosted variable fonts (offline, no third-party request) ---- */
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 300 700;
  font-display: swap; src: url("fonts/space-grotesk-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk"; font-style: normal; font-weight: 100 900;
  font-display: swap; src: url("fonts/hanken-grotesk-latin.woff2") format("woff2");
}

/* ---- theme tokens ---- */
:root {
  /* warm paper (light) */
  --bg:#f5f0e6; --surface:#fbf8f1; --line:#e2d9c9; --ink:#26221b; --ink2:#3a3327;
  --muted:#7a7060; --faint:#9a9080; --stroke:#26221b; --shadow:#26221b;
  --chip-neutral:#efe7d6;
  --accent-soft:#eaf6f2; --accent-line:#bfe0d8; --accent-ink:#17726a;
  --you:#eef4f0; --lead-bg:#d6efec; --lead-ink:#17726a;
  --badge-bg:#efe7d6; --badge-ink:#8a7c60; --slot:#d8cfbd;
  --turn:#1f8f83; --status-bg:#ffffff;
  --dead-bg:#fbeceb; --dead-border:#c9524f; --dead-ink:#a53f3c; --avoid:#b0603a;
  /* fixed accents (both themes) */
  --teal:#1f8f83; --amber:#f0b323; --amber-ink:#26221b; --ramp:#d98a2b;
  /* suit fills — theme-independent (chips are self-coloured); dark digit passes AA */
  --suit-A:#e06a6a; --suit-B:#e6b84e; --suit-C:#5a97e0; --suit-D:#4bb37e; --suit-E:#c56fbd;
  --suit-T:#eef0f4; --suit-T-ink:#2a2d34; --chip-ink:#16181d;

  --sans:"Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display:"Space Grotesk", var(--sans);
  --radius:16px; --sticker-shadow:4px 5px 0 var(--shadow);
  --backdrop:#c7c1b2; --phone-body:#0b0b0d;   /* desktop-only phone-preview frame */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#1b1712; --surface:#262019; --line:#3a342a; --ink:#f2ece1; --ink2:#e4dccd;
    --muted:#ab9f8c; --faint:#837a68; --stroke:#f4efe6; --shadow:rgba(0,0,0,.6);
    --chip-neutral:#322b20;
    --accent-soft:#14322d; --accent-line:#2c5b53; --accent-ink:#5fd0c1;
    --you:#1e2b27; --lead-bg:#14322d; --lead-ink:#5fd0c1;
    --badge-bg:#322b20; --badge-ink:#b7a887; --slot:#4a4234;
    --turn:#37b6a7; --status-bg:#262019;
    --dead-bg:#3a2320; --dead-border:#e0736f; --dead-ink:#e78c88; --avoid:#e0956f;
    --backdrop:#0d0b09;
  }
}
:root[data-theme="dark"] {
  --bg:#1b1712; --surface:#262019; --line:#3a342a; --ink:#f2ece1; --ink2:#e4dccd;
  --muted:#ab9f8c; --faint:#837a68; --stroke:#f4efe6; --shadow:rgba(0,0,0,.6);
  --chip-neutral:#322b20;
  --accent-soft:#14322d; --accent-line:#2c5b53; --accent-ink:#5fd0c1;
  --you:#1e2b27; --lead-bg:#14322d; --lead-ink:#5fd0c1;
  --badge-bg:#322b20; --badge-ink:#b7a887; --slot:#4a4234;
  --turn:#37b6a7; --status-bg:#262019;
  --dead-bg:#3a2320; --dead-border:#e0736f; --dead-ink:#e78c88; --avoid:#e0956f;
  --backdrop:#0d0b09;
}

/* ---- base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }   /* respect, don't fight, user text sizing */
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 1rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
button { font-family: inherit; color: inherit; }

/* app shell: a scrolling screen region above a fixed bottom tab bar. On a real phone it fills
   the viewport; on desktop it renders inside a phone body (below) so the web build previews as
   the mobile app. */
#app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; width: 100%; max-width: 30rem; margin: 0 auto;
  background: var(--bg); overflow: hidden;
}

/* Desktop preview: a thick black phone body with dead space around it. Gated on width so narrow
   (real-phone) viewports stay full-bleed — the eventual native app must fill the screen.
   Recent-iPhone screen ~393x852; +14px bezel each side. aspect-ratio keeps it phone-shaped and
   it shrinks to fit shorter windows. */
@media (min-width: 481px) {
  body { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center;
         justify-content: center; background: var(--backdrop); }
  #app {
    width: auto; max-width: none; aspect-ratio: 421 / 880;
    height: min(880px, calc(100dvh - 24px));
    border: 14px solid var(--phone-body); border-radius: 54px; overflow: hidden;
    box-shadow: 0 24px 60px -12px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.06);
  }
}
#screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* simple scrolling screens (home / learn / recent / settings / win) */
.page { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
        padding: 0.5rem 1.35rem calc(1.5rem + env(safe-area-inset-bottom)); }
.page.pad-top { padding-top: 0.9rem; }

/* stacked screens with fixed chrome (play / tutorial) */
.stack { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.stack-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
                padding: 0.75rem 1rem 0.25rem; }

/* ---- utilities ---- */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden;
           clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.skip { position:absolute; left:-999px; top:0; background:var(--teal); color:#fff;
        padding:.5rem .8rem; border-radius:0 0 8px 0; z-index:60; }
.skip:focus { left:0; }
:focus-visible { outline:3px solid var(--turn); outline-offset:2px; border-radius:8px; }
.display { font-family: var(--display); }

/* ============================ TAB BAR ============================ */
.tabbar {
  flex: none; display: flex; align-items: stretch; justify-content: space-around;
  gap: .25rem; padding: .6rem .5rem calc(.6rem + env(safe-area-inset-bottom));
  border-top: 1.5px solid var(--line); background: var(--surface);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: .25rem;
  background: none; border: none; cursor: pointer; padding: .35rem .1rem;
  font-family: var(--sans); font-weight: 600; font-size: .625rem; letter-spacing: .01em;
  color: var(--faint); min-height: 44px; border-radius: 12px;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--teal); }
:root[data-theme="dark"] .tab[aria-current="page"],
:root:not([data-theme="light"]) .tab[aria-current="page"] { color: var(--turn); }

/* ============================ HOME ============================ */
.masthead { text-align: center; padding: 1rem 0 .95rem; border-bottom: 2px solid var(--stroke); }
.masthead .suits { display: flex; justify-content: center; gap: 7px; margin-bottom: .7rem; }
.masthead .suits svg { width: 18px; height: 18px; }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 2rem; line-height: 1;
            letter-spacing: .14em; text-transform: uppercase; margin: 0; }
.masthead .dateline { font-weight: 500; font-size: .75rem; letter-spacing: .05em;
                      color: var(--muted); margin-top: .6rem; }

/* weekday ramp */
.ramp { display: flex; justify-content: space-between; align-items: flex-end; margin: 1.15rem .25rem .3rem; }
.ramp .day { display: flex; flex-direction: column; align-items: center; gap: .35rem; flex: 1;
             background: none; border: none; padding: 0; font: inherit; color: inherit; }
button.day { cursor: pointer; }
.ramp .mark { min-height: .85rem; display: flex; align-items: center; justify-content: center; }
.ramp .mark .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ramp .mark .dot.hollow { background: transparent; border: 1.5px solid currentColor; }
.ramp .mark .tick { width: 12px; height: 12px; color: var(--teal); }
.ramp .bar, .ramp .frame { transition: transform .12s ease, filter .12s ease; }
.ramp .bar { width: 26px; border-radius: 6px 6px 3px 3px; background: var(--teal); }
.ramp .lbl { font-weight: 600; font-size: .625rem; line-height: 1; color: var(--faint); text-transform: uppercase; }
.ramp .day.solved .lbl { color: var(--teal); }
.ramp .day.past .mark { color: var(--ramp); }                          /* hollow orange ○ = not done */
.ramp .day.today .mark, .ramp .day.today .lbl { color: var(--ramp); font-weight: 700; }  /* solid ● */
/* today: an amber "you are here" capsule with internal padding around a solid fill */
.ramp .day.today .frame { border: 2px solid var(--ramp); border-radius: 6px; padding: 4px 3px;
                          display: flex; align-items: flex-end;
                          background: color-mix(in srgb, var(--ramp) 9%, transparent); }
.ramp .day.today .fill { width: 18px; background: var(--teal); border-radius: 3px 3px 2px 2px; }
.ramp .day.future .bar { background: var(--chip-neutral); }
.ramp .day.future .lbl { color: var(--faint); }
button.day:hover .bar, button.day:hover .frame { transform: translateY(-3px); filter: brightness(1.06); }
button.day:active .bar, button.day:active .frame { transform: translateY(-1px); }
.ramp-caption { font-weight: 500; font-size: .6875rem; color: var(--faint); text-align: center; margin: .5rem 0 1.15rem; }

/* today card (the big sticker). Specific class so it does NOT bleed onto other
   "today"-classed elements (the ramp's current-day button, the Recent today row). */
.today-card {
  border: 2px solid var(--stroke); border-radius: 20px; background: var(--surface);
  box-shadow: var(--sticker-shadow); overflow: hidden; cursor: pointer;
  width: 100%; text-align: left; display: block; padding: 0; color: inherit;
}
.today-card:active { transform: translate(1px, 1px); box-shadow: 3px 4px 0 var(--shadow); }
.today-head { display: flex; align-items: center; justify-content: space-between; padding: .95rem 1.1rem .75rem; }
.today-head .kicker { font-family: var(--sans); font-weight: 700; font-size: .75rem;
                      text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tier-pill { background: var(--amber); border: 1.5px solid var(--stroke); border-radius: 8px;
             padding: .25rem .55rem; font-family: var(--display); font-weight: 700; font-size: .6875rem;
             letter-spacing: .02em; color: var(--amber-ink); text-transform: uppercase; }
.spec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
        background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.spec .cell { background: var(--surface); color: var(--ink);
              display: flex; flex-direction: column; align-items: center; gap: .45rem; padding: .95rem .25rem .8rem; }
.spec .cell .glyphs { display: flex; align-items: center; gap: 3px; min-height: 16px; }
.spec .cell .cap { font-weight: 600; font-size: .625rem; color: var(--faint);
                   text-transform: uppercase; letter-spacing: .05em; }
.spec .meter { display: flex; align-items: flex-end; gap: 2px; }
.spec .meter i { width: 4px; height: 16px; background: var(--line); border-radius: 1px; }
.spec .meter i.on { background: var(--ramp); }
.spec .steps { display: flex; align-items: flex-end; gap: 2.5px; }
.spec .steps i { width: 5px; background: currentColor; border-radius: 1px; }
.today-cta { display: flex; align-items: center; justify-content: center; gap: .5rem;
             background: var(--teal); color: #fff; padding: 1.05rem; border-top: 2px solid var(--stroke);
             font-family: var(--display); font-weight: 700; font-size: 1.125rem; }
.today-cta .cta-play { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.home-note { font-weight: 400; font-size: .8125rem; line-height: 1.55; color: var(--faint);
             text-align: center; margin: 1.25rem .5rem 0; }
.home-note.lead { margin: .85rem .5rem .1rem; }
/* the "New here?" tutorial card — a header + a green Play/Continue strip, with a corner dismiss */
.home-firsttime-wrap { position: relative; margin: .85rem 0 .2rem; }
.learn-card { border: 2px solid var(--stroke); border-radius: 20px; background: var(--surface);
              box-shadow: var(--sticker-shadow); overflow: hidden; cursor: pointer;
              width: 100%; text-align: left; display: block; padding: 0; color: inherit; }
.learn-card:active { transform: translate(1px, 1px); box-shadow: 3px 4px 0 var(--shadow); }
.learn-head { display: flex; align-items: center; gap: .7rem; padding: .8rem 3rem .78rem 1rem; }
.lc-q { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--amber);
        border: 1.5px solid var(--stroke); color: var(--amber-ink); display: inline-flex;
        align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; font-size: 1.1rem; }
.learn-head .txt .lt { font-family: var(--display); font-weight: 700; font-size: .9375rem; color: var(--ink); }
.learn-head .txt .ls { font-size: .8125rem; color: var(--muted); margin-top: 1px; }
.learn-card .today-cta { font-size: 1rem; padding: .85rem; }
.home-dismiss { position: absolute; top: .5rem; right: .5rem; width: 34px; height: 34px;
                display: inline-flex; align-items: center; justify-content: center;
                border: none; background: none; color: var(--faint); cursor: pointer; border-radius: 8px; }
.home-dismiss svg { width: 15px; height: 15px; }
.home-dismiss:hover { color: var(--ink); background: var(--bg); }

/* "Play the archive" — a two-part card like today's: stats head + green strip */
.archive-card { margin-top: .7rem; }
.arch-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
              background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.arch-stats .astat { background: var(--surface); color: var(--ink); display: flex; flex-direction: column;
                     align-items: center; gap: .35rem; padding: 1rem .25rem .85rem; }
.arch-stats .anum { font-family: var(--display); font-weight: 800; font-size: 1.75rem; line-height: 1; color: var(--ink); }
.arch-stats .astat .cap { font-weight: 600; font-size: .625rem; color: var(--faint);
                          text-transform: uppercase; letter-spacing: .05em; }

/* ============================ ARCHIVE CALENDAR ============================ */
.cal { margin: 0 0 1.4rem; }
.cal-month { font-family: var(--display); font-weight: 700; font-size: 1rem; color: var(--ink); margin: .6rem .2rem .4rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-wd { text-align: center; font-size: .6875rem; font-weight: 700; color: var(--faint); padding: .1rem 0 .3rem; }
.cal-cell { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
            gap: 2px; border-radius: 10px; border: 1.5px solid transparent; padding: 0; }
.cal-cell.pad { visibility: hidden; }
.cal-cell .cd { font-size: .8125rem; font-weight: 600; color: var(--ink); }
.cal-cell.out .cd { color: var(--faint); }
.cal-cell.day { cursor: pointer; background: var(--surface); border-color: var(--line); color: inherit; }
.cal-cell.day:active { transform: translate(1px, 1px); }
.cal-cell.day.started { border-color: var(--amber); }
.cal-cell.day.complete { background: var(--accent-soft); border-color: var(--accent-line); }
.cal-cell.day.complete .cd { color: var(--accent-ink); }
.cal-cell.day.today { border-color: var(--teal); border-width: 2px; }
.cal-cell .ci { width: 14px; height: 14px; color: var(--accent-ink); }
.cal-cell .ci.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); display: inline-block; }

/* ============================ TOP BARS ============================ */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem;
          padding: .75rem 1.1rem .6rem; border-bottom: 1.5px solid var(--line); flex: none; }
.topbar .mid { font-family: var(--display); font-weight: 700; font-size: .9375rem; letter-spacing: .02em; margin: 0; }
.midwrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
/* deliberately faint + small: an elapsed readout, not a countdown, not a pressure clock */
.clock { font-size: .625rem; font-weight: 600; color: var(--faint); letter-spacing: .06em;
         font-variant-numeric: tabular-nums; }
.linkbtn { display: inline-flex; align-items: center; gap: .35rem; border: none; background: none;
           color: var(--muted); font-weight: 600; font-size: .875rem; cursor: pointer;
           min-height: 44px; padding: 0 .2rem; }
.linkbtn svg { width: 18px; height: 18px; }
.topbar .spacer { min-width: 3.4rem; }

/* ============================ STATUS LINE ============================ */
.status { margin: .75rem 1rem 0; border-radius: 14px; padding: .75rem .95rem;
          font-weight: 600; font-size: .875rem; line-height: 1.3; display: flex; align-items: center; gap: .55rem;
          background: var(--status-bg); border: 1.5px solid var(--line); color: var(--ink); flex: none; }
.status.dead, .status.lost { background: var(--dead-bg); border-color: var(--dead-border); color: var(--dead-ink); }
.status.won { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
/* radar-ping flash on the resolved states — ported from the prototype: three pulses, green for
   solved, red for not-solved (dead / lost). The ring expands and fades; a slight scale bump too. */
.status.won { --flash: color-mix(in srgb, var(--turn) 55%, transparent); }
.status.dead, .status.lost { --flash: color-mix(in srgb, var(--dead-border) 55%, transparent); }
.status.won, .status.dead, .status.lost { animation: status-flash .55s ease-out 3; }
@keyframes status-flash {
  0%   { transform: scale(1);     box-shadow: 0 0 0 0    var(--flash); }
  20%  { transform: scale(1.025); box-shadow: 0 0 0 4px  var(--flash); }
  100% { transform: scale(1);     box-shadow: 0 0 0 12px transparent; }
}
.status .swatch { display: inline-flex; }

/* shape-order key — chips only, sits in the top bar's left slot */
.suitkey-h { display: inline-flex; align-items: center; flex: none; }
.suitkey-h .sk-shape { display: inline-flex; }
.suitkey-h .sk-shape svg { width: 15px; height: 15px; }
.suitkey-h .sk-lt { color: var(--faint); font-size: .75rem; margin: 0 1px; }

/* ============================ BOARD / SEATS ============================ */
.seat { background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px;
        padding: .75rem .8rem; margin-bottom: .7rem; }
.seat.you { background: var(--you); }
.seat.turn { border-color: var(--turn); box-shadow: 0 0 0 2px var(--turn); }
.shead { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.shead .name { font-family: var(--display); font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.badge { font-weight: 600; font-size: .625rem; line-height: 1; text-transform: uppercase; letter-spacing: .04em;
         border: none; border-radius: 20px; padding: .3rem .5rem; }
.badge.policy { color: var(--badge-ink); background: var(--badge-bg); }
.badge.leads { color: var(--lead-ink); background: var(--lead-bg); }
button.badge.policy { display: inline-flex; align-items: center; gap: .28rem; cursor: help; font-family: inherit; }
.badge.policy .info { width: 12px; height: 12px; opacity: .7; }
.policy-tip { font-weight: 400; font-size: .78125rem; line-height: 1.4; text-transform: none; letter-spacing: normal;
              color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
              padding: .5rem .65rem; margin: -.1rem 0 .6rem; }
.goal { margin-left: auto; display: flex; align-items: center; gap: .35rem;
        font-weight: 600; font-size: .8125rem; color: var(--ink2); }
.goal .g-verb { color: var(--ink2); }
.goal .g-verb.avoid { color: var(--avoid); }
.goal .mark { font-weight: 800; font-size: .95rem; }
.goal .mark.met { color: var(--turn); }
.goal .mark.failed { color: var(--dead-border); }

.seat-main { display: flex; align-items: center; gap: .75rem; }
.hand { display: flex; flex-wrap: wrap; gap: 7px; flex: 1; min-width: 0; }
.playzone { flex: none; }
.wonstrip { display: flex; align-items: flex-start; gap: 5px; flex-wrap: wrap; margin-top: .6rem; min-height: 26px; }
.wonstrip .wl { font-weight: 600; font-size: .6875rem; color: var(--faint);
                text-transform: uppercase; letter-spacing: .05em; align-self: center; }
.wonstrip .gap { width: 6px; }

/* ============================ CHIPS ============================ */
/* A fixed-size graphical token: a shaped, self-coloured glyph behind a dark digit.
   Sizes are px (touch geometry); the digit passes WCAG AA on every fill. */
.chip {
  position: relative; width: 46px; height: 46px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; padding: 0; margin: 0; border-radius: 12px;
  cursor: default;
}
.chip.tap { cursor: pointer; }
.chip.tap:disabled { cursor: default; }
.chip .glyph { position: absolute; width: 96%; height: 96%; overflow: visible;
               filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.28)); }
.chip .rank { position: relative; z-index: 1; font-family: var(--display); font-weight: 700;
              font-size: 19px; line-height: 1; color: var(--chip-ink); }
.chip.suit-C .rank { transform: translateY(0.16em); }   /* triangle optical centre */
.chip.dim { opacity: .36; }                              /* teaching by constraint: illegal greyed */
.chip.dim .glyph { filter: grayscale(.35) drop-shadow(0 1px 1px rgba(0,0,0,.2)); }
.chip.tap:not(:disabled):hover .glyph { filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.chip.sm { width: 34px; height: 34px; }
.chip.sm .rank { font-size: 14px; }
.chip.mini { width: 22px; height: 22px; border-radius: 7px; }
.chip.mini .glyph { filter: drop-shadow(0 1px 1px rgba(0,0,0,.22)); }
.chip.mini .rank { font-size: 9px; }
/* the chip you played, in the won-tricks strip: a border on the shape itself (stroke behind
   the fill), not a square around the box */
.chip.mini.mine .glyph > * { stroke: var(--stroke); stroke-width: 9; paint-order: stroke; }
/* the chip a hint recommends: a clear ring (not colour alone — it is a ring on a specific chip) */
.chip.hinted { box-shadow: 0 0 0 3px var(--turn), 0 0 11px 1px var(--turn); border-radius: 13px; }

/* the empty play-zone slot */
.slot { width: 46px; height: 46px; border-radius: 12px; border: 1.5px dashed var(--slot); flex: none; }

/* per-suit fill, applied to the glyph's shape via currentColor of the class */
.suit-A { --fill: var(--suit-A); }
.suit-B { --fill: var(--suit-B); }
.suit-C { --fill: var(--suit-C); }
.suit-D { --fill: var(--suit-D); }
.suit-E { --fill: var(--suit-E); }
.suit-T { --fill: var(--suit-T); }

/* small inline suit token (goal labels, spec grid, masthead legend) */
.tok { position: relative; display: inline-flex; flex: none; width: 20px; height: 20px; vertical-align: -.28rem; }
.tok svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* ============================ CONTROLS ============================ */
.controls { display: flex; gap: .55rem; padding: .65rem 1rem calc(1.05rem + env(safe-area-inset-bottom));
            border-top: 1.5px solid var(--line); flex: none; }
.btn { flex: 1; min-height: 48px; border: 1.5px solid var(--stroke); background: var(--surface);
       color: var(--ink); border-radius: 13px; font-family: var(--display); font-weight: 700;
       font-size: .9375rem; cursor: pointer; }
.btn:disabled { opacity: .4; cursor: default; }
/* Hint sits alongside Undo/Restart, calmer than either so it reads as an aid, not a primary control */
.btn.hint { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); font-size: .875rem; }
/* the hint line under the board — NOT a live region (the status line owns that role) */
.hintmsg { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; margin: .5rem 1rem .1rem;
           padding: .5rem .7rem; border-radius: 12px; background: var(--accent-soft);
           border: 1.5px solid var(--accent-line); color: var(--accent-ink);
           font-size: .8125rem; font-weight: 600; line-height: 1.35; }
.hintmsg.dead { background: var(--dead-bg); border-color: var(--dead-border); color: var(--dead-ink); }
.hintmsg .hl { font-family: var(--display); font-weight: 700; text-transform: uppercase;
               letter-spacing: .04em; font-size: .6875rem; }
.hintmsg .chip { display: inline-flex; vertical-align: middle; }
.btn.primary { background: var(--teal); border-color: var(--stroke); color: #fff; box-shadow: 3px 4px 0 var(--shadow); }
.btn.primary:active { transform: translate(1px,1px); box-shadow: 2px 3px 0 var(--shadow); }
.btn.ghost { border-color: var(--line); background: var(--surface); color: var(--muted); box-shadow: none; }

/* ============================ TUTORIAL ============================ */
.teach { margin: .85rem 1rem .15rem; background: var(--accent-soft); border: 1.5px solid var(--accent-line);
         border-radius: 14px; padding: .8rem .95rem; flex: none; }
.teach.dead { background: var(--dead-bg); border-color: var(--dead-border); }
.teach .t-title { font-family: var(--display); font-weight: 700; font-size: .875rem;
                  color: var(--accent-ink); margin-bottom: .3rem; }
.teach.dead .t-title { color: var(--dead-ink); }
.teach .t-body { font-weight: 500; font-size: .84375rem; line-height: 1.45; color: var(--ink); }
.teach .t-body .chip { display: inline-flex; vertical-align: -.35em; }   /* text nodes carry the spacing */
/* collapsible lesson: tap the title to fold the body away (auto-folds once play begins) */
.teach.collapsible .t-title { display: flex; align-items: center; justify-content: space-between;
                              gap: .5rem; cursor: pointer; margin-bottom: 0; min-height: 24px; }
.teach.collapsible:not(.collapsed) .t-title { margin-bottom: .3rem; }
.teach .t-chev { width: 20px; height: 20px; flex: none; color: var(--accent-ink);
                 transition: transform .15s ease; }
.teach.collapsed .t-chev { transform: rotate(-90deg); }
.teach.collapsed .t-body { display: none; }
.tut-solved { margin: .85rem 1rem .15rem; background: var(--accent-soft); border: 1.5px solid var(--accent-line);
              border-radius: 14px; padding: .7rem .9rem; display: flex; align-items: center;
              justify-content: space-between; gap: .6rem; flex: none; }
.tut-solved span { font-family: var(--display); font-weight: 700; font-size: .875rem; color: var(--accent-ink); }
.tut-solved button { border: 2px solid var(--stroke); background: var(--teal); color: #fff; border-radius: 11px;
                     padding: .7rem .95rem; min-height: 44px; font-family: var(--display); font-weight: 700;
                     font-size: .8125rem; cursor: pointer; white-space: nowrap; display: inline-flex;
                     align-items: center; gap: .3rem; }
.tut-solved button svg { width: 15px; height: 15px; }

/* ============================ LEARN ============================ */
.screen-title { padding: .9rem 0 1rem; }
.screen-title .title-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.screen-title .tut-reset { flex: none; }
.screen-title h1 { font-family: var(--display); font-weight: 700; font-size: 1.625rem; letter-spacing: -.01em; margin: 0; }
.screen-title p { font-weight: 400; font-size: .875rem; line-height: 1.5; color: var(--muted); margin: .5rem 0 0; }
.lessons { display: flex; flex-direction: column; gap: .55rem; }
.lesson { display: flex; align-items: center; gap: .8rem; border-radius: 15px; padding: .85rem 1rem;
          border: 1.5px solid var(--line); background: var(--surface); text-align: left; width: 100%;
          color: inherit; font-family: inherit; }
.lesson .num { width: 34px; height: 34px; flex: none; border-radius: 10px; display: flex; align-items: center;
               justify-content: center; font-family: var(--display); font-weight: 700; font-size: .9375rem; }
.lesson .txt { flex: 1; min-width: 0; }
.lesson .lt { font-family: var(--display); font-weight: 700; font-size: .9375rem; line-height: 1.2; }
.lesson .ls { font-weight: 400; font-size: .75rem; line-height: 1.3; color: var(--muted); margin-top: .1rem; }
.lesson .chev { width: 20px; height: 20px; flex: none; color: var(--muted); }
.lesson.done { border-color: var(--accent-line); background: var(--accent-soft); }
.lesson.done .num { background: var(--teal); color: #fff; }
.lesson.done .lt { color: var(--accent-ink); }
.lesson.done .ls { color: var(--accent-ink); opacity: .85; }
.lesson.next { border: 2px solid var(--stroke); box-shadow: 3px 4px 0 var(--shadow); cursor: pointer; }
.lesson.next .num { background: var(--amber); border: 1.5px solid var(--stroke); color: var(--amber-ink); }
.lesson.locked { opacity: .6; }
.lesson.locked .num { background: var(--chip-neutral); color: var(--faint); }
.lesson.locked .lt { color: var(--muted); }
button.lesson { cursor: pointer; }
.learn-progress { font-weight: 500; font-size: .75rem; color: var(--faint); text-align: center; margin-top: 1rem; }
.intro-lesson .num { background: var(--ramp); border: 1.5px solid var(--stroke); color: #fff; }   /* the "0" on the Learn list */

/* quiet opt-in link to the written rules, below the tutorial */
.rules-link { display: flex; align-items: center; justify-content: center; gap: .35rem; width: 100%;
              margin: 1.15rem 0 .2rem; padding: .5rem; background: none; border: none; cursor: pointer;
              font-family: var(--display); font-weight: 600; font-size: .9375rem; color: var(--teal); }
.rules-link svg { width: 15px; height: 15px; flex: none; }

/* the written-rules reference screen */
.rules { display: flex; flex-direction: column; gap: 1.15rem; }
.rules section h2 { font-family: var(--display); font-weight: 700; font-size: .9375rem; color: var(--ink);
                    margin: 0 0 .35rem; }
.rules section p { font-weight: 400; font-size: .875rem; line-height: 1.55; color: var(--muted); margin: 0; }
.rules section p + p { margin-top: .5rem; }
.rules ul + p { margin-top: .6rem; }
.rules ul { margin: .4rem 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.rules li { font-weight: 400; font-size: .875rem; line-height: 1.5; color: var(--muted);
            padding-left: 1rem; position: relative; }
.rules li::before { content: ""; position: absolute; left: .15rem; top: .55em; width: 5px; height: 5px;
                    border-radius: 50%; background: var(--teal); }
.rules b, .rules strong { color: var(--ink); font-weight: 700; }

/* ============================ RECENT ============================ */
.rows { display: flex; flex-direction: column; gap: .55rem; margin-top: .5rem; }
.row { display: flex; align-items: center; gap: .75rem; border: 1.5px solid var(--line); background: var(--surface);
       border-radius: 14px; padding: .8rem .95rem; text-align: left; width: 100%; color: inherit;
       font-family: inherit; cursor: pointer; }
.row .rn { font-family: var(--display); font-weight: 700; font-size: 1.0625rem; min-width: 2.75rem; }
.row .rmeta { font-weight: 600; font-size: .8125rem; color: var(--muted); }
.row .rres { margin-left: auto; display: inline-flex; align-items: center; gap: .3rem;
             font-weight: 700; font-size: .75rem; }
.row .rres.solved { color: var(--teal); }
.row .rres.solved svg { width: 14px; height: 14px; }
.row .rres.none { color: var(--faint); font-weight: 600; }
.row .rres.today { color: var(--ramp); font-family: var(--display); }
.row.today { border: 2px solid var(--stroke); box-shadow: var(--sticker-shadow); }
:root[data-theme="dark"] .row .rres.solved, :root:not([data-theme="light"]) .row .rres.solved { color: var(--turn); }

/* ============================ SETTINGS ============================ */
.group-label { font-weight: 700; font-size: .6875rem; text-transform: uppercase; letter-spacing: .09em;
               color: var(--faint); margin: 1.35rem .15rem .6rem; }
.group { border: 1.5px solid var(--line); background: var(--surface); border-radius: 16px; overflow: hidden; }
.grow { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .95rem 1rem; }
.grow + .grow { border-top: 1px solid var(--line); }
.grow .gtitle { font-weight: 600; font-size: .9375rem; }
.grow.link { cursor: pointer; width: 100%; text-align: left; background: none; border: none; color: inherit; font-family: inherit; }
.grow.link svg { width: 18px; height: 18px; color: var(--faint); flex: none; }
.grow.col { flex-direction: column; align-items: stretch; gap: .75rem; }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 11px; overflow: hidden; flex: none; }
.seg button { padding: .6rem .9rem; border: none; cursor: pointer; background: transparent; color: var(--muted);
              font-family: var(--display); font-weight: 700; font-size: .8125rem; min-height: 44px; }
.seg button[aria-pressed="true"] { background: var(--teal); color: #fff; }
.sizes { display: flex; gap: .5rem; align-items: flex-end; }
.sizes button { flex: 1; text-align: center; border: 1.5px solid var(--line); border-radius: 9px;
                background: transparent; color: var(--muted); cursor: pointer; font-family: var(--display);
                font-weight: 700; min-height: 44px; }
.sizes button.s { font-size: .75rem; } .sizes button.m { font-size: .9375rem; }
.sizes button.l { font-size: 1.125rem; } .sizes button.xl { font-size: 1.375rem; }
.sizes button[aria-pressed="true"] { border: 2px solid var(--stroke); color: var(--ink); background: var(--accent-soft); }
.about-foot { text-align: center; font-weight: 500; font-size: .75rem; line-height: 1.5; color: var(--faint); margin-top: 1.25rem; }
.scoring-note { font-weight: 400; font-size: .8125rem; line-height: 1.5; color: var(--muted);
                padding: 0 1rem .95rem; }
.scoring-note .note-link { color: var(--teal); font-weight: 600; text-decoration: none; white-space: nowrap; }

/* ============================ WIN ============================ */
.win-head { text-align: center; padding: 1.6rem 0 .4rem; }
.solved-pill { display: inline-flex; align-items: center; gap: .45rem; background: var(--accent-soft);
               border: 1.5px solid var(--accent-line); border-radius: 999px; padding: .45rem 1rem;
               font-family: var(--display); font-weight: 700; font-size: .75rem; letter-spacing: .05em; color: var(--accent-ink); }
.solved-pill svg { width: 15px; height: 15px; }
.win-num { font-family: var(--display); font-weight: 700; font-size: 2.875rem; line-height: 1;
           letter-spacing: -.03em; margin-top: 1.1rem; }
.win-sub { font-weight: 500; font-size: .9375rem; color: var(--muted); margin-top: .6rem; }
.share-card { margin-top: 1.35rem; border: 2px solid var(--stroke); border-radius: 20px;
              background: #26221b; color: #f5f0e6; box-shadow: 4px 5px 0 var(--teal); padding: 1.25rem 1.35rem; }
.share-card .brand { display: flex; align-items: center; gap: .5rem; margin-bottom: .85rem; }
.share-card .brand svg { width: 14px; height: 14px; }
.share-card .brand .bt { font-family: var(--display); font-weight: 700; font-size: .875rem; letter-spacing: .08em; }
.share-card .l1 { font-family: var(--display); font-weight: 700; font-size: .9375rem; line-height: 1.4; }
.share-card .l2 { font-weight: 500; font-size: .875rem; line-height: 1.5; color: #c9c0b0; margin-top: .35rem; }
.win-actions { display: flex; gap: .625rem; margin-top: 1rem; }
.win-actions button { flex: 1; min-height: 50px; border-radius: 15px; border: 2px solid var(--stroke);
                      font-family: var(--display); font-weight: 700; font-size: 1rem; cursor: pointer;
                      display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.win-actions .copy { background: var(--teal); color: #fff; box-shadow: 3px 4px 0 var(--shadow); }
.win-actions .share { background: #26221b; color: #f5f0e6; box-shadow: 3px 4px 0 var(--teal); }
.win-actions .share svg { width: 17px; height: 17px; }
.win-again { display: flex; gap: .625rem; margin-top: .7rem; }
.win-again .win-2nd { flex: 1; min-height: 48px; border-radius: 15px; border: 2px solid var(--stroke);
                      background: var(--surface); color: var(--ink); box-shadow: var(--sticker-shadow);
                      font-family: var(--display); font-weight: 700; font-size: .9375rem; cursor: pointer; }
.win-again .win-2nd:active { transform: translate(1px, 1px); box-shadow: 3px 4px 0 var(--shadow); }
.win-replay { font-weight: 500; font-size: .75rem; line-height: 1.5; color: var(--faint);
              text-align: center; margin-top: .7rem; }
.win-back { width: 100%; margin-top: .7rem; min-height: 46px; border: 1.5px solid var(--line);
            background: var(--surface); color: var(--muted); border-radius: 14px;
            font-family: var(--display); font-weight: 700; font-size: .875rem; cursor: pointer; }
.win-foot { font-weight: 500; font-size: .75rem; line-height: 1.5; color: var(--faint); text-align: center; margin-top: 1rem; }

/* ============================ MOTION ============================ */
.chip.flip { transition: transform .5s cubic-bezier(.22,.68,.28,1); }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
