/* The game table: layout, panels, controls and the board around the shared card
   (cards.css) and phone (compact.css) components. Loaded by index.html after both. */
  :root {
    --ink:#1a1a1a; --red:#d11; --line:rgba(0,0,0,.25);
    --accent:#2f6fed; --yellow:#f4c542; --yellow-d:#d9a72a;
    --ui-scale:1;
    --spotlight-glow:0 0 0 3px var(--yellow),0 0 18px rgba(244,197,66,.38);
    --font-scale:1.3333;
    /* Deck color + face/back theming moved to cards.css (shared with the site). */
    --side-width:calc(200px * var(--ui-scale));
    --arena-width:calc(484px * var(--ui-scale));
    --hand-card-w:calc(70px * var(--ui-scale));
    --pile-card-w:calc(70px * var(--ui-scale));
    --opp-card-w:calc(44px * var(--ui-scale));
    --opp-card-h:calc(var(--opp-card-w) * 1.40625);
    --opp-card-overlap:calc(-22px * var(--ui-scale));
    /* renderFan() arcs cards with rotate(off*3.2deg) translateY(off*off*1.3px),
       off up to ±5 while Gus holds 11 cards after drawing. That paint escapes
       the flex box, so the fan reserves the maximum envelope as real padding:
       5²*1.3 = 32.5 design px of arc drop, plus the rotated corner dip of half
       a card width * sin(5*3.2deg) = w * .1378.
       If the constants in renderFan change, the layout sweep test fails. */
    --opp-fan-dip:calc(32.5px * var(--ui-scale) + var(--opp-card-w) * .1378);
    /* The fan gets its own flexible row. Breathing room keeps that row taller
       than the painted arc at the 900x520 floor; the small balance correction
       accounts for the arc reserving more paint below the card than above it. */
    --opp-fan-breathing:calc(27px * var(--ui-scale));
    --opp-fan-balance:calc(4px * var(--ui-scale));
    --opp-fan-slot-min:calc(var(--opp-card-h) + var(--opp-fan-dip) + var(--opp-fan-breathing));
    --hud-inset:calc(8px * var(--ui-scale));
    --hud-gap:calc(2px * var(--ui-scale));
    --card-controls-gap:calc(3px * var(--ui-scale));
    --spring-gap-min:calc(6px * var(--ui-scale));
    --sai-top:env(safe-area-inset-top);
    --sai-right:env(safe-area-inset-right);
    --sai-bottom:env(safe-area-inset-bottom);
    --sai-left:env(safe-area-inset-left);
    /* Font scale knob: ONE multiplier drives every readable table text size,
       written as calc(<design-px> * var(--fs)). Standard uses the original design
       size; Large (the default) adds the 50+ readability multiplier. Inside the
       table, --fs combines that preference with the shared viewport scale. */
    --fs: var(--font-scale);
    --sb-font-base:  calc(13px * var(--font-scale) * var(--ui-scale));
    --sb-font-score: calc(20px * var(--font-scale) * var(--ui-scale));
    --sb-font-meta:  calc(11px * var(--font-scale) * var(--ui-scale));
    --sb-font-mode:  calc(10px * var(--font-scale) * var(--ui-scale));
  }
  :root[data-font-size="standard"] { --font-scale:1; }
  * { box-sizing:border-box; }
  [hidden] { display:none !important; }
  html, body { margin:0; min-height:100%; overflow-x:hidden; }
  html,
  body {
    width:100%; height:100%; min-height:0; overflow:hidden;
  }
  body {
    font:15px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
    font-size:calc(15px * var(--fs)); /* base readable text — all inherited text scales from here */
    color:#fff; background:#14572d;
  }

  /* ---- the table ---- */
  .table {
    --fs:calc(var(--font-scale) * var(--ui-scale));
    position:relative;
    height:100svh; min-height:0;
    background:radial-gradient(ellipse 90% 70% at 50% 36%, #2fa15a 0%, #218046 55%, #155f33 100%);
    display:grid;
    grid-template-columns:var(--side-width) minmax(var(--arena-width),1fr) var(--side-width);
    grid-template-areas:"left arena right";
    gap:0;
    padding:
      calc(var(--hud-inset) + env(safe-area-inset-top))
      calc(var(--hud-inset) + env(safe-area-inset-right))
      calc(var(--hud-inset) + env(safe-area-inset-bottom))
      calc(var(--hud-inset) + env(safe-area-inset-left));
    font-size:calc(15px * var(--fs));
    overflow:hidden;
  }
  @supports (height:100dvh) {
    .table { height:100dvh; }
  }
  .hud-column {
    position:relative; z-index:5; min-width:0;
    display:flex; flex-direction:column; gap:var(--hud-gap);
    pointer-events:none;
  }
  .hud-column > * { pointer-events:auto; }
  .side { align-self:stretch; }
  .side > * { pointer-events:auto; }
  .left-rail { grid-area:left; align-items:flex-start; }
  .right-rail { grid-area:right; align-items:flex-end; }
  .arena {
    grid-area:arena; min-width:0; min-height:0;
    display:grid;
    grid-template-rows:
      auto
      minmax(var(--opp-fan-slot-min),2fr)
      auto
      minmax(var(--spring-gap-min),1fr)
      auto;
    align-items:center;
    justify-items:center;
    padding:0;
  }
  .seat {
    display:flex; width:min(100%,var(--arena-width)); min-width:0;
    flex-direction:column; align-items:center; gap:var(--hud-gap);
  }
  .seat.opponent { display:contents; }
  .seat.opponent #cpuPlate {
    grid-row:1; align-self:start; justify-self:center;
  }
  .seat.opponent #computer {
    grid-row:2; align-self:center; justify-self:center;
    width:min(100%,var(--arena-width)); min-width:0;
    transform:translateY(var(--opp-fan-balance));
  }
  .seat.player { grid-row:5; align-self:end; }
  .center {
    grid-row:3;
    display:flex; width:min(100%,var(--arena-width)); min-width:0;
    flex-direction:column; align-items:center;
    margin:0; padding:0; transform:none;
  }
  /* Deck themes (clean / deco / classic) moved to cards.css. */

  /* ---- floating HUD (casino plaque vibe) ---- */
  .hud-panel {
    border-radius:calc(10px * var(--ui-scale));
    box-shadow:inset 0 1px 0 rgba(255,255,255,.05), 0 calc(2px * var(--ui-scale)) calc(6px * var(--ui-scale)) rgba(0,0,0,.35);
  }
  .hud-panel--dark {
    background: #0f2a1f;
    color: #f1e9d2;
    border: 1px solid #3a5f4a;
    padding:calc(8px * var(--ui-scale)) calc(11px * var(--ui-scale));
    font-weight: 600;
    font-size: calc(16px * var(--fs));
    line-height: 1.35;
  }
  .bubble { width:calc(184px * var(--ui-scale)); max-width:100%; margin-top:auto; }
  .bubble .status-main {
    display:block;
    font-size:calc(14px * var(--fs));
    font-weight:500;
    color:#e8d9a8;
  }
  .bubble .status-next {
    display:block;
    margin-top:calc(2px * var(--ui-scale));
    font-size:calc(11px * var(--fs));
    font-weight:400;
    color:#c8ccd1;
  }

  .mode-badge {
    width:100%;
    max-width:none;
    background:
      linear-gradient(180deg,rgba(255,255,255,.05),rgba(0,0,0,.08)),
      #0f2a1f;
    border:1px solid #7c6333;
    color:#f1e9d2;
    text-align:center;
    padding:
      calc(8px * var(--ui-scale))
      calc(9px * var(--ui-scale))
      calc(9px * var(--ui-scale));
    overflow:hidden;
  }
  .brand-line { display:contents; }
  .brand-mark {
    display:block;
    margin:0;
    white-space:nowrap;
    font:900 calc(14px * var(--fs))/1.25 Georgia,"Times New Roman",serif;
    letter-spacing:0;
    text-decoration:none;
    /* The silver lettering is .silver-text .silver-glow (brand.css). */
  }
  .brand-logo { width:1.55em; height:1.55em; margin-right:.4em; vertical-align:-.4em; }
  .mode-badge .mode-title::before { content:"— "; }
  .mode-badge .mode-title::after { content:" —"; }
  .mode-badge .mode-title {
    display:block;
    margin-top:calc(6px * var(--ui-scale));
    color:#ffe070;
    font:700 calc(12px * var(--fs))/1.15 Georgia,"Times New Roman",serif;
    letter-spacing:-.03em;
    white-space:nowrap;
    text-transform:none;
    text-shadow:0 1px 2px rgba(0,0,0,.42);
  }
  /* The game-type menu matches the Free Play / Teaching switch above it. */
  /* On the wide table the pill and its ⓘ center as one row, and the title's dashes sit
     inside the pill: ( — Classic ▾ — ) ⓘ. The dashes are drawn over the menu and let
     taps through, so the whole pill opens it. */
  html[data-layout="wide"] #modeBadge > .mode-title {
    display:flex; align-items:center; justify-content:center; gap:.35em;
  }
  html[data-layout="wide"] #modeBadge > .mode-title::before,
  html[data-layout="wide"] #modeBadge > .mode-title::after { content:none; }
  html[data-layout="wide"] .mode-pill { position:relative; display:inline-flex; min-width:0; }
  html[data-layout="wide"] .mode-pill::before,
  html[data-layout="wide"] .mode-pill::after {
    content:"—"; position:absolute; z-index:1; top:50%; transform:translateY(-52%);
    font-size:.75em; line-height:1; pointer-events:none;
  }
  html[data-layout="wide"] .mode-pill::before { left:.7em; }
  html[data-layout="wide"] .mode-pill::after { right:.7em; }
  html[data-layout="wide"] .mode-select { padding-left:1.7em; padding-right:2.55em; background-position:right 1.62em center; }
  .mode-select {
    appearance:none; -webkit-appearance:none;
    display:inline-block; max-width:100%; margin:0;
    padding:.22em 1.7em .22em .8em;
    border:1px solid rgba(226,190,93,.5); border-radius:999px;
    background:rgba(4,23,15,.42) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23ffe070'/%3E%3C/svg%3E") no-repeat right .7em center / .58em .35em;
    box-shadow:inset 0 1px 3px rgba(0,0,0,.35);
    color:#ffe070; font:inherit; letter-spacing:inherit; text-shadow:inherit;
    cursor:pointer;
    transition:border-color .12s ease, background-color .12s ease;
  }
  .mode-select:hover { border-color:#e2be5d; background-color:rgba(255,255,255,.07); }
  .mode-select:focus-visible { outline:2px solid #ffe070; outline-offset:2px; }
  /* Safari and Firefox open the system's light menu, so its options read in dark ink. */
  .mode-select option { color:#1a1a1a; background:#fff; text-shadow:none; }
  /* Chrome and Edge (customizable selects) draw the open list in the table's colors:
     the green, gold-edged panel of the hand-review outcome. */
  @supports (appearance: base-select) {
    .mode-select,
    .mode-select::picker(select) { appearance:base-select; }
    /* The customizable button lays out as the browser's own inline-flex box. */
    .mode-select { display:inline-flex; align-items:center; }
    .mode-select::picker-icon { display:none; }
    .mode-select::picker(select) {
      margin-top:calc(6px * var(--ui-scale)); padding:calc(4px * var(--ui-scale));
      border:1px solid #c9a54d; border-radius:calc(10px * var(--ui-scale));
      background:linear-gradient(145deg,#173f2c,#0b271b);
      box-shadow:inset 0 1px 0 rgba(255,240,197,.12),0 10px 24px rgba(0,0,0,.42);
    }
    .mode-select option {
      gap:.55em; padding:calc(7px * var(--ui-scale)) calc(14px * var(--ui-scale)) calc(7px * var(--ui-scale)) calc(10px * var(--ui-scale));
      border-radius:calc(6px * var(--ui-scale));
      background:transparent; color:#f1e9d2;
      font:700 calc(13px * var(--fs))/1.2 Georgia,"Times New Roman",serif;
      white-space:nowrap; cursor:pointer;
    }
    .mode-select option:hover,
    .mode-select option:focus-visible { background:rgba(255,224,112,.14); color:#fff0c5; outline:none; }
    .mode-select option:checked { color:#ffe070; }
    .mode-select option::checkmark { color:#ffe070; }
  }
  /* The ⓘ beside the menu: a gold outline, filled while its rules card is open. */
  .mode-info {
    position:relative; display:inline-grid; place-items:center; flex:none;
    width:1.1em; height:1.1em; margin:0 0 0 .3em; padding:0; border:0;
    background:none; color:#ffe070; cursor:pointer; vertical-align:-.18em;
  }
  html[data-layout="wide"] .mode-badge .mode-info { margin:0; }
  .mode-info[hidden] { display:none; }
  /* A larger target than the glyph, for fingers. */
  .mode-info::after { content:""; position:absolute; inset:-.45em; }
  .mode-info svg { width:100%; height:100%; overflow:visible; }
  .mode-info circle { fill:none; stroke:currentColor; stroke-width:1.6; transition:fill .15s ease; }
  .mode-info path { fill:none; stroke:currentColor; stroke-width:2.1; stroke-linecap:round; transition:stroke .15s ease; }
  .mode-info:hover circle { fill:rgba(255,224,112,.16); }
  .mode-info[aria-expanded="true"] circle { fill:currentColor; }
  .mode-info[aria-expanded="true"] path { stroke:#0f2a1f; }
  .mode-info:focus-visible { outline:2px solid #ffe070; outline-offset:2px; border-radius:50%; }
  /* Rules card (src/rules-card.js): the glossary's definition card (glossary.css),
     floating below the ⓘ with a notch pointing at it. It sits outside the table, so it
     takes the table's text scale here. Both classes in the selector: glossary.css loads
     later and would otherwise put the card back in the page flow, below the table. */
  .gin-tutorial-definition.mode-rules-card {
    --fs:calc(var(--font-scale) * var(--ui-scale));
    position:fixed; z-index:500; margin:0;
    width:max-content; max-width:min(calc(260px * var(--ui-scale)), calc(100vw - 16px));
    text-align:left; text-shadow:none;
  }
  .mode-rules-card[hidden] { display:none; }
  /* A definition opened inside the card wraps to the card's width instead of widening
     it: at width 0 it adds nothing to the card's fit-to-content width, then fills it.
     It also reaches into the card's right padding (kept clear for the card's own ×, up
     top), so it sits as far from the right border as from the left: 11px. */
  .gin-tutorial-definition.mode-rules-card .gin-tutorial-definition {
    box-sizing:border-box; width:0;
    min-width:calc(100% + 19px * var(--ui-scale)); margin-right:calc(-19px * var(--ui-scale));
  }
  /* Compact layouts give definition cards 46px of right padding (compact.css). */
  html[data-layout="compact"] .gin-tutorial-definition.mode-rules-card .gin-tutorial-definition {
    min-width:calc(100% + 35px); margin-right:-35px;
  }
  .mode-rules-card::before {
    content:""; position:absolute; top:-6px; left:calc(var(--rules-notch-x, 24px) - 6px);
    width:10px; height:10px; background:#edf5ef;
    border-top:1px solid #6c998c; border-left:1px solid #6c998c; transform:rotate(45deg);
  }
  .mode-rules-list { margin:calc(4px * var(--ui-scale)) 0 0; padding:0 0 0 1.15em; }
  .mode-rules-list li { margin:calc(3px * var(--ui-scale)) 0 0; }
  .mode-badge .mode-description {
    display:block;
    margin-top:calc(6px * var(--ui-scale));
    color:rgba(241,233,210,.72);
    font:600 calc(11px * var(--fs))/1.2 system-ui,sans-serif;
  }
  .player-record {
    min-width:0;
    padding:calc(7px * var(--ui-scale)) calc(8px * var(--ui-scale));
    border:1px solid rgba(124,99,51,.85);
    border-radius:calc(8px * var(--ui-scale));
    background:rgba(15,42,31,.78);
    color:#f1e9d2;
    text-align:center;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.05),0 2px 6px rgba(0,0,0,.2);
  }
  .scoreboard .player-record {
    margin-top:calc(8px * var(--ui-scale));
  }
  .player-record-label {
    display:block;
    color:#c9a85d;
    font:800 calc(8px * var(--fs))/1 system-ui,sans-serif;
    letter-spacing:.12em;
    text-transform:uppercase;
  }
  .player-record-values {
    display:flex;
    align-items:baseline;
    justify-content:center;
    gap:calc(5px * var(--ui-scale));
    margin-top:calc(3px * var(--ui-scale));
    font:800 calc(10px * var(--fs))/1 system-ui,sans-serif;
  }
  .player-record-values b { font-size:calc(16px * var(--fs)); color:#ffe070; }
  .player-record-values .record-wins { color:#9fd4ff; }
  .player-record-values .record-losses { color:#ff9a9a; }
  .player-record-values small { color:rgba(241,233,210,.64); font-size:calc(8px * var(--fs)); letter-spacing:.04em; }

  /* scoreboard - premium tote / casino counter look */
  .scoreboard {
    width:min(calc(132px * var(--ui-scale)),100%);
    margin-left: auto;
    background: #0f2a1f;
    color: #e8d9a8;
    border: 1px solid #3a5f4a;
    overflow: hidden;
    font-size: var(--sb-font-base);
  }
  .scoreboard .row {
    display:flex; justify-content:space-between; align-items:center;
    padding:calc(5px * var(--ui-scale)) calc(9px * var(--ui-scale));
    border-top: 1px solid rgba(255,255,255,.08);
  }
  .scoreboard .row:first-child { border-top: none; }
  .scoreboard .meta-row {
    display:grid; grid-template-columns:1fr 1fr;
    gap:calc(4px * var(--ui-scale));
    padding:calc(6px * var(--ui-scale)) calc(6px * var(--ui-scale)) 0;
    border-top:1px solid rgba(201,168,93,.22);
  }
  .scoreboard .meta-row .row {
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:calc(4px * var(--ui-scale));
    border-top:none;
    border-radius:calc(6px * var(--ui-scale));
    background:rgba(255,255,255,.045);
    text-align:center;
  }
  .scoreboard .meta-row .row span {
    align-self:center;
    width:auto;
    padding-top:0;
    border-top:0;
    font-size:calc(8px * var(--fs));
    letter-spacing:.1em;
    text-transform:uppercase;
    line-height:1;
  }
  .scoreboard .row.round span,
  .scoreboard .row.turn span {
    font-weight: 800;
    color: #c9a85d;
  }
  .scoreboard .row.round,
  .scoreboard .row.turn {
    font-size: var(--sb-font-meta);
    color: #a38e5f;
    padding:calc(6px * var(--ui-scale)) calc(4px * var(--ui-scale));
  }
  .scoreboard .meta-row .row b {
    font-size: calc(16px * var(--fs));
    line-height: 1;
    min-width:0;
    text-align:center;
    color:#f1e9d2;
  }
  .scoreboard .row b {
    font: 900 20px/1 "SF Pro Rounded", ui-rounded, system-ui, sans-serif;
    font-size: var(--sb-font-score);
    color: #ffe070;
    text-shadow: 0 1px 0 rgba(0,0,0,.6);
    transition: transform .2s;
    display: inline-block;
    min-width: 1.6em;
    text-align: right;
  }
  .scoreboard .you b,
  .scoreboard .cpu b { color: #c8ccd1; }
  .scoreboard b.bump { transform: scale(1.35); }
  /* Wide layouts: Hand and Turn read as one quiet stat strip under the scores,
     split by a hairline instead of two boxed tiles. Phones keep compact.css. */
  html[data-layout="wide"] .scoreboard .meta-row {
    gap:0;
    margin-top:calc(2px * var(--ui-scale));
    padding:calc(8px * var(--ui-scale)) 0 calc(2px * var(--ui-scale));
    border-top:1px solid rgba(201,168,93,.28);
  }
  html[data-layout="wide"] .scoreboard .meta-row .row {
    gap:calc(5px * var(--ui-scale));
    padding:calc(2px * var(--ui-scale)) calc(4px * var(--ui-scale));
    border-radius:0;
    background:none;
  }
  html[data-layout="wide"] .scoreboard .meta-row .row.turn {
    border-left:1px solid rgba(201,168,93,.22);
  }
  html[data-layout="wide"] .scoreboard .meta-row .row span {
    font-size:calc(9px * var(--fs));
    letter-spacing:.14em;
  }
  html[data-layout="wide"] .scoreboard .meta-row .row b {
    font-size:calc(18px * var(--fs));
  }

  /* ---- name plates ---- */
  .plate {
    display:inline-flex; align-items:center; gap:calc(8px * var(--ui-scale));
    background:rgba(255,255,255,.92); color:#1e3a8a; font-weight:700;
    padding:calc(5px * var(--ui-scale)) calc(16px * var(--ui-scale));
    border-radius:calc(14px * var(--ui-scale)); box-shadow:0 1px 3px rgba(0,0,0,.25);
    transition:box-shadow .2s, background .2s;
  }
  .plate.cpu {
    gap:calc(7px * var(--ui-scale)); position:relative; align-items:stretch; overflow:visible; color:#f6e8bd;
    background:linear-gradient(145deg,#244735 0%,#142e22 62%,#0d2118 100%);
    border:1px solid #9b793f;
    padding:
      calc(2px * var(--ui-scale))
      calc(8px * var(--ui-scale))
      calc(2px * var(--ui-scale))
      calc(2px * var(--ui-scale));
    border-radius:calc(12px * var(--ui-scale));
    box-shadow:inset 0 -1px 0 rgba(0,0,0,.3),0 4px 10px rgba(0,0,0,.28);
  }
  .plate.cpu::after {
    /* A glint on the gold top border itself; drawn inside it, it read as a dip in the fill. */
    content:""; position:absolute; top:-1px; right:calc(10px * var(--ui-scale)); width:42%; height:1px;
    background:linear-gradient(90deg,transparent,rgba(246,220,151,.5),transparent);
  }
  .opponent-copy {
    display:flex; width:calc(72px * var(--ui-scale)); min-width:0; flex-direction:column;
    justify-content:center; align-self:stretch;
    padding:calc(3px * var(--ui-scale)) 0 calc(4px * var(--ui-scale));
  }
  .opponent-identity {
    display:flex; width:100%; min-width:calc(52px * var(--ui-scale)); flex-direction:column; align-items:center;
    line-height:1; text-align:center;
  }
  .opponent-name {
    /* The silver lettering is .silver-text (brand.css). */
    font:700 calc(15px * var(--fs))/1 Georgia,"Times New Roman",serif;
    letter-spacing:.015em;
  }
  .opponent-role {
    margin-top:calc(3px * var(--ui-scale)); color:#c6a65d;
    font:800 calc(6px * var(--fs))/1 system-ui,-apple-system,"Segoe UI",sans-serif;
    letter-spacing:.16em; text-transform:uppercase; white-space:nowrap;
  }
  .opponent-portrait-frame {
    width:calc(58px * var(--ui-scale)); aspect-ratio:4/5; flex:none; display:block;
    overflow:hidden; border-radius:calc(10px * var(--ui-scale));
    border:1px solid #b68c45; background:#efe3c8;
    box-shadow:0 0 0 1px rgba(8,25,17,.8),inset 0 1px 0 rgba(255,255,255,.7),0 2px 5px rgba(0,0,0,.3);
  }
  .opponent-portrait {
    width:100%; height:100%; display:block; object-fit:cover; object-position:50% 28%;
    image-rendering:auto;
  }
  /* Mute toggle for Gus's comments: a corner badge kept out of the plate's flow. */
  /* Solid little speech balloon in the speech bubble's paper and ink colors. */
  .gus-mute {
    position:absolute; right:calc(4px * var(--ui-scale)); bottom:calc(2.5px * var(--ui-scale));
    width:calc(20px * var(--ui-scale)); height:calc(20px * var(--ui-scale));
    display:grid; place-items:center; padding:0; margin:0;
    border:0; border-radius:50%; background:transparent; cursor:pointer;
    transition:transform .12s ease;
  }
  .gus-mute[hidden] { display:none; }
  .gus-mute svg { width:100%; height:100%; overflow:visible; filter:drop-shadow(0 1px 1px rgba(0,0,0,.45)); }
  .gus-mute-bubble { fill:#fff4d6; stroke:#332b20; stroke-width:1.5; stroke-linejoin:round; }
  .gus-mute-bubble { transition:fill .18s ease, stroke .18s ease; }
  /* Muted: the wave bars shrink into a row of dots. */
  .gus-mute-wave { fill:none; stroke:#332b20; stroke-width:1.3; stroke-linecap:round; }
  .gus-mute-dots { fill:#332b20; }
  .gus-mute-wave { transform-box:fill-box; transform-origin:center; transition:transform .18s ease; }
  .gus-mute-dots { opacity:0; transition:opacity .12s ease .08s; }
  .gus-mute[aria-pressed="false"] .gus-mute-wave { transform:scaleY(0); }
  .gus-mute[aria-pressed="false"] .gus-mute-dots { opacity:1; }
  .gus-mute[aria-pressed="false"] .gus-mute-bubble { fill:#9fb0a5; stroke:#9fb0a5; }
  @media (hover:hover) { .gus-mute:hover { transform:scale(1.12) rotate(-6deg); } }
  .gus-mute:active { transform:scale(.94); }
  .gus-mute:focus-visible { outline:2px solid #ffe070; outline-offset:2px; }
  .plate.cpu.portrait-missing { padding-left:calc(10px * var(--ui-scale)); }
  .plate.cpu.portrait-missing .opponent-portrait-frame { display:none; }
  .plate.active { box-shadow:0 0 0 3px var(--yellow), 0 1px 3px rgba(0,0,0,.25); }
  .plate.cpu.active {
    box-shadow:var(--spotlight-glow),0 5px 12px rgba(0,0,0,.34);
  }
  /* Shared gold glow: Gus's plate on his turn, and whatever a tip's Show me points at.
     It pulses twice, then fades; with animations off it simply shows until removed. */
  .gus-spotlight { border-radius:calc(8px * var(--ui-scale)); box-shadow:var(--spotlight-glow); animation:gus-spotlight 2.4s ease-out forwards; }
  @keyframes gus-spotlight {
    0%, 40%, 75% { box-shadow:var(--spotlight-glow); }
    20%, 58% { box-shadow:0 0 0 3px rgba(244,197,66,.35); }
    100% { box-shadow:0 0 0 0 rgba(244,197,66,0); }
  }
  /* Script places speech against the viewport (index.html positionOpponentBubble,
     compact-ui.js). It sizes to its text; lines wrap at --speech-max-width. */
  .opponent-comment {
    --speech-max-width:calc(180px * var(--ui-scale));
    position:fixed; z-index:60; margin:0;
    padding:calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
    border:1px solid #b89b67; border-radius:calc(10px * var(--ui-scale));
    background:linear-gradient(145deg,#fff9e9,#f2e4c3); color:#332b20;
    font-family:Georgia,"Times New Roman",serif; font-weight:600; font-size:calc(13px * var(--fs)); line-height:1.34;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.9),0 5px 14px rgba(0,0,0,.28);
    opacity:0; transition:opacity .18s ease;
    pointer-events:none;
  }
  .opponent-comment::before {
    content:""; position:absolute; left:calc(-6px * var(--ui-scale)); top:var(--gus-tail-top,calc(13px * var(--ui-scale)));
    width:calc(10px * var(--ui-scale)); height:calc(10px * var(--ui-scale));
    background:#f9efd5; border-left:1px solid #b89b67; border-bottom:1px solid #b89b67;
    transform:rotate(45deg);
  }
  .opponent-comment.show { opacity:1; }
  /* Tips run a little wider, take taps (tap to close) and carry a Show me button. */
  .opponent-comment.gus-tip { --speech-max-width:calc(240px * var(--ui-scale)); pointer-events:auto; cursor:pointer; }
  .gus-tip-actions { display:flex; justify-content:flex-end; margin-top:calc(6px * var(--ui-scale)); }
  .opponent-comment[hidden] { display:none; }
  .player-hand-area {
    display:flex; width:100%; flex-direction:column; align-items:center;
    gap:var(--card-controls-gap);
  }
  .player-hand-area #hand { width:100%; min-width:0; }
  .hand-tools-wrap {
    display:flex; flex:none; align-items:center; justify-content:center; gap:calc(4px * var(--ui-scale));
  }
  .hand-tools-title {
    color:rgba(255,255,255,.85);
    font:700 calc(9px * var(--fs))/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
    letter-spacing:.06em; text-transform:uppercase; white-space:nowrap;
  }
  .hand-tools { display:flex; gap:calc(5px * var(--ui-scale)); }
  .hand-sort-btn {
    display:inline-flex; align-items:center; justify-content:center;
    gap:calc(5px * var(--ui-scale));
    padding:calc(3px * var(--ui-scale)) calc(6px * var(--ui-scale));
    min-width:calc(72px * var(--ui-scale)); height:calc(24px * var(--ui-scale));
    border:1px solid rgba(255,255,255,.3); border-radius:calc(8px * var(--ui-scale)); background:rgba(8,54,28,.74);
    color:#fff; font:700 calc(7.5px * var(--fs))/1 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
    cursor:pointer; box-shadow:0 1px 3px rgba(0,0,0,.2);
  }
  .hand-sort-btn:hover:not(:disabled) { background:rgba(19,83,45,.92); border-color:rgba(255,255,255,.52); }
  .hand-sort-btn:active:not(:disabled) { transform:translateY(1px); }
  /* Gin's review locks Sort until the next hand (src/gin-rummy-ui.js). */
  .hand-sort-btn:disabled { opacity:.42; cursor:default; box-shadow:none; }
  .hand-sort-btn svg { width:calc(18px * var(--ui-scale)); height:calc(14px * var(--ui-scale)); flex:none; }
  .sort-suit-icon,
  .sort-label-suit { display:none; }
  .sort-suit-icon { align-items:center; gap:calc(1px * var(--ui-scale)); }
  .sort-suit-icon img {
    display:block; width:calc(6px * var(--ui-scale)); height:calc(6px * var(--ui-scale)); object-fit:contain;
  }
  html[data-card-theme="classic"] .sort-color-icon,
  html[data-card-theme="classic"] .sort-label-color { display:none; }
  html[data-card-theme="classic"] .sort-suit-icon,
  html[data-card-theme="classic"] .sort-label-suit { display:inline-flex; }

  /* ---- cards ---- */
  .fan {
    display:flex; justify-content:center; align-items:flex-end;
    min-height:calc(96px * var(--ui-scale)); max-width:100%;
  }
  /* The .cardface component (pips, dots, suit marks, face art, backs) moved to
     cards.css — shared verbatim with the site. Game-only card behavior below. */
  button.cardface { cursor:pointer; }
  button.cardface:disabled { cursor:default; }

  /* opponent: smaller, tighter fan. The box owns the painted arc: cards sit at
     the top (flex-end against the dip padding), and the arc's below-the-box
     paint lands inside --opp-fan-dip instead of escaping into the piles. */
  .opponent .fan { min-height:0; padding-bottom:var(--opp-fan-dip); }
  .opponent .cardface { width:var(--opp-card-w); height:var(--opp-card-h); margin-left:var(--opp-card-overlap); transform-origin:bottom center; }
  .opponent .cardface:first-child { margin-left:0; }
  .opponent .cardface .pip { font-size:calc(20px * var(--ui-scale)); }

  /* your hand: bigger, overlapping, fanned, lifts on hover/select */
  #hand {
    min-height:calc(var(--hand-card-w) * 1.32 + 14px * var(--ui-scale));
    gap:calc(3px * var(--ui-scale));
    padding:
      calc(8px * var(--ui-scale))
      0
      calc(4px * var(--ui-scale));
  }
  /* Three-part "you can group these" hint; then it rests. */
  #hand .cardface.match-new .pip {
    animation:match-triple-double-bob 9.2s ease-in-out var(--match-cue-delay,0ms) 1;
  }
  #hand .cardface.match-new .face-art {
    animation:face-art-triple-double-bob 9.2s ease-in-out var(--match-cue-delay,0ms) 1;
  }


  /* One emphatic unison bounce the moment the match is grouped, then it rests. */
  #hand .cardface.match-settle .pip {
    animation:match-settle-bounce .56s cubic-bezier(.34,1.56,.5,1) 1;
  }
  #hand .cardface.match-settle .face-art {
    animation:face-art-settle-bounce .56s cubic-bezier(.34,1.56,.5,1) 1;
  }


  #hand .cardface.meld-run .color-dot {
    transform:scale(1.06);
    box-shadow:0 0 0 1px rgba(37,40,45,.18),inset 0 -3px 5px rgba(0,0,0,.12),inset 0 3px 6px rgba(255,255,255,.72);
    animation:breathe-glow 2.8s ease-in-out var(--glow-delay,0s) infinite;
  }
  /* Classic has no lamp. Three staggered ink waves mirror the finite match cue,
     then the run rests without a halo or bob. */
  html[data-card-theme="classic"] #hand .cardface.meld-run.classic-suit:not(.meld-grouped) .pip,
  html[data-card-theme="classic"] #hand .cardface.meld-run.classic-suit:not(.meld-grouped) .suit-mark,
  html[data-card-theme="classic"] #hand .cardface.meld-run.classic-suit:not(.meld-grouped).face .face-art {
    animation:classic-run-ink-wave 9.2s ease-in-out var(--run-wave-delay,0s) 1;
  }

  #hand .cardface.meld-run .color-dot::after {
    width:42%; top:12%; left:14%;
    background:rgba(255,255,255,.88);
    box-shadow:inset 0 0 2px #fff;
  }
  @keyframes breathe-glow {
    0%,100% {
      filter:brightness(1.03) saturate(1.05)
        drop-shadow(0 0 2px color-mix(in srgb,var(--card-color) 40%,transparent));
    }
    50% {
      filter:brightness(1.16) saturate(1.18)
        drop-shadow(0 0 11px color-mix(in srgb,var(--card-color) 92%,transparent));
    }
  }
  #hand .cardface.meld-run.meld-grouped .color-dot {
    animation:none;
    filter:brightness(1.1) saturate(1.1);
  }
  html[data-card-theme="classic"] #hand .cardface.meld-run.meld-grouped.classic-suit .suit-mark,
  html[data-card-theme="classic"] #hand .cardface.meld-run.meld-grouped.classic-suit.face .face-art {
    animation:none;
    filter:brightness(1.1) saturate(1.1);
  }
  #hand .cardface.meld-run.run-settle .color-dot {
    animation:run-settle-flash .6s cubic-bezier(.2,.9,.2,1) 1;
  }
  #hand .cardface.meld-run.run-settle .pip,
  #hand .cardface.meld-run.run-settle .face-art,
  html[data-card-theme="classic"] #hand .cardface.meld-run.run-settle.classic-suit .pip,
  html[data-card-theme="classic"] #hand .cardface.meld-run.run-settle.classic-suit .suit-mark,
  html[data-card-theme="classic"] #hand .cardface.meld-run.run-settle.classic-suit.face .face-art {
    animation:run-settle-ink 1.4s ease-in-out 1;
  }

  @media (prefers-reduced-motion:reduce) {
    #hand .cardface.meld-run .color-dot { animation:none; }
    #hand .cardface.meld-run .pip,
    #hand .cardface.match-new .pip,
    #hand .cardface.match-new .face-art,
    #hand .cardface.match-settle .pip,
    #hand .cardface.match-settle .face-art,
    #hand .cardface.meld-run .suit-mark,
    #hand .cardface.meld-run .face-art,
    #hand .cardface.run-settle .color-dot { animation:none; }
  }
  #hand:not(.click-move-active):not(.drag-active) button.cardface:not(:disabled):hover { box-shadow:0 0 0 2px rgba(255,255,255,.95),0 6px 12px rgba(0,0,0,.35); }
  #hand .cardface.selected { box-shadow:0 0 0 3px #fff,0 0 0 5px rgba(21,48,32,.55),0 10px 16px rgba(0,0,0,.4); }
  #hand .cardface.click-carried {
    box-shadow:0 0 0 3px #ffe27a,0 0 0 6px rgba(20,67,42,.68),0 12px 20px rgba(0,0,0,.42);
    cursor:copy;
  }
  #hand .cardface.dragging { opacity:.42; }
  #hand.drag-active { cursor:grabbing; }
  #hand.click-move-active { cursor:copy; }
  .hand-drop-marker {
    /* A full card-width landing slot: it shares the card's transform (bottom-centre
       pivot, same tilt) so the rotated indicator lines up perfectly with the rotated
       card the user is about to drop there. Only the left half is painted via ::after
       — extending the gradient into the right half would tint the next card over. */
    position:fixed; z-index:1; width:var(--hand-card-w); height:calc(var(--hand-card-w) * 1.40625);
    transform:translate(-50%,-50%) rotate(var(--drop-angle,0deg));
    transform-origin:50% 100%;
    transition:left .05s linear,top .05s linear,transform .05s linear;
    background:transparent; border:0; pointer-events:none;
  }
  .hand-drop-marker::after {
    content:"";
    position:absolute; top:0; bottom:0; left:0; width:50%;
    background: linear-gradient(90deg, rgba(255,233,138,1) 0px, rgba(255,233,138,1) 3px, rgba(255,233,138,0) 100%);
    background-clip:padding-box;
    border-top:1px solid var(--line);
    border-left:1px solid var(--line);
    border-bottom:1px solid var(--line);
    border-right:0;
    border-radius:11px 0 0 11px; /* match .cardface border-radius */
    pointer-events:none;
  }
  .hand-drop-marker[hidden] { display:none; }
  .hand-drag-preview.cardface { margin:0; transform:none; }
  .hand-drag-preview.cardface .pip { font-size:calc(44px * var(--ui-scale)); }
  #hand .cardface:disabled:not(.selected) { filter:brightness(.92); }
  #hand .cardface.justdrew { animation:drewpulse 1s ease; }
  @keyframes drewpulse {
    0%   { box-shadow:0 0 0 4px #ffe27a, 0 10px 18px rgba(0,0,0,.45); }
    70%  { box-shadow:0 0 0 4px #ffe27a, 0 10px 18px rgba(0,0,0,.45); }
    100% { box-shadow:0 2px 4px rgba(0,0,0,.3); }
  }

  /* center piles */
  .piles { display:flex; gap:calc(10px * var(--ui-scale)); align-items:flex-start; }
  .pilecol {
    display:flex; flex-direction:column; align-items:center; gap:calc(4px * var(--ui-scale));
  }
  #topWrap, #stockWrap {
    position:relative; width:var(--pile-card-w); height:calc(var(--pile-card-w) * 1.40625); flex:none;
  }
  /* Cover the disabled upcard for a legal selected-card tap or drag so the wrapper
     receives drop events. The gold target fills the card, without a fade. */
  #topWrap.discard-drop-ready::after {
    content:""; position:absolute; z-index:5; inset:0;
    border-radius:11px; pointer-events:auto;
  }
  #topWrap.discard-drop-hover::after {
    background:rgba(255,233,138,.72);
    box-shadow:inset 0 0 0 2px #ffe98a,0 0 0 2px #ffe98a,0 4px 10px rgba(0,0,0,.35);
  }
  .pilecol .label {
    font-size:calc(7.5px * var(--fs)); font-weight:700; color:rgba(255,255,255,.9);
    text-transform:uppercase; letter-spacing:.06em;
  }
  .pile.cardface { width:var(--pile-card-w); height:calc(var(--pile-card-w) * 1.40625); }
  .pile.cardface .pip { font-size:calc(46px * var(--ui-scale)); }
  button.pile.cardface:not(:disabled):hover { box-shadow:0 0 0 3px var(--yellow),0 4px 10px rgba(0,0,0,.35); }
  .count {
    position:absolute;
    right:calc(-8px * var(--ui-scale)); bottom:calc(-8px * var(--ui-scale));
    width:calc(24px * var(--ui-scale)); height:calc(24px * var(--ui-scale));
    background:#fff; color:#25282d; border:2px solid var(--yellow); border-radius:50%;
    box-sizing:border-box; display:flex; align-items:center; justify-content:center;
    font:800 calc(9px * var(--fs))/1 system-ui,sans-serif; text-align:center;
    box-shadow:0 2px 5px rgba(0,0,0,.38); pointer-events:none;
  }
  .ghost { position:fixed; z-index:200; margin:0; pointer-events:none; box-shadow:0 8px 18px rgba(0,0,0,.45); }

  /* action buttons */
  .actions {
    display:flex; flex-direction:column; gap:calc(9px * var(--ui-scale));
    width:100%; min-height:calc(38px * var(--ui-scale)); align-items:stretch;
  }
  #drawActions {
    display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); justify-content:center;
    align-items:center; gap:calc(8px * var(--ui-scale)); width:100%;
  }
  #drawDiscard { justify-self:end; }
  #drawStock { justify-self:start; }
  /* Buttons size to their label (min-width floor, never a fixed width): a fixed
     width + nowrap + centered flex silently pushes overflowing text past the
     padding. The visual suite asserts every button label keeps its inset. */
  #drawActions .btn {
    display:inline-flex; align-items:center; justify-content:center; gap:calc(7px * var(--ui-scale));
    min-width:calc(112px * var(--ui-scale)); padding-inline:calc(8px * var(--ui-scale)); white-space:nowrap;
  }
  #drawActions .arrow {
    width:calc(18px * var(--ui-scale)); height:calc(18px * var(--ui-scale)); flex:none;
  }
  .btn {
    font:700 calc(11.25px * var(--fs))/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
    padding:calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border-radius:calc(8px * var(--ui-scale)); cursor:pointer;
    background: linear-gradient(#f4c542, #e8b732);
    border: 1px solid #c78f1f;
    color:#5a3e00;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.75), 0 1px 2px rgba(0,0,0,.25);
  }
  .btn:hover:not(:disabled) { background: linear-gradient(#f7d062, #e8b732); }
  .btn:disabled { opacity:.5; cursor:not-allowed; }
  #discardChoice { position:fixed; z-index:300; display:inline-flex; transform:translate(-50%,calc(-100% - 10px * var(--ui-scale))); border-radius:calc(8px * var(--ui-scale)); box-shadow:0 4px 10px rgba(0,0,0,.25); }
  #discardChoice[hidden], #discardChoice .btn[hidden] { display:none; }
  #discardChoice::after {
    content:""; position:absolute; top:calc(100% - 2px); left:var(--choice-caret-x,50%);
    transform:translateX(-50%); width:0; height:0; pointer-events:none;
    border-left:8px solid transparent; border-right:8px solid transparent;
    border-top:8px solid #e8b732;
  }
  #discardChoice[data-side="below"]::after {
    top:auto; bottom:calc(100% - 2px); border-top:0; border-bottom:8px solid #f7d062;
  }
  #discardChoice .btn { border-radius:0; box-shadow:none; white-space:nowrap; }
  #discardChoice #discard { border-radius:calc(8px * var(--ui-scale)) 0 0 calc(8px * var(--ui-scale)); }
  #discardChoice #knock { border-left:0; border-radius:0 calc(8px * var(--ui-scale)) calc(8px * var(--ui-scale)) 0; }
  #discardChoice:not(.has-knock) #discard { border-radius:calc(8px * var(--ui-scale)); }
  /* ---- deadwood / loose total, inlaid into the felt ---- */
  .loose-plaque {
    display:grid; grid-template-areas:"label" "value" "status" "rule";
    align-self:center;
    position:relative;
    width:calc(132px * var(--ui-scale));
    margin-top:auto;
    margin-bottom:0;
    padding:
      calc(10px * var(--ui-scale))
      calc(4px * var(--ui-scale))
      calc(7px * var(--ui-scale));
    overflow:visible;
    transform-origin:bottom center;
    background:radial-gradient(ellipse at center,
      rgba(4,42,20,.28) 0%,rgba(4,42,20,.13) 46%,rgba(4,42,20,0) 74%);
    border:0;
    border-radius:0;
    box-shadow:none;
    color:#f8f1d7;
    text-align:center;
    min-width:0;
  }
  .lhud-copy { display:contents; }
  .lhud-label {
    grid-area:label;
    margin-bottom:calc(4px * var(--ui-scale));
    color:#e0bd68;
    font:800 calc(9px * var(--fs))/1 system-ui,sans-serif;
    letter-spacing:.14em;
    text-transform:uppercase;
    text-shadow:0 1px 1px rgba(4,37,18,.95),0 2px 5px rgba(3,30,14,.62);
  }
  .lhud-reel { grid-area:value; position:relative; }
  .lhud-value-wrap {
    position:relative; display:grid; place-items:center; overflow:hidden;
    padding:
      calc(4px * var(--fs))
      0
      calc(5px * var(--fs));
  }
  .lhud-value,
  .lhud-previous {
    grid-area:1/1;
    display:block;
    font:900 calc(32px * var(--fs))/1 "SF Pro Rounded",ui-rounded,system-ui,sans-serif;
    color:#ffe37a;
    text-shadow:
      0 -1px 0 rgba(5,48,24,.96),
      0 1px 0 rgba(255,248,203,.16),
      0 3px 3px rgba(2,31,14,.72),
      0 7px 14px rgba(2,31,14,.28);
    letter-spacing:-.02em;
    position:relative;
    top:0;
  }
  .lhud-previous { opacity:0; pointer-events:none; }
  .lhud-delta {
    display:none;
    margin:0;
    color:rgba(248,241,215,.7);
    font:850 calc(8px * var(--fs))/1 system-ui,sans-serif;
    letter-spacing:.055em;
    text-shadow:0 1px 1px rgba(3,31,14,.9),0 2px 5px rgba(3,31,14,.5);
  }
  .gin-teaching-active .lhud-delta:not([hidden]) { display:inline-block; }
  .lhud-delta--good { color:#9aeca5; }
  .lhud-delta--bad { color:#ffc174; }
  .lhud-delta--neutral { color:rgba(248,241,215,.7); }
  .lhud-status {
    grid-area:status;
    display:flex;
    min-height:calc(18px * var(--ui-scale));
    align-items:center;
    justify-content:center;
    gap:calc(6px * var(--ui-scale));
    margin-top:calc(4px * var(--ui-scale));
    white-space:nowrap;
  }
  .lhud-tag {
    margin:0;
    min-height:0;
    color:rgba(248,241,215,.86);
    font:800 calc(9px * var(--fs))/1.1 system-ui,sans-serif;
    letter-spacing:.065em;
    white-space:nowrap;
    text-shadow:0 1px 1px rgba(3,31,14,.96),0 2px 6px rgba(3,31,14,.6);
  }
  /* This hand's rules (a mode's handNotes, e.g. Oklahoma's upcard): small gold tags. */
  .lhud-rule {
    grid-area:rule; display:flex; flex-wrap:wrap; justify-content:center;
    gap:calc(4px * var(--ui-scale)); margin-top:calc(6px * var(--ui-scale));
  }
  .lhud-rule[hidden] { display:none; }
  .lhud-rule-chip {
    padding:calc(2px * var(--ui-scale)) calc(6px * var(--ui-scale));
    border:1px solid rgba(226,190,93,.55); border-radius:999px; background:rgba(4,23,15,.38);
    color:#ffe9a0; font:800 calc(8px * var(--fs))/1.15 system-ui,sans-serif;
    letter-spacing:.06em; text-transform:uppercase; white-space:nowrap;
  }
  .lhud-rule-short { display:none; }
  /* Carry over the inline emphasis that mode hooks embed inside tag HTML. */
  .lhud-tag .lt-knock-value {
    color:#ffe9a0;
    font:900 calc(11px * var(--fs))/1 "SF Pro Rounded",ui-rounded,system-ui,sans-serif;
  }
  .lhud-tag .lt-knock-limit {
    color:rgba(248,241,215,.68);
    font:750 calc(8px * var(--fs))/1 system-ui,sans-serif;
  }
  /* Screen-reader-only live region */
  .lhud-sr {
    position:absolute; width:1px; height:1px; padding:0; margin:-1px;
    overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
  }
  /* Preview tints */
  .lhud-preview .lhud-value { color:#c6eff0; }
  .lhud-preview .lhud-tag { color:#a5ecaf; }
  .gin-teaching-active .lhud-preview .lhud-value {
    text-shadow:0 -1px 0 rgba(5,48,24,.96),0 2px 3px rgba(2,31,14,.76),0 0 16px rgba(174,232,237,.2);
  }
  /* The old value exits as the selected-discard preview enters. */
  @keyframes lhud-new-down {
    from { opacity:.15; transform:translateY(-92%); }
    to { opacity:1; transform:translateY(0); }
  }
  @keyframes lhud-old-down {
    from { opacity:1; transform:translateY(0); }
    to { opacity:.08; transform:translateY(92%); }
  }
  @keyframes lhud-new-up {
    from { opacity:.15; transform:translateY(92%); }
    to { opacity:1; transform:translateY(0); }
  }
  @keyframes lhud-old-up {
    from { opacity:1; transform:translateY(0); }
    to { opacity:.08; transform:translateY(-92%); }
  }
  .lhud-value-wrap.lhud-roll-down .lhud-value { animation:lhud-new-down .34s cubic-bezier(.18,.82,.3,1) both; }
  .lhud-value-wrap.lhud-roll-down .lhud-previous { animation:lhud-old-down .34s cubic-bezier(.18,.82,.3,1) both; }
  .lhud-value-wrap.lhud-roll-up .lhud-value { animation:lhud-new-up .34s cubic-bezier(.18,.82,.3,1) both; }
  .lhud-value-wrap.lhud-roll-up .lhud-previous { animation:lhud-old-up .34s cubic-bezier(.18,.82,.3,1) both; }
  /* Directional feedback stays in the lettering instead of drawing a box. */
  @keyframes lhud-thunk {
    0%,100% { filter:none; }
    35% { filter:drop-shadow(0 0 8px rgba(112,233,130,.48)); }
  }
  @keyframes lhud-flash-bad {
    0%,100% { filter:none; }
    35% { filter:drop-shadow(0 0 8px rgba(237,167,78,.46)); }
  }
  @keyframes lhud-pulse {
    0%,100% { filter:none; }
    40% { filter:drop-shadow(0 0 10px rgba(126,231,142,.5)); }
  }
  @keyframes lhud-win {
    0%,100% { filter:none; }
    38% { filter:drop-shadow(0 0 13px rgba(255,224,112,.68)); }
  }
  .loose-plaque.lhud-thunk    { animation:lhud-thunk .62s ease both; }
  .loose-plaque.lhud-flash-bad { animation:lhud-flash-bad .62s ease both; }
  .loose-plaque.lhud-pulse    { animation:lhud-pulse    .5s ease both; }
  .loose-plaque.lhud-win      { animation:lhud-win      .68s ease both; }
  @media (prefers-reduced-motion: reduce) {
    .lhud-value-wrap.lhud-roll-down .lhud-value,
    .lhud-value-wrap.lhud-roll-down .lhud-previous,
    .lhud-value-wrap.lhud-roll-up .lhud-value,
    .lhud-value-wrap.lhud-roll-up .lhud-previous { animation:none; }
    .loose-plaque.lhud-thunk,
    .loose-plaque.lhud-flash-bad,
    .loose-plaque.lhud-pulse,
    .loose-plaque.lhud-win { animation:none; }
  }

  /* round-over overlay */
  .overlay {
    --ui-scale:1;
    --fs:var(--font-scale);
    position:absolute; inset:0; display:none; align-items:center; justify-content:center;
    padding:16px; background:rgba(5,20,13,.66); z-index:2000;
    font-size:calc(15px * var(--fs));
  }
  .overlay.show { display:flex; animation:fadein .3s ease; }
  .battle-table-ui {
    position:absolute; z-index:24; left:50%; top:43%; width:min(760px,calc(100% - 2 * var(--side-width) - 36px));
    transform:translate(-50%,-50%); display:none; pointer-events:none;
  }
  .battle-table-ui.show { display:block; animation:fadein .2s ease; }
  .battle-table-ui.battle-compact { top:18% !important; }
  .battle-table-ui.battle-loose-pick { top:57% !important; }
  .battle-table-ui.battle-compact .battle-table-panel { gap:4px; padding:7px 12px; }
  .battle-table-ui.battle-compact .battle-stage-title { font-size:clamp(23px,2.4vw,34px) !important; }
  .battle-table-ui.battle-compact #battleStake { display:none; }
  .battle-table-ui.battle-compact #battleMeldChoices:empty,
  .battle-table-ui.battle-compact #battleActions:empty { display:none !important; margin:0 !important; }
  .battle-table-panel {
    display:flex; flex-direction:column; align-items:center; gap:8px; padding:10px 14px;
    color:#fff5d6; text-align:center; text-shadow:0 1px 2px rgba(0,0,0,.8);
    background:rgba(8,42,25,.84); border:1px solid rgba(226,190,93,.7); border-radius:14px;
    box-shadow:0 8px 24px rgba(0,0,0,.28); backdrop-filter:blur(5px); pointer-events:auto;
  }
  .battle-table-panel h3 { margin:0; font:800 18px/1.2 system-ui,sans-serif; }
  .battle-table-panel p { margin:0; color:rgba(255,255,255,.86) !important; }
  .battle-meld-choice, .battle-pile-choice {
    border:0; padding:5px; border-radius:11px; background:transparent; color:#fff5d6; cursor:pointer;
  }
  .battle-meld-choice:hover .cardface, .battle-pile-choice:hover .cardface,
  .battle-meld-choice:focus-visible .cardface, .battle-pile-choice:focus-visible .cardface {
    transform:translateY(-8px); box-shadow:0 0 0 3px var(--yellow),0 8px 15px rgba(0,0,0,.4);
  }
  .battle-choice-cards { display:flex; justify-content:center; gap:3px; }
  .battle-choice-label { display:block; margin-top:5px; font-weight:800; font-size:calc(11px * var(--fs)); }
  .battle-table-ui .cardface { width:54px; height:76px; transition:transform .15s,box-shadow .15s; }
  .battle-table-ui .cardface .pip { font-size:32px; }
  .cardface.battle-table-card-action { cursor:pointer; box-shadow:0 0 0 2px var(--yellow),0 5px 12px rgba(0,0,0,.38); }
  .cardface.battle-table-card-action:hover { transform:translateY(-8px); box-shadow:0 0 0 4px var(--yellow),0 9px 18px rgba(0,0,0,.45); }
  #computer.battle-pick-mode { gap:8px; min-height:120px; overflow:visible; }
  #computer.battle-pick-mode .cardface { width:62px; height:87px; margin-left:0 !important; }
  #computer.battle-pick-mode .cardface .pip { font-size:38px; }
  .battle-stage-title {
    font-size:clamp(28px,3.2vw,48px) !important; line-height:1 !important; letter-spacing:.035em;
    color:#ffe070; text-transform:uppercase; animation:battle-title-in .45s cubic-bezier(.2,.8,.25,1);
  }
  .battle-stage-title.danger { color:#ff9b86; }
  .battle-stage-title.victory { color:#fff0a6; animation:battle-win-in .65s cubic-bezier(.18,.9,.25,1); }
  .battle-title-sub { display:block; font-size:.4em; font-weight:500; font-style:italic; color:rgba(255,224,112,.38); letter-spacing:.01em; margin-bottom:.2em; text-transform:none; }
  .battle-meld-stage { display:flex; justify-content:center; align-items:flex-start; gap:24px; flex-wrap:wrap; }
  .battle-meld-side { padding:8px 10px; border:1px solid rgba(255,255,255,.25); border-radius:11px; background:rgba(0,0,0,.18); animation:battle-meld-in .5s ease both; }
  .battle-meld-side.defense { animation-delay:.12s; }
  .battle-meld-side.winner { border-color:#ffe070; box-shadow:0 0 18px rgba(255,224,112,.34); }
  .battle-meld-side.loser { opacity:.55; filter:saturate(.55); }
  .battle-meld-owner { display:block; margin-bottom:6px; color:#fff3c6; font-weight:850; font-size:calc(12px * var(--fs)); text-transform:uppercase; }
  .battle-rule-step { min-height:24px; color:#fff !important; font-size:calc(16px * var(--fs)); font-weight:750; animation:battle-rule-in .35s ease; }
  @keyframes battle-title-in { from { opacity:0; transform:scale(.72) translateY(-14px); } to { opacity:1; transform:none; } }
  @keyframes battle-win-in { 0% { opacity:0; transform:scale(.7); } 55% { transform:scale(1.08); } 100% { opacity:1; transform:scale(1); } }
  @keyframes battle-meld-in { from { opacity:0; transform:translateY(-24px) rotate(-2deg); } to { opacity:1; transform:none; } }
  @keyframes battle-rule-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
  @keyframes fadein { from{opacity:0;} to{opacity:1;} }
  .modal,
  .result-modal { position:relative; }
  .modal {
    width:90%; max-width:560px;
    max-height:calc(100svh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow:hidden; border-radius:12px;
    background:#fff; color:#1a1a1a; box-shadow:0 10px 40px rgba(0,0,0,.4);
  }
  .modal-scroll {
    max-height:inherit; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable;
    padding:18px 20px;
  }
  .options-modal-header {
    display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:16px;
  }
  .options-modal-header h2 { margin:0; color:#1a1a1a; }
  .options-modal-header .modal-close { position:static; flex:0 0 auto; }
  .modal .btn { background:#e9eef7; border-color:#cdd8ec; color:#1e3a8a; }
  .modal .btn.primary { background:var(--yellow); border-color:var(--yellow-d); color:#5a3e00; }
  .result-modal {
    width:min(920px,96vw);
    max-height:calc(100svh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow:auto;
    padding:clamp(16px,2.4vw,28px); border:1px solid #ad8b4d; border-radius:18px;
    background:linear-gradient(145deg,#fffdf5,#f0e3c4); color:#282219;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.95),0 18px 55px rgba(0,0,0,.48);
  }
  .result-header { display:grid; grid-template-columns:1fr auto; gap:12px 20px; align-items:center; margin-bottom:16px; }
  .result-kicker { color:#8a6b32; font:800 10px/1 system-ui,sans-serif; letter-spacing:.14em; text-transform:uppercase; }
  .result-title { margin:5px 0 0; font:700 clamp(25px,3.2vw,38px)/1.05 Georgia,"Times New Roman",serif; color:#183829; }
  .result-reason { grid-column:1/-1; margin:0; color:#5f5545; font-size:calc(13px * var(--fs)); }
  .result-award {
    grid-row:1/3; grid-column:2; max-width:180px; padding:5px 0 5px 14px;
    border-left:2px solid #c89524; color:#74551c;
    text-align:left; font:850 14px/1.25 "SF Pro Rounded",ui-rounded,system-ui,sans-serif;
  }
  .result-hands { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
  .result-hand {
    min-width:0; padding:13px; border:1px solid #c8b68c; border-radius:13px;
    background:rgba(255,255,255,.62); box-shadow:inset 0 1px 0 #fff;
  }
  .result-hand.winner { border-color:#c89524; box-shadow:inset 0 0 0 2px rgba(232,183,50,.22),inset 0 1px 0 #fff; }
  .result-hand-header { display:flex; align-items:baseline; justify-content:space-between; gap:10px; margin-bottom:10px; }
  .result-hand-name { font:800 17px/1 system-ui,sans-serif; color:#183829; }
  .result-loose-total { color:#7c6741; font-size:calc(11px * var(--fs)); font-weight:700; }
  .result-loose-total b { color:#9c3a2d; font:900 22px/1 "SF Pro Rounded",ui-rounded,system-ui,sans-serif; }
  .result-groups { display:flex; flex-direction:column; gap:8px; }
  .result-group { padding:7px; border-radius:9px; background:#e9f1e7; }
  .result-group.loose { background:#f4e3dc; }
  .result-group-label { display:block; margin-bottom:5px; color:#59705f; font:800 8px/1 system-ui,sans-serif; letter-spacing:.1em; text-transform:uppercase; }
  .result-group.loose .result-group-label { color:#98564b; }
  .result-card-row { display:flex; flex-wrap:wrap; gap:4px; min-height:44px; }
  .result-card.cardface { width:38px; height:53px; border-radius:7px; box-shadow:0 2px 4px rgba(0,0,0,.2); }
  .result-card.cardface .pip { font-size:22px; }
  .result-card.cardface .color-dot { top:4px; left:4px; width:9px; border-width:1px; }
  html[data-card-theme="classic"] .result-card.cardface.classic-suit .suit-mark { top:4px; left:4px; width:10px; }
  .result-empty { display:flex; align-items:center; min-height:36px; color:#59705f; font:700 11px/1.2 system-ui,sans-serif; }
  .result-scoreline {
    display:flex; align-items:center; justify-content:center; gap:clamp(18px,5vw,54px);
    margin-top:12px; padding:10px 14px; border-radius:10px; background:#173629; color:#e8d9a8;
  }
  .result-score-item { display:flex; align-items:baseline; gap:8px; font-size:calc(12px * var(--fs)); font-weight:700; }
  .result-score-item b { color:#ffe070; font:900 24px/1 "SF Pro Rounded",ui-rounded,system-ui,sans-serif; }
  .result-actions { display:flex; justify-content:center; flex-wrap:wrap; gap:8px; margin-top:14px; }
  .result-actions .btn { min-width:126px; }
  .result-modal .btn { background:#e9eef7; border-color:#cdd8ec; color:#1e3a8a; }
  .result-modal .btn.primary { background:var(--yellow); border-color:var(--yellow-d); color:#5a3e00; }
  .modal-close {
    position:absolute; top:10px; right:10px; width:30px; height:30px; padding:0;
    display:inline-flex; align-items:center; justify-content:center;
    border-radius:999px; border:1px solid rgba(0,0,0,.12);
    background:#f4f7fb; color:#5a3e00; font:900 18px/1 system-ui,sans-serif;
    box-shadow:0 2px 6px rgba(0,0,0,.14);
  }
  .modal-close:hover { background:#fff; }
  .modal-close > span { display:block; line-height:1; transform:translateY(-2px); }
  .result-modal .modal-close {
    top:14px; right:14px; width:34px; height:34px;
    background:rgba(255,255,255,.7); color:#74551c;
  }
  /* The result plaque once the pop-up closes: its title and award over Summary /
     Next hand, gold-edged when you win. Gin sets it where the piles were. */
  .round-review-bar {
    position:absolute; z-index:25; left:50%; bottom:14px; transform:translateX(-50%);
    display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px;
    width:min(calc(100% - 24px),340px);
    padding:12px; border:1px solid #9b793f; border-radius:14px;
    background:linear-gradient(145deg,#173f2c,#0b271b); color:#f1e9d2;
    box-shadow:inset 0 1px 0 rgba(255,240,197,.12),0 8px 24px rgba(0,0,0,.38);
    animation:round-review-in .24s ease-out;
  }
  .round-review-bar.round-review-win {
    border-color:#ffe070;
    box-shadow:inset 0 1px 0 rgba(255,240,197,.16),0 0 18px rgba(255,224,112,.22),0 8px 24px rgba(0,0,0,.38);
  }
  @keyframes round-review-in { from { opacity:0; translate:0 8px; } }
  #roundReviewBar[hidden] { display:none; }
  .round-review-outcome { grid-column:1 / -1; display:grid; gap:4px; padding:0 4px 4px; text-align:center; }
  .round-review-title {
    color:#fff0c5; font:700 calc(22px * var(--fs))/1.1 Georgia,"Times New Roman",serif;
    text-shadow:0 2px 4px rgba(0,0,0,.35);
  }
  .round-review-summary {
    color:#e8d9a8; font:800 calc(10px * var(--fs))/1.2 system-ui,sans-serif;
    letter-spacing:.12em; text-transform:uppercase;
  }
  .round-review-bar .btn { padding:6px 10px; font-size:calc(11px * var(--fs)); white-space:nowrap; }
  .font-size-btn {
    flex:1; padding:12px 8px; font-weight:600; background:#e9eef7; border-color:#cdd8ec;
    color:#1e3a8a; border:1px solid #cdd8ec; border-radius:6px; cursor:pointer; transition:all .2s;
  }
  .font-size-btn:hover { background:#d5dff0; }
  .card-theme-btn.active,
  .font-size-btn.active { background:var(--yellow); border-color:var(--yellow-d); color:#5a3e00; }
  .card-theme-row { display:flex; gap:8px; flex-wrap:wrap; }
  .card-theme-btn {
    display:flex; align-items:center; justify-content:flex-start; gap:8px;
    min-width:118px; padding:8px 10px; border:1px solid #cdd8ec;
    border-radius:6px; background:#e9eef7; color:#1e3a8a; font-weight:700;
  }
  .card-theme-preview { display:flex; align-items:center; flex:none; }
  .theme-mini-card {
    position:relative; width:18px; height:25px; border:1px solid rgba(48,45,38,.28);
    border-radius:4px; background:var(--theme-face-bg,#fbfaf4);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.85),0 1px 2px rgba(0,0,0,.22);
  }
  .theme-mini-card.back {
    margin-left:-6px; background:var(--theme-back-bg,linear-gradient(135deg,#465994,#1e2e58));
    border-color:var(--theme-back-border,#26345e);
  }
  .card-theme-btn[data-card-theme="clean"] {
    --theme-face-bg:#f8f7f2;
    --theme-back-bg:repeating-linear-gradient(45deg,#3a4a86 0 4px,#2b3a67 4px 8px);
  }
  .card-theme-btn[data-card-theme="classic"] {
    --theme-face-bg:#fffdf7;
    --theme-back-bg:
      repeating-linear-gradient(45deg,rgba(255,255,255,.16) 0 1px,transparent 1px 5px),
      linear-gradient(135deg,#27508f,#14315f);
    --theme-back-border:#183568;
  }
  .card-theme-btn[data-card-theme="classic"] .theme-mini-card:not(.back)::after {
    content:""; position:absolute; top:3px; left:3px; width:8px; height:8px;
    background:url("./assets/card-art/suit-heart.svg") center/contain no-repeat;
  }
  .card-theme-btn[data-card-theme="linen"] {
    --theme-face-bg:
      repeating-linear-gradient(45deg,rgba(67,52,32,.05) 0 1px,transparent 1px 5px),
      #fbfaf4;
    --theme-back-bg:
      repeating-linear-gradient(45deg,rgba(255,255,255,.16) 0 1px,transparent 1px 5px),
      linear-gradient(135deg,#465994,#1e2e58);
  }
  .card-theme-btn[data-card-theme="deco"] {
    --theme-face-bg:
      radial-gradient(circle at 20% 20%,rgba(159,40,48,.12) 0 2px,transparent 2.5px),
      #fff8ea;
    --theme-back-bg:
      radial-gradient(circle at 50% 50%,rgba(255,232,173,.18) 0 2px,transparent 3px),
      linear-gradient(135deg,#7a2140,#17294f);
    --theme-back-border:#4b1e3c;
  }
  .option-toggle {
    display:flex; align-items:center; gap:10px; padding:10px 12px;
    border:1px solid #cdd8ec; border-radius:8px; background:#f0f3f8;
    color:#1a1a1a; font-weight:700; cursor:pointer;
  }
  .option-toggle input { width:18px; height:18px; margin:0; accent-color:#c9951d; cursor:pointer; }
  .option-toggle-copy { display:flex; flex-direction:column; gap:2px; }
  .option-toggle-copy small { color:#667085; font-size:calc(11px * var(--fs)); font-weight:500; }

  /* One shared, subordinate utility control for free play and lessons. */
  #optionsBtn {
    display:inline-flex; align-items:center; justify-content:center;
    gap:calc(5px * var(--ui-scale));
    width:auto; min-width:0; min-height:calc(30px * var(--ui-scale));
    margin:calc(9px * var(--ui-scale)) auto 0;
    padding:calc(5px * var(--ui-scale)) calc(9px * var(--ui-scale));
    background:transparent; border:1px solid rgba(226,190,93,.22);
    border-radius:calc(6px * var(--ui-scale)); box-shadow:none;
    color:rgba(241,233,210,.78);
    font:600 calc(10px * var(--fs))/1.2 system-ui,sans-serif;
    letter-spacing:0; text-transform:none;
  }
  #optionsBtn:hover:not(:disabled) { background:rgba(255,255,255,.07); border-color:rgba(226,190,93,.5); color:#fff0c5; }
  #optionsBtn:focus-visible { outline:2px solid #ffe070; outline-offset:2px; }
  #optionsBtn .options-gear { font-size:calc(12px * var(--fs)); line-height:1; }
  .mode-utilities { display:flex; align-items:center; justify-content:center; gap:6px; margin-top:calc(9px * var(--ui-scale)); }
  .mode-utilities #optionsBtn { margin:0; }
  #headerNewGame {
    min-width:0; min-height:calc(30px * var(--ui-scale)); padding:calc(5px * var(--ui-scale)) calc(9px * var(--ui-scale));
    font:850 calc(10px * var(--fs))/1.2 system-ui,sans-serif; color:#302000;
  }
  /* As wide as its text grows with the table, so the title keeps to one line. */
  html[data-layout="wide"] .round-review-bar {
    position:static; transform:none; width:min(100%,calc(360px * var(--ui-scale))); margin-top:6px;
  }
  .center > .round-review-bar { margin-inline:auto; }
  /* Gin centers it in the open felt between the hands (src/gin-rummy-ui.js); moving it
     relatively leaves everything else where it is. */
  html[data-layout="wide"] .center > .round-review-bar {
    position:relative; inset:var(--review-center-shift, 0px) auto auto;
  }
  #overlay .result-modal { width:min(520px,96vw); }
  /* The start-over question: the result panel, sized for one question and two choices. */
  .confirm-game-modal { width:min(420px,92vw); text-align:center; }
  .confirm-game-modal .result-header { grid-template-columns:1fr; margin-bottom:6px; }
  .confirm-game-modal .result-title { font-size:clamp(24px,2.6vw,32px); }
  /* Below the question, the homepage's deal scene: four face cards fanned. As on the
     homepage, one --cw sets each card's size and its details scale from it. */
  /* The cards lie on a patch of the table's own felt (the .table background). */
  .confirm-game-modal .deal-scene {
    display:flex; justify-content:center; margin:12px 0 18px; padding:22px 0 26px;
    border:1px solid rgba(0,0,0,.18); border-radius:14px;
    background:radial-gradient(ellipse 90% 70% at 50% 36%, #2fa15a 0%, #218046 55%, #155f33 100%);
    box-shadow:inset 0 2px 9px rgba(0,0,0,.38), inset 0 -1px 0 rgba(255,255,255,.08);
  }
  .confirm-game-modal .card-fan { display:flex; }
  .confirm-game-modal .card-fan .cardface {
    --cw:52px; width:var(--cw); height:auto; aspect-ratio:64/90; margin-inline:-10px;
    border-radius:calc(var(--cw) * .172); box-shadow:0 10px 18px rgba(0,0,0,.32);
  }
  .confirm-game-modal .card-fan .cardface:not(.empty)::after { inset:calc(var(--cw) * .078); border-radius:calc(var(--cw) * .11); }
  .confirm-game-modal .card-fan .cardface .pip { font-size:calc(var(--cw) * .625); }
  .confirm-game-modal .card-fan .cardface .color-dot { top:8%; left:8%; width:18%; }
  html[data-card-theme="classic"] .confirm-game-modal .card-fan .cardface.classic-suit .suit-mark { top:7%; left:7%; width:19%; }
  .confirm-game-modal .card-fan .cardface:nth-child(1) { transform:rotate(-18deg) translateY(6px); }
  .confirm-game-modal .card-fan .cardface:nth-child(2) { transform:rotate(-6deg) translateY(1px); }
  .confirm-game-modal .card-fan .cardface:nth-child(3) { transform:rotate(6deg) translateY(1px); }
  .confirm-game-modal .card-fan .cardface:nth-child(4) { transform:rotate(18deg) translateY(6px); }
  html[data-layout="compact"] .confirm-game-modal { width:min(420px,100%); }
  /* Review hand opens the hands; a mode's own boxes (#resultModeHands, gin's deadwood
     boxes) take the place of the two shared ones. */
  .result-hands[hidden] { display:none; }
  .result-hands:focus { outline:none; }
  .result-mode-hands { display:contents; }
  .result-hands:has(> .result-mode-hands:not(:empty)) > .result-hand { display:none; }
  html[data-layout="wide"] #overlay .result-modal:has(> .result-hands:not([hidden])) { width:min(760px,96vw); }
  #overlay .result-actions { flex-wrap:wrap; justify-content:center; }
  #overlay .result-title { font-size:clamp(30px,4vw,46px); }
  #overlay .result-header { padding-top:38px; }
  .result-extra-actions { display:contents; }
  html[data-layout="wide"] .arena:has(.gin-tutorial-bubble-actions) #computer:not(.gin-review-lane) { visibility:hidden; }

  .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;
  }
  @media (prefers-reduced-motion: reduce) { * { animation:none !important; transition:none !important; } }

  /* Result cue in the turn-status box (src/status-hud.js). */
  .gin-lesson-active #rightRail > .bubble.gin-status-result { display:block; }
  .gin-status-result .status-main { color:#fff0c5; font-weight:750; }
  .gin-status-result .status-next { font-size:calc(11px * var(--fs)); font-weight:400; color:#f1e9d2; }
  .gin-status-flash { animation:gin-status-flash 1.2s ease-in-out 2; }
  @keyframes gin-status-flash { 0%,100% { box-shadow:inset 0 1px 0 rgba(255,255,255,.05),0 2px 6px rgba(0,0,0,.35); } 50% { box-shadow:inset 0 1px 0 rgba(255,255,255,.08),0 0 0 2px rgba(255,224,112,.5),0 0 18px rgba(255,224,112,.2); } }

  /* Gin's review and Gus's strategy note (src/gin-rummy-ui.js). In play the review lays
     both hands out in the hand view's groups: Gus's face up at his card size, and
     deadwood as its own tagged group beside Run and Set. */
  .gin-review-fan {
    --hand-card-w:var(--opp-card-w);
    display:flex; justify-content:center; align-items:flex-end; width:100%;
  }
  .hand-group.deadwood { --group-fill:rgba(255,164,132,.12); --group-edge:rgba(255,180,150,.34); }
  .deadwood .group-label { background:#a5523f; }
  /* Each player's deadwood total on a tab of their deadwood group, in the group's own
     tint, toward the middle of the table: up from the middle of yours, down from the
     middle of Gus's. The group's outline moves to a ::before, so its edge can open where
     the tab joins. Yours adds, left of the tab, how it compares and how the hand went. */
  html:not([data-layout="compact"]) .hand-group.deadwood:has(> .gin-deadwood-figure) {
    --tab-w:calc(42px * var(--ui-scale)); --tab-h:calc(30px * var(--ui-scale));
    border-color:transparent;
  }
  html:not([data-layout="compact"]) .hand-group.deadwood:has(> .gin-deadwood-figure)::before {
    content:""; position:absolute; inset:-1px; pointer-events:none;
    border:1px solid var(--group-edge); border-radius:inherit;
    -webkit-mask:linear-gradient(#000 0 0),linear-gradient(#000 0 0) var(--tab-gap-at) / var(--tab-gap) no-repeat;
    -webkit-mask-composite:xor;
    mask:linear-gradient(#000 0 0),linear-gradient(#000 0 0) var(--tab-gap-at) / var(--tab-gap) no-repeat;
    mask-composite:exclude;
  }
  /* The gap stops 1px short of each tab edge, so the outline turns its corner. */
  .hand-group.deadwood:has(> .gin-deadwood-figure-human) { --tab-gap-at:center top; --tab-gap:calc(var(--tab-w) - 2px) 1px; }
  .hand-group.deadwood:has(> .gin-deadwood-figure-ai) { --tab-gap-at:center bottom; --tab-gap:calc(var(--tab-w) - 2px) 1px; }
  /* Under the cards, like the group's own tint, so an arced card's corner lies over it. */
  .gin-deadwood-figure {
    position:absolute; z-index:0;
    display:flex; align-items:center; pointer-events:none; white-space:nowrap;
    animation:gin-deadwood-figure-in .3s ease-out .25s both;
  }
  .gin-deadwood-figure-human { bottom:calc(100% + 1px); left:50%; transform:translateX(-50%); }
  .gin-deadwood-figure-ai { top:calc(100% + 1px); left:50%; transform:translateX(-50%); }
  /* Short desktop windows run out of height between the hands for the plaque and your
     chip. Gus's face-up review hand paints no face-down arc below it, so there his row
     gives that room back and the plaque sits a little tighter. Taller tables (800px and
     up) keep their layout exactly. */
  @media (max-height:790px) {
    html[data-layout="wide"] .arena:has(.gin-review-fan) { --opp-fan-slot-min:calc(var(--opp-card-h) + 30px * var(--ui-scale)); }
    /* Enough for the outer cards of a ten-card group's arc. */
    html[data-layout="wide"] #computer:has(> .gin-review-fan) { padding-bottom:calc(16px * var(--ui-scale)); }
    html[data-layout="wide"] .center > .round-review-bar { padding-block:calc(8px * var(--ui-scale)); }
  }
  /* Each fades in once the cards have settled. */
  @keyframes gin-deadwood-figure-in { from { opacity:0; } }
  .gin-deadwood-chip {
    display:flex; align-items:center; justify-content:center; box-sizing:border-box;
    width:var(--tab-w); height:var(--tab-h);
    background:var(--group-fill); border:1px solid var(--group-edge);
  }
  .gin-deadwood-figure-human .gin-deadwood-chip {
    border-bottom:0; border-radius:calc(9px * var(--ui-scale)) calc(9px * var(--ui-scale)) 0 0;
  }
  .gin-deadwood-figure-ai .gin-deadwood-chip {
    border-top:0; border-radius:0 0 calc(9px * var(--ui-scale)) calc(9px * var(--ui-scale));
  }
  .gin-deadwood-chip b {
    color:#ffe070; font:900 calc(17px * var(--fs))/1 "SF Pro Rounded",ui-rounded,system-ui,sans-serif;
    font-variant-numeric:tabular-nums; text-shadow:0 1px 3px rgba(0,0,0,.45);
  }
  .gin-deadwood-figure-win .gin-deadwood-chip b {
    text-shadow:0 0 10px rgba(255,224,112,.5),0 1px 3px rgba(0,0,0,.45);
  }
  .gin-deadwood-note {
    position:absolute; right:100%; top:50%; transform:translateY(-50%);
    margin-right:calc(8px * var(--ui-scale));
    display:flex; align-items:baseline; gap:calc(7px * var(--ui-scale));
    text-shadow:0 1px 3px rgba(0,0,0,.6);
  }
  .gin-deadwood-compare {
    color:#e8d9a8; font:800 calc(8px * var(--fs))/1.15 system-ui,sans-serif;
    letter-spacing:.11em; text-transform:uppercase;
  }
  .gin-deadwood-compare + .gin-deadwood-outcome::before {
    content:"·"; margin-right:calc(7px * var(--ui-scale)); color:rgba(255,240,197,.45);
  }
  .gin-deadwood-outcome {
    color:#fff0c5; font:700 calc(12.5px * var(--fs))/1.1 Georgia,"Times New Roman",serif;
  }
  .gin-deadwood-figure-win .gin-deadwood-outcome { color:#ffe070; }
  .gin-strategy-note {
    display:none; position:absolute; z-index:6; top:calc(50% + 36px * var(--ui-scale)); left:0; width:100%;
    padding:
      calc(13px * var(--ui-scale))
      calc(12px * var(--ui-scale))
      calc(11px * var(--ui-scale));
    overflow:visible; transform:translateY(-50%) rotate(-.7deg);
    border:1px solid #c5aa70;
    border-radius:
      calc(3px * var(--ui-scale))
      calc(8px * var(--ui-scale))
      calc(4px * var(--ui-scale))
      calc(6px * var(--ui-scale));
    background:
      repeating-linear-gradient(0deg,rgba(70,111,130,.055) 0 1px,transparent 1px 23px),
      linear-gradient(145deg,#fff9e7,#ead7aa);
    color:#302a1e; text-align:left; pointer-events:auto;
    box-shadow:0 10px 20px rgba(3,28,13,.28),inset 0 1px 0 rgba(255,255,255,.82);
  }
  .gin-strategy-note::before {
    content:""; position:absolute; top:calc(-8px * var(--ui-scale)); left:50%;
    width:calc(58px * var(--ui-scale)); height:calc(17px * var(--ui-scale));
    transform:translateX(-50%) rotate(1.8deg);
    background:rgba(224,211,163,.82); border:1px solid rgba(151,132,84,.18);
    box-shadow:0 2px 3px rgba(73,57,24,.16);
  }
  .gin-teaching-active .gin-strategy-note:not([hidden]) { display:block; animation:gin-strategy-note-in .28s ease both; }
  @keyframes gin-strategy-note-in {
    from { opacity:0; transform:translateY(calc(-50% + 8px * var(--ui-scale))) rotate(-1.4deg); }
    to { opacity:1; transform:translateY(-50%) rotate(-.7deg); }
  }
  .gin-strategy-copy {
    margin:0; color:#29251c;
    font:700 calc(11px * var(--fs))/1.5 "Segoe Print","Bradley Hand",cursive;
  }
  .gin-strategy-note .gin-tutorial-term { color:#174d42; text-decoration-color:#527b6c; }
  .gin-strategy-note .gin-tutorial-term:hover,
  .gin-strategy-note .gin-tutorial-term[aria-expanded="true"] { color:#0d352e; }
  .gin-strategy-note .gin-tutorial-term:focus-visible { outline-color:#2f7d70; }
  .gin-review-lane {
    display:flex !important; justify-content:center; align-items:center;
    width:100%; overflow:visible;
  }
  .seat.opponent #computer.gin-review-lane {
    align-self:start;
    min-height:max-content; padding:0;
    margin-top:var(--card-controls-gap); transform:none;
  }
  #hand.gin-review-lane { min-height:0; padding:0; }
  /* Leave room beside Gus for the shared teaching bubble during review. */
  .gin-teaching-active #computer.gin-review-lane { justify-content:flex-start; }
  .gin-teaching-active #computer .gin-review-hand { max-width:var(--gin-review-coach-width,64%); }
  .gin-review-hand {
    max-width:min(calc(920px * var(--ui-scale)),100%);
    padding:calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
    border:1px solid rgba(255,240,197,.34);
    border-radius:calc(8px * var(--ui-scale)); background:rgba(11,42,27,.6);
    box-shadow:0 8px 22px rgba(0,0,0,.18);
  }
  .gin-review-winner { border-color:#ffe070; box-shadow:0 0 0 2px rgba(255,224,112,.16),0 8px 22px rgba(0,0,0,.22); }
  .gin-review-hand-title {
    margin:0; padding-bottom:calc(8px * var(--ui-scale));
    border-bottom:1px solid rgba(255,240,197,.24);
    color:#fff0c5; text-align:center;
    font:800 calc(12px * var(--fs))/1.2 system-ui,sans-serif; letter-spacing:.04em; text-transform:uppercase;
  }
  .gin-review-groups {
    padding-top:calc(8px * var(--ui-scale));
    display:flex; justify-content:center; align-items:flex-end;
    gap:calc(8px * var(--ui-scale)); flex-wrap:wrap;
  }
  .gin-review-group {
    padding:calc(5px * var(--ui-scale)) calc(6px * var(--ui-scale));
    border-radius:calc(8px * var(--ui-scale)); background:rgba(255,255,255,.12);
    border:1px solid rgba(255,255,255,.18);
  }
  .gin-review-group-loose { background:rgba(255,164,132,.16); }
  .gin-review-group-label {
    display:block; margin-bottom:calc(4px * var(--ui-scale)); color:rgba(255,240,197,.82);
    font:800 calc(8px * var(--fs))/1 system-ui,sans-serif;
    letter-spacing:.1em; text-transform:uppercase; text-align:center;
  }
  .gin-review-cards {
    display:flex; justify-content:center; align-items:flex-end;
    min-height:calc(62px * var(--ui-scale));
  }
  #hand.gin-review-lane .gin-review-cards .cardface,
  #computer.gin-review-lane .gin-review-cards .cardface {
    --gin-review-card-w:calc(38px * var(--ui-scale));
    width:var(--gin-review-card-w); height:calc(var(--gin-review-card-w) * 1.4);
    margin-left:calc(-7px * var(--ui-scale));
  }
  #hand.gin-review-lane .gin-review-cards .cardface:first-child,
  #computer.gin-review-lane .gin-review-cards .cardface:first-child { margin-left:0; }
  #hand.gin-review-lane .gin-review-cards .cardface .pip,
  #computer.gin-review-lane .gin-review-cards .cardface .pip { font-size:calc(24px * var(--ui-scale)); }
  .gin-review-layoff-card { box-shadow:0 0 0 2px #ffe070,0 0 14px rgba(255,224,112,.46),var(--card-face-shadow); }
  .gin-review-empty {
    display:flex; align-items:center; min-height:calc(50px * var(--ui-scale)); color:rgba(255,240,197,.72);
    font:700 calc(11px * var(--fs))/1.2 system-ui,sans-serif;
  }
  /* The same boxes in the result pop-up, on its scoreline green, with its small cards. */
  .result-hands .gin-review-hand { min-width:0; max-width:none; background:#173629; }
  .result-hands .gin-review-cards { min-height:53px; }
  .result-hands .gin-review-cards .cardface { width:38px; height:53px; margin-left:-7px; border-radius:7px; }
  .result-hands .gin-review-cards .cardface:first-child { margin-left:0; }
  .result-hands .gin-review-cards .cardface .pip { font-size:22px; }
  .result-hands .gin-review-cards .cardface .color-dot { top:4px; left:4px; width:9px; border-width:1px; }
  html[data-card-theme="classic"] .result-hands .gin-review-cards .cardface.classic-suit .suit-mark { top:4px; left:4px; width:10px; }

  /* Teaching: play-style switch, Gus's coaching bubble and highlights (src/gin-tutorial-ui.js). */
  :root {
    --gin-tutorial-focus:#7836ad;
    --gin-tutorial-focus-text:#a45dce;
    --gin-tutorial-focus-glow:rgba(120,54,173,.58);
    --gin-tutorial-focus-keyline:#fff8e8;
  }
  .gin-play-style {
    display:grid; grid-template-columns:1fr 1fr; gap:calc(2px * var(--ui-scale)); width:100%;
    margin-top:calc(10px * var(--ui-scale)); padding:calc(2px * var(--ui-scale));
    border:1px solid rgba(226,190,93,.42); border-radius:999px; background:rgba(4,23,15,.42);
    box-shadow:inset 0 1px 3px rgba(0,0,0,.35);
  }
  .gin-play-style-button {
    min-width:0; padding:calc(6px * var(--ui-scale)) calc(8px * var(--ui-scale));
    border:0; border-radius:999px; background:transparent;
    color:rgba(241,233,210,.62); cursor:pointer;
    font:850 calc(8px * var(--fs))/1 system-ui,sans-serif; letter-spacing:.07em; text-transform:uppercase;
  }
  .gin-play-style-button:hover { color:#fff0c5; background:rgba(255,255,255,.06); }
  .gin-play-style-button:focus-visible { outline:2px solid #ffe070; outline-offset:2px; }
  .gin-play-style-button.active {
    color:#4b3500; background:linear-gradient(180deg,#ffe06b,#e9b92f);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.52),0 1px 3px rgba(0,0,0,.3);
  }
  .gin-tutorial-bubble {
    position:fixed; z-index:60; margin:0;
    padding:calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border:1px solid #b89b67; border-radius:calc(10px * var(--ui-scale));
    background:linear-gradient(145deg,#fff9e9,#f2e4c3); color:#111;
    font:600 calc(12px * var(--fs))/1.36 Georgia,"Times New Roman",serif;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.9),0 5px 14px rgba(0,0,0,.28);
    pointer-events:auto;
  }
  .gin-tutorial-bubble::before {
    content:""; position:absolute; left:calc(-6px * var(--ui-scale)); top:var(--gus-tail-top,calc(13px * var(--ui-scale)));
    width:calc(10px * var(--ui-scale)); height:calc(10px * var(--ui-scale));
    background:#f9efd5; border-left:1px solid #b89b67; border-bottom:1px solid #b89b67; transform:rotate(45deg);
  }
  .gin-tutorial-bubble[hidden] { display:none; }
  .gin-tutorial-bubble, .gin-coach-speech {
    --speech-max-width:calc(290px * var(--ui-scale));
    display:flex; flex-direction:column; pointer-events:auto;
    max-height:calc(320px * var(--ui-scale));
  }
  .gin-tutorial-bubble-content { display:block; min-width:0; min-height:0; overflow-x:hidden; overflow-y:auto; overflow-wrap:anywhere; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#9f7b37 #f2e4c3; }
  .gin-tutorial-bubble-content:focus-visible { outline:2px solid #2f7d70; outline-offset:-2px; }
  .gin-tutorial-more { flex:none; margin-top:5px; padding:4px; border:0; border-top:1px solid #b89b67; background:transparent; color:#174d42; cursor:pointer; font:750 12px/1.2 system-ui,sans-serif; }
  .gin-tutorial-more[hidden] { display:none; }
  .gin-tutorial-bubble-actions {
    display:flex; justify-content:flex-end; gap:calc(7px * var(--ui-scale)); margin-top:calc(8px * var(--ui-scale)); flex-wrap:wrap;
    /* The content pane scrolls; reserve the full focus ring inside its clip. */
    padding:5px;
  }
  /* Shared paper tabs for every coach action, in normal play and lessons. */
  .btn.gin-tutorial-bubble-button {
    --paper-button-fill:#dfcba4;
    --paper-button-hover:#d3bc92;
    --paper-button-pressed:#c7ab7a;
    padding:calc(5px * var(--ui-scale)) calc(9px * var(--ui-scale));
    font-size:calc(10px * var(--fs));
    border:1px solid #80633d; border-radius:calc(4px * var(--ui-scale));
    background:var(--paper-button-fill); color:#392c1d;
    box-shadow:none; text-shadow:none; transform:none;
    transition:background-color .12s ease,border-color .12s ease;
  }
  .btn.gin-tutorial-bubble-button.secondary {
    --paper-button-fill:#efe2c4;
    --paper-button-hover:#e2d0a8;
    --paper-button-pressed:#d7be93;
  }
  .btn.gin-tutorial-bubble-button:hover:not(:disabled) {
    background:var(--paper-button-hover); border-color:#604a2e;
  }
  .btn.gin-tutorial-bubble-button:active:not(:disabled) {
    background:var(--paper-button-pressed); border-color:#604a2e; transform:none;
  }
  .btn.gin-tutorial-bubble-button:focus-visible { outline:2px solid #2f6556; outline-offset:3px; }
  .gin-tutorial-inline-link:focus-visible { outline:2px solid #2f7d70; outline-offset:2px; border-radius:2px; }
  .gin-tutorial-inline-link {
    color:#174d42; font:inherit; font-weight:750; text-decoration:underline; text-underline-offset:3px;
  }
  .gin-tutorial-inline-link:hover { color:#0d352e; }
  .gin-tutorial-card-reference {
    color:#4A2578; font-weight:800; letter-spacing:.01em;
    -webkit-text-stroke:1px #5B2E91; paint-order:stroke fill;
    text-shadow:
      0 0 1px #fff8e8,
      0 0 5px rgba(120,54,173,.72),
      0 0 12px rgba(120,54,173,.35);
  }
  .gin-tutorial-action-reference {
    display:inline; margin:0; padding:0 0 .12em; color:#111; font-weight:850;
    white-space:normal; overflow-wrap:anywhere;
    -webkit-box-decoration-break:clone; box-decoration-break:clone;
    background:linear-gradient(90deg,rgba(122,88,18,.42) 0 38%,rgba(255,244,214,.96) 47%,rgba(215,174,61,.96) 53%,rgba(122,88,18,.42) 62% 100%) left bottom .05em / 280% .18em no-repeat;
    animation:gin-tutorial-action-underline-sweep 6.5s linear var(--gin-tutorial-wave-delay,0ms) infinite;
  }
  .gin-tutorial-target {
    position:relative; isolation:isolate;
  }
  .gin-tutorial-control-wave { position:absolute; z-index:10; inset:0; overflow:hidden; border-radius:inherit; pointer-events:none; }
  .gin-tutorial-control-wave::after {
    content:""; position:absolute; top:-40%; bottom:-40%; left:-52%; width:38%;
    background:linear-gradient(90deg,transparent,rgba(255,255,255,.9) 42%,rgba(255,219,116,.82) 62%,transparent);
    filter:blur(1px); transform:skewX(-18deg);
    animation:gin-tutorial-control-sweep 6.5s linear var(--gin-tutorial-wave-delay,0ms) infinite;
  }
  .cardface.gin-tutorial-card-target,
  #hand .cardface.gin-tutorial-card-target {
    box-shadow:0 0 0 2px var(--gin-tutorial-focus-keyline),0 0 0 6px var(--gin-tutorial-focus),0 0 18px 4px var(--gin-tutorial-focus-glow),var(--card-face-shadow);
    animation:gin-tutorial-card-halo 3.2s ease-in-out var(--gin-tutorial-focus-delay,0ms) infinite;
  }
  @keyframes gin-tutorial-card-halo {
    0%,55%,100% {
      box-shadow:0 0 0 2px var(--gin-tutorial-focus-keyline),0 0 0 6px var(--gin-tutorial-focus),-8px 0 15px 1px rgba(79,70,229,.16),0 0 17px 3px rgba(120,54,173,.3),8px 0 15px 1px rgba(217,70,239,.12),var(--card-face-shadow);
    }
    12% {
      box-shadow:0 0 0 2px var(--gin-tutorial-focus-keyline),0 0 0 6px var(--gin-tutorial-focus),-16px 0 25px 7px rgba(79,70,229,.72),0 0 19px 4px rgba(120,54,173,.38),8px 0 15px 1px rgba(217,70,239,.12),var(--card-face-shadow);
    }
    28% {
      box-shadow:0 0 0 2px var(--gin-tutorial-focus-keyline),0 0 0 6px var(--gin-tutorial-focus),-9px 0 17px 2px rgba(79,70,229,.22),0 0 29px 10px rgba(120,54,173,.72),9px 0 17px 2px rgba(217,70,239,.2),var(--card-face-shadow);
    }
    44% {
      box-shadow:0 0 0 2px var(--gin-tutorial-focus-keyline),0 0 0 6px var(--gin-tutorial-focus),-8px 0 15px 1px rgba(79,70,229,.14),0 0 19px 4px rgba(120,54,173,.38),16px 0 25px 7px rgba(217,70,239,.68),var(--card-face-shadow);
    }
  }
  @keyframes gin-tutorial-control-sweep {
    0% { left:-52%; }
    38.46%,100% { left:116%; }
  }
  @keyframes gin-tutorial-action-underline-sweep {
    0% { background-position:100% calc(100% - .05em); }
    38.46%,100% { background-position:-100% calc(100% - .05em); }
  }
  @media (prefers-reduced-motion:reduce) {
    .gin-tutorial-action-reference { animation:none; background:#c38d1d; background-size:100% .18em; background-repeat:no-repeat; background-position:left bottom .05em; }
  }
  .gin-tutorial-try { background:#f4c542; color:#4a3500; }
  .gin-tutorial-exercise-lane { flex-direction:column; gap:calc(8px * var(--ui-scale)); }
  .gin-tutorial-picked {
    box-shadow:0 0 0 3px #ffe070,0 0 16px rgba(255,224,112,.62),var(--card-face-shadow) !important;
    transform:translateY(calc(-7px * var(--ui-scale))) !important;
  }
  .gin-tutorial-pending { box-shadow:0 0 0 3px #9fd4ff,0 0 16px rgba(85,163,225,.6),var(--card-face-shadow) !important; }
  .gin-tutorial-exercise-meld { cursor:pointer; color:inherit; font:inherit; }
  .gin-tutorial-exercise-meld.targetable { border-color:#ffe070; box-shadow:0 0 0 2px rgba(255,224,112,.28); }
  .gin-tutorial-exercise-controls {
    display:flex; justify-content:center; gap:calc(7px * var(--ui-scale)); flex-wrap:wrap;
  }

  /* Guided lessons on the real table (src/lesson-ui.js). */
  .gin-lesson-answer { outline:3px solid #ffe071; outline-offset:2px; }
  .gin-lesson-hide-rails #leftRail > :not(.gin-strategy-note),
  .gin-lesson-hide-rails #rightRail > :not(.bubble),
  .gin-lesson-hide-rails #loosePlaque,
  .gin-lesson-hide-knock #knock,
  .gin-lesson-hide-discard #discard { display:none !important; }
  .gin-lesson-hide-handTools .hand-tools-wrap { visibility:hidden; }
  .gin-lesson-active #rightRail > .bubble { display:none; }
  .gin-lesson-active #drawActions button[inert],
  .gin-lesson-active #drawActions [inert] button { opacity:.4; cursor:default; }
  /* Lessons repeat the game's existing cues until that task is complete. */
  .gin-lesson-hint-set #hand .cardface.match-new .pip,
  .gin-lesson-hint-set #hand .cardface.match-new .face-art,
  html[data-card-theme="classic"] .gin-lesson-hint-run #hand .cardface.meld-run.classic-suit:not(.meld-grouped) .pip,
  html[data-card-theme="classic"] .gin-lesson-hint-run #hand .cardface.meld-run.classic-suit:not(.meld-grouped) .suit-mark,
  html[data-card-theme="classic"] .gin-lesson-hint-run #hand .cardface.meld-run.classic-suit:not(.meld-grouped).face .face-art {
    animation-iteration-count:infinite;
  }
  .gin-lesson-complete .gin-lesson-return { animation:gin-lesson-return-wave .8s ease-in-out 2; }
  @keyframes gin-lesson-return-wave {
    0%,100% { transform:rotate(0); }
    25% { transform:rotate(-2deg); }
    75% { transform:rotate(2deg); }
  }
  .gin-lesson-header {
    position:absolute; z-index:25; top:var(--hud-inset); left:var(--hud-inset);
    width:calc(var(--side-width) - var(--hud-inset));
  }
  .gin-lesson-header .gin-lesson-play {
    display:block; width:100%; margin-top:calc(10px * var(--ui-scale));
    padding:calc(8px * var(--ui-scale)) calc(5px * var(--ui-scale));
    font-size:calc(10px * var(--fs)); text-decoration:none;
  }
  .gin-lesson-header .gin-lesson-play[hidden] { display:none; }
  .gin-lesson-nav {
    position:absolute; z-index:25;
    bottom:calc(24px * var(--ui-scale));
    width:calc(var(--side-width) - var(--hud-inset));
    display:flex; align-items:center; justify-content:center; gap:calc(7px * var(--ui-scale));
    white-space:normal; font-size:calc(11px * var(--fs)); text-decoration:none;
  }
  /* Keep desktop navigation inside the sidebar, with an inset before cards. */
  .gin-lesson-return { left:calc(var(--hud-inset) + env(safe-area-inset-left)); }
  .gin-lesson-nav[hidden] { display:none; }
  /* The cloned brand line's "Practice" shows only in the handheld one-line brand;
     html raises this above the compact title rule below. */
  html .mode-badge.gin-lesson-header .brand-line .mode-title { display:none; }
  /* The lesson's title ("Lesson: Name") is styled like the mode title. Its dashes
     show only on the wide table; compact layouts have no room for them. */
  html[data-layout="compact"] .mode-badge.gin-lesson-header > .mode-title::before,
  html[data-layout="compact"] .mode-badge.gin-lesson-header > .mode-title::after { content:none; }
  html[data-layout="compact"] .gin-lesson-header {
    position:relative; grid-area:mode; top:auto; left:auto; width:100%;
  }
  html[data-layout="compact"] .gin-lesson-header .mode-title { display:block; font-size:13px; margin:0; }
  html[data-layout="compact"] .gin-lesson-header .gin-lesson-play {
    grid-column:1; grid-row:3; margin:0; padding:6px; min-height:44px;
  }
  html[data-layout="compact"] .gin-lesson-nav {
    position:static; width:auto; min-height:44px; margin:0; font-size:13px;
  }
  html[data-layout="compact"] .gin-lesson-return { grid-area:status; justify-self:start; }
  html[data-layout="compact"][data-orientation="portrait"] #mobileFooter > .gin-lesson-nav {
    grid-area:auto; grid-column:1; justify-self:stretch; align-self:end;
    padding:8px; font-size:12px;
  }
  /* Handheld lesson navigation sits centred in the bottom row. */
  html[data-layout="compact"][data-orientation="portrait"][data-device="handheld"] #mobileFooter > .gin-lesson-nav {
    grid-column:1 / -1; justify-self:center;
    margin-bottom:12px; padding:10px 16px; font-size:14px;
  }
  html[data-layout="compact"][data-orientation="portrait"] #mobileFooter > .gin-lesson-return { grid-row:1; }
  html[data-layout="compact"][data-orientation="portrait"] .gin-lesson-hide-handTools .hand-tools-wrap { display:none; }
  html[data-layout="compact"][data-orientation="portrait"] .gin-lesson-header {
    grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
    grid-template-areas:"brand brand brand" "play title utilities";
    align-items:center;
  }
  /* Handheld screens show the game's one-line brand, so "Practice" sits beside it. */
  html[data-layout="compact"][data-orientation="portrait"][data-device="handheld"] .gin-lesson-header .brand-line .mode-title { display:inline; }
  html[data-layout="compact"][data-orientation="portrait"] .gin-lesson-header > .mode-title {
    grid-area:title; min-width:0; font-size:18px; line-height:1.2; text-align:center;
  }
  html[data-layout="compact"][data-orientation="portrait"] .gin-lesson-header .gin-lesson-play {
    grid-area:play; justify-self:start; width:auto; padding:8px 10px; font-size:12px;
  }
  html[data-layout="compact"][data-orientation="portrait"] .gin-lesson-header #optionsBtn {
    grid-area:utilities; justify-self:end;
  }
  html[data-layout="compact"][data-orientation="landscape"] .gin-lesson-header { grid-column:1 / -1; }
  html[data-layout="compact"][data-orientation="landscape"] .gin-lesson-header:has(.gin-lesson-play:not([hidden])) {
    grid-template-columns:minmax(0,1fr) auto auto;
  }
  html[data-layout="compact"][data-orientation="landscape"] .gin-lesson-header:has(.gin-lesson-play:not([hidden])) #optionsBtn { grid-column:3; }
  html[data-layout="compact"][data-orientation="landscape"] .gin-lesson-header .gin-lesson-play { grid-column:2; grid-row:1 / 3; width:auto; }
