/* Our Game Shelf — app.css
   One stylesheet for the whole app. Tokens first, then one section per screen. */

/* Layout: game night on a blue linen tablecloth. Everything is a physical thing on the table —
   watercolour-paper cards held with washi tape, a sage-painted dresser, a milk-painted Connect Four
   frame, a sea chart. One deliberate look (no light/dark split). Thumb controls sit at the bottom. */
:root {
  color-scheme: light;
  --linen: #6d88a5;
  --paper: #f5f0e7;
  --paper-cream: #f0ece3;
  --paper-beige: #e6ded0;
  --ink: #232e46;
  --ink-soft: #4c5a72;
  --ink-mute: #5d6a80;
  --cream: #f3ead8;
  --cream-dim: #e3d8c3;
  --poppy: #c4482f;
  --poppy-deep: #8e2f1d;
  --ochre: #e2a83c;
  --navy: #2c4562;
  --navy-deep: #1b2c40;
  --sage: #7f9f86;
  --sea-ink: rgba(24, 44, 72, .6);
  --good: #5f9d6e;

  --display: "Caprasimo", "Cooper Black", Georgia, serif;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --body: "Figtree", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;

  --t-paper: url(/art/paper.jpg);
  --t-linen: url(/art/linen.jpg);
  --t-sage: url(/art/sage-wood.jpg);
  --t-blue: url(/art/blue-board.jpg);
  --t-sea: url(/art/sea.jpg);
  --t-hull: url(/art/hull.jpg);

  --lift: 0 1px 1px rgba(16, 26, 46, .25), 0 18px 30px -14px rgba(16, 26, 46, .6);
  --cloth-shadow: 0 1px 0 rgba(16, 26, 46, .35); /* handwriting straight on the tablecloth */
  /* letter tiles, number cards, keypad keys and setup options are the same buff card */
  /* charts on the stats sheet (checked for colour-blind separation on --paper): you, your partner, draws,
     and rock, paper, scissors */
  --chart-me: #2f68ad;
  --chart-them: #c4482f;
  --chart-draw: #a39d92;
  --chart-rock: #c7861a;
  --chart-paper: #5a62c8;
  --chart-scissors: #c2457f;
  --tile-face: #efe0bf;
  --tile-edge: #b99d6b;
  --ease-out: cubic-bezier(.2, .9, .25, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- base ---------- */
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--linen);
  color: var(--cream);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
input { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--ochre); outline-offset: 3px; }
img { -webkit-user-drag: none; }

/* ---------- the tablecloth ---------- */
#app {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--linen);
  background-image: var(--t-linen);
  background-size: 220px;
}
#app::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(130% 70% at 50% -5%, rgba(255, 232, 190, .3), transparent 60%),
    radial-gradient(120% 100% at 50% 45%, transparent 58%, rgba(16, 26, 46, .42));
}
#stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; z-index: 1; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 10px 18px;
  animation: screenIn .4s var(--ease-out) both;
  overflow-y: auto; overflow-x: hidden;
}
.screen.leaving { animation: screenOut .22s ease-in both; pointer-events: none; }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px) rotate(-.4deg); } }
@keyframes screenOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- materials ---------- */
.paper {
  background-color: var(--paper-cream);
  background-image: var(--t-paper);
  background-size: 560px;
  background-blend-mode: luminosity;
  color: var(--ink);
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), var(--lift);
}
.wc { mix-blend-mode: multiply; display: block; }
.tape {
  position: absolute; height: 24px; width: 88px; pointer-events: none; z-index: 2;
  background: rgba(232, 190, 110, .62);
  mix-blend-mode: multiply;
  clip-path: polygon(0 8%, 5% 0, 10% 10%, 15% 0, 20% 6%, 80% 0, 85% 8%, 90% 0, 95% 10%, 100% 2%, 100% 92%, 95% 100%, 90% 90%, 85% 100%, 80% 94%, 20% 100%, 15% 90%, 10% 100%, 5% 92%, 0 100%);
}
.tape.sage { background: rgba(150, 180, 140, .62); }
.tape.rose { background: rgba(222, 150, 160, .55); }
.sage-wood { background-color: var(--sage); background-image: var(--t-sage); background-size: 700px; }

/* plain paper for small things: game boxes, notes, toasts, turn chips, tools */
.gbox, .chat-note, .toast, .turn-chip, .tool { background-color: var(--paper); background-image: var(--t-paper); background-size: 300px; }

/* ---------- type ---------- */
.display { font-family: var(--display); font-weight: 400; line-height: 1; text-wrap: balance; }
.h1 { font-size: clamp(40px, 11.5vw, 52px); letter-spacing: -.01em; }
.h2 { font-size: clamp(28px, 8.4vw, 36px); }
.script { font-family: var(--hand); }
.muted { color: var(--cream-dim); }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 800; color: var(--poppy); }
.hand-note { font-family: var(--hand); font-size: 23px; line-height: 1.15; color: var(--cream); text-align: center; text-shadow: var(--cloth-shadow); margin: 0; text-wrap: balance; }

/* ---------- buttons (painted, with paper grain) ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 0 20px; width: 100%;
  border-radius: 14px;
  font-weight: 800; font-size: 17px; letter-spacing: .01em;
  background-image: var(--t-paper); background-size: 300px; background-blend-mode: multiply;
  transition: transform .12s var(--ease-out), opacity .2s;
}
.btn:active { transform: translateY(2px) scale(.985); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary { color: #fbf3e6; background-color: var(--poppy); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 2px 0 var(--poppy-deep), 0 10px 16px -8px rgba(80, 20, 10, .6); }
.btn-ink { color: var(--paper); background-color: var(--navy); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2), 0 2px 0 var(--navy-deep), 0 10px 16px -8px rgba(16, 26, 46, .6); }
.btn-felt { color: #fbf6ec; background-color: #5f8169; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 2px 0 #3c5644, 0 10px 16px -8px rgba(16, 26, 46, .6); }
.btn-ghost { color: var(--cream); background-color: rgba(245, 239, 227, .08); background-image: none; box-shadow: inset 0 0 0 2px rgba(245, 239, 227, .5); }
.paper .btn-ghost, #sheet .btn-ghost { color: var(--ink); background-color: transparent; box-shadow: inset 0 0 0 2px rgba(35, 46, 70, .45); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.back-link { align-self: center; color: var(--cream); font-family: var(--hand); font-size: 22px; padding: 8px 14px; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: rgba(245, 239, 227, .14); color: var(--paper); flex: none; }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- top bar ---------- */
#bar {
  position: relative; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  padding-block: 10px 6px;
  min-height: 60px;
}
.bar-side { display: flex; gap: 6px; justify-self: start; }
.bar-side.right { justify-self: end; }
.bar-mid { display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 52vw; }
.bar-title { font-family: var(--display); font-size: 22px; line-height: 1.1; color: #fbf6ec; text-shadow: 0 2px 0 rgba(16, 26, 46, .25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.presence { display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 6px; font: 800 11px var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--cream); max-width: 100%; }
.presence span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #a7a29a; flex: none; transition: background .3s, box-shadow .3s; }
.dot.here { background: var(--good); box-shadow: 0 0 0 3px rgba(95, 157, 110, .25); }
.dot.near { background: var(--ochre); box-shadow: 0 0 0 3px rgba(226, 168, 60, .25); }
.dot.gone { background: var(--poppy); box-shadow: 0 0 0 3px rgba(196, 72, 47, .22); }

/* ---------- front door ---------- */
.landing { gap: 22px; max-width: 440px; width: 100%; margin: 0 auto; justify-content: flex-start; padding-top: 34px; }
/* History can make the landing page taller than a phone: never centre content above its scroll origin. */
.landing > * { flex-shrink: 0; }
.hero-card { position: relative; padding: 16px 20px 22px; transform: rotate(-1.2deg); display: flex; flex-direction: column; gap: 6px; }
.hero-card img { width: 100%; height: auto; margin: -6px 0 -10px; }
.hero-card .h1 { color: var(--ink); }
.hero-card p { margin: 4px 0 0; font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.form-card { position: relative; padding: 20px 20px 22px; transform: rotate(.6deg); display: flex; flex-direction: column; gap: 16px; }
.name-tag { display: flex; flex-direction: column; gap: 0; }
.name-tag span { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; font-weight: 800; color: var(--poppy); }
.name-tag input {
  border: 0; background: transparent; outline: none;
  font-family: var(--hand); font-weight: 700; font-size: 36px; line-height: 1; color: var(--navy);
  height: 52px; padding: 0 2px;
  border-bottom: 2px solid rgba(44, 69, 98, .35);
}
.name-tag input::placeholder { color: rgba(44, 69, 98, .35); }
.code-label { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; font-weight: 800; color: var(--ink-mute); }
.tile {
  position: relative; display: grid; place-items: center;
  width: 24px; height: 26px; border-radius: 4px;
  font-family: var(--display); font-size: 15px; line-height: 1; color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -2px 0 rgba(120,90,40,.22), 0 2px 0 var(--tile-edge), 0 3px 6px rgba(16,26,46,.35);
}
.tile, .qf-num, .qf-key, .qf-opt { background-color: var(--tile-face); background-image: var(--t-paper); background-size: 200px; background-blend-mode: multiply; }
.rack {
  position: relative;
  display: flex; gap: 8px; justify-content: center;
  padding: 4px 0 6px;
}
.rack .tile { flex: none; width: clamp(44px, 14vw, 58px); height: auto; min-height: 48px; aspect-ratio: 58 / 62; font-size: clamp(28px, 9vw, 36px); border-radius: 7px; transition: transform .15s var(--ease-spring); }
.rack .tile.empty { opacity: .6; color: transparent; }
.rack .tile.cursor { opacity: 1; outline: 3px solid var(--ochre); outline-offset: 2px; }
.rack .tile.pop { animation: tileIn .32s var(--ease-spring); }
.code-entry { position: relative; }
.code-entry input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; text-transform: uppercase; caret-color: transparent; color: transparent; }
.form-error { color: var(--poppy); font-weight: 800; font-size: 15px; min-height: 1.4em; text-align: center; }

/* ---------- table code ---------- */
.waiting { justify-content: center; align-items: center; text-align: center; gap: 24px; max-width: 440px; margin: 0 auto; width: 100%; }
.code-card { position: relative; width: 100%; padding: 26px 22px 24px; transform: rotate(-.8deg); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.code-card .h2 { color: var(--ink); }
.code-card .script { font-size: 25px; line-height: 1.15; color: var(--navy); margin: 0; text-wrap: balance; }
.code-card .rack .tile { animation: tileIn .5s var(--ease-spring) both; }
.code-card .rack .tile:nth-child(2) { animation-delay: .07s; } .code-card .rack .tile:nth-child(3) { animation-delay: .14s; } .code-card .rack .tile:nth-child(4) { animation-delay: .21s; }
.code-card .sprig { position: absolute; right: -4px; bottom: -14px; width: 70px; transform: rotate(18deg); }
@keyframes tileIn { from { transform: translateY(-26px) rotate(-10deg); opacity: 0; } }
.chair { display: flex; gap: 10px; align-items: center; color: var(--cream); font-weight: 700; }
.pulse-dots { display: inline-flex; gap: 5px; }
.pulse-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ochre); animation: pd 1.2s infinite; }
.pulse-dots i:nth-child(2) { animation-delay: .15s; } .pulse-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes pd { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.stack { width: 100%; display: flex; flex-direction: column; gap: 12px; }

/* ---------- the dresser ---------- */
.shelf-screen { gap: 14px; }
.shelf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 4px 4px 0; }
.shelf-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.shelf-names { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.shelf-head .script { font-size: 22px; line-height: 1; color: var(--cream); }
/* the table code as four small letter tiles beside the names */
.table-code { display: inline-flex; gap: 3px; rotate: -2deg; }
.table-code .tile { width: 20px; height: 22px; font-size: 13px; border-radius: 3px; }
/* the stats: a little paper card taped up beside the title, with a painted pie */
.stats-btn { position: relative; flex: none; display: grid; justify-items: center; gap: 2px; width: 84px; min-height: 76px; padding: 12px 6px 6px; rotate: 2.5deg; font: 700 17px/1 var(--hand); color: var(--navy); text-align: center; }
.stats-btn .tape { top: -9px; left: 50%; width: 46px; height: 18px; margin-left: -23px; rotate: -4deg; }
.stats-btn svg { width: 34px; height: 34px; }
.stats-btn:active { transform: translateY(2px) rotate(-1deg); }
.shelf-head .h2 { color: #fbf6ec; text-shadow: 0 2px 0 rgba(16, 26, 46, .3); }
.dresser { position: relative; border-radius: 8px 8px 4px 4px; padding: 0 0 14px; box-shadow: 0 22px 36px -16px rgba(16, 26, 46, .75); }
.cornice { height: 26px; margin: 0 -8px; border-radius: 6px 6px 3px 3px; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .22), inset 0 -4px 0 rgba(30, 50, 36, .25), 0 6px 10px -4px rgba(16, 26, 46, .5); }
.cubby {
  margin: 0 14px;
  background: rgba(28, 44, 34, .42);
  box-shadow: inset 0 14px 22px rgba(10, 20, 14, .55), inset 0 0 0 2px rgba(20, 34, 26, .35);
  border-radius: 2px;
  padding: 20px 8px 12px;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 10px;
  grid-auto-rows: max-content; align-items: end; align-content: start;
  max-height: clamp(240px, 40svh, 340px);
  overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch; touch-action: pan-y;
  scrollbar-width: thin; scrollbar-color: var(--cream-dim) rgba(28,44,34,.3);
}
.cubby:focus-visible { outline: 3px solid var(--ochre); outline-offset: -3px; }
@media (max-width: 359px) { .cubby { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 760px) {
  .cubby { grid-template-columns: repeat(5, minmax(0, 180px)); justify-content: space-evenly; max-height: min(60svh, 500px); }
}
.shelf-board { height: 20px; display: grid; place-items: center; margin: 0 8px; border-radius: 2px; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .25), 0 8px 12px -4px rgba(10, 20, 14, .65); }
.gbox {
  position: relative; display: flex; flex-direction: column;
  border-radius: 4px 4px 2px 2px; overflow: hidden;
  box-shadow: inset -5px 0 0 rgba(16, 26, 46, .18), 0 -1px 0 rgba(255, 255, 255, .4), 4px 6px 10px -4px rgba(16, 26, 46, .6);
  transform-origin: 50% 100%;
  transition: transform .28s var(--ease-spring);
  max-width: 100%;
}
.gbox img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.gbox .lbl { display: grid; place-items: center; min-height: 44px; font-family: var(--display); font-size: clamp(12px, 3.2vw, 16px); line-height: 1.15; color: var(--ink); padding: 7px 2px 8px; text-align: center; overflow-wrap: anywhere; }
.gbox:active { transform: translateY(-6px) rotate(-1.5deg); }
.gbox.pulled { transform: translateY(-12px) scale(1.04) rotate(-1deg); }
.gbox .sticker.saved { background: var(--sage); }
.gbox .sticker { position: absolute; top: 8px; right: -4px; padding: 3px 10px 3px 12px; font: 800 10px var(--body); letter-spacing: .14em; text-transform: uppercase; color: #fbf3e6; background: var(--poppy); clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%); transform: rotate(8deg); }
.dresser-lower { position: relative; padding: 16px 14px 0; }
.score-sheet {
  position: relative; padding: 14px 16px 12px; transform: rotate(-1deg);
  background-image: var(--t-paper), repeating-linear-gradient(transparent 0 25px, rgba(58, 106, 140, .22) 25px 26px);
  background-blend-mode: multiply;
}
.score-sheet h3 { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 22px; color: var(--poppy); line-height: 1; }
.score-grid { display: grid; grid-template-columns: minmax(0, 1fr) repeat(2, minmax(2.4ch, 92px)); column-gap: 12px; font-family: var(--hand); font-size: 21px; line-height: 26px; color: var(--navy); margin-top: 4px; }
.score-grid .n { text-align: center; }
.score-grid .hd { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 359px) {
  .score-grid { grid-template-columns: minmax(0, 1fr) repeat(2, minmax(2.4ch, 48px)); column-gap: 8px; }
  .score-grid > span:not(.n) { overflow-wrap: anywhere; }
}
/* the sprig leans over the score sheet's corner */
.dresser .sprig { position: absolute; right: 2px; top: -26px; width: 58px; z-index: 2; pointer-events: none; transform: rotate(10deg); filter: brightness(1.4) saturate(1.1); }
.shelf-note { margin: 0 4px; }
.shelf-foot { margin-top: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 132px)); justify-content: center; gap: 8px; }
.foot-btn { flex-direction: column; gap: 4px; min-height: 60px; padding: 8px 6px; border-radius: 10px; font-size: 13px; line-height: 1.1; text-align: center; }
.foot-btn i { display: block; width: 20px; height: 20px; }
.foot-btn i svg { width: 100%; height: 100%; display: block; }
.rename-form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }

/* ---------- stats (a sheet from the score sheet) ---------- */
.stats { display: flex; flex-direction: column; gap: 22px; padding-bottom: 4px; }
.stats-sec h3 { margin: 0 0 8px; font: 700 24px/1 var(--hand); color: var(--poppy); }
.stats-foot { margin: 6px 0 0; font: 600 18px/1.25 var(--hand); color: var(--ink-soft); }
.stats-log { list-style: none; margin: 4px 0 0; padding: 0; }
.stats-log li { position: relative; display: grid; gap: 1px; padding: 9px 0 9px 18px; border-bottom: 1px solid rgba(35, 46, 70, .2); }
.stats-log li::before { content: ''; position: absolute; left: 0; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--chart-draw); }
.stats-log li.me::before { background: var(--chart-me); } .stats-log li.them::before { background: var(--chart-them); }
/* the charts: watercolour-flat colour on the sheet's paper, every mark carries its number */
.stats-sec h4 { margin: 14px 0 6px; font: 800 11px var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); }
.st-legend { display: flex; gap: 16px; font: 700 15px var(--body); color: var(--ink); }
.st-legend span { display: inline-flex; align-items: center; gap: 6px; }
.st-legend i, .st-key i { width: 12px; height: 12px; border-radius: 3px; background: var(--chart-me); }
.st-legend .them i { background: var(--chart-them); }
.st-hero { display: flex; justify-content: space-between; margin: 6px 0 4px; }
.st-hero div { display: grid; }
.st-hero .them { text-align: right; }
.st-hero b { font: 400 42px/1 var(--display); color: var(--chart-me); }
.st-hero .them b { color: var(--chart-them); }
.st-hero small { font: 700 17px/1.1 var(--hand); color: var(--ink-soft); }
.st-split { display: flex; gap: 2px; height: 26px; }
.st-seg { display: grid; place-items: center; min-width: 26px; border-radius: 4px; font: 800 13px var(--body); color: #fbf6ec; background-color: var(--chart-me); background-image: var(--t-paper); background-size: 300px; background-blend-mode: multiply; }
.st-seg.them { background-color: var(--chart-them); }
.st-seg.draw { background-color: var(--chart-draw); }
.st-seg.none { flex: 1; color: var(--ink-mute); background: none; box-shadow: inset 0 0 0 1px rgba(35, 46, 70, .25); font-weight: 600; }
.st-form { display: flex; flex-wrap: wrap; gap: 6px; }
.st-form i { width: 18px; height: 18px; border-radius: 50%; background: var(--chart-me); }
.st-form i.them { background: var(--chart-them); }
.st-form i.draw { background: none; box-shadow: inset 0 0 0 2px var(--chart-draw); }
.st-duels { display: grid; gap: 8px; margin-top: 10px; }
.st-duel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 2px; row-gap: 2px; }
.st-label { grid-column: 1 / -1; text-align: center; font: 700 19px/1.1 var(--hand); color: var(--ink); }
.st-half { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.st-half.me { flex-direction: row-reverse; }
.st-bar { height: 16px; border-radius: 4px 0 0 4px; background-color: var(--chart-me); background-image: var(--t-paper); background-size: 300px; background-blend-mode: multiply; opacity: .9; }
.st-half.them .st-bar { border-radius: 0 4px 4px 0; background-color: var(--chart-them); }
.st-half b { font: 600 15px var(--body); color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.st-half.lead b { font-weight: 800; color: var(--ink); }
.st-half.lead b::after { content: ' ★'; color: var(--chart-rock); }
.st-half.me.lead b::after { content: none; } .st-half.me.lead b::before { content: '★ '; color: var(--chart-rock); }
.st-pies { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.st-pie { margin: 0; display: grid; justify-items: center; gap: 8px; }
.st-ring { position: relative; width: min(100%, 150px); aspect-ratio: 1; }
.st-donut { width: 100%; height: 100%; display: block; }
.st-arc { fill: none; stroke-width: 20; stroke: var(--chart-rock); } /* hand-rock */
.st-arc.hand-paper { stroke: var(--chart-paper); } .st-arc.hand-scissors { stroke: var(--chart-scissors); }
.st-arc.empty { stroke: rgba(35, 46, 70, .1); }
.st-mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.st-mid b { font: 700 20px/1 var(--hand); color: var(--ink); max-width: 5em; overflow: hidden; text-overflow: ellipsis; }
.st-mid small { font: 600 13px var(--body); color: var(--ink-mute); }
.st-pie figcaption { display: grid; gap: 3px; width: 100%; max-width: 150px; }
.st-key { display: grid; grid-template-columns: 12px 22px 1fr auto; align-items: center; gap: 5px; font: 700 15px var(--body); color: var(--ink-soft); }
.st-key img { width: 22px; height: 22px; object-fit: contain; }
.st-key b { color: var(--ink); font-variant-numeric: tabular-nums; }
.st-key.hand-rock i { background: var(--chart-rock); } .st-key.hand-paper i { background: var(--chart-paper); } .st-key.hand-scissors i { background: var(--chart-scissors); }
.stats-log small { font: 800 11px var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); }
.stats-log b { font-size: 15px; color: var(--ink); }
.stats-log span { font: 600 18px/1.2 var(--hand); color: var(--navy); }
/* the home face: the score out of the pool, the line it took, and a paper slip per game */
.st-score { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 8px; margin-top: 2px; }
.st-score > div { display: grid; min-width: 0; }
.st-score .them { text-align: right; }
.st-score small { font: 800 11px var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-score b { font: 400 clamp(42px, 13vw, 56px)/1 var(--display); color: var(--chart-me); font-variant-numeric: tabular-nums; }
.st-score .them b { color: var(--chart-them); }
.st-score .st-of { justify-items: center; padding-bottom: 6px; font: 700 19px/1 var(--hand); color: var(--ink-soft); white-space: nowrap; }
.st-lead { margin: -10px 0 0; text-align: center; font: 700 26px/1.1 var(--hand); color: var(--poppy); rotate: -1deg; text-wrap: balance; }
.st-h { margin: 4px 0 -12px; font: 800 11px var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); }
/* the score's line: ruled like an exercise book, ink over a watercolour wash, a dot where the lead changed hands */
.st-chart { margin: 0; display: grid; gap: 5px; }
.st-plot { position: relative; height: 132px; border-radius: 3px; background: repeating-linear-gradient(to bottom, transparent 0 21px, rgba(47, 104, 173, .13) 21px 22px); box-shadow: inset 0 0 0 1px rgba(35, 46, 70, .12); }
.st-lines { position: absolute; left: 0; top: 8px; width: 100%; height: calc(100% - 16px); overflow: visible; }
.st-lines path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.st-lines .st-level { stroke: var(--ink-mute); stroke-width: 1.2; stroke-dasharray: 4 5; opacity: .7; }
.st-lines .st-wash { stroke-width: 9; opacity: .18; }
.st-lines .st-ink { stroke-width: 2.4; opacity: .92; }
.st-lines .me { stroke: var(--chart-me); }
.st-lines .them { stroke: var(--chart-them); }
.st-lines .st-cross { stroke: var(--chart-rock); stroke-width: 10; }
.st-level-lbl { position: absolute; left: 6px; top: calc(50% - 22px); font: 700 15px/1 var(--hand); color: var(--ink-mute); text-shadow: 0 0 3px var(--paper-cream), 0 0 3px var(--paper-cream), 0 0 6px var(--paper-cream); }
.st-chart figcaption { display: flex; justify-content: space-between; gap: 10px; font: 800 10px var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
/* how points work, folded under the score */
.st-how { border-radius: 6px; box-shadow: inset 0 0 0 2px rgba(35, 46, 70, .28); }
.st-how summary { display: flex; align-items: center; min-height: 46px; padding: 0 14px; font: 800 13px var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--ink); list-style: none; cursor: pointer; }
.st-how summary::-webkit-details-marker { display: none; }
.st-how summary::after { content: '+'; margin-left: auto; font: 400 24px/1 var(--display); color: var(--poppy); }
.st-how[open] summary::after { content: '–'; }
.st-how summary:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; border-radius: 6px; }
.st-how ul { margin: 0; padding: 0 16px 14px 32px; display: grid; gap: 8px; font: 600 15px/1.4 var(--body); color: var(--ink-soft); }
.st-cards { display: grid; gap: 18px; padding: 6px 2px 4px; }
.st-card {
  position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto 14px; align-items: center; gap: 12px;
  width: 100%; min-height: 86px; padding: 12px 10px 12px 12px; border: 0; border-radius: 4px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background-color: var(--paper); background-image: var(--t-paper); background-size: 300px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55), 0 1px 1px rgba(16, 26, 46, .22), 0 9px 14px -9px rgba(16, 26, 46, .5);
  rotate: -.6deg; transition: transform .2s var(--ease-spring);
}
.st-card:nth-child(even) { rotate: .5deg; }
.st-card:nth-child(3n) { rotate: -.2deg; }
.st-card:active { transform: translateY(2px) scale(.99); }
.st-card:focus-visible { outline: 3px solid var(--ochre); outline-offset: 3px; }
.st-card .tape { top: -9px; left: 20px; width: 52px; height: 17px; rotate: -5deg; }
.st-card:nth-child(even) .tape { left: auto; right: 34px; rotate: 4deg; background: rgba(150, 180, 140, .62); }
.st-card.quiet { opacity: .7; }
.st-art { width: 48px; height: 64px; object-fit: contain; filter: drop-shadow(1px 2px 2px rgba(16, 26, 46, .35)); }
.st-art.hand { filter: none; }
.st-art.pie { display: grid; place-items: center; filter: none; }
.st-art.pie svg { width: 40px; height: 40px; }
.st-card-txt { display: grid; gap: 3px; min-width: 0; }
.st-name { font: 400 19px/1.05 var(--display); color: var(--ink); }
.st-glance { font: 700 13px/1.25 var(--body); color: var(--ink-soft); }
.st-glance2 { font: 700 18px/1.1 var(--hand); color: var(--navy); overflow-wrap: anywhere; }
.st-card .st-form { gap: 4px; margin-top: 3px; }
.st-card .st-form i { width: 12px; height: 12px; }
.st-pts { display: grid; justify-items: end; gap: 2px; }
.st-pts b { font: 400 22px/1 var(--display); color: var(--chart-me); font-variant-numeric: tabular-nums; }
.st-pts b.them { color: var(--chart-them); }
.st-more { color: var(--ink-mute); }
.st-more svg { display: block; width: 14px; height: 14px; }
/* one card's full stats */
.st-back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 16px 0 8px; border: 0; border-radius: 8px; background: transparent; box-shadow: inset 0 0 0 2px rgba(35, 46, 70, .4); font: 800 13px var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--ink); cursor: pointer; }
.st-back svg { display: block; width: 20px; height: 20px; }
.st-back:active { transform: translateY(2px); }
.st-back:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; }
.st-back.bottom { align-self: stretch; justify-content: center; }
.st-head { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 14px; align-items: center; margin-top: -6px; }
.st-head .st-art { width: 56px; height: 74px; }
.st-head h2 { margin: 0; font: 400 28px/1 var(--display); color: var(--ink); text-wrap: balance; }
.st-head p { margin: 5px 0 0; font: 700 20px/1.15 var(--hand); color: var(--poppy); }
.st-notes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 9px; }
.st-notes li { position: relative; padding-left: 22px; font: 600 20px/1.2 var(--hand); color: var(--navy); }
.st-notes li::before { content: ''; position: absolute; left: 2px; top: .6em; width: 12px; height: 3px; border-radius: 2px; background: var(--poppy); rotate: -8deg; }
@media (max-width: 359px) {
  .st-card { grid-template-columns: 38px minmax(0, 1fr) auto 12px; gap: 9px; padding-inline: 9px 8px; }
  .st-art { width: 38px; height: 50px; }
  .st-name { font-size: 17px; }
  .st-glance2 { font-size: 17px; }
}

