/* ==========================================================================
   Doku Jam — design system
   Palette derives from the logo: ink, coral, amber, sky, mint (+3 extensions
   for 8 player colors). Real light & dark modes via prefers-color-scheme.
   ========================================================================== */

@font-face {
  font-family: 'Baloo 2';
  src: url('/brand/Baloo2-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* brand */
  --coral: #F94F4F;   --coral-2: #FF7A64;
  --amber: #F79E1B;   --amber-2: #FFC24A;
  --sky:   #2F6FF0;   --sky-2:   #57A0FF;
  --mint:  #1FAE78;   --mint-2:  #43DCA0;
  --violet:#7C5CE0;   --violet-2:#A78BFA;
  --magenta:#E0489A;  --magenta-2:#F97AB8;
  --cyan:  #18A8C0;   --cyan-2:  #4AD4E4;
  --lime:  #66C42B;   --lime-2:  #9BE15D;

  /* 8 player colors (mid-tones tuned for tint readability in both modes) */
  --p0: #F5604F; --p1: #F7A11B; --p2: #3F82F5; --p3: #27BE87;
  --p4: #8E6CF0; --p5: #E85AA6; --p6: #22B9CF; --p7: #7FCC3F;

  /* light theme (warm paper) */
  --bg: #F4F2EC;
  --bg-grad: linear-gradient(180deg, #F8F6F0 0%, #EFEDE5 100%);
  --surface: #FFFFFF;
  --surface-2: #FAF9F5;
  --line: #DAD7CC;
  --line-strong: #3A3F58;
  --text: #1C2033;
  --text-dim: #7A7E92;
  --given: #232842;
  --entry: var(--sky);
  --danger: #E0322F;
  --good: var(--mint);
  --sel: rgba(63, 130, 245, 0.16);
  --peer: rgba(28, 32, 51, 0.055);
  --same: rgba(63, 130, 245, 0.22);
  --shadow: 0 1px 2px rgba(20, 23, 42, .06), 0 8px 24px rgba(20, 23, 42, .09);
  --shadow-lg: 0 4px 12px rgba(20, 23, 42, .12), 0 24px 64px rgba(20, 23, 42, .22);
  --keycap: #FFFFFF;
  --keycap-press: #F1EFE8;
  --tint-mix: 17%;      /* claimed-cell tint strength — subtle, digits first */
  --note-alpha: .85;
  color-scheme: light;
}

/* Dark palette applies when the browser prefers dark (unless the user
   forced light in the app) OR when the user forced dark. The two blocks
   below must stay identical — no build step to dedupe them. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14172A;
    --bg-grad: radial-gradient(120% 90% at 50% -10%, #1E2340 0%, #14172A 62%);
    --surface: #1E2340;
    --surface-2: #242A44;
    --line: #303752;
    --line-strong: #4A5170;
    --text: #F1F2F8;
    --text-dim: #8A90AC;
    --given: #EDEFF8;
    --entry: var(--sky-2);
    --danger: #FF6659;
    --good: var(--mint-2);
    --sel: rgba(87, 160, 255, 0.24);
    --peer: rgba(255, 255, 255, 0.045);
    --same: rgba(87, 160, 255, 0.30);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, .4), 0 24px 64px rgba(0, 0, 0, .55);
    --keycap: #262C4A;
    --keycap-press: #2E355A;
    --tint-mix: 24%;
    --note-alpha: .95;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14172A;
  --bg-grad: radial-gradient(120% 90% at 50% -10%, #1E2340 0%, #14172A 62%);
  --surface: #1E2340;
  --surface-2: #242A44;
  --line: #303752;
  --line-strong: #4A5170;
  --text: #F1F2F8;
  --text-dim: #8A90AC;
  --given: #EDEFF8;
  --entry: var(--sky-2);
  --danger: #FF6659;
  --good: var(--mint-2);
  --sel: rgba(87, 160, 255, 0.24);
  --peer: rgba(255, 255, 255, 0.045);
  --same: rgba(87, 160, 255, 0.30);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .4), 0 24px 64px rgba(0, 0, 0, .55);
  --keycap: #262C4A;
  --keycap-press: #2E355A;
  --tint-mix: 24%;
  --note-alpha: .95;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- reset */

/* touch-action on every element (it doesn't inherit): kills iOS double-tap
   zoom on cells/sheets/whitespace while keeping pinch zoom and scrolling. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; }
html { height: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}
button {
  font: inherit; color: inherit; background: none; border: none;
  cursor: pointer; touch-action: manipulation;
}
input {
  font: inherit; color: var(--text);
}
.hidden { display: none !important; }

h1, h2, h3, .display {
  font-family: 'Baloo 2', -apple-system, sans-serif;
  font-weight: 800;
  letter-spacing: .01em;
}

/* ---------------------------------------------------------------- layout */

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(6px, env(safe-area-inset-top)) 8px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px 8px;
}
.wordmark { height: 34px; display: block; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.iconbtn {
  width: 40px; height: 40px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text-dim);
  transition: transform .12s ease, color .12s ease;
}
.iconbtn:active { transform: scale(.92); }
.iconbtn svg { width: 21px; height: 21px; }
.iconbtn.accent {
  background: linear-gradient(135deg, var(--coral-2), var(--coral));
  color: #fff;
}

/* room chip */
.roomchip {
  display: flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-family: 'Baloo 2', sans-serif; font-weight: 800;
  letter-spacing: .12em; font-size: 15px;
}
.roomchip svg { width: 16px; height: 16px; color: var(--text-dim); }

/* score chips */
.chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 2px 8px; align-items: center;
}
.chips::-webkit-scrollbar { display: none; }
.chip-player {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 8px; border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: opacity .3s;
}
.chip-player.off { opacity: .45; }
.chip-player .dot {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--pc, var(--p0));
  display: grid; place-items: center;
  color: #fff; font-size: 10px; font-weight: 800;
}
.chip-player .score {
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 15px;
  min-width: 14px; text-align: right;
  transition: transform .15s;
}
.chip-player .score.bump { transform: scale(1.45); }

