/* main.berdua — dark, warm, mobile-first.
   One stylesheet for all screens; screens are toggled with [hidden]. */

:root {
  --bg: #14111f;
  --bg-2: #1b1729;
  --surface: #221d33;
  --surface-2: #2b2440;
  --line: #372f4f;
  --text: #f2eefb;
  --muted: #a79cc4;
  --p1: #ffb057;
  --p2: #a78bfa;
  --good: #4ade80;
  --bad: #fb7185;
  --info: #60a5fa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -8%, rgba(255, 176, 87, 0.13), transparent 60%),
    radial-gradient(800px 460px at 92% 4%, rgba(167, 139, 250, 0.15), transparent 62%);
  background-attachment: fixed;
}

a { color: var(--p2); }

.screen { min-height: 100dvh; }
[hidden] { display: none !important; }

/* ---------------- buttons & fields ---------------- */

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--p1), #ff7a59);
  color: #2a1300;
  box-shadow: 0 6px 18px rgba(255, 140, 70, 0.28);
}
.btn-secondary { background: var(--p2); color: #1b1033; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-tiny { padding: 8px 14px; font-size: 13px; background: var(--surface-2); color: var(--text); }
.btn-wide { width: 100%; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); }

input {
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  outline: none;
}
input:focus { border-color: var(--p2); box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.18); }
input::placeholder { color: #6f6590; }

.field { display: block; }
.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; min-height: 18px; text-align: center; }
.hint.bad { color: var(--bad); }
.muted { color: var(--muted); }

/* ---------------- home ---------------- */

