/* Doku Duel styles. Colors are tokens on :root; dark mode and board themes only swap tokens. */

/* ---------- tokens: light ---------- */
:root {
  --bg: #F5F4EF;
  --page-bg: var(--bg);
  --surface: #FFFFFF;
  --surface-2: #EDECE6;
  --surface-3: #E3E2DA;
  --ink: #16191F;
  --ink-2: #555B66;
  --ink-3: #656A74;   /* 4.5:1 or more on surface and surface-2 */
  --line: #E0DED6;
  --you: #2563EB;
  --you-ink: #1D4ED8;
  --you-soft: #DFE8FC;
  --riv: #C2570C;
  --riv-ink: #A9490A;
  --riv-soft: #FBE6D6;
  --good: #15803D;
  --bad: #DC2626;
  --bad-soft: #FDE4E4;
  --gold: #B7791F;
  --on-accent: #FFFFFF;
  --shadow: 0 1px 2px rgba(20, 22, 30, .06), 0 6px 18px rgba(20, 22, 30, .07);
  --shadow-up: 0 -1px 2px rgba(20, 22, 30, .05), 0 -6px 18px rgba(20, 22, 30, .06);
  --scrim: rgba(14, 16, 22, .42);
  --r: 16px;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --num-font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Segoe UI Variable Display", "Segoe UI",
    system-ui, -apple-system, Roboto, sans-serif;
  --num-weight: 600;

  /* momentum background (duels): pale washes of the leader's color */
  --mom-b1: #ECEFF4; --mom-b2: #E3EAF7; --mom-b3: #D9E5FA;
  --mom-o1: #F7EFE8; --mom-o2: #F9E9DD; --mom-o3: #FAE2D1;

  /* board: Clean (light) */
  --b-cell: #FFFFFF;
  --b-line: #D3D6DC;
  --b-thick: #1B1F27;
  --b-given: #1B1F27;
  --b-user: #2563EB;
  --b-note: #545C69;
  --b-hl: #EEF1F6;
  --b-same: #D7E0EE;
  --b-sel: #C6D6F2;
  --b-ring: #2563EB;
  --b-you-bg: #E2EBFD;
  --b-you-fg: #1D4ED8;
  --b-you-cap: #C7D8FB;
  --b-riv-bg: #FBEADD;
  --b-riv-fg: #A9490A;
  --b-riv-cap: #F6D3B8;
  --b-wrong-bg: #FDE2E2;
  --b-wrong-fg: #DC2626;
}

/* ---------- tokens: dark ---------- */
:root[data-dark="1"] {
  --bg: #101318;
  --surface: #1A1E26;
  --surface-2: #242934;
  --surface-3: #2D3340;
  --ink: #ECEEF2;
  --ink-2: #A9B0BD;
  --ink-3: #8E96A5;   /* 4.5:1 or more on surface and surface-2 */
  --line: #2C323D;
  --you-ink: #8DB2FF;
  --you-soft: #1B2C52;
  --riv-ink: #F7A066;
  --riv-soft: #3E2513;
  --bad: #F87171;
  --bad-soft: #3D1C1F;
  --gold: #E3B04B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
  --shadow-up: 0 -1px 2px rgba(0, 0, 0, .3), 0 -6px 18px rgba(0, 0, 0, .25);
  --scrim: rgba(0, 0, 0, .55);
  --mom-b1: #111824; --mom-b2: #121D31; --mom-b3: #14223D;
  --mom-o1: #1B1617; --mom-o2: #251A15; --mom-o3: #2F1E13;

  --b-cell: #1A1E26;
  --b-line: #2E3440;
  --b-thick: #C9CED8;
  --b-given: #ECEEF2;
  --b-user: #8DB2FF;
  --b-note: #ABB4C3;
  --b-hl: #222733;
  --b-same: #2C3546;
  --b-sel: #31405F;
  --b-ring: #8DB2FF;
  --b-you-bg: #1C3061;
  --b-you-fg: #A8C4FF;
  --b-you-cap: #254189;
  --b-riv-bg: #42250F;
  --b-riv-fg: #FFB37E;
  --b-riv-cap: #63360F;
  --b-wrong-bg: #4A1D22;
  --b-wrong-fg: #FF8A8A;
}