/* meta row */
.meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 8px; min-height: 24px;
  color: var(--text-dim); font-size: 13px; font-weight: 600;
}

/* ---------------------------------------------------------------- board */

#board-wrap { position: relative; }
#board {
  --cell: 40px;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  /* Explicit rows: without this, a row whose 9 cells are all empty has no
     content height and renders shorter than the digit-bearing rows. */
  grid-template-rows: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 2px solid var(--line-strong);
}

.cell {
  position: relative;
  display: grid; place-items: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  transition: background-color .12s ease;
  cursor: pointer;
}
.cell.edge-r { border-right: 2px solid var(--line-strong); }
.cell.edge-b { border-bottom: 2px solid var(--line-strong); }
.cell:nth-child(9n) { border-right: none; }
.cell:nth-child(n+73) { border-bottom: none; }

/* layered highlights */
.cell.peer { background-color: var(--peer); }
.cell.same { background-color: var(--same); }
.cell.sel  { background-color: var(--sel); box-shadow: inset 0 0 0 2px var(--sky-2); }

/* claimed / owner tints (multiplayer) & unit-complete (solo) */
.cell.owned { background-color: color-mix(in srgb, var(--pc) var(--tint-mix), var(--surface)); }
.cell.owned.peer { background-color: color-mix(in srgb, var(--pc) calc(var(--tint-mix) + 8%), var(--surface)); }
/* same-digit highlight is uniform blue regardless of who placed the digit,
   so number patterns read at a glance; ownership shows again on deselect */
.cell.owned.same { background-color: var(--same); }

/* pattern mode: while a digit is highlighted (co-op / after reveal), owner
   tints drop out entirely so only the number pattern remains */
#board.hide-owners .cell.owned { background-color: transparent; }
#board.hide-owners .cell.owned.peer { background-color: var(--peer); }
#board.hide-owners .cell.owned.same { background-color: var(--same); }
#board.hide-owners .cell.owned.sel { background-color: var(--sel); box-shadow: inset 0 0 0 2px var(--sky-2); }
.cell.owned.sel { box-shadow: inset 0 0 0 2px var(--pc); }
.cell.udone { background-color: color-mix(in srgb, var(--mint) 16%, var(--surface)); }
.cell.udone.peer { background-color: color-mix(in srgb, var(--mint) 24%, var(--surface)); }
.cell.udone.same { background-color: color-mix(in srgb, var(--mint) 20%, var(--same)); }

/* multiplayer unit-complete: glow that coexists with owner tints */
.cell.udone-mp { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--mint) 75%, transparent); filter: brightness(1.08) saturate(1.08); }
.cell.udone-mp.sel { box-shadow: inset 0 0 0 2px var(--sky-2), inset 0 0 10px color-mix(in srgb, var(--mint) 40%, transparent); }

.cell .digit {
  font-size: calc(var(--cell) * .54);
  font-weight: 650;
  color: var(--entry);
  line-height: 1;
  z-index: 1;
}
.cell.given .digit { color: var(--given); font-weight: 750; }
.cell.owned .digit { color: var(--given); font-weight: 750; }
.cell.bad .digit { color: var(--danger); }
.cell.bad::after {
  content: ''; position: absolute; inset: 12%;
  border-radius: 30%;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  pointer-events: none;
}

/* notes 3x3 mini-grid */
.cell .notes {
  position: absolute; inset: 4%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}
.cell .notes span {
  display: grid; place-items: center;
  font-size: calc(var(--cell) * .24);
  font-weight: 700;
  color: color-mix(in srgb, var(--text-dim) calc(100% * var(--note-alpha)), transparent);
  line-height: 1;
}
.cell .notes span.by { color: color-mix(in srgb, var(--pc) 85%, var(--text)); }

/* placement pop */
@keyframes pop {
  0% { transform: scale(.4); }
  55% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
.cell .digit.pop { animation: pop .26s cubic-bezier(.2,.9,.3,1.4); }

/* wrong flash */
@keyframes wrongflash {
  0%, 100% { background-color: transparent; }
  25%, 60% { background-color: color-mix(in srgb, var(--danger) 32%, transparent); }
}
@keyframes wrongshake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}
.cell.wrong { animation: wrongflash .55s ease, wrongshake .3s ease; }

/* staggered sweep on unit completion */
@keyframes sweep {
  0% { background-color: transparent; transform: scale(1); }
  40% { background-color: color-mix(in srgb, var(--mint-2) 55%, transparent); transform: scale(1.06); }
  100% { background-color: transparent; transform: scale(1); }
}
.cell .sweeper {
  position: absolute; inset: 0; border-radius: 8px;
  pointer-events: none; z-index: 2;
  animation: sweep .5s ease var(--swd, 0s) both;
}

/* claim pulse (multiplayer) */
@keyframes claimpulse {
  0% { box-shadow: inset 0 0 0 0 color-mix(in srgb, var(--pc) 80%, transparent); }
  60% { box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--pc) 55%, transparent); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}
.cell.claimed-anim { animation: claimpulse .5s ease; }

/* ---------------------------------------------------------------- pad */

#msg {
  min-height: 22px; padding: 6px 6px 2px;
  text-align: center; font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  transition: color .2s;
}
#msg.alert { color: var(--danger); }

#pad { padding-top: 8px; margin-top: auto; }
@media (min-height: 800px) and (max-width: 699px) {
  #pad { padding-bottom: 14px; }
  .meta { padding-bottom: 12px; }
}
.digits {
  display: grid; grid-template-columns: repeat(9, 1fr);
  gap: 6px;
}
.key {
  aspect-ratio: .82;
  max-height: 64px;
  border-radius: 14px;
  background: var(--keycap);
  box-shadow: var(--shadow);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: clamp(20px, 6.4vw, 27px);
  color: var(--text);
  display: grid; place-items: center;
  transition: transform .1s ease, opacity .25s ease, background-color .15s;
  position: relative;
}
.key:active { transform: scale(.9); background: var(--keycap-press); }
.key.done { opacity: .28; pointer-events: none; }
.key.noting { color: var(--sky); font-size: clamp(15px, 4.6vw, 19px); }

.tools {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding-top: 8px;
}
.tools.three { grid-template-columns: 1fr 1fr 1.4fr; }
.toolbtn {
  height: 48px; border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 15px;
  color: var(--text-dim);
  transition: transform .1s, color .15s, background-color .15s, box-shadow .15s;
}
.toolbtn:active { transform: scale(.96); }
.toolbtn svg { width: 19px; height: 19px; }
.toolbtn.on {
  color: #fff;
  background: linear-gradient(135deg, var(--sky-2), var(--sky));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--sky) 45%, transparent);
}
.toolbtn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--coral-2), var(--coral));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--coral) 40%, transparent);
}

/* cooldown veil (versus wrong-entry) */
#cooldown {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(1.5px);
  border-radius: 18px;
  z-index: 5;
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 44px;
  color: var(--danger);
}

/* ---------------------------------------------------------------- sheets */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 12, 26, .45);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .22s ease;
}
.scrim.show { opacity: 1; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(103%);
  transition: transform .28s cubic-bezier(.3, 1.1, .4, 1);
  max-height: 82dvh; overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet .grip {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--line);
  margin: 2px auto 12px;
}
.sheet h2 { font-size: 21px; padding-bottom: 12px; }
.sheet h3 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; padding: 14px 0 8px; }

.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  font-weight: 700; font-size: 16px;
  text-align: left;
  transition: transform .1s, border-color .15s, background-color .15s;
  width: 100%;
}
.menu-item:active { transform: scale(.98); }
.menu-item .mi-icon {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: #fff; flex-shrink: 0;
}
.menu-item .mi-icon svg { width: 20px; height: 20px; }
.menu-item small { display: block; font-weight: 600; font-size: 12.5px; color: var(--text-dim); }
.menu-item.selected { border-color: var(--sky); background: color-mix(in srgb, var(--sky) 9%, var(--surface-2)); }

.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--surface-2); border: 1.5px solid var(--line);
  padding: 4px; border-radius: 14px;
}
.seg button {
  padding: 10px 6px; border-radius: 10px; font-weight: 700; font-size: 14px;
  color: var(--text-dim); transition: all .15s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.seg3 { grid-template-columns: 1fr 1fr 1fr; }

.field { padding: 8px 0; }
.field input {
  width: 100%; padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  font-size: 16px; font-weight: 600;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--sky); }
.field input.code { text-transform: uppercase; letter-spacing: .4em; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 22px; text-align: center; }

.bigbtn {
  width: 100%; padding: 15px;
  border-radius: 16px;
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 17px;
  color: #fff;
  background: linear-gradient(135deg, var(--coral-2), var(--coral));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--coral) 40%, transparent);
  transition: transform .12s;
  margin-top: 10px;
}
.bigbtn:active { transform: scale(.97); }
.bigbtn.alt { background: linear-gradient(135deg, var(--sky-2), var(--sky)); box-shadow: 0 6px 18px color-mix(in srgb, var(--sky) 40%, transparent); }
.bigbtn.ghost { background: var(--surface-2); color: var(--text); box-shadow: none; border: 1.5px solid var(--line); }
.bigbtn:disabled { opacity: .5; pointer-events: none; }

/* history list */
.hist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--line);
}
.hist-item:last-child { border-bottom: none; }
.hist-main { flex: 1; min-width: 0; cursor: pointer; }
.hist-title { font-weight: 700; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.hist-sub { font-size: 12.5px; color: var(--text-dim); padding-top: 2px; }
.badge {
  font-size: 10.5px; font-weight: 800; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 999px;
  color: #fff; background: var(--mint);
  text-transform: uppercase;
}
.hist-bar {
  width: 52px; height: 6px; border-radius: 3px;
  background: var(--surface-2); border: 1px solid var(--line);
  overflow: hidden; flex-shrink: 0;
}
.hist-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--sky-2), var(--sky)); }
.hist-del { color: var(--text-dim); padding: 8px; border-radius: 10px; }
.hist-del svg { width: 18px; height: 18px; }
.hist-del:active { color: var(--danger); }
.hist-del.play:active { color: var(--sky); }

/* replay watch-back viewer */
.replay-img {
  display: block; width: 100%;
  border-radius: 14px;
  margin: 6px 0 14px;
  box-shadow: var(--shadow);
}

/* -------------------------------------------------------------- overlays */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(10, 12, 26, .55);
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
  padding: 20px;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
  padding: 28px 22px 22px;
  text-align: center;
  transform: scale(.85) translateY(12px);
  transition: transform .32s cubic-bezier(.3, 1.3, .4, 1);
}
.overlay.show .card { transform: scale(1) translateY(0); }
.card h2 { font-size: 30px; }
.card .sub { color: var(--text-dim); font-weight: 600; font-size: 14.5px; padding: 6px 0 4px; }
.standings { padding: 12px 0 4px; display: flex; flex-direction: column; gap: 6px; }
.standing {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 14px;
  background: var(--surface-2);
  font-weight: 700; font-size: 15px;
}
.standing .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--pc); color:#fff; font-size:11px; font-weight:800; display:grid; place-items:center; }
.standing .pts { margin-left: auto; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 17px; }
.standing.winner { background: color-mix(in srgb, var(--amber-2) 20%, var(--surface-2)); }

/* scanned cells needing a human look */
.cell.ocrflag { background-color: color-mix(in srgb, var(--amber-2) 30%, var(--surface)); }
.cell.ocrflag.sel { background-color: color-mix(in srgb, var(--amber-2) 42%, var(--surface)); }

/* scan progress bar */
.scanbar {
  height: 8px; border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  margin: 14px 0 2px;
}
.scanbar i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--sky-2), var(--sky));
  transition: width .2s ease;
}

/* read-only archived game viewer */
.mini-board {
  display: grid; grid-template-columns: repeat(9, 1fr);
  width: 100%; aspect-ratio: 1;
  background: var(--surface-2);
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  overflow: hidden;
  margin: 12px 0 2px;
}
.mini-cell {
  display: grid; place-items: center;
  font-size: clamp(11px, 3.6vw, 15px);
  font-weight: 650;
  color: var(--entry);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.mini-cell.given { color: var(--given); font-weight: 750; }
.mini-cell.owned {
  background: color-mix(in srgb, var(--pc) var(--tint-mix), var(--surface));
  color: var(--given);
}
.mini-cell.edge-r { border-right: 2px solid var(--line-strong); }
.mini-cell.edge-b { border-bottom: 2px solid var(--line-strong); }
.mini-cell:nth-child(9n) { border-right: none; }
.mini-cell:nth-child(n+73) { border-bottom: none; }

#confetti-canvas {
  position: fixed; inset: 0; z-index: 60;
  pointer-events: none;
}

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  z-index: 70;
  background: var(--line-strong);
  color: #fff;
  padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: all .25s ease;
  max-width: 88vw; text-align: center;
  box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------- desktop */

@media (min-width: 700px) {
  #app { padding-top: 20px; }
  .wordmark { height: 40px; }
  #board { border-radius: 22px; }
  .key { max-height: 58px; }
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: 420px;
    transform: translate(-50%, -46%) scale(.96);
    opacity: 0;
    border-radius: 24px;
    transition: transform .22s ease, opacity .22s ease;
  }
  .sheet.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .sheet .grip { display: none; }
}

/* -------------------------------------------------------- reduced motion */

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