.home-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.brand { text-align: center; }
.brand-mark { font-size: 34px; letter-spacing: 6px; }
.brand h1 {
  margin: 10px 0 6px;
  font-size: clamp(30px, 9vw, 42px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand .dot { color: var(--p1); }
.tagline { margin: 0; color: var(--muted); line-height: 1.55; font-size: 15px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.actions { display: grid; gap: 10px; margin-top: 16px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.join-row { display: flex; gap: 8px; }
#code-input {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  text-transform: uppercase;
  padding: 12px 8px 12px 16px;
}

.showcase { display: grid; gap: 12px; }
.show-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.show-card .emoji { font-size: 28px; flex: none; }
.show-card h3 { margin: 0 0 2px; font-size: 16px; }
.show-card p { margin: 0; font-size: 13px; color: var(--muted); }

.site-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.site-foot .sep { opacity: 0.5; }
.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
  transition: background 0.3s ease;
}
.conn-dot.online { background: var(--good); box-shadow: 0 0 8px rgba(74, 222, 128, 0.7); }
.conn-dot.offline { background: var(--bad); }

/* ---------------- queue ---------------- */

.center-card {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
}
.center-card h2 { margin: 0; }
.center-card p { max-width: 320px; margin: 0; line-height: 1.5; }

.spinner {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--p1);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- room ---------------- */

.room-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 120px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.room-head { display: flex; align-items: center; gap: 12px; }
.room-code { flex: 1; text-align: center; }
.room-code-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.room-code strong { font-family: var(--mono); font-size: 26px; letter-spacing: 6px; color: var(--p1); }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.player {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.player.p1 { border-top-color: var(--p1); }
.player.p2 { border-top-color: var(--p2); }
.player.empty { border-style: dashed; opacity: 0.6; justify-content: center; align-items: center; text-align: center; }
.player .who { font-weight: 700; font-size: 16px; word-break: break-word; }
.player .you-tag {
  font-size: 10px; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
  padding: 2px 6px; border-radius: 5px; margin-left: 6px;
  vertical-align: middle;
}
.player .state { font-size: 13px; color: var(--muted); }
.player .state.ready { color: var(--good); font-weight: 600; }
.player .state.off { color: var(--bad); }
.player .wins { font-size: 12px; color: var(--muted); margin-top: auto; }

.section-title { margin: 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.game-picker { display: grid; gap: 10px; }
.game-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.game-opt:hover { background: var(--surface-2); }
.game-opt.selected { border-color: var(--p1); background: rgba(255, 176, 87, 0.08); }
.game-opt .emoji { font-size: 26px; flex: none; }
.game-opt h3 { margin: 0 0 2px; font-size: 16px; }
.game-opt p { margin: 0; font-size: 13px; color: var(--muted); }
.game-opt .check { margin-left: auto; color: var(--p1); font-size: 18px; opacity: 0; }
.game-opt.selected .check { opacity: 1; }

.howto {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.howto h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.howto ul { margin: 0; padding-left: 18px; }
.howto li { font-size: 14px; line-height: 1.55; margin: 5px 0; color: #ddd5f0; }

.ready-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}
.ready-bar > .btn { max-width: 528px; margin: 0 auto; display: block; }
.ready-bar .hint { max-width: 528px; margin: 8px auto 0; }

.result-banner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--p1);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
}

/* ---------------- game shell ---------------- */

.game-wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 12px 14px 90px;
  position: relative;
  min-height: 100dvh;
}
.game-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.game-title { flex: 1; font-weight: 700; font-size: 17px; }

.timer { position: relative; width: 44px; height: 44px; flex: none; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 3; }
.timer-track { stroke: var(--line); }
.timer-fill {
  stroke: var(--p1);
  stroke-linecap: round;
  stroke-dasharray: 100.5;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s ease;
}
.timer.urgent .timer-fill { stroke: var(--bad); }
#timer-text { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

.turn-bar {
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.turn-bar.yours { background: rgba(255, 176, 87, 0.14); border-color: var(--p1); color: var(--p1); }
.turn-bar.theirs { color: var(--muted); }

.board { display: flex; flex-direction: column; gap: 16px; }

.scoreline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.score-chip.p1 { border-left: 3px solid var(--p1); }
.score-chip.p2 { border-left: 3px solid var(--p2); }
.score-chip .name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-chip .val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-chip.active { box-shadow: inset 0 0 0 1px var(--p1); }

.pause-veil {
  position: absolute;
  inset: 0;
  background: rgba(20, 17, 31, 0.86);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 20;
  border-radius: var(--radius);
}
.pause-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 24px; }

/* ---------------- UNO ---------------- */

.uno-table {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 20px 0;
}
.uno-pile { text-align: center; }
.uno-pile .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }

.uno-card {
  width: 68px; height: 98px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  border: 3px solid rgba(255, 255, 255, 0.85);
  position: relative;
  user-select: none;
}
.uno-card.red { background: linear-gradient(160deg, #ff6b6b, #d63447); }
.uno-card.yellow { background: linear-gradient(160deg, #ffd166, #f0a500); color: #4a3200; border-color: rgba(255,255,255,0.9); }
.uno-card.green { background: linear-gradient(160deg, #4ade80, #16a34a); }
.uno-card.blue { background: linear-gradient(160deg, #60a5fa, #2563eb); }
/* Wilds belong to no colour, so the face shows all four at once. */
.uno-card.wild {
  background:
    conic-gradient(from 45deg, #ff6b6b 0deg 90deg, #ffd166 90deg 180deg,
                   #4ade80 180deg 270deg, #60a5fa 270deg 360deg);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}
.uno-card.glyph { font-size: 34px; }
.uno-card.word { font-size: 15px; letter-spacing: 0.5px; }

.active-color {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.active-color.red { color: #ff8787; }
.active-color.yellow { color: #ffd166; }
.active-color.green { color: #6ee7a0; }
.active-color.blue { color: #7cb3ff; }

.color-picker {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 16, 0.78);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 25;
  animation: fadeIn 0.15s ease;
}
.color-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.color-card p { margin: 0 0 14px; font-weight: 700; }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.color-swatch {
  width: 64px; height: 64px;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.color-swatch:hover { transform: scale(1.06); }
.color-swatch:active { transform: scale(0.97); }
.color-swatch.red { background: linear-gradient(160deg, #ff6b6b, #d63447); }
.color-swatch.yellow { background: linear-gradient(160deg, #ffd166, #f0a500); }
.color-swatch.green { background: linear-gradient(160deg, #4ade80, #16a34a); }
.color-swatch.blue { background: linear-gradient(160deg, #60a5fa, #2563eb); }
.uno-card.back {
  background: repeating-linear-gradient(45deg, #3b3357, #3b3357 6px, #2b2440 6px, #2b2440 12px);
  border-color: var(--line);
  font-size: 22px;
  color: var(--muted);
}

.uno-hand-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.uno-hand {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 12px;
  scrollbar-width: thin;
}
.uno-hand .uno-card {
  flex: none;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.uno-hand .uno-card.playable:hover { transform: translateY(-8px); }
.uno-hand .uno-card.dead { opacity: 0.34; filter: grayscale(0.6); cursor: not-allowed; }
.uno-hand .uno-card.new { animation: dealIn 0.35s ease; }
@keyframes dealIn {
  from { transform: translateY(24px) scale(0.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.uno-actions { display: flex; justify-content: center; }
.opp-hand { display: flex; gap: 4px; justify-content: center; }
.opp-hand .mini {
  width: 22px; height: 32px; border-radius: 5px;
  background: repeating-linear-gradient(45deg, #3b3357, #3b3357 4px, #2b2440 4px, #2b2440 8px);
  border: 1px solid var(--line);
}

/* ---------------- Math ---------------- */

.math-problem {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  font-family: var(--mono);
  font-size: clamp(30px, 10vw, 48px);
  font-weight: 700;
  letter-spacing: 1px;
  min-height: 126px;
  display: grid;
  place-items: center;
}
.math-problem.between { font-size: 20px; font-family: var(--font); line-height: 1.5; color: var(--muted); }
.math-problem .big-answer { color: var(--p1); font-family: var(--mono); font-size: 34px; display: block; margin-top: 6px; }
.math-round { text-align: center; font-size: 13px; color: var(--muted); }

.math-form { display: flex; gap: 8px; }
#math-answer {
  font-family: var(--mono);
  font-size: 24px;
  text-align: center;
  letter-spacing: 2px;
}
.math-form .btn { flex: none; }
.math-flash { animation: flashBad 0.4s ease; }
@keyframes flashBad {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* ---------------- Memory ---------------- */

.mem-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.mem-cell {
  /* Positioned so .mem-inner can size itself off the cell instead of relying
     on a percentage height resolving through the aspect-ratio box. */
  position: relative;
  aspect-ratio: 3 / 4;
  border: 0;
  padding: 0;
  background: transparent;
  perspective: 700px;
  cursor: pointer;
}
.mem-inner {
  /* MUST be block: a <button>'s content model only allows phrasing content,
     so this is a <span> — and browsers ignore width, height AND transform on
     non-replaced inline elements. Left inline, the card never flips and the
     back-facing front never becomes visible. */
  display: block;
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.4, 0.1, 0.2, 1.2);
  border-radius: 12px;
}
.mem-cell.up .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: clamp(22px, 7vw, 34px);
}
.mem-back {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--mono);
}
.mem-front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, #3a3157, #2a2340);
  border: 1px solid var(--p2);
  /* A revealed card is always a disabled <button>; state the colour so no UA
     stylesheet dims the emoji to its greyed-out default. */
  color: var(--text);
}
.mem-cell.matched .mem-front { background: linear-gradient(160deg, rgba(74,222,128,0.28), rgba(74,222,128,0.12)); border-color: var(--good); }
.mem-cell.matched { cursor: default; }
.mem-cell.miss .mem-front { border-color: var(--bad); animation: flashBad 0.4s ease; }
.mem-cell:disabled { cursor: default; }

/* ---------------- Dakon ---------------- */

.dakon {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  gap: 8px;
  background: linear-gradient(160deg, #4a3a2a, #32261c);
  border: 1px solid #5c4632;
  border-radius: 20px;
  padding: 10px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.4);
}
.dakon-rows { display: grid; gap: 8px; min-width: 0; }
.dakon-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }

.dakon-hole {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid #6b5238;
  background: radial-gradient(circle at 50% 35%, #241b14, #16100b 70%);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.7);
  color: var(--text);
  font: inherit;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: default;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.dakon-hole .seeds {
  position: relative;
  z-index: 2;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.dakon-hole .pips {
  position: absolute;
  inset: 18%;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 2px;
  z-index: 1;
  opacity: 0.55;
}
.dakon-hole .pips i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #e8c07d;
}
.dakon-hole.empty .pips { display: none; }
.dakon-hole.empty .seeds { opacity: 0.35; }

.dakon-hole.sowable {
  border-color: var(--p1);
  cursor: pointer;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(255, 176, 87, 0.35);
}
.dakon-hole.sowable:hover { transform: translateY(-3px); }
.dakon-hole.lit {
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.6), 0 0 14px 3px rgba(255, 209, 102, 0.85);
  border-color: #ffd166;
}
.dakon-hole.captured { animation: dakonPop 0.5s ease; border-color: var(--good); }
.dakon-hole.taken { animation: dakonPop 0.5s ease; border-color: var(--bad); }
@keyframes dakonPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.dakon-store {
  width: 62px;
  border-radius: 34px;
  border: 1px solid #6b5238;
  background: radial-gradient(circle at 50% 30%, #2c2117, #16100b 75%);
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 4px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.dakon-store .store-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dakon-store .store-count { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dakon-store.you { border-color: var(--p1); }
.dakon-store.opp { border-color: var(--p2); }
.dakon-store.active { box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(255, 176, 87, 0.4); }
.dakon-store.lit { box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.6), 0 0 16px 4px rgba(255, 209, 102, 0.85); }

.dakon-hint { text-align: center; font-size: 12px; color: var(--muted); margin: 10px 0 0; min-height: 16px; }

/* On a narrow phone the two stores eat the width the holes need; trimming them
   keeps each hole at a ~46px touch target instead of dropping to 41px. */
@media (max-width: 460px) {
  .dakon { padding: 7px; gap: 6px; }
  .dakon-store { width: 50px; }
  .dakon-row { gap: 5px; }
  .dakon-rows { gap: 6px; }
}

@media (min-width: 620px) {
  .dakon-store { width: 76px; }
  .dakon-hole .seeds { font-size: 17px; }
}

/* ---------------- chat ---------------- */

.chat { position: fixed; right: 14px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30; }
.chat-toggle {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
}
.chat-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 20px; height: 20px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 5px;
}
.chat-panel {
  position: absolute;
  right: 0; bottom: 62px;
  width: min(320px, calc(100vw - 28px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.chat-log {
  height: 240px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 14px;
}
.chat-msg { line-height: 1.45; word-break: break-word; }
.chat-msg .from { font-weight: 700; margin-right: 5px; }
.chat-msg.p1 .from { color: var(--p1); }
.chat-msg.p2 .from { color: var(--p2); }
.chat-msg.system { color: var(--muted); font-size: 13px; font-style: italic; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { padding: 9px 12px; font-size: 14px; }

/* ---------------- overlay & toasts ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 16, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: popIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }

.result-emoji { font-size: 52px; line-height: 1; }
.result-card h2 { margin: 10px 0 6px; font-size: 24px; }
.result-summary { margin: 0 0 14px; color: var(--muted); line-height: 1.5; }
.result-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.result-actions { display: grid; gap: 10px; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 50;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.2s forwards;
}
.toast.good { border-color: var(--good); color: var(--good); }
.toast.bad { border-color: var(--bad); color: var(--bad); }
.toast.info { border-color: var(--info); color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------------- responsive ---------------- */

@media (min-width: 620px) {
  .uno-card { width: 76px; height: 110px; }
  .mem-grid { gap: 10px; }
}

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