/* ---------- board themes ---------- */
:root[data-theme="paper"] {
  --b-cell: #FFFCF4; --b-line: #E2DAC5; --b-thick: #3A3326; --b-given: #2E2A22; --b-note: #6E6450;
  --b-hl: #F6EFDD; --b-same: #ECE0C2; --b-sel: #E3D3A8;
}
:root[data-theme="ocean"] {
  --b-cell: #F5FAFD; --b-line: #CDE1EA; --b-thick: #0E3A4F; --b-given: #0E3A4F; --b-note: #4C6A78;
  --b-hl: #E4F1F7; --b-same: #CBE5F0; --b-sel: #B3D8E9;
}
:root[data-theme="forest"] {
  --b-cell: #F6FAF4; --b-line: #D2E2CD; --b-thick: #1F3A26; --b-given: #1F3A26; --b-note: #4F6655;
  --b-hl: #E6F1E2; --b-same: #D0E6C9; --b-sel: #BBDCB1;
}
:root[data-theme="midnight"] {
  --b-cell: #1B2233; --b-line: #2F3A52; --b-thick: #8FA2C8; --b-given: #E7EBF5; --b-note: #9AA6C2;
  --b-user: #9DBCFF; --b-ring: #9DBCFF;
  --b-hl: #232C42; --b-same: #2D3A5A; --b-sel: #36476F;
  --b-you-bg: #1F3B78; --b-you-fg: #B4CCFF; --b-you-cap: #2A4C96;
  --b-riv-bg: #4A2A14; --b-riv-fg: #FFC59B; --b-riv-cap: #6A3A15;
  --b-wrong-bg: #4C1E27; --b-wrong-fg: #FF9A9A;
}
:root[data-theme="neon"] {
  --b-cell: #121319; --b-line: #272A3B; --b-thick: #2FD9BE; --b-given: #F2F4FF; --b-note: #A2A8C8;
  --b-user: #7FA9FF; --b-ring: #2FD9BE;
  --b-hl: #1B1D2A; --b-same: #252946; --b-sel: #2E3360;
  --b-you-bg: #1A2C5E; --b-you-fg: #9FBEFF; --b-you-cap: #23408A;
  --b-riv-bg: #45230C; --b-riv-fg: #FFB988; --b-riv-cap: #66330E;
  --b-wrong-bg: #4C1C25; --b-wrong-fg: #FF8C9A;
}
:root[data-dark="1"][data-theme="paper"] {
  --b-cell: #221F1A; --b-line: #38332A; --b-thick: #D8CDB2; --b-given: #F2EBDA; --b-note: #B3A88F;
  --b-hl: #2A2620; --b-same: #3B3428; --b-sel: #4B412F;
}
:root[data-dark="1"][data-theme="ocean"] {
  --b-cell: #12212A; --b-line: #1F3642; --b-thick: #9CCDE0; --b-given: #E4F3F9; --b-note: #8FB3C2;
  --b-hl: #172A35; --b-same: #1F3B4A; --b-sel: #27495B;
}
:root[data-dark="1"][data-theme="forest"] {
  --b-cell: #15201A; --b-line: #23362A; --b-thick: #A9D3B2; --b-given: #E6F3E8; --b-note: #93B39A;
  --b-hl: #1A2A20; --b-same: #233A2C; --b-sel: #2B4836;
}

/* ---------- number styles ---------- */
/* Times first: Georgia's digits are "old style" (uneven heights, a 0 like a small o), wrong for a sudoku board */
:root[data-num="classic"] { --num-font: "Times New Roman", Times, "Noto Serif", "Liberation Serif", serif; --num-weight: 500; }
:root[data-num="mono"] { --num-font: ui-monospace, "Cascadia Mono", Consolas, Menlo, "Roboto Mono", monospace; --num-weight: 600; }
:root[data-num="bold"] { --num-font: var(--font); --num-weight: 800; }
:root[data-num="slim"] { --num-font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; --num-weight: 300; }

/* momentum: only the page background behind everything changes */
:root[data-mom="b1"] { --page-bg: var(--mom-b1); }
:root[data-mom="b2"] { --page-bg: var(--mom-b2); }
:root[data-mom="b3"] { --page-bg: var(--mom-b3); }
:root[data-mom="o1"] { --page-bg: var(--mom-o1); }
:root[data-mom="o2"] { --page-bg: var(--mom-o2); }
:root[data-mom="o3"] { --page-bg: var(--mom-o3); }
/* the tint fades only in a match: a theme switch elsewhere changes the page and its text at the same moment */
body[data-screen="match"] { transition: background-color .6s ease; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background-color: var(--page-bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--you); outline-offset: 2px; }
button:disabled, button[aria-disabled="true"] { cursor: default; }
svg { display: block; flex: none; }
h1, h2, h3, p { margin: 0; }

#app {
  position: fixed; inset: 0;
  display: flex; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen-host {
  position: relative;
  width: 100%; max-width: 520px; height: 100%;
  overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.page { --pad: 16px; min-height: 100%; padding: 8px var(--pad) 24px; display: flex; flex-direction: column; gap: 14px; }
.nudge { animation: nudge .32s ease; }
@keyframes nudge {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 1px); } 40% { transform: translate(4px, -1px); }
  60% { transform: translate(-3px, 0); } 80% { transform: translate(2px, 1px); }
}

/* ---------- common pieces ---------- */
/* the top bar (Back, title) stays in reach while a long page scrolls under it */
.topbar {
  display: flex; align-items: center; gap: 8px; min-height: 52px;
  position: sticky; top: 0; z-index: 5; background: var(--page-bg);
  margin: 0 calc(-1 * var(--pad, 16px)); padding: 0 var(--pad, 16px);
}
.topbar-title { flex: 1; text-align: center; font-size: 19px; font-weight: 700; letter-spacing: .2px; min-width: 0; }
.iconbtn, .iconbtn-gap { width: 44px; height: 44px; flex: none; }
.iconbtn {
  display: grid; place-items: center; border-radius: 14px; color: var(--ink);
  background: var(--surface); box-shadow: var(--shadow);
}
.iconbtn:active { transform: scale(.94); }
.iconbtn[aria-disabled="true"] { opacity: .3; box-shadow: none; }
.iconbtn[aria-disabled="true"]:active { transform: none; }

.card {
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px; position: relative;
}
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.sec-title { font-size: 13px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--ink-2); margin: 6px 2px -4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 10px 18px; border-radius: 14px;
  background: var(--surface-2); color: var(--ink); font-weight: 650; font-size: 17px;
  text-align: center; white-space: normal; line-height: 1.2;
  transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--you); color: var(--on-accent); }
.btn.rival { background: var(--riv); color: var(--on-accent); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.big { min-height: 64px; font-size: 21px; border-radius: 18px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: 15px; white-space: nowrap;
}
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.tag.easy { background: #DCF2E3; color: #166534; }
.tag.medium { background: #FDF0D2; color: #8A5A07; }
.tag.hard { background: #FBE0E0; color: #A61B1B; }
:root[data-dark="1"] .tag.easy { background: #183524; color: #86E0A6; }
:root[data-dark="1"] .tag.medium { background: #3A2E12; color: #F2C866; }
:root[data-dark="1"] .tag.hard { background: #3D1A1C; color: #FF9C9C; }

.bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--you); transition: width .9s cubic-bezier(.2, .8, .2, 1); }

/* ---------- popups ---------- */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#layer > * { pointer-events: auto; }
.overlay {
  position: fixed; inset: 0; background: var(--scrim);
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  opacity: 0; transition: opacity .18s ease;
}
.overlay.in { opacity: 1; }
.overlay.out { opacity: 0; pointer-events: none; }
.sheet {
  position: relative; width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto;
  background: var(--surface); color: var(--ink); border-radius: 22px; box-shadow: var(--shadow);
  padding: 22px 18px 18px; transform: translateY(14px) scale(.98); transition: transform .2s cubic-bezier(.2, .9, .3, 1.2);
}
.overlay.in .sheet { transform: none; }
.sheet-x {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; color: var(--ink-2); z-index: 2;
}
.sheet-x:active { background: var(--surface-2); }
.sheet-title { font-size: 21px; font-weight: 750; text-align: center; padding: 4px 40px 10px; line-height: 1.2; }
.sheet-body { text-align: center; color: var(--ink); }
.sheet-body p { margin: 6px 0; line-height: 1.4; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { width: 100%; }
.sheet .hero { display: grid; place-items: center; margin: 4px auto 10px; }

/* hint card sits at the bottom so the board stays visible */
.overlay.hintpop { align-items: flex-end; background: transparent; }
.sheet.hint { max-width: 520px; box-shadow: 0 -2px 4px rgba(20, 22, 30, .08), 0 -10px 30px rgba(20, 22, 30, .16); text-align: left; }
.sheet.hint .sheet-title { text-align: left; padding: 0 44px 6px 0; font-size: 19px; }
.sheet.hint .sheet-body { text-align: left; }
.hint-tech { display: inline-flex; align-items: center; gap: 6px; color: var(--you-ink); font-weight: 700; font-size: 14px; margin-bottom: 6px; }

/* ---------- toasts and banners ---------- */
.toast {
  /* under the top bar, so a message never hides Back, the level, the trophies or a Solo game's clock */
  position: fixed; left: 50%; top: calc(62px + env(safe-area-inset-top)); z-index: 60;
  transform: translate(-50%, -16px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 22px; font-weight: 650;
  /* max-content: a long message uses the screen's width before it wraps (left: 50% alone would halve it) */
  width: max-content; max-width: calc(100% - 32px); text-align: center; text-wrap: balance; box-shadow: var(--shadow);
}
.toast.in { transform: translate(-50%, 0); opacity: 1; }
/* in a duel the top holds the two score cards: on a tall phone a message goes into the free band above the board,
   on a short one (no band) it stays at the very top */
body[data-screen="match"] .toast { top: calc(14px + env(safe-area-inset-top)); }
@media (min-height: 780px) { body[data-screen="match"] .toast { top: calc(152px + env(safe-area-inset-top)); } }
.banner {
  position: fixed; left: 50%; top: 38%; z-index: 40; pointer-events: none;
  transform: translate(-50%, -50%) scale(.4); opacity: 0;
  font-size: 44px; font-weight: 900; letter-spacing: 1px; color: var(--you);
  background: var(--surface); padding: 8px 22px; border-radius: 18px; box-shadow: var(--shadow);
  white-space: nowrap; animation: banner 1.1s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
.banner.rival { color: var(--riv); }
@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(.96); opacity: 0; }
}
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }

/* ---------- board ---------- */
/* the board, the tools and the pad stay together as one group: the board's box is a square as wide as the screen
   allows (it only shrinks when the screen is too short), and the space left over is split above the board and
   below the pad (the two auto margins) */
.board-wrap { flex: 0 1 auto; aspect-ratio: 1; min-height: 0; margin-top: auto; container-type: size; display: grid; place-items: center; }
.board {
  container-type: inline-size;
  width: min(100cqw, 100cqh); aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 2.5px; padding: 2.5px; background: var(--b-thick); border-radius: 10px;
  box-shadow: var(--shadow); transition: filter .25s ease;
}
.board.blur { filter: blur(11px); }
.box {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 1px; background: var(--b-line); overflow: hidden;
}
.box:nth-child(1) { border-top-left-radius: 8px; }
.box:nth-child(3) { border-top-right-radius: 8px; }
.box:nth-child(7) { border-bottom-left-radius: 8px; }
.box:nth-child(9) { border-bottom-right-radius: 8px; }
.cell {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 0;
  background: var(--b-cell); color: var(--b-given);
  font-family: var(--num-font); font-weight: var(--num-weight);
  font-size: 6.9cqw; line-height: 1;
  transition: background-color .35s ease, color .2s ease;
  transition-delay: var(--d, 0s);
  cursor: pointer;
}
.cell.hl { background: var(--b-hl); }
.cell.same { background: var(--b-same); }
.cell.user .v { color: var(--b-user); }
.cell.p1 { background: var(--b-you-bg); color: var(--b-you-fg); }
.cell.p2 { background: var(--b-riv-bg); color: var(--b-riv-fg); }
.cell.cap1 { background: var(--b-you-cap); }
.cell.cap2 { background: var(--b-riv-cap); }
.cell.same.p1, .cell.same.p2, .cell.same.cap1, .cell.same.cap2 { box-shadow: inset 0 0 0 2px var(--b-ring); }
.cell.sel { background: var(--b-sel); box-shadow: inset 0 0 0 2.5px var(--b-ring); }
.cell.sel.p1, .cell.sel.p2, .cell.sel.cap1, .cell.sel.cap2 { box-shadow: inset 0 0 0 2.5px var(--b-ring); }
.cell.wrong { background: var(--b-wrong-bg); }
.cell.wrong .v { color: var(--b-wrong-fg); }
/* the number a wrong number repeats (same row, column or box): a red ring, so the eye finds the clash */
.cell.clash { box-shadow: inset 0 0 0 2px var(--b-wrong-fg); }
.cell .v { position: relative; z-index: 1; }
.cell .v.pop { animation: pop .34s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(.25); opacity: .2; } 60% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); } }
.cell.flash { animation: flashbad .7s ease; }
.cell.flash .v { color: var(--b-wrong-fg); }
@keyframes flashbad { 0%, 40% { background: var(--b-wrong-bg); } 100% { background: var(--b-cell); } }
.cell.shake .v { animation: cshake .36s ease; }
@keyframes cshake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.notes {
  position: absolute; inset: 3px 2px 2px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-family: var(--font); font-weight: 700; font-size: 3cqw; color: var(--b-note); line-height: 1;
}
.notes > span { display: grid; place-items: center; }
.notes > span.on { color: var(--b-ring); font-weight: 800; }

.cell.near::after, .cell.coach::after, .cell.scan::after, .cell.peek::after, .cell.hintc::after {
  content: ""; position: absolute; inset: 2px; border-radius: 6px; pointer-events: none;
}
.cell.near::after { box-shadow: 0 0 0 2.5px var(--you); animation: nearpulse 1.1s ease-in-out infinite; }
.cell.near.n2::after { box-shadow: 0 0 0 2.5px var(--riv); }
@keyframes nearpulse { 0%, 100% { opacity: .25; transform: scale(.9); } 50% { opacity: 1; transform: scale(1); } }
.cell.coach::after { box-shadow: 0 0 0 3px var(--you); animation: nearpulse .9s ease-in-out infinite; }
.cell.scan::after { box-shadow: inset 0 0 0 2px var(--riv); opacity: .75; }
.cell.peek::after { box-shadow: inset 0 0 0 2px var(--you); border-radius: 50%; }
.cell.peek .pk { color: var(--you); opacity: .8; font-style: italic; position: relative; z-index: 1; }
/* Live Duel: a number on its way to the server */
.cell.sending .snd { color: var(--b-user); opacity: .45; animation: sendpulse .8s ease-in-out infinite alternate; }
@keyframes sendpulse { from { opacity: .3; } to { opacity: .6; } }
/* Live Duel: the friend's card while they are away (dropped), and the bar while this phone reconnects */
.pcard.away { opacity: .5; }
.game.duel .status { position: relative; }
/* "Connection lost: getting back..." covers the turn line, between Back and the seconds */
.linebar { position: absolute; left: 44px; right: 44px; top: 50%; transform: translateY(-50%); z-index: 30; text-align: center;
  padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; line-height: 1.2; }
.cell.hintc::after { box-shadow: inset 0 0 0 2px var(--good); }
.cell.hintu { background: color-mix(in srgb, var(--good) 13%, var(--b-cell)); }
.cell.sweep { animation: sweep .9s ease both; animation-delay: var(--d, 0s); }
@keyframes sweep {
  0% { background: var(--b-cell); }
  35% { background: color-mix(in srgb, var(--you) 45%, var(--b-cell)); }
  100% { background: var(--b-cell); }
}
.cell.sweep .v { animation: pop .5s ease both; animation-delay: var(--d, 0s); }
.cell.drawin { opacity: 0; animation: fadein .4s ease forwards; animation-delay: var(--d, 0s); }
@keyframes fadein { to { opacity: 1; } }

/* ---------- number pad and tools ---------- */
.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; margin-bottom: auto; }
.key {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: clamp(54px, 7.4vh, 68px); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
  font-family: var(--num-font); font-weight: var(--num-weight); font-size: 27px; color: var(--ink); line-height: 1;
}
.key small { font-family: var(--font); font-size: 11px; font-weight: 700; color: var(--ink-3); margin-top: 3px; }
.key:active { transform: scale(.93); }
.key.done { opacity: .28; box-shadow: none; }
.key.noting { color: var(--you-ink); box-shadow: inset 0 0 0 2px var(--you), var(--shadow); }
.tools { display: flex; gap: 8px; justify-content: space-around; }
.tool {
  position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; border-radius: 12px; color: var(--ink); font-size: 13px; font-weight: 650;
}
.tool span { max-width: 100%; text-align: center; line-height: 1.15; }
.tool:active { background: var(--surface-2); }
.tool[aria-disabled="true"] { opacity: .38; }
.tool.on { color: var(--you-ink); }
.tool .ico { position: relative; width: 44px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.tool.on .ico { background: var(--you); color: #fff; }
.tool .cost { position: absolute; top: -5px; right: -9px; min-width: 20px; height: 20px; padding: 0 6px 0 4px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 1px; }
.tool .cost svg { width: 10px; height: 10px; fill: currentColor; }
.tool .flag { position: absolute; top: -5px; right: -9px; padding: 1px 6px; border-radius: 10px; background: var(--you); color: #fff; font-size: 10px; font-weight: 800; }

/* ---------- game screens ---------- */
.game { height: 100%; display: flex; flex-direction: column; gap: 8px; padding: 6px 10px 10px; }
.status {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
}
/* the guided match keeps room for a three-line tip from the start: the board does not jump when one comes */
.game.guided .status { min-height: 58px; }
/* Solo: while the Hint panel is open, the tools and keys under it step aside (their labels showed cut in half) */
.game.hinting .tools, .game.hinting .pad { visibility: hidden; }
.status-text {
  flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 18px; line-height: 1.15; color: var(--ink);
  transition: opacity .2s ease;
}
/* whose turn it is, in that player's color */
/* the seconds a person has left, in figures, opposite the Leave button (the ring alone was easy to miss) */
.status .secs { display: grid; place-items: center; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.status .secs[data-who="1"] { color: var(--you-ink); }
.status .secs[data-who="2"] { color: var(--riv-ink); }
.status .secs.low { color: var(--bad); }
.league-card { cursor: pointer; }
.status-text[data-who="1"] { color: var(--you-ink); }
.status-text[data-who="2"] { color: var(--riv-ink); }
.status-text.coachy { color: var(--you-ink); font-weight: 700; font-size: 16px; line-height: 1.2; }
.status-text.fade { opacity: 0; }

/* duel: player cards */
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pcard {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow); min-width: 0; position: relative;
  border: 2px solid transparent; transition: border-color .25s ease;
}
.pcard.p2 { flex-direction: row-reverse; text-align: right; }
.pcard.turn.p1 { border-color: var(--you); }
.pcard.turn.p2 { border-color: var(--riv); }
.pcard.pulse { animation: lead .9s ease; }
.pcard.p1.pulse { --pc: var(--you); }
.pcard.p2.pulse { --pc: var(--riv); }
@keyframes lead {
  0% { box-shadow: var(--shadow), 0 0 0 0 color-mix(in srgb, var(--pc) 45%, transparent); transform: scale(1); }
  40% { box-shadow: var(--shadow), 0 0 0 9px color-mix(in srgb, var(--pc) 0%, transparent); transform: scale(1.035); }
  100% { box-shadow: var(--shadow), 0 0 0 0 transparent; transform: scale(1); }
}
.ava { position: relative; width: 48px; height: 48px; flex: none; }
.ava .face { position: absolute; inset: 5px; border-radius: 50%; overflow: hidden; }
.ava .face svg { width: 100%; height: 100%; }
.ava .ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ava .ring circle { fill: none; stroke-width: 3.5; }
.ava .ring .trk { stroke: var(--surface-3); }
.ava .ring .arc { stroke-linecap: round; transition: stroke .2s; }
.p1 .ava .ring .arc { stroke: var(--you); }
.p2 .ava .ring .arc { stroke: var(--riv); }
.ava .ring .arc.low { stroke: var(--bad); }
.ava .think { position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); display: none; gap: 3px; padding: 3px 5px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.ava .think i { width: 5px; height: 5px; border-radius: 50%; background: var(--riv); animation: dots 1s infinite ease-in-out; }
.ava .think i:nth-child(2) { animation-delay: .15s; } .ava .think i:nth-child(3) { animation-delay: .3s; }
.thinking .ava .think { display: flex; }
@keyframes dots { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
.ava .frz { position: absolute; top: -4px; right: -4px; width: 22px; height: 22px; border-radius: 50%; background: #E0F2FE; color: #0369A1; display: none; place-items: center; }
.frozen .ava .frz { display: grid; }
.pinfo { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.pname { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.pscore { font-family: var(--num-font); font-weight: 800; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.p1 .pscore { color: var(--you-ink); }
.p2 .pscore { color: var(--riv-ink); }
.sparks { display: flex; gap: 2px; }
.p2 .sparks { justify-content: flex-end; }
/* a meter: empty slots are grey outlines, won sparks are filled gold */
.sparks i { width: 15px; height: 15px; display: grid; place-items: center; color: var(--ink-3); opacity: .6; }
.sparks i.on { color: var(--gold); opacity: 1; }
.sparks i.on svg { fill: currentColor; }
.sparks.point { animation: sparkpoint .9s ease 3; }
@keyframes sparkpoint { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.45); } }
/* the +N / -N pop-ups stay inside the screen: the card is at its very top */
.pcard .flt { position: absolute; top: 2px; font-weight: 900; font-size: 18px; pointer-events: none; animation: floatup 1s ease forwards; }
.pcard.p1 .flt { right: 12px; color: var(--you-ink); }
.pcard.p2 .flt { left: 12px; color: var(--riv-ink); }
@keyframes floatup { 0% { opacity: 0; transform: translateY(12px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
/* points lost to a miss: the same pop-up, sinking instead of rising */
.pcard .flt.neg { animation-name: floatdown; }
@keyframes floatdown { 0% { opacity: 0; transform: translateY(-4px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(14px); } }

/* pass and play cover */
.handoff {
  position: fixed; inset: 0; z-index: 35; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px;
  text-align: center;
}
.handoff h2 { font-size: 26px; font-weight: 800; max-width: 340px; }
.handoff p { color: var(--ink-2); max-width: 320px; }

/* solo top */
.solo-top { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.solo-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.solo-level { font-weight: 800; font-size: 17px; }
.solo-sub { display: flex; gap: 12px; color: var(--ink-2); font-size: 14px; font-weight: 650; white-space: nowrap; }
.solo-sub b { color: var(--ink); font-variant-numeric: tabular-nums; }
.solo-sub .bad b { color: var(--bad); }
.solo-time { font-variant-numeric: tabular-nums; }

/* ---------- title ---------- */
.title-screen { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; }
.title-board { width: min(62vw, 260px); aspect-ratio: 1; }
.title-board svg { width: 100%; height: 100%; }
.title-board line, .title-board rect { stroke: var(--ink); fill: none; stroke-linecap: round; }
.title-board .thin { stroke-width: 1.2; opacity: .35; }
.title-board .thick { stroke-width: 3; }
.title-board .draw { stroke-dasharray: 300; stroke-dashoffset: 300; animation: drawline .9s ease forwards; animation-delay: var(--d, 0s); }
@keyframes drawline { to { stroke-dashoffset: 0; } }
.title-board .tc { font-family: var(--num-font); font-weight: 700; font-size: 20px; text-anchor: middle; dominant-baseline: central; opacity: 0; animation: fadein .4s ease forwards; animation-delay: var(--d, 0s); }
.title-board .tc.a { fill: var(--you); } .title-board .tc.b { fill: var(--riv); }
.logo { font-size: 40px; font-weight: 850; letter-spacing: .5px; opacity: 0; animation: fadein .6s ease forwards; animation-delay: 1.3s; }
.logo .a { color: var(--you); } .logo .b { color: var(--riv); }
.tagline { color: var(--ink-2); opacity: 0; animation: fadein .6s ease forwards; animation-delay: 1.6s; text-align: center; text-wrap: balance; }
.taphint { color: var(--ink-3); font-size: 14px; font-weight: 650; opacity: 0; animation: fadein .6s ease forwards; animation-delay: 1.2s; }
.gain .l.to { margin-top: 2px; }

/* ---------- home ---------- */
.home-top { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.lvl { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.lvl-num { width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--you); color: #fff; font-weight: 850; display: grid; place-items: center; font-size: 17px; }
.lvl .bar { flex: 1; min-width: 40px; height: 8px; }
.lvl-txt { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.troph { display: flex; align-items: center; gap: 6px; font-weight: 800; padding: 4px 10px 4px 6px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); white-space: nowrap; }
.home-logo { text-align: center; font-size: 30px; font-weight: 850; margin: 4px 0 0; }
.home-logo .a { color: var(--you); } .home-logo .b { color: var(--riv); }
.mainbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mainbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px;
  min-height: clamp(168px, 25vh, 230px); padding: 22px 10px 16px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow);
  text-align: center;
}
.mainbtn:active { transform: scale(.98); }
.mainbtn .ic { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; color: #fff; }
.mainbtn.solo .ic { background: var(--ink); color: var(--bg); }
.mainbtn.duel .ic { background: var(--you); }
.mainbtn b { font-size: 22px; font-weight: 800; }
.mainbtn small { color: var(--ink-2); font-size: 13px; font-weight: 600; line-height: 1.25; }
.continue {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 18px;
  background: var(--you); color: #fff; box-shadow: var(--shadow); text-align: left;
}
.continue .grow b { display: block; font-size: 18px; }
.continue .grow small { opacity: .9; font-size: 13px; }
.dailies { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.daily {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow); text-align: left; min-width: 0;
}
.daily .row { width: 100%; }
.daily b { font-size: 16px; font-weight: 800; }
.daily small { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.daily .done { color: var(--good); }
.streakrow { display: flex; align-items: center; gap: 4px; font-weight: 800; font-size: 14px; }
.home-foot { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ---------- list rows (ladder, solo levels, settings) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.lrow {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow); text-align: left; min-height: 64px;
}
.lrow:active { transform: scale(.99); }
.lrow .t { font-weight: 750; font-size: 17px; }
.lrow .d { color: var(--ink-2); font-size: 13px; line-height: 1.3; display: inline-block; margin-top: 2px; }
.lrow .end { flex: none; display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-weight: 700; font-size: 14px; }
.lrow.locked { opacity: .55; }
.lrow.next { box-shadow: inset 0 0 0 2px var(--you), var(--shadow); }
.lrow .avs { width: 52px; height: 52px; flex: none; border-radius: 50%; overflow: hidden; }
.lrow .avs svg { width: 100%; height: 100%; }
.lvlic { width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center; font-weight: 900; font-size: 18px; color: #fff; }
.lvlic.t1 { background: #16A34A; } .lvlic.t2 { background: #0EA5E9; } .lvlic.t3 { background: #D97706; }
.lvlic.t4 { background: #DC2626; } .lvlic.t5 { background: #7C3AED; }

/* settings */
.set { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px; }
.set + .set { border-top: 1px solid var(--line); }
.set .ic { color: var(--ink-2); }
.set .t { font-weight: 700; }
.set .d { color: var(--ink-2); font-size: 13px; line-height: 1.3; display: inline-block; margin-top: 2px; }
.group { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.switch { width: 52px; height: 32px; flex: none; border-radius: 999px; background: var(--surface-3); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--you); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; flex: none; }
.seg button { padding: 8px 10px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--ink-2); min-height: 38px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.set.stack { flex-wrap: wrap; }
/* a row with a choice switch: the label keeps its own width, and a switch that does not fit beside it goes to the
   next line, at the right (it used to squeeze the label and sit on top of it: "Modo oscuro" in Spanish) */
.set.stack .grow { flex: 1 0 auto; }
.set.stack .seg { margin-left: auto; }
.flipx { display: grid; transform: scaleX(-1); }

/* style picker */
.picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow); text-align: center; position: relative; min-width: 0;
}
.pick.on { box-shadow: inset 0 0 0 3px var(--you), var(--shadow); }
.pick.locked { opacity: .55; }
.pick b { font-size: 14px; }
.pick small { font-size: 12px; color: var(--ink-2); font-weight: 650; }
/* the lock sits in the "Level 8" line (on the corner of the card it cut into the board preview) */
.pick small { display: inline-flex; align-items: center; gap: 3px; }
.pick .lk { display: inline-grid; color: var(--ink-2); }
.mini { width: 100%; max-width: 84px; aspect-ratio: 1; border-radius: 8px; padding: 2px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.mini i { border-radius: 2px; }
.numprev { font-family: var(--pf); font-weight: var(--pw); font-size: 30px; height: 44px; display: grid; place-items: center; }
.fxprev { width: 56px; height: 44px; display: grid; place-items: center; color: var(--you); }

/* ---------- results ---------- */
.result-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 4px; }
.result-head h1 { font-size: 30px; font-weight: 850; line-height: 1.15; }
.result-head h1.win { color: var(--you-ink); }
.result-head h1.loss { color: var(--riv-ink); }
.score-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.score-vs .side { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.score-vs .side .nm { font-weight: 700; color: var(--ink-2); font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-vs .big { font-family: var(--num-font); font-size: 46px; font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; }
.score-vs .pts { font-size: 12px; color: var(--ink-2); font-weight: 650; margin-top: -2px; }
.score-vs .side.p1 .big { color: var(--you-ink); }
.score-vs .side.p2 .big { color: var(--riv-ink); }
.omap { width: 96px; height: 96px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border-radius: 10px; background: var(--b-thick); }
.omap i { border-radius: 3px; background: var(--surface-3); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; font-style: normal; }
.omap i.o1 { background: var(--you); } .omap i.o2 { background: var(--riv); }
.omap-label { font-size: 12px; color: var(--ink-2); font-weight: 650; text-align: center; }
.gains { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gain { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-width: 0; }
.gain .v { font-size: 20px; font-weight: 850; }
.gain .v.up { color: var(--good); } .gain .v.down { color: var(--bad); }
.gain .l { font-size: 12px; color: var(--ink-2); font-weight: 650; }
.xpcard { display: flex; flex-direction: column; gap: 8px; }
.nextun { display: flex; align-items: center; gap: 10px; }
.nextrival { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; }
.nextrival .avs { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; flex: none; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; text-align: center; }
.stat b { font-size: 20px; font-weight: 850; font-variant-numeric: tabular-nums; }
.stat small { font-size: 12px; color: var(--ink-2); font-weight: 650; line-height: 1.2; }
.newbest { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--gold); color: #fff; font-weight: 800; font-size: 13px; }
.res-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; }
.cal-head h2 { flex: 1; text-align: center; font-size: 18px; font-weight: 800; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-3); padding: 4px 0; }
.cal .day {
  aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; position: relative;
  font-weight: 700; font-size: 15px; background: var(--surface-2); color: var(--ink);
}
.cal .day.empty { background: transparent; }
.cal .day.future { color: var(--ink-3); background: transparent; }
.cal .day.today { box-shadow: inset 0 0 0 2px var(--you); }
.cal .day.solved { background: var(--you); color: #fff; }
.cal .day.late { background: var(--you-soft); color: var(--you-ink); }
.cal .day .mk { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); }
.cal .day.sel { outline: 3px solid var(--riv); outline-offset: -3px; }
.legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); font-weight: 650; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; }

/* ---------- versus card ---------- */
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 6px 0 4px; }
.vs .side { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.vs .side b { font-size: 16px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs .avs { width: 76px; height: 76px; border-radius: 50%; overflow: hidden; }
.vs .avs svg { width: 100%; height: 100%; }
.vs .vsx { font-weight: 900; color: var(--ink-3); font-size: 18px; }
.quote { font-style: italic; color: var(--ink-2); margin: 8px 0 2px; }

/* ---------- duel hub, ladder, settings extras ---------- */
.league-card { gap: 14px; align-items: center; }
.league-card .grow { display: flex; flex-direction: column; gap: 6px; }
.league-card .row { gap: 6px; flex-wrap: wrap; }
.league-card .row b { font-size: 16px; }
.lg-name { font-size: 20px; font-weight: 850; }
.statgrid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; }
.statgrid3 .stat + .stat { border-left: 1px solid var(--line); }
.lvlic.plain { background: var(--surface-2); color: var(--ink); }
.lockface { width: 100%; height: 100%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3); border-radius: 50%; }
.lrow .avs .lockface { width: 52px; height: 52px; }
.lrow .tag { vertical-align: 2px; }
.good { color: var(--good); display: inline-grid; place-items: center; }
.nexttag { padding: 4px 10px; border-radius: 999px; background: var(--you); color: #fff; font-size: 13px; font-weight: 800; white-space: nowrap; }
.bigcd { font-size: 34px; font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: .5px; display: inline-block; margin: 6px 0 0; }
.set.danger-row .t, .set.danger-row .ic { color: var(--bad); }
.set { width: 100%; text-align: left; }
.sheet.tall { max-width: 460px; }
.sheet.tall .sheet-body { text-align: left; }
.sheet.tall h3 { font-size: 16px; font-weight: 800; margin: 14px 0 4px; color: var(--you-ink); }
.sheet.privacy ul { margin: 4px 0 8px; padding-left: 20px; }
.sheet.privacy li { margin: 3px 0; }
.sheet.privacy p, .sheet.privacy li { overflow-wrap: anywhere; }
/* the Privacy link at the foot of the Play-a-friend screen */
.privlink { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px auto 0; min-height: 44px; padding: 0 14px;
  background: none; border: 0; color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 650; text-decoration: underline; cursor: pointer; }
.sheet.tall h3:first-child { margin-top: 2px; }
/* a long popup (How to play) on a short phone: a little tighter, so all of it and its button fit without scrolling */
@media (max-height: 700px) {
  .sheet.tall { padding: 14px 16px 14px; }
  .sheet.tall .sheet-title { padding-bottom: 4px; font-size: 20px; }
  .sheet.tall .sheet-body p { margin: 3px 0; line-height: 1.3; font-size: 15px; }
  .sheet.tall .sheet-body h3 { margin: 8px 0 2px; }
  .sheet.tall .sheet-actions { margin-top: 10px; }
}
.today-card { display: flex; flex-direction: column; gap: 12px; }
.done-line { display: flex; align-items: center; gap: 8px; color: var(--good); font-weight: 750; }
button.troph:active { transform: scale(.96); }
.troph b { font-variant-numeric: tabular-nums; }

.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--surface-3); border-top-color: var(--you); animation: spin .9s linear infinite; margin: 8px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- small phones ---------- */
@media (max-height: 700px) {
  .game { gap: 6px; padding: 4px 8px 8px; }
  .key { min-height: 50px; font-size: 24px; }
  .key small { font-size: 10px; margin-top: 2px; }
  .tool .ico { height: 32px; }
  .tool { font-size: 12px; padding: 3px 2px; gap: 2px; }
  .status { min-height: 38px; }
  .ava { width: 42px; height: 42px; }
  .pcard { padding: 6px 8px; }
  .pscore { font-size: 24px; }
  .mainbtn { min-height: 140px; }
  .page { gap: 12px; }
}
@media (max-width: 370px) {
  .pad { gap: 4px; }
  .key { font-size: 24px; border-radius: 10px; }
  .page { --pad: 12px; }
  .seg button { padding: 8px 8px; font-size: 13px; }
  /* both daily cards keep their title on one line (in Spanish one wrapped and the other did not) */
  .daily b { font-size: 14.5px; }
}
/* tall phones: the board is already as wide as the screen allows, so some of the spare height goes to the
   controls (number keys up to 72 px tall, bigger tool buttons) */
@media (min-height: 780px) {
  .game { gap: 10px; padding-bottom: 14px; }
  .key { min-height: clamp(62px, 8.6vh, 72px); font-size: 30px; }
  .key small { font-size: 12px; margin-top: 5px; }
  .tool { font-size: 14px; gap: 4px; }
  .tool .ico { width: 50px; height: 40px; }
}
/* ---------- Live Duel ---------- */
.live .lbl { display: block; font-weight: 700; font-size: 15px; margin: 8px 0 6px; }
.live .field {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: 18px; font-weight: 650;
}
.live .field:focus { outline: none; border-color: var(--you); }
.live .field.code { text-align: center; letter-spacing: 4px; font-size: 26px; font-weight: 800; text-transform: uppercase; }
.live .err { color: var(--bad); font-weight: 650; min-height: 18px; margin-top: 6px; }
.live .notice p { font-weight: 650; }
.live .res-actions { display: flex; flex-direction: column; gap: 10px; }
.live .card + .card, .live .card + .res-actions { margin-top: 12px; }
.bigcode { font-size: 44px; font-weight: 850; letter-spacing: 6px; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.lobby-players { display: flex; flex-direction: column; gap: 10px; }
.lp { display: flex; align-items: center; gap: 12px; }
.lp .avs { width: 40px; height: 40px; flex: none; }
.lp b { font-size: 18px; overflow-wrap: anywhere; }
.lp.away { opacity: .5; }
.lp .ok { color: var(--good, #1F8A4C); }
.live .seg { margin-top: 8px; }
.live .seg button { flex: 1; }
.live .seg button[aria-disabled="true"] { cursor: default; }
/* Start before both are in: plainly switched off (round 7: it looked ready and did nothing) */
.live .btn[aria-disabled="true"] { opacity: .42; box-shadow: none; }
.live .btn[aria-disabled="true"]:active { transform: none; }
.live .sharenote { overflow-wrap: anywhere; margin-top: 6px; }
.countdown { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 82%, transparent); }
.countdown b { font-size: 120px; font-weight: 900; color: var(--you); animation: cdpop .9s ease-out both; }
@keyframes cdpop { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); opacity: 1; } }
.game.duel { position: relative; }

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