/* ---------- sheet ---------- */
#sheet { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: flex-end; padding-top: max(16px, env(safe-area-inset-top, 0px)); }
#sheet .scrim { position: absolute; inset: 0; background: rgba(20, 30, 50, .45); animation: fade .25s both; }
#sheet .panel {
  position: relative; margin: 0 auto; width: 100%; max-width: 520px;
  padding: 10px max(22px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(22px, env(safe-area-inset-left, 0px));
  border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column; gap: 14px;
  animation: sheetUp .38s var(--ease-out) both;
  touch-action: pan-y;
  /* long rules stay inside the viewport, with the sheet's decisions always reachable */
  max-height: 100%; min-height: 0;
}
#sheet .panel > .grip, #sheet .panel > .btn-row { flex: none; }
.sheet-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 14px; }
.sheet-content > * { flex-shrink: 0; }
.sheet-content:focus-visible { outline: 2px solid var(--ochre); outline-offset: -2px; }
#sheet .grip { width: 44px; height: 5px; border-radius: 3px; background: rgba(35, 46, 70, .2); align-self: center; margin-bottom: 4px; }
#sheet .panel .tape { top: -12px; left: 50%; margin-left: -44px; transform: rotate(-2deg); }
#sheet.closing .scrim { animation: fade .2s reverse both; }
#sheet.closing .panel { animation: sheetDown .22s ease-in both; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
.sheet-title { font-family: var(--display); font-size: 32px; line-height: 1; color: var(--ink); text-wrap: balance; }
.sheet-sub { font-family: var(--hand); font-weight: 700; font-size: 28px; line-height: 1; color: var(--poppy); margin-top: -6px; }
.sheet-body { color: var(--ink-soft); font-weight: 600; font-size: 16px; }
.sheet-body ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }

/* ---------- chat ---------- */
#chatBtn { position: relative; }
#chatBtn .unread { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--poppy); box-shadow: 0 0 0 2px #6d88a5; display: none; }
#chatBtn.has .unread { display: block; animation: dotIn .35s var(--ease-spring) both; }
@keyframes dotIn { from { transform: scale(0); } }
#chatfx { position: fixed; inset: 0; z-index: 35; pointer-events: none; }
.chat-pop { position: fixed; font-size: 44px; line-height: 1; filter: drop-shadow(0 6px 8px rgba(16, 26, 46, .35)); will-change: transform, opacity; }
.chat-pop.mine { font-size: 30px; }
.chat-note {
  pointer-events: auto; position: relative;
  max-width: min(300px, calc(100vw - 40px)); padding: 9px 16px 11px; text-align: left;
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(16, 26, 46, .25), 0 12px 22px -8px rgba(16, 26, 46, .6);
  transform: rotate(-1.4deg); animation: toastIn .35s var(--ease-spring) both;
}
.chat-note:nth-child(even) { transform: rotate(1deg); }
.chat-note::before { content: ""; position: absolute; top: -9px; right: 22px; width: 46px; height: 17px; background: rgba(226, 168, 60, .55); transform: rotate(4deg); }
.chat-note.out { animation: toastOut .24s ease-in both; }
.chat-note b { display: block; font: 800 11px var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--poppy); }
.chat-note span { display: block; font-family: var(--hand); font-size: 23px; line-height: 1.12; color: var(--navy); overflow-wrap: anywhere; }
.chat-panel { display: grid; gap: 10px; margin-top: 2px; }
.chat-thread {
  display: flex; flex-direction: column; gap: 6px; height: min(36vh, 300px); overflow-y: auto; padding: 8px 10px;
  border-radius: 6px; background: repeating-linear-gradient(transparent 0 27px, rgba(58, 106, 140, .16) 27px 28px); box-shadow: inset 0 0 0 1.5px rgba(24, 44, 72, .12);
}
.chat-thread > :first-child { margin-top: auto; }
.chat-line { max-width: 82%; font-family: var(--hand); font-size: 21px; line-height: 1.1; overflow-wrap: anywhere; }
.chat-line.me { align-self: flex-end; text-align: right; color: var(--ink); }
.chat-line.them { align-self: flex-start; color: var(--navy); }
.chat-line .who { display: block; font: 800 10px var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
.chat-line .e { font-family: var(--body); font-size: 28px; }
.chat-empty { font-family: var(--hand); font-size: 20px; color: var(--ink-mute); text-align: center; }
.chat-emoji { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 2px; }
.chat-emoji button { height: 46px; border-radius: 8px; font-size: 26px; line-height: 1; transition: transform .12s; }
.chat-emoji button:active { transform: scale(.9); }
.chat-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -22px; padding: 2px 22px; }
.chat-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 0 14px; border-radius: 6px; font-weight: 800; font-size: 14px; color: var(--ink); background: rgba(24, 44, 72, .06); box-shadow: inset 0 0 0 1.5px rgba(24, 44, 72, .18); }
.chip:active { transform: scale(.96); }
.chat-form { display: flex; gap: 8px; }
.chat-input { flex: 1; min-width: 0; height: 52px; padding: 0 14px; border-radius: 14px; border: 1.5px solid rgba(24, 44, 72, .25); background: #fffdf8; color: var(--ink); font: 600 16px var(--body); }
.chat-form .btn { width: auto; flex: none; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  z-index: 40; pointer-events: none;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  padding: 9px 16px; border-radius: 6px;
  color: var(--ink); font-weight: 800; font-size: 15px; text-align: center;
  box-shadow: 0 1px 1px rgba(16, 26, 46, .25), 0 10px 20px -8px rgba(16, 26, 46, .6);
  animation: toastIn .35s var(--ease-spring) both;
}
.toast:nth-child(odd) { transform: rotate(-1deg); } .toast:nth-child(even) { transform: rotate(.8deg); }
.toast.out { animation: toastOut .25s ease-in both; }
@keyframes toastIn { from { opacity: 0; translate: 0 -14px; scale: .9; } }
@keyframes toastOut { to { opacity: 0; translate: 0 -10px; } }

/* ---------- match chrome ---------- */
.match { gap: 10px; padding-top: 2px; }
.phase { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
/* each phase of a game (how to play, RPS, the game itself) comes in like a screen */
.phase-box { flex: 1; display: flex; flex-direction: column; min-height: 0; animation: screenIn .4s var(--ease-out) both; }
.status-line { font-family: var(--hand); font-size: 24px; line-height: 1.05; color: #fbf6ec; text-align: center; min-height: 2.1em; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; column-gap: .25em; text-shadow: 0 1px 0 rgba(16, 26, 46, .3); text-wrap: balance; }
.status-line b { color: #f6c66e; font-weight: 700; }
.bs-status, .c4-status { flex: none; }

/* ---------- rock · paper · scissors ---------- */
.rps { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 10px 14px; transform: rotate(-.6deg); }
.sb-side { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sb-side.right { align-items: flex-end; text-align: right; }
.sb-name { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pips { display: flex; gap: 6px; }
.pip { width: 15px; height: 15px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(44, 69, 98, .5); transition: background .3s; }
.pip.on { background: var(--poppy); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .2); animation: pipPop .45s var(--ease-spring); }
@keyframes pipPop { from { transform: scale(.2); } 60% { transform: scale(1.35); } }
.sb-mid { font-family: var(--hand); font-size: 21px; line-height: 1; color: var(--navy); text-align: center; }
.sb-mid small { display: block; font-size: 16px; color: var(--ink-mute); }
.arena { flex: 1; min-height: 220px; position: relative; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 4px 0; }
.slot { width: 100%; height: 44%; display: grid; place-items: center; position: relative; }
.slot-label { position: absolute; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 800; color: var(--cream-dim); }
.slot.top .slot-label { top: 0; } .slot.bottom .slot-label { bottom: 0; }
.verdict { position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); text-align: center; z-index: 3; pointer-events: none; }
.verdict .v1 { font-family: var(--hand); font-weight: 700; font-size: clamp(34px, 10vw, 42px); line-height: .95; color: #fbf6ec; text-shadow: 0 2px 0 rgba(16, 26, 46, .4); }
.verdict .v2 { font-weight: 700; color: var(--cream-dim); font-size: 15px; margin-top: 4px; }
.verdict.show { animation: verdictIn .45s var(--ease-spring) both; }
@keyframes verdictIn { from { opacity: 0; transform: translateY(-50%) scale(.6) rotate(-4deg); } }
.hand {
  position: relative;
  width: min(32vw, 128px); aspect-ratio: 3 / 4.1;
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink);
  background-color: #f7f1e6; background-image: var(--t-paper); background-size: 300px;
  box-shadow: inset 0 0 0 6px #f7f1e6, inset 0 0 0 7.5px rgba(196, 72, 47, .55), 0 2px 1px rgba(16, 26, 46, .25), 0 16px 24px -10px rgba(16, 26, 46, .65);
  transition: transform .25s var(--ease-spring), opacity .25s, filter .3s;
}
.hand img { width: 84%; height: auto; margin-top: -4px; }
.hand .nm { font-family: var(--hand); font-weight: 700; font-size: 22px; line-height: 1; margin-top: -8px; }
.hand .idx { position: absolute; font-family: var(--display); font-size: 16px; line-height: 1; color: var(--poppy); }
.hand .idx.a { top: 11px; left: 12px; } .hand .idx.b { bottom: 11px; right: 12px; transform: rotate(180deg); }
.hand.back {
  background-color: #3f6a8a; background-image: var(--t-sea); background-size: 260px;
  box-shadow: inset 0 0 0 6px #f7f1e6, inset 0 0 0 7.5px rgba(24, 44, 72, .5), 0 2px 1px rgba(16, 26, 46, .25), 0 16px 24px -10px rgba(16, 26, 46, .65);
  color: var(--paper);
}
.hand.back b { font-family: var(--display); font-weight: 400; font-size: 44px; line-height: 1; text-shadow: 0 2px 0 rgba(16, 26, 46, .35); }
.hand.back small { font-family: var(--hand); font-weight: 700; font-size: 20px; color: var(--paper); text-shadow: 0 1px 0 rgba(16, 26, 46, .4); }
.hand.back.waiting { animation: waitBob 1.8s ease-in-out infinite; }
.hand.back.waiting::after { content: ""; position: absolute; inset: -6px; border-radius: 16px; box-shadow: 0 0 0 3px rgba(226, 168, 60, .7); animation: waitRing 1.8s ease-in-out infinite; }
@keyframes waitBob { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-7px) rotate(1.5deg); } }
@keyframes waitRing { 0%, 100% { opacity: .15; } 50% { opacity: 1; } }
.ticking i { font-style: normal; animation: tick 1.2s infinite both; }
.ticking i:nth-child(2) { animation-delay: .2s; } .ticking i:nth-child(3) { animation-delay: .4s; }
@keyframes tick { 0%, 20% { opacity: .15; } 50% { opacity: 1; } 100% { opacity: .15; } }
.hand.lost { filter: saturate(.4) brightness(.82); }
.hand.won { box-shadow: inset 0 0 0 6px #f7f1e6, inset 0 0 0 7.5px rgba(196, 72, 47, .55), 0 0 0 4px var(--ochre), 0 0 40px rgba(226, 168, 60, .55); }
.hand .crack { position: absolute; inset: 0; pointer-events: none; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-top: 4px; justify-items: center; }
.choices .hand { width: 100%; max-width: 118px; box-shadow: inset 0 0 0 5px #f7f1e6, inset 0 0 0 6.5px rgba(44, 69, 98, .35), 0 2px 1px rgba(16, 26, 46, .25), 0 12px 18px -10px rgba(16, 26, 46, .6); }
.choices .hand:active { transform: translateY(4px) scale(.96); }
.choices .hand .idx { display: none; }
.choices.locked .hand { opacity: .35; transform: scale(.94); pointer-events: none; }
.choices.locked .hand.picked { opacity: 1; transform: translateY(-6px) rotate(-2deg); box-shadow: inset 0 0 0 5px #f7f1e6, inset 0 0 0 7px var(--poppy), 0 12px 18px -10px rgba(16, 26, 46, .6); }
.rps-hint { font-family: var(--hand); font-size: 23px; line-height: 1.05; color: var(--cream); text-align: center; min-height: 1.2em; text-wrap: balance; }
/* how to play */
.howto-wrap { flex: 1; display: grid; place-items: center; padding: 10px 0; overflow-y: auto; }
.howto-card { position: relative; width: 100%; max-width: 360px; padding: 26px 20px 20px; display: flex; flex-direction: column; gap: 12px; transform: rotate(-.6deg); animation: tileIn .55s var(--ease-spring) both; }
.howto-card .h2 { color: var(--ink); margin: 0; }
.howto { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.howto li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; text-align: left; }
.howto .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: var(--paper); font: 800 13px var(--body); }
.howto b { display: block; color: var(--ink); font-weight: 800; font-size: 16px; line-height: 1.2; }
.howto li div span { display: block; color: var(--ink-soft); font-weight: 600; font-size: 14.5px; line-height: 1.32; }
.howto img { width: 42px; height: 42px; object-fit: contain; }
.howto-skip { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; font-size: 14px; color: var(--ink-soft); }
.howto-skip input { width: 22px; height: 22px; margin: 0; accent-color: var(--navy); flex: none; }
.starter-card { position: absolute; inset: 0; display: grid; place-items: center; z-index: 5; }
.starter-card .paper { position: relative; padding: 28px 22px 22px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; animation: tileIn .55s var(--ease-spring) both; max-width: 320px; width: 100%; transform: rotate(-1deg); }
.starter-card .paper .h2 { color: var(--ink); }
.starter-card .disc-demo { position: relative; width: 58px; height: 58px; }
.starter-card .line { font-family: var(--hand); font-size: 23px; line-height: 1.1; color: var(--navy); }

/* ---------- Connect Four ---------- */
.c4 { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 0; }
.turnbar { width: 100%; display: flex; gap: 10px; }
.turn-chip {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 6px;
  font-weight: 800; font-size: 15px; color: var(--ink);
  box-shadow: 0 1px 1px rgba(16, 26, 46, .25), 0 10px 16px -10px rgba(16, 26, 46, .55);
  opacity: .72; transform: rotate(.8deg);
  transition: opacity .3s, box-shadow .3s, transform .3s var(--ease-spring);
}
.turn-chip:first-child { transform: rotate(-1deg); }
.turn-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-chip.active { opacity: 1; box-shadow: inset 0 -4px 0 var(--ochre), 0 1px 1px rgba(16, 26, 46, .25), 0 14px 20px -10px rgba(16, 26, 46, .6); transform: rotate(0) translateY(-2px); }
.turn-chip .mini { position: relative; width: 22px; height: 22px; flex: none; }
/* a disc is watercolour on paper: the painting multiplies over a paper layer */
.disc, .mini {
  border-radius: 50%;
  background-color: var(--paper);
  background-size: 100% 100%, 160px;
  background-blend-mode: multiply;
}
.disc.red, .mini.red { background-image: url(/art/disc-red.png), var(--t-paper); }
.disc.yellow, .mini.yellow { background-image: url(/art/disc-yellow.png), var(--t-paper); }
.disc { position: absolute; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .14); }
.disc.ghost { opacity: .92; box-shadow: 0 8px 12px -4px rgba(16, 26, 46, .6); transition: left .12s var(--ease-out); }
.disc.ghost.partner { opacity: .5; }
.disc.win { animation: winPulse .9s ease-in-out infinite; z-index: 2; }
@keyframes winPulse { 50% { filter: brightness(1.18) drop-shadow(0 0 8px rgba(255, 236, 190, .9)); } }
.c4-wrap { position: relative; touch-action: none; margin: auto 0; }
.c4-aim { position: relative; }
.c4-board { position: relative; }
.c4-back {
  position: absolute; inset: var(--pad);
  background-color: #4a6380; background-image: var(--t-linen); background-size: 220px; background-blend-mode: multiply;
  box-shadow: inset 0 0 30px rgba(10, 20, 40, .55);
}
.c4-discs { position: absolute; inset: 0; }
.c4-front {
  position: absolute; inset: 0;
  padding: var(--pad);
  border-radius: calc(var(--pad) * 1.4);
  background-color: #2c4a75; background-image: var(--t-blue); background-size: 420px;
  -webkit-mask-image: radial-gradient(circle at calc(var(--cell) / 2) calc(var(--cell) / 2), #000 var(--hole), transparent calc(var(--hole) + 1px)), linear-gradient(#000, #000);
  -webkit-mask-size: var(--cell) var(--cell), 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  -webkit-mask-origin: content-box, border-box;
  -webkit-mask-clip: content-box, border-box;
  -webkit-mask-composite: xor;
  mask-image: radial-gradient(circle at calc(var(--cell) / 2) calc(var(--cell) / 2), #000 var(--hole), transparent calc(var(--hole) + 1px)), linear-gradient(#000, #000);
  mask-size: var(--cell) var(--cell), 100% 100%;
  mask-repeat: repeat, no-repeat;
  mask-origin: content-box, border-box;
  mask-clip: content-box, border-box;
  mask-composite: exclude;
  filter: drop-shadow(0 12px 14px rgba(16, 26, 46, .45));
}
.c4-rims {
  position: absolute; inset: var(--pad); pointer-events: none;
  background: radial-gradient(circle at calc(var(--cell) / 2) calc(var(--cell) / 2), transparent calc(var(--hole) - 1px), rgba(8, 20, 44, .55) var(--hole), rgba(8, 20, 44, 0) calc(var(--hole) + 3px)) 0 0 / var(--cell) var(--cell);
}
.c4-edge { position: absolute; inset: 0; border-radius: calc(var(--pad) * 1.4); pointer-events: none; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .22), inset 0 -4px 0 rgba(10, 20, 40, .35); }
.c4-feet { display: flex; justify-content: space-between; padding: 0 12px; }
.c4-feet i { width: 20%; height: 14px; border-radius: 0 0 10px 10px; display: block; background-color: #1f3657; background-image: var(--t-blue); background-size: 300px; background-blend-mode: multiply; box-shadow: 0 8px 10px -4px rgba(10, 20, 40, .6); }
.c4-status { min-height: 1.1em; }
.end-area { width: 100%; min-height: 56px; display: flex; align-items: flex-end; }

/* ---------- Battleships ---------- */
.bs { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; align-items: center; }
.seg { display: flex; gap: 6px; align-self: stretch; padding-left: 12px; margin-bottom: -1px; position: relative; z-index: 2; }
.seg button {
  height: 40px; padding: 0 16px; border-radius: 12px 12px 0 0;
  font-weight: 800; font-size: 15px; color: #2c3a52;
  background-color: #a7b6c6; background-image: var(--t-paper); background-size: 300px; background-blend-mode: multiply;
  margin-top: 4px; transition: margin .2s, height .2s, background-color .2s;
  display: flex; align-items: center; gap: 6px;
}
.seg button.on { background-color: var(--paper); color: var(--ink); height: 44px; margin-top: 0; }
.grid-wrap {
  position: relative; touch-action: none;
  background-color: var(--paper); background-image: var(--t-paper); background-size: 380px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), var(--lift);
}
.bs-grid {
  position: relative; display: grid;
  border-radius: 3px;
  background-color: #9fbccc; background-image: linear-gradient(rgba(226, 236, 238, .32), rgba(226, 236, 238, .32)), var(--t-sea); background-size: auto, 520px;
  box-shadow: inset 0 0 0 1.5px var(--sea-ink), inset 0 0 24px rgba(24, 44, 72, .25);
  overflow: hidden;
}
.bs-grid .cell { position: relative; border-right: 1px solid rgba(24, 44, 72, .26); border-bottom: 1px solid rgba(24, 44, 72, .26); }
.axis { position: absolute; display: grid; font-weight: 800; font-size: 11px; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.axis span { display: grid; place-items: center; }
.ship {
  position: absolute; z-index: 1;
  border-radius: 999px;
  background-color: #8f9a95; background-image: var(--t-hull); background-size: 180px;
  box-shadow: inset 0 0 0 1.5px rgba(24, 32, 40, .65), inset 0 3px 0 rgba(255, 255, 255, .25), 0 4px 6px -2px rgba(16, 26, 46, .5);
  transition: left .18s var(--ease-out), top .18s var(--ease-out), width .2s var(--ease-out), height .2s var(--ease-out), opacity .2s;
}
.ship::after { content: ""; position: absolute; inset: 30% 16%; border-radius: 999px; border: 1.5px solid rgba(24, 32, 40, .4); background: rgba(255, 255, 255, .12); }
.ship.v::after { inset: 16% 30%; }
.ship.sel { box-shadow: inset 0 0 0 1.5px rgba(24, 32, 40, .65), 0 0 0 3px var(--ochre), 0 6px 10px -2px rgba(16, 26, 46, .5); }
.ship.bad { background-color: #d48a78; background-blend-mode: multiply; }
.ship.dragging { z-index: 60; transition: none; opacity: .94; box-shadow: inset 0 0 0 1.5px rgba(24, 32, 40, .65), 0 14px 18px -6px rgba(16, 26, 46, .6); }
.ship.enemy { background: rgba(44, 30, 30, .55); box-shadow: inset 0 0 0 2px var(--poppy); }
.ship.enemy::after { display: none; }
.ship.ghosted { opacity: .55; }
.ship.sunk { filter: grayscale(.5) brightness(.6); }
.ship.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { translate: -4px 0; } 40%, 80% { translate: 4px 0; } }
.peg { position: absolute; border-radius: 50%; z-index: 3; pointer-events: none; }
.peg.flag { border-radius: 0; transform-origin: 25% 93%; filter: drop-shadow(0 1px 1px rgba(16, 26, 46, .3)); }
.peg.flag svg { display: block; overflow: visible; }
.peg.hit .flame {
  position: absolute; left: 15%; bottom: 35%; width: 70%; height: 115%;
  border-radius: 50% 50% 45% 45% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 78%, #fff3b0 0 16%, #ffc24a 34%, #ef6a32 60%, rgba(214, 58, 32, 0) 74%);
  transform-origin: 50% 100%; animation: flicker .7s ease-in-out infinite alternate;
}
.peg.hit .smoke {
  position: absolute; left: -30%; top: -40%; width: 160%; height: 160%; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(62, 64, 70, .72) 0, rgba(62, 64, 70, .38) 42%, rgba(70, 72, 78, 0) 70%);
  animation: smoke 2.7s ease-out infinite;
}
@keyframes flicker {
  0% { transform: scale(1, 1) rotate(-4deg); }
  50% { transform: scale(.9, 1.14) rotate(3deg); }
  100% { transform: scale(1.06, .92) rotate(-1deg); }
}
@keyframes smoke {
  0% { transform: translate(0, 0) scale(.35); opacity: 0; }
  15% { opacity: .9; }
  100% { transform: translate(var(--drift, 0px), calc(var(--cell, 36px) * -1.5)) scale(1.9); opacity: 0; }
}
.peg.hit { background: var(--poppy); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25), inset 0 2px 0 rgba(255, 200, 170, .5), 0 0 0 1.5px rgba(80, 20, 10, .6), 0 0 12px rgba(239, 110, 60, .65); }
.fx { position: absolute; pointer-events: none; z-index: 7; border-radius: 50%; }
.reticle { position: absolute; z-index: 5; pointer-events: none; border-radius: 6px; box-shadow: 0 0 0 3px var(--ochre), 0 0 16px rgba(226, 168, 60, .75); animation: retPulse 1s ease-in-out infinite; }
.reticle.partner { box-shadow: 0 0 0 3px #ff9a7a, 0 0 16px rgba(255, 120, 90, .55); }
.reticle::before, .reticle::after { content: ""; position: absolute; background: var(--ochre); }
.reticle::before { left: 50%; top: 18%; bottom: 18%; width: 2px; transform: translateX(-50%); }
.reticle::after { top: 50%; left: 18%; right: 18%; height: 2px; transform: translateY(-50%); }
.reticle.partner::before, .reticle.partner::after { background: #ff9a7a; }
@keyframes retPulse { 50% { transform: scale(.88); } }
.bs-status { width: 100%; }
.fleet-track { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: -2px; }
.fleet-track .who { font: 800 10px var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--cream-dim); }
.fleet-track .ships { display: flex; flex-wrap: wrap; justify-content: center; row-gap: 8px; width: 100%; max-width: 360px; }
.fleet-track .ship-tag { flex: 0 0 33.33%; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--hand); font-size: 19px; line-height: 1; color: var(--cream); }
.fleet-track .len { display: flex; gap: 2px; }
.fleet-track .len i { width: 7px; height: 7px; border-radius: 1px; background: rgba(245, 239, 227, .75); }
.fleet-track .ship-tag.sunk { color: #ffc1b0; opacity: .8; }
.fleet-track .ship-tag.sunk b { text-decoration: line-through; text-decoration-thickness: 2px; }
.fleet-track .ship-tag.sunk .len i { background: var(--poppy); }
.fleet-track .ship-tag b { font-weight: 700; }
.dock {
  width: 100%;
  display: flex; flex-wrap: wrap; gap: 12px 16px; justify-content: center; align-items: flex-end;
  min-height: 60px; padding: 12px 14px;
  position: relative; touch-action: none;
}
.dock .ship { position: relative; flex: none; transition: transform .2s var(--ease-spring); }
.dock .ship.sel { transform: translateY(-3px); }
.dock .slip { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.dock .slip span { font-family: var(--hand); font-size: 18px; line-height: 1; color: var(--ink); }
.dock-empty { font-family: var(--hand); font-size: 20px; color: var(--ink-soft); }
.place-tools { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tool {
  min-height: 46px; border-radius: 12px; font-weight: 800; font-size: 14px; color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 2px 0 rgba(16, 26, 46, .25), 0 8px 14px -8px rgba(16, 26, 46, .5);
}
.tool:active { transform: scale(.96); }
.tool[disabled] { opacity: .5; pointer-events: none; }
.tool svg { width: 18px; height: 18px; }
.bs-bottom { width: 100%; margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Hues ---------- */
/* Cards are watercolour paper with a painted panel (art/hue-*.png multiplied over the paper);
   numbers and symbols sit on the paint in paper-white. */
.hu { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 0; padding-top: 4px; --cw: 66px; --ch: 94px; }
.hu .turnbar { margin-bottom: 14px; }
.turn-chip b { margin-left: auto; font-family: var(--hand); font-size: 22px; line-height: 1; color: var(--navy); }
.hcard {
  position: relative; flex: none; width: var(--cw); height: var(--ch); border-radius: 7px;
  background-color: var(--paper); background-image: url(/art/hue-navy.png), var(--t-paper);
  background-size: 100% 100%, 300px; background-blend-mode: multiply;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), 0 1px 1px rgba(16, 26, 46, .3), 0 8px 14px -8px rgba(16, 26, 46, .7);
  color: #fbf6ec; font-family: var(--display);
  display: grid; place-items: center;
}
.hcard.lavender { background-image: url(/art/hue-lavender.png), var(--t-paper); }
.hcard.orange { background-image: url(/art/hue-orange.png), var(--t-paper); }
.hcard.sage { background-image: url(/art/hue-sage.png), var(--t-paper); }
.hcard.wild { background-image: url(/art/hue-wild.png), var(--t-paper); }
.hcard.back { background-image: url(/art/hue-back.png), var(--t-paper); }
.hcard .v { font-weight: 400; font-size: calc(var(--cw) * .5); line-height: 1; text-shadow: 0 0 2px rgba(20, 28, 48, .7), 0 2px 0 rgba(20, 28, 48, .35); }
.hcard .sym { display: block; width: 52%; filter: drop-shadow(0 1px 1px rgba(20, 28, 48, .6)); }
.hcard .sym svg { display: block; width: 100%; height: auto; }
.hcard.wild .sym, .hcard.wild .v { color: var(--ink); filter: none; text-shadow: 0 0 3px rgba(251, 246, 236, .9); }
.hcard .ix { position: absolute; top: 5px; left: 7px; font-size: 13px; line-height: 1; text-shadow: 0 0 2px rgba(20, 28, 48, .7); }
.hcard .ix.end { top: auto; left: auto; bottom: 5px; right: 7px; rotate: 180deg; }
.hcard:not(.k-n) .ix.end { display: none; } /* the name label sits there */
.hcard.wild .ix { color: var(--ink); text-shadow: none; }
.hcard .nm { position: absolute; bottom: 7px; left: 0; right: 0; text-align: center; font: 800 8.5px var(--body); letter-spacing: .14em; text-transform: uppercase; text-shadow: 0 0 2px rgba(20, 28, 48, .8); }
.hcard.wild .nm { color: var(--ink); text-shadow: 0 0 2px rgba(251, 246, 236, .9); }

.hu-their { position: relative; flex: none; height: calc(var(--ch) * .62 + 4px); max-width: 100%; }
.hu-their .hcard { position: absolute; top: 0; width: calc(var(--cw) * .62); height: calc(var(--ch) * .62); border-radius: 5px; }

.hu-table { flex: none; display: flex; align-items: center; justify-content: center; gap: 22px; padding: 22px 0 8px; margin-top: auto; }
.hu-deck { position: relative; width: var(--cw); height: var(--ch); }
.hu-deck .hcard { position: absolute; inset: 0; }
.hu-deck .hcard:first-child { translate: 3px 3px; rotate: 2deg; }
.hu-deck .hcard:nth-child(2) { rotate: -1.5deg; }
.hu-deck:active .hcard:nth-child(2) { translate: 0 -4px; }
.hu-deck.empty .hcard { opacity: .35; }
.hu-left { position: absolute; left: 0; right: 0; bottom: -24px; text-align: center; font: 700 18px var(--hand); color: var(--cream); text-shadow: var(--cloth-shadow); }
.hu-pile { position: relative; width: var(--cw); height: var(--ch); scale: 1.12; }
.hu-pile .hcard { position: absolute; inset: 0; }
.hu-side { width: 74px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hu-swatch { display: flex; flex-direction: column; align-items: center; gap: 0; }
.hu-swatch i { width: 46px; height: 46px; border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%; background-color: var(--paper); background-image: url(/art/hue-navy.png), var(--t-paper); background-size: 180% 180%, 200px; background-position: center; background-blend-mode: multiply; box-shadow: 0 6px 12px -6px rgba(16, 26, 46, .7); rotate: -8deg; }
.hu-swatch.lavender i { background-image: url(/art/hue-lavender.png), var(--t-paper); }
.hu-swatch.orange i { background-image: url(/art/hue-orange.png), var(--t-paper); }
.hu-swatch.sage i { background-image: url(/art/hue-sage.png), var(--t-paper); }
.hu-swatch span { font: 700 20px var(--hand); color: var(--cream); text-shadow: var(--cloth-shadow); }
.hu-pen { font: 700 34px/1 var(--hand); color: #fbf3e6; background: var(--poppy); padding: 2px 10px 4px; border-radius: 4px; rotate: -4deg; box-shadow: 0 6px 12px -6px rgba(80, 20, 10, .7); }
.hu-status { flex: none; width: 100%; margin-top: 22px; }
/* thumb row: Hues! · draw / pick up / keep / pass · Call out, with the hand under it at the bottom */
.hu-btns { flex: none; width: 100%; margin-top: auto; display: flex; gap: 8px; }
.hu-act { flex: 1; min-height: 50px; padding: 0 10px; }
.hu-call { flex: none; width: 92px; min-height: 50px; padding: 0 6px; font-size: 15px; }
.hu-call.btn-primary { font-family: var(--display); font-weight: 400; font-size: 19px; letter-spacing: .02em; rotate: -2deg; }
.hu-call.btn-ghost { rotate: 1.5deg; }
.hu-call[disabled] { opacity: .45; }
.hu-hand { position: relative; flex: none; width: 100%; touch-action: none; }
.hu-hand .hcard { position: absolute; transition: translate .16s var(--ease-out); }
.hu-hand .hcard.sel { translate: 0 -16px; box-shadow: 0 0 0 3px var(--ochre), 0 14px 20px -10px rgba(16, 26, 46, .8); }
.hu-order { position: absolute; top: -10px; left: -6px; width: 24px; height: 24px; border-radius: 3px; rotate: 6deg; display: grid; place-items: center; font: 800 13px var(--body); color: var(--ink); background: var(--ochre); box-shadow: 0 2px 4px rgba(16, 26, 46, .4); }
.hu-hand .hcard.dragging { z-index: 999 !important; transition: none; box-shadow: 0 0 0 3px var(--ochre), 0 24px 30px -12px rgba(16, 26, 46, .8); }
.hu .end-area { flex: none; }

.hue-pots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hue-pot { min-height: 64px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; box-shadow: inset 0 0 0 2px rgba(35, 46, 70, .2); font: 700 24px var(--hand); color: var(--ink); }
.hue-pot:active { transform: scale(.97); }
.hue-pot i { width: 42px; height: 42px; flex: none; border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%; background-size: 180% 180%; background-position: center; mix-blend-mode: multiply; }
.hue-pot.lavender i { background-image: url(/art/hue-lavender.png); }
.hue-pot.orange i { background-image: url(/art/hue-orange.png); }
.hue-pot.navy i { background-image: url(/art/hue-navy.png); }
.hue-pot.sage i { background-image: url(/art/hue-sage.png); }

.table-history { position: relative; width: 100%; padding: 22px 18px; margin: 12px 0; rotate: -.4deg; }
.table-history .tape { top: -11px; right: 24px; }
.table-history h2 { margin: 0; font-size: 23px; }
.table-history-list { display: grid; gap: 12px; color: var(--ink); }
.table-history-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid rgba(35,46,70,.2); }
.table-history-row > div { display: grid; gap: 3px; }
.table-history-row b { font-size: 15px; overflow-wrap: anywhere; }
.table-history-row .script { color: var(--navy); font-size: 26px; letter-spacing: .13em; }
.table-history-row small { color: var(--ink-soft); }
.table-history-row .btn { min-height: 44px; padding: 8px 14px; align-self: center; }
.history-remove { min-height: 44px; grid-column: 1/-1; justify-self: start; text-decoration: underline; color: var(--ink-soft); font-size: 13px; }

/* Hues rules are chosen once, by the RPS winner, on the same taped paper. */
.hu-rules-wrap { flex: 1; min-height: 0; overflow: auto; padding: 14px 2px; }
.hu-rules-card { position: relative; padding: 24px 18px; margin: 6px auto; max-width: 540px; rotate: -.5deg; }
.hu-rules-card .tape { top: -11px; left: 40%; }
.hu-rules-card h1 { margin: 8px 0; }
.hu-rules-card .hand-note { color: var(--navy); }
.hu-rules-table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 16px 0; table-layout: fixed; }
.hu-rules-table th, .hu-rules-table td { text-align: left; vertical-align: top; padding: 10px 6px; border-bottom: 1px solid rgba(35,46,70,.2); overflow-wrap: anywhere; }
.hu-rules-table thead { color: var(--poppy-deep); }
.hu-rules-table tbody th { width: 30%; }
.hu-rule-badge { margin: -18px 0 0; font-size: 19px; }
.hu-shuffle { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 74px; min-height: 52px; padding: 6px 4px; margin-top: 4px; border: 1px solid rgba(243,234,216,.6); font-weight: 800; font-size: 11px; color: var(--cream); }
.hu-shuffle small { font: 700 17px var(--hand); }
.hu-shuffle:disabled { opacity: .45; }
.hu-catch-countdown { flex: none; color: var(--cream); font-size: 23px; min-height: 28px; }
.hu-colour-picker { flex: none; width: 100%; padding: 10px 12px 6px; rotate: -.4deg; }
.hu-colour-picker > .script { color: var(--navy); font-size: 22px; }
.hu-colour-picker .hue-pots { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; margin-top: 6px; }
.hu-colour-picker .hue-pot { flex-direction: column; justify-content: center; gap: 3px; padding: 8px 3px; min-height: 64px; font: 700 16px var(--hand); border-radius: 5px; }
.hu-colour-picker .hue-pot i { width: 28px; height: 28px; }
.hu-colour-cancel { color: var(--ink-soft); min-height: 44px; width: 100%; font-size: 13px; text-decoration: underline; }
.hu.choosing-colour .hu-table { padding-top: 8px; }
.hu.choosing-colour .hu-status { margin-top: 4px; }
.hu.choosing-colour .hu-btns { display: none; }
.hu.choosing-colour .hu-hand { pointer-events: none; }
.hu-rules-card .muted, .table-history .muted { color: var(--ink-soft); }

/* ---------- Quickfire: letter tiles and a sum on a taped card, a paper keypad ---------- */
.gbox.qf { rotate: .8deg; }
.qf { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 560px; margin: 0 auto; padding-top: 4px; }
.qf-sb { flex: none; }
.qf-sb .sb-side > b { font: 700 34px/1 var(--hand); color: var(--navy); }
.qf-card { position: relative; flex: none; display: flex; flex-direction: column; gap: 12px; padding: 18px 14px 16px; rotate: -.6deg; color: var(--ink); }
.qf-card > .tape { top: -11px; left: 42%; }
.qf-head { display: flex; justify-content: space-between; align-items: baseline; min-height: 26px; }
.qf-clock { font-size: 24px; color: var(--navy); font-variant-numeric: tabular-nums; }
.qf-entry { position: relative; }
/* the real input lies invisibly over the tiles, as in the code entry: tapping the tiles types */
.qf-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; background: none; font-size: 16px; color: transparent; caret-color: transparent; text-transform: uppercase; }
.qf-tap { position: absolute; left: 0; right: 0; bottom: -6px; text-align: center; font: 700 18px var(--hand); color: var(--poppy); pointer-events: none; }
.qf-rack { gap: 6px; padding: 2px 0 8px; }
.qf-rack .tile { flex: 0 1 56px; width: auto; min-width: 0; }
.qf-rack .tile.fixed { color: var(--poppy-deep); background-color: #f3d79b; }
.qf-rack .tile.back { color: var(--cream); background-color: var(--navy); background-image: var(--t-blue); background-size: cover; font-size: clamp(20px, 7vw, 28px); }
.qf-rack .tile.shown { animation: tileIn .32s var(--ease-spring) both; }
.qf-rack .tile.shown:nth-child(3) { animation-delay: .05s; } .qf-rack .tile.shown:nth-child(4) { animation-delay: .1s; } .qf-rack .tile.shown:nth-child(5) { animation-delay: .15s; }
.qf-sum { display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: .28em; min-height: 64px; font: 400 clamp(36px, 11vw, 50px)/1.15 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.qf-sum .op { color: var(--poppy); }
.qf-sum .ans { min-width: 1.6em; text-align: center; color: var(--navy); border-bottom: 3px solid var(--ochre); }
.qf-sum .ans.empty { color: var(--ink-mute); }
.qf-sum .ans.shown { animation: tileIn .32s var(--ease-spring) both; }
.qf-num { min-width: 1.8em; padding: 0 .14em; text-align: center; border-radius: 7px; box-shadow: inset 0 -2px 0 rgba(120,90,40,.22), 0 2px 0 var(--tile-edge); }
.qf-num.typing { outline: 3px solid var(--ochre); outline-offset: 2px; }
.qf-num.back { color: var(--cream); background-color: var(--navy); background-image: var(--t-blue); background-size: cover; box-shadow: 0 2px 0 var(--navy-deep); }
.qf-card.racing { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), 0 0 0 3px rgba(226, 168, 60, .55), 0 10px 16px -10px rgba(16, 26, 46, .6); }
.qf-result { display: grid; gap: 2px; text-align: center; font-family: var(--hand); color: var(--ink-soft); }
.qf-result b { font: 400 24px/1.1 var(--display); color: var(--ink); }
.qf-result .times { font-size: 22px; color: var(--navy); }
.qf-result .also { font-size: 19px; }
.qf-status { flex: none; }
.qf-status small { font-size: 19px; opacity: .85; }
.qf-actions { display: flex; justify-content: center; gap: 10px; flex: none; }
.qf-actions .btn { flex: 0 1 260px; }
.qf-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: auto; flex: none; touch-action: manipulation; }
.qf-key { min-height: 56px; border-radius: 8px; font: 400 28px/1 var(--display); color: var(--ink); box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -3px 0 rgba(120,90,40,.22), 0 2px 0 var(--tile-edge), 0 4px 8px rgba(16,26,46,.3); -webkit-user-select: none; user-select: none; }
.qf-key:active { transform: translateY(2px); box-shadow: inset 0 -1px 0 rgba(120,90,40,.22), 0 1px 0 var(--tile-edge); }
.qf-key.del { font: 700 24px var(--body); color: var(--ink-soft); }
.qf-key[disabled] { opacity: .5; pointer-events: none; }
.qf-key.ok { font: 800 18px var(--body); color: #fbf3e6; background-color: var(--poppy); background-image: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 2px 0 var(--poppy-deep); }
/* the keyboard is up: give it the room, keep the tiles, clock and status above it */
body.kb-open #app { height: var(--vvh, 100%); }
body.kb-open .qf { gap: 6px; }
body.kb-open .qf-sb { padding-block: 4px; }
body.kb-open .qf-sb .sb-side > b { font-size: 26px; }
body.kb-open .qf-card { padding-block: 12px 10px; gap: 8px; }
@media (max-height: 560px) { .qf-sb .sb-side > b { font-size: 26px; } .qf-card { padding-block: 12px 10px; gap: 8px; } .qf-key { min-height: 46px; } }

.qf-setup-wrap { flex: 1; min-height: 0; overflow: auto; padding: 14px 2px; }
.qf-setup { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 24px 18px; margin: 6px auto; max-width: 540px; rotate: -.5deg; color: var(--ink); }
.qf-setup > .tape { top: -11px; left: 40%; }
.qf-setup h1 { margin: 4px 0; }
.qf-setup .hand-note { color: var(--navy); text-shadow: none; }
.qf-setup h3 { margin: 8px 0 0; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-mute); }
.qf-opts { display: grid; gap: 8px; }
.qf-opts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qf-opts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.qf-opt { display: grid; place-content: center; gap: 2px; min-height: 56px; padding: 8px 4px; border-radius: 7px; text-align: center; color: var(--ink); box-shadow: inset 0 -3px 0 rgba(120,90,40,.2), 0 2px 0 var(--tile-edge); }
.qf-opt b { font: 400 19px/1.1 var(--display); }
.qf-opt small { font: 700 16px/1.1 var(--hand); color: var(--ink-soft); }
.qf-opt.on { color: #fbf3e6; background-color: var(--navy); background-image: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 2px 0 var(--navy-deep); }
.qf-opt.on small { color: var(--cream); }
.qf-go { margin-top: 10px; }

/* ---------- Word Wheel: the newspaper puzzle inked on a paper disc, swiped with a red pencil ---------- */
.gbox.ww { rotate: -.7deg; }
.ww { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 560px; margin: 0 auto; padding-top: 4px; }
.ww-sb { flex: none; }
.ww-sb .ww-pts > b { font: 700 34px/1 var(--hand); color: var(--navy); }
.ww-pts { display: flex; align-items: baseline; gap: 5px; }
.ww-extra { font: 700 20px/1 var(--hand); color: var(--ink-mute); }
.ww-extra:empty { display: none; }
.ww-word { flex: none; gap: 4px; min-height: 52px; align-items: center; padding: 2px 0; }
.ww-word .tile { width: clamp(28px, 9vw, 38px); min-height: 0; aspect-ratio: 58 / 62; font-size: clamp(19px, 6vw, 25px); border-radius: 6px; animation: tileIn .2s var(--ease-spring) both; }
.ww-word .tile.wrong { color: var(--poppy-deep); background-color: #ecc9b8; animation: none; }
.ww-word .tile.shown { color: var(--navy); }
.ww-word .tile.clue { color: var(--ink); background-color: #f1dcaa; }
.ww-word .tile.clue.blank { background: transparent; box-shadow: none; border: 2px dashed rgba(244, 236, 220, .55); }
.ww-word .tile.shown:nth-child(2) { animation-delay: .04s; } .ww-word .tile.shown:nth-child(3) { animation-delay: .08s; } .ww-word .tile.shown:nth-child(4) { animation-delay: .12s; } .ww-word .tile.shown:nth-child(5) { animation-delay: .16s; } .ww-word .tile.shown:nth-child(6) { animation-delay: .2s; } .ww-word .tile.shown:nth-child(7) { animation-delay: .24s; } .ww-word .tile.shown:nth-child(8) { animation-delay: .28s; } .ww-word .tile.shown:nth-child(9) { animation-delay: .32s; }
.ww-hint { font: 700 22px var(--hand); color: var(--cream); text-shadow: var(--cloth-shadow); }

.ww-stage { position: relative; flex: none; display: grid; place-items: center; }
.ww-wheel {
  position: relative; width: clamp(264px, min(84vw, 34dvh), 320px); aspect-ratio: 1; /* 264: letters stay ≥ 44 px */ border-radius: 50%;
  container-type: inline-size; touch-action: none; rotate: -1deg;
  background-color: var(--paper); background-image: var(--t-paper); background-size: 420px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), inset 0 0 22px rgba(120, 90, 40, .18), var(--lift);
}
.ww-lines, .ww-trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ww-lines { fill: none; stroke: var(--ink); stroke-width: .9; stroke-linecap: round; opacity: .85; }
.ww-lines .hub { fill: rgba(226, 168, 60, .3); }
.ww-trail polyline { fill: none; stroke: var(--poppy); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; opacity: .6; mix-blend-mode: multiply; }
.ww-l {
  position: absolute; translate: -50% -50%; display: grid; place-items: center;
  width: 17cqw; height: 17cqw; border-radius: 50%; pointer-events: none;
  font: 400 12.5cqw/1 var(--display); color: var(--ink);
  transition: left .35s var(--ease-out), top .35s var(--ease-out), color .12s;
}
.ww-l::before { content: ''; position: absolute; inset: 4%; z-index: -1; border-radius: 47% 53% 50% 50%; background: var(--ochre); opacity: 0; scale: .5; mix-blend-mode: multiply; transition: opacity .12s, scale .18s var(--ease-spring); }
.ww-l.on { color: var(--poppy-deep); }
.ww-l.on::before { opacity: .55; scale: 1; }
/* the tools round the wheel, paper tiles in its corners: give up top left, hint bottom left, shuffle bottom right */
.ww-tool { position: absolute; width: 46px; height: 46px; background: var(--paper); background-image: var(--t-paper); background-size: 300px; color: var(--ink); box-shadow: 0 2px 0 var(--tile-edge), 0 4px 8px rgba(16, 26, 46, .3); }
.ww-tool[disabled] { opacity: .5; }
.ww-shuffle { right: max(0px, calc(50% - 50vw + 10px)); bottom: 0; rotate: 4deg; }
.ww-give { left: max(0px, calc(50% - 50vw + 10px)); top: 0; rotate: -3deg; color: var(--ink-soft); }
.ww-clue { left: max(0px, calc(50% - 50vw + 10px)); bottom: 0; rotate: -4deg; }
.ww-clue.locked svg { opacity: .45; }
/* hints left, pencilled on the corner */
.ww-clue::after { content: attr(data-left); position: absolute; top: -9px; right: -7px; font: 700 20px/1 var(--hand); color: var(--poppy-deep); rotate: 8deg; }
.ww-status { flex: none; }

/* tall enough for five words a side without scrolling */
.ww-found { position: relative; flex: 1 0 auto; min-height: 146px; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 0 14px; padding: 12px 16px 10px; rotate: .5deg; }
.ww-found > .tape { top: -11px; left: 44%; }
.ww-col h3 { margin: 0 0 2px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-mute); }
.ww-list { margin: 0; padding: 0; list-style: none; font: 700 19px/1.1 var(--hand); color: var(--navy); overflow-wrap: anywhere; }
.ww-col + .ww-col .ww-list { color: var(--poppy-deep); }
.ww-list li.new { animation: tileIn .32s var(--ease-spring) both; }
.ww-list li.sending { opacity: .45; }
.ww-list li.extra { opacity: .72; }
.ww-list li.extra::before { content: '+'; margin-right: 2px; }
.ww-done { width: 100%; min-height: 44px; padding-block: 7px; }
/* the partner's words while the race is on: one inked star a letter */
.ww-list li.hidden { display: flex; align-items: center; gap: 2px; height: 1.12em; }
.ww-list li.hidden i { width: 11px; height: 11px; background: currentColor; opacity: .8; clip-path: polygon(50% 0, 62% 35%, 100% 38%, 70% 61%, 80% 100%, 50% 77%, 20% 100%, 30% 61%, 0 38%, 38% 35%); rotate: -8deg; }
.ww-list li.hidden i:nth-child(even) { rotate: 7deg; scale: .92; }
.ww-left { grid-column: 1 / -1; margin: 8px 0 0; font: 700 18px/1.15 var(--hand); color: var(--ink-soft); }
.ww .end-area { flex: none; min-height: 0; }
@media (max-height: 760px) { .ww { gap: 6px; } .ww-sb { padding-block: 7px; } .ww-sb .ww-pts > b { font-size: 30px; } .ww-word { min-height: 46px; } }
@media (max-height: 640px) { .ww { gap: 5px; } .ww-sb { padding-block: 5px; } .ww-sb .ww-pts > b { font-size: 26px; } .ww-word { min-height: 42px; } }

/* ================= Word Slam: letter cards on cream paper ================= */
.gbox.sl { rotate: 1deg; }
.sl-game {
  --sl-card-height: clamp(60px, 10svh, 80px);
  --sl-word-height: clamp(72px, 12svh, 100px);
  width: min(100%, 500px); margin: 0 auto; padding: 0 2px 4px;
  display: flex; flex-direction: column; gap: clamp(4px, 1svh, 9px);
}
.sl-sb { padding: 6px 12px; background-color: var(--paper-cream); background-blend-mode: luminosity; }
.sl-sb .sb-side { gap: 0; }
.sl-sb .sb-name { font-size: 12px; }
.sl-sb .sb-side > b { font-size: 29px; line-height: 1; color: var(--navy); }
.sl-sb .sb-side.right > b { color: var(--poppy-deep); }
.sl-sb .sb-mid { font-size: 20px; }
.sl-sb .sb-mid small { font-size: 14px; }
.sl-status { flex: none; text-align: center; margin: 0; min-height: 42px; font-size: 23px; }
.sl-table { padding: 0 2px 8px; }
.sl-caption { font: 700 11px var(--body); letter-spacing: .02em; color: var(--cream); text-align: center; margin: 0 0 7px; }
.sl-word { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.sl-letter, .sl-card { border: 1px solid rgba(61, 48, 28, .28); color: var(--ink); border-radius: 6px 8px 5px 7px; font-family: var(--display); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sl-letter { min-height: 48px; font-size: clamp(32px, 8vw, 46px); box-shadow: 0 3px 0 #b8a98b, 0 5px 8px rgba(22, 35, 49, .18); padding: 5px; transition: transform .13s, outline-color .13s; }
.sl-word .sl-letter { height: var(--sl-word-height); background-color: var(--paper-beige); background-blend-mode: luminosity; color: var(--poppy-deep); }
.sl-word .sl-letter:nth-child(even) { background-color: var(--paper-cream); color: var(--navy); }
.sl-letter:nth-child(odd) { rotate: -.8deg; }
.sl-letter:nth-child(even) { rotate: .9deg; }
.sl-letter:disabled, .sl-card:disabled { opacity: 1; cursor: default; }

.sl-letter.drop-target { outline: 4px solid var(--ochre); transform: translateY(-5px); color: var(--poppy); }
.sl-choice { width: 112px; height: 44px; flex: none; }
.sl-flip { width: 112px; margin: 0; padding: 8px 10px; min-height: 44px; border-radius: 8px; font-size: 14px; }
.sl-rack {
  position: relative; padding: 12px;
  background-color: var(--paper-cream);
  background-image: var(--t-paper); background-size: 560px;
  background-blend-mode: luminosity;
}
.sl-rack > .tape { top: -6px; left: 14px; width: 62px; height: 15px; }
.sl-rack-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.sl-rack h3 { font: 800 16px/1.2 var(--body); margin: 0; color: var(--ink); }
.sl-instruction { color: var(--ink-soft); text-align: left; margin: 4px 0 12px; font: 600 12px/1.35 var(--body); }
.sl-hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 9px; touch-action: none; }
.sl-card { position: relative; min-width: 44px; height: var(--sl-card-height, 76px); padding: 0; touch-action: none; background-color: #fcf3d5; background-blend-mode: multiply; box-shadow: 0 2px 0 #b8a98b; transition: transform .15s, outline-color .15s; }
.sl-card b { font-size: 30px; font-weight: 400; display: block; margin-top: -7px; }
.sl-card small { position: absolute; right: 4px; bottom: 3px; padding: 0 3px; border-radius: 3px; background: rgba(255,248,216,.8); font: 800 12px var(--body); color: var(--poppy-deep); }
.sl-card:nth-child(3n) { rotate: 1deg; background-color: #e2eadb; color: #355b47; }
.sl-card:nth-child(3n + 1) { rotate: -1deg; background-color: #dce8ee; color: var(--navy); }
.sl-card:nth-child(3n + 2) { color: var(--poppy-deep); }
.sl-card.selected { outline: 3px solid var(--poppy); outline-offset: 1px; transform: translateY(-5px); }
.sl-card.dragging { opacity: .32; }
.sl-card:focus-visible, .sl-letter:focus-visible { outline: 3px solid var(--ochre); outline-offset: 3px; }
.sl-ghost { position: fixed; z-index: 120; width: 65px; height: 78px; pointer-events: none; transform: translate(-50%, -50%) rotate(-7deg); box-shadow: var(--lift); }
.sl-footer { display: flex; align-items: center; gap: 12px; min-height: 53px; margin-top: 12px; padding-top: 8px; border-top: 1px solid rgba(76,90,114,.22); }
.sl-pass { width: 112px; flex: none; margin: 0; padding: 8px 10px; min-height: 44px; border-radius: 8px; font-size: 14px; }
.sl-history { min-width: 0; flex: 1; color: var(--ink-soft); text-align: left; font: 700 13px/1.3 var(--body); }
.sl-trail { display: flex; flex-wrap: nowrap; gap: 8px; list-style: none; padding: 0; margin: 5px 0 0; font: 800 14px/1.3 var(--body); color: var(--ink); overflow: hidden; }
.sl-trail li { flex: none; border-bottom: 2px solid var(--poppy); padding-bottom: 2px; }
.sl-trail li.mine { border-color: var(--navy); }
.sl-game .end-area:empty { display: none; }
.sl-game .end-area .btn { min-height: 44px; padding-block: 7px; }
.sl-alphabet { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 8px 0; }
.sl-alphabet .sl-letter { min-height: 48px; font-size: 25px; background-color: #f7e5a6; background-blend-mode: multiply; }
@media (max-width: 359px) {
  .sl-hand { gap: 9px 7px; }
  .sl-rack { padding-inline: 9px; }
  .sl-alphabet { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .sl-footer { gap: 8px; }
  .sl-pass { padding-inline: 10px; }
  .sl-trail { gap: 6px; font-size: 13px; }
}
@media (max-height: 700px) {
  .sl-game { gap: 4px; }
  .sl-sb { padding-block: 4px; }
  .sl-sb .sb-side > b { font-size: 25px; }
  .sl-status { min-height: 38px; font-size: 21px; }
  .sl-rack { padding-block: 8px 10px; }
  .sl-rack h3 { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { .sl-card, .sl-letter { transition: none; } }

/* The main shelf stays on the table; games and long score lists scroll inside the dresser. */
.shelf-screen .shelf-head, .shelf-screen .shelf-note, .shelf-screen .shelf-foot { flex: none; }
.shelf-screen .dresser { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.shelf-screen .cubby { flex: 1; min-height: 160px; max-height: none; }
.shelf-screen .cornice, .shelf-screen .shelf-board, .shelf-screen .dresser-lower { flex: none; }
.shelf-screen .score-grid { max-height: 182px; overflow-y: auto; overscroll-behavior: contain; }
.shelf-screen .shelf-foot { margin-top: 0; }

@media (max-height: 740px) {
  #bar { padding-block: 8px 4px; }
  .shelf-screen { gap: 8px; }
  .shelf-head .script { font-size: 18px; }
  .shelf-head .h2 { font-size: 28px; }
  .shelf-names .script { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stats-btn { width: 68px; min-height: 60px; padding-top: 8px; font-size: 16px; }
  .stats-btn svg { width: 26px; height: 26px; }
  .shelf-screen .cornice { height: 18px; }
  .shelf-screen .cubby { padding-block: 12px; }
  .shelf-screen .shelf-board { height: 20px; }
  .shelf-screen .dresser-lower { padding: 10px 12px 0; }
  .shelf-screen .score-sheet { padding: 8px 12px; }
  .shelf-screen .score-sheet h3 { font-size: 20px; }
  .shelf-screen .score-grid { max-height: 66px; font-size: 18px; line-height: 22px; }
  .shelf-screen .score-grid .hd { font-size: 16px; }
  .shelf-screen .shelf-note { display: none; }
  .foot-btn { min-height: 48px; padding-block: 6px; font-size: 12px; gap: 3px; }
  .foot-btn i { width: 16px; height: 16px; }
  .bs { gap: 8px; }
  .bs .bs-status { min-height: 42px; font-size: 22px; }
  .bs-bottom { gap: 8px; }
  .bs-bottom .btn { min-height: 48px; }
  .fleet-track { gap: 4px; }
  .fleet-track .ships { row-gap: 6px; }
  .fleet-track .ship-tag { font-size: 17px; }
  .hu { gap: 6px; }
  .hu .turnbar { margin-bottom: 6px; }
  .hu-table { padding-top: 12px; }
  .hu-status { margin-top: 10px; }
  .qf { gap: 6px; }
  .qf-sb { padding-block: 5px; }
  .qf-sb .sb-side > b { font-size: 26px; }
  .qf-card { padding: 10px 12px; gap: 8px; }
  .qf-sum { min-height: 48px; font-size: 36px; }
  .qf-status { min-height: 42px; font-size: 22px; }
  .qf-actions .btn { min-height: 44px; }
  .qf-pad { gap: 6px; }
  .qf-key { min-height: 44px; font-size: 25px; }
  .ww-sb { padding-block: 5px; }
  .ww-status { min-height: 42px; font-size: 22px; }
  .ww-found { flex: 1 1 auto; min-height: 120px; padding: 8px 12px; }
}

@media (max-height: 900px) {
  .landing { padding-top: 14px; gap: 12px; }
  .hero-card { padding: 12px 16px 16px; }
  .hero-card img { height: 90px; object-fit: contain; margin: -4px 0; }
  .hero-card .h1 { font-size: 36px; }
  .hero-card p { font-size: 14px; line-height: 1.35; }
  .form-card { padding: 14px 16px 16px; gap: 12px; }
  .landing .btn { min-height: 48px; }
  .landing .name-tag input { height: 46px; font-size: 32px; }
  .landing > .hand-note { font-size: 20px; }
  .landing .table-history { flex: 1 1 100px; min-height: 80px; padding: 12px; margin: 0; overflow-y: auto; }
  .landing:has(.table-history) .hero-card img, .landing:has(#codeInput) .hero-card img { height: 60px; }
}

.shelf-browse { font: 800 11px/1 var(--body); color: var(--navy-deep); text-shadow: 0 1px rgba(255,255,255,.35); }

/* ================= Sharp Wits: four quick races on paper ================= */
.gbox.sw { rotate: -.9deg; }
.sw { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 560px; margin: 0 auto; padding-top: 4px; }
.sw-sb { flex: none; padding: 7px 14px; }
.sw-sb .sb-side { gap: 2px; }
.sw-sb .sb-side > b { font: 700 32px/1 var(--hand); color: var(--navy); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sw-sb .sb-side.right > b { color: var(--poppy-deep); }
.sw-sb .sb-mid { font-size: 20px; }
.sw-clock { display: block; margin-top: 2px; font-size: 18px; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.sw-clock.pen { animation: swPen 1.3s ease-out; } /* a level game's wrong tap: +1 s */
@keyframes swPen { 0%, 60% { color: var(--poppy); scale: 1.25; } }
.sw-status { flex: none; min-height: 44px; font-size: 23px; }
.sw-table { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sw-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; transition: opacity .25s; }
.sw-table:has(> .sw-cover:not([hidden])) .sw-stage { opacity: .3; }
.sw-cover { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 8px; }
.sw-cover[hidden] { display: none; }
.sw-count, .sw-done { position: relative; display: grid; gap: 4px; justify-items: center; min-width: 200px; max-width: 100%; padding: 22px 24px 18px; text-align: center; color: var(--ink); rotate: -1deg; animation: swPop .3s var(--ease-spring) both; }
.sw-count > .tape, .sw-done > .tape { top: -11px; left: 40%; }
.sw-count b { font-size: 96px; line-height: .9; font-weight: 700; color: var(--poppy); }
.sw-done b { font-size: clamp(24px, 7vw, 30px); line-height: 1.1; }
.sw-done p { margin: 0; font-size: 21px; line-height: 1.15; color: var(--ink-soft); text-wrap: balance; }
.sw-actions { flex: none; display: flex; justify-content: center; }
.sw-actions[hidden] { display: none; }
.sw-giveup { flex: 0 1 200px; min-height: 44px; font-size: 15px; gap: 8px; }
.sw-giveup i { display: block; width: 18px; height: 18px; }
.sw-giveup i svg { display: block; width: 100%; height: 100%; }
.sw .end-area { flex: none; min-height: 0; }
@keyframes swPop { from { scale: .3; opacity: 0; } }
.sw.locked .sw-stage { filter: saturate(.5); }

/* the RPS winner's choice: eight paper options, two by four */
.sw-setup { gap: 8px; padding-block: 20px 16px; }
.sw-opts { gap: 7px; }
.sw-opts .qf-opt { min-height: 62px; padding: 7px 6px; }
.sw-opts .qf-opt b { font-size: 17px; }
.sw-opts .qf-opt small { font-size: 15px; text-wrap: balance; }

/* Painted pieces: one watercolour mask each (tools/paint_art.py), coloured here */
.sw .wash, .sw .ring, .sw-ring, .sw-cross, .sw-arr {
  -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center;
  background-image: var(--t-paper); background-size: 200px; background-blend-mode: multiply;
}
.sw .wash { -webkit-mask-image: url(/art/sw-blob.png); mask-image: url(/art/sw-blob.png); }
.sw .ring, .sw-ring { -webkit-mask-image: url(/art/sw-ring.png); mask-image: url(/art/sw-ring.png); }
.sw-cross { -webkit-mask-image: url(/art/sw-cross.png); mask-image: url(/art/sw-cross.png); }
.sw-arr { -webkit-mask-image: url(/art/sw-arrow.png); mask-image: url(/art/sw-arrow.png); }
.sw-arr.bar { -webkit-mask-image: url(/art/sw-bar.png); mask-image: url(/art/sw-bar.png); }

/* a grid laid on a taped sheet of paper */
.sw-sheet { position: relative; width: min(100cqw, 100cqh); aspect-ratio: 1; padding: 4.5%; border-radius: 6px 9px 7px 8px; rotate: -.5deg; }
.sw-sheet > .tape { top: -10px; left: 38%; z-index: 1; }
.sw-sheet.watching > .tape { background: rgba(226, 168, 60, .7); }

/* Spot the Difference: two pictures, one above the other; the emoji scale with their picture */
.sw-spot { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; container-type: size; }
.sw-panel {
  position: relative; width: min(100cqw, (50cqh - 5px) * 1.5); aspect-ratio: 3 / 2; container-type: inline-size; overflow: hidden;
  border-radius: 7px 10px 8px 6px; background-color: var(--paper); background-image: var(--t-paper); background-size: 300px;
  box-shadow: var(--lift); touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.sw-panel.p1 { background-color: var(--paper-cream); }
.sw-e { position: absolute; font-size: 10.5cqw; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; transform: translate(-50%, -50%) rotate(var(--r)) scale(calc(var(--s) * var(--f)), var(--s)); pointer-events: none; }
.sw-ring { position: absolute; width: 17cqw; aspect-ratio: 1; background-color: var(--poppy); transform: translate(-50%, -50%) rotate(-12deg); pointer-events: none; animation: swPop .3s var(--ease-spring) both; }
.sw-ring.missed { background-color: var(--ochre); }
.sw-cross { position: absolute; width: 10cqw; aspect-ratio: 1; background-color: var(--poppy); transform: translate(-50%, -50%); pointer-events: none; animation: swPop .2s var(--ease-spring) both; }

/* Follow the Dots: dots of watercolour on a square of paper, each in a brush-drawn ring; the one
   lighting up flashes poppy red, ring and all, so it can't be missed */
.sw-copy { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.sw-dots { position: relative; width: min(100cqw, 100cqh); aspect-ratio: 1; border-radius: 9px 7px 10px 8px; box-shadow: var(--lift); rotate: .5deg; touch-action: none; }
.sw-dot { position: absolute; width: 20%; aspect-ratio: 1; translate: -50% -50%; rotate: var(--tilt, 0deg); -webkit-user-select: none; user-select: none; }
.sw-dot > i { position: absolute; inset: 0; transition: background-color .12s, opacity .12s, scale .12s; }
.sw-dot .wash { inset: 9%; background-color: var(--paper-beige); opacity: .85; }
.sw-dot .ring { background-color: var(--ink); opacity: .5; }
.sw-dot.lit .wash { background-color: var(--poppy); opacity: 1; scale: 1.22; animation: swDotLit .3s var(--ease-spring) both; }
.sw-dot.lit .ring { background-color: var(--poppy-deep); opacity: 1; scale: 1.22; animation: swDotLit .3s var(--ease-spring) both; }
.sw-dot.tap .wash { background-color: var(--navy); opacity: 1; scale: 1.06; }
.sw-dot.wrong .wash { background-color: var(--ink); opacity: .85; }
.sw-dot.wrong .ring { background-color: var(--ink); opacity: 1; }
@keyframes swDotLit { from { scale: .75; } 55% { scale: 1.36; } }
.sw-dot.hint .ring { background-color: var(--ochre); opacity: 1; scale: 1.12; }
.sw-dots.watching { outline: 2px dashed rgba(44, 69, 98, .35); outline-offset: -10px; }

/* True Colours: a word painted onto a card, four paper buttons */
.sw-ink { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.sw-ink-card { position: relative; flex: 1 1 auto; min-height: 110px; max-height: 280px; display: grid; place-items: center; rotate: -.8deg; }
.sw-ink-card > .tape { top: -11px; left: 42%; }
.sw-word {
  font: 400 clamp(44px, 15vw, 76px)/1.1 var(--display); letter-spacing: .02em; padding: 0 .06em; rotate: -2deg; -webkit-user-select: none; user-select: none;
  color: var(--paint, var(--ink)); mix-blend-mode: multiply; /* soaks into the card like the painted art */
}
.sw-ink-btns { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; touch-action: manipulation; }
.sw-ink-btn, .sw-cell, .sw-tile, .sw-way-btn { background-color: var(--tile-face); background-image: var(--t-paper); background-size: 200px; background-blend-mode: multiply; color: var(--ink); box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -3px 0 rgba(120,90,40,.22), 0 2px 0 var(--tile-edge), 0 4px 8px rgba(16,26,46,.3); -webkit-user-select: none; user-select: none; }
.sw-ink-btn { min-height: 64px; border-radius: 9px; font: 800 18px var(--body); letter-spacing: .14em; }
.sw-ink-btn:nth-child(odd) { rotate: -.6deg; }
.sw-ink-btn:nth-child(even) { rotate: .7deg; }
.sw-ink-btn:active, .sw-cell:active, .sw-tile:active, .sw-way-btn:active, .sw-sq:active { transform: translateY(2px); }

/* the grids: Number Hunt, Odd Shade, Memory Grid (on paper) and Pairs (on the cloth) */
.sw-hunt { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.sw-grid { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2.4%; touch-action: manipulation; }
.sw-cell, .sw-tile { position: relative; min-width: 0; border-radius: 6px 7px 5px 7px; }
.sw-grid > :nth-child(3n) { rotate: .8deg; }
.sw-grid > :nth-child(4n + 1) { rotate: -.7deg; }
.sw-cell { display: grid; place-items: center; font: 400 min(7.4cqw, 7.4cqh)/1 var(--display); }
.sw-cell span { display: block; transform: rotate(var(--r)) scale(var(--s)); }
.sw-grid:not(.on) .sw-cell span { visibility: hidden; }
.sw-cell.done { background-color: var(--paper-beige); box-shadow: inset 0 2px 4px rgba(120, 90, 40, .22); }
.sw-cell.done span { opacity: .3; }
.sw-cell.done::after, .sw-sq.odd::after { content: ""; position: absolute; inset: 6%; background-color: var(--sage); background-image: none; -webkit-mask: url(/art/sw-ring.png) center / contain no-repeat; mask: url(/art/sw-ring.png) center / contain no-repeat; rotate: -14deg; }
.sw-cell.wrong { color: var(--poppy-deep); background-color: #ecc1a8; }

/* Odd Shade: swatches of one paint on a colour card, one a shade off */
.sw-shade-grid { grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 3%; }
.sw-sq { position: relative; min-width: 0; -webkit-user-select: none; user-select: none; }
.sw-sq .wash { position: absolute; inset: -7%; -webkit-mask-image: url(/art/sw-swatch.png); mask-image: url(/art/sw-swatch.png); }
.sw-sq:nth-child(odd) .wash { rotate: 1.2deg; }
.sw-sq:nth-child(3n) .wash { rotate: -1.4deg; scale: -1 1; }
.sw-sq.odd::after { background-color: var(--ochre); inset: -6%; }

/* Pairs: painted cards on the cloth that turn up to a watercolour symbol */
.sw-pairs .sw-grid { width: min(100cqw, 100cqh); height: auto; aspect-ratio: 1; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3.2%; }
.sw-card { position: relative; min-width: 0; perspective: 500px; -webkit-user-select: none; user-select: none; }
.sw-card:nth-child(odd) { rotate: -1.2deg; }
.sw-card:nth-child(3n) { rotate: 1.4deg; }
.sw-card > span { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 7px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .24s var(--ease-out); box-shadow: 0 1px 1px rgba(16, 26, 46, .3), 0 8px 12px -8px rgba(16, 26, 46, .7); }
.sw-card .back { background: var(--paper-cream); }
.sw-card .back img { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: multiply; }
.sw-card .face { background-color: var(--paper); background-image: var(--t-paper); background-size: 200px; transform: rotateY(180deg); }
.sw-card .face img { width: 68%; height: 68%; object-fit: contain; }
.sw-card.up .back { transform: rotateY(-180deg); }
.sw-card.up .face { transform: rotateY(0); }
.sw-card.found .face { background-color: var(--paper-beige); }
.sw-card.found .face img { opacity: .6; scale: .9; }
.sw-pairs-grid:not(.on) .sw-card { visibility: hidden; }

/* Which Way: five brush arrows on a card, two big paper keys */
.sw-way { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.sw-way-card { position: relative; flex: 1 1 auto; min-height: 120px; max-height: 300px; display: grid; place-items: center; overflow: hidden; rotate: .6deg; }
.sw-way-card > .tape { top: -11px; left: 40%; }
.sw-arrows { display: flex; gap: 0; }
.sw-arrows .sw-arr { display: block; width: clamp(52px, 16.5vw, 72px); aspect-ratio: 5 / 3; background-color: var(--ink); }
.sw-arr.l { scale: -1 1; }
.sw-arrows .sw-arr.mid { background-color: var(--poppy); }
.sw-arrows .sw-arr:nth-child(2) { rotate: 2deg; } .sw-arrows .sw-arr:nth-child(4) { rotate: -2deg; }
.sw-way-btns { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; touch-action: manipulation; }
.sw-way-btn { display: grid; place-items: center; min-height: 76px; border-radius: 10px; }
.sw-way-btn .sw-arr { display: block; width: 72px; aspect-ratio: 5 / 3; background-color: var(--navy); }
.sw-way-btn.l { rotate: -.8deg; } .sw-way-btn.r { rotate: .8deg; }

/* Memory Grid: paper tiles that take a wash of ochre, then navy as you find them */
.sw-tile .wash { position: absolute; inset: 10%; background-color: transparent; -webkit-mask-image: url(/art/sw-swatch.png); mask-image: url(/art/sw-swatch.png); transition: background-color .15s, scale .15s; }
.sw-tile.lit .wash { background-color: var(--ochre); scale: 1.06; }
.sw-tile.tap .wash { background-color: var(--navy); }
.sw-tile.wrong .wash { background-color: var(--poppy); }
.sw-tile.hint::after { content: ""; position: absolute; inset: 4%; background-color: var(--ochre); -webkit-mask: url(/art/sw-ring.png) center / contain no-repeat; mask: url(/art/sw-ring.png) center / contain no-repeat; }

@media (max-height: 740px) {
  .sw-setup .hand-note { display: none; }
  .sw-opts .qf-opt { min-height: 54px; }
  .sw-way-btn { min-height: 60px; }
  .sw { gap: 6px; }
  .sw-sb { padding-block: 5px; }
  .sw-sb .sb-side > b { font-size: 26px; }
  .sw-sb .sb-mid { font-size: 18px; }
  .sw-clock { font-size: 16px; }
  .sw-status { min-height: 40px; font-size: 21px; }
  .sw-spot { gap: 7px; }
  .sw-ink { gap: 10px; }
  .sw-ink-btn { min-height: 52px; }
  .sw-count b { font-size: 76px; }
}
