/* Game Hub shared design system — mobile-first. Games reuse these tokens/components. */
:root {
  --bg: #f4f1ea;
  --bg2: #ebe5d8;
  --surface: #fffdf8;
  --ink: #1d2433;
  --muted: #6b7280;
  --line: #ddd5c4;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #d5efe9;
  --danger: #c2410c;
  --warn: #b45309;
  --x: #e0533d;
  --o: #2563eb;
  --win: #facc15;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(30 25 10 / 6%), 0 6px 20px rgb(30 25 10 / 8%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171f; --bg2: #1b1f2a; --surface: #1f2430; --ink: #e8eaf0; --muted: #9aa3b5; --line: #343b4b;
    --primary: #2dd4bf; --primary-ink: #062b28; --primary-soft: #123a37; --danger: #fb923c; --warn: #fbbf24;
    --x: #ff7a66; --o: #6aa1ff; --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.45;
  -webkit-tap-highlight-color: transparent; min-height: 100dvh;
}
a { color: var(--primary); }
[hidden] { display: none !important; }
.offscreen { position: fixed; top: -1000px; left: 0; opacity: 0; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 14px 32px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brand-logo { flex: none; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; color: var(--primary-ink); font-size: 0.95rem; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.9rem; color: var(--ink); max-width: 60vw; }
.chip .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.chip { cursor: pointer; font: inherit; font-size: 0.9rem; }

/* cards & buttons */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.card h2, .card h3 { margin: 0 0 6px; font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--bg2); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.big { font-size: 1.1rem; padding: 14px 18px; min-height: 52px; }
.btn.sm { padding: 8px 12px; min-height: 36px; font-size: 0.9rem; border-radius: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

/* forms */
label.f { display: block; font-size: 0.86rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.input, select.input {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); min-height: 44px;
}
.input:focus, .btn:focus-visible, .chip:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
a.btn { text-decoration: none; }
.stack > p { margin: 0; }
.err { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; margin: 6px 0 0; }

/* hub */
.hero { padding: 22px 2px 8px; }
.hero h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.hero p { margin: 6px 0 0; color: var(--muted); }
.games { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
@media (min-width: 560px) { .games { grid-template-columns: 1fr 1fr; } }
.games > .card { margin-top: 0; } /* grid gap spaces them; .card + .card margin made the right column sit lower */
.game-card { display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; position: relative; }
.game-card.live:active { transform: scale(0.99); }
.game-card .icon { width: 64px; height: 64px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); }
.game-card .icon svg { width: 44px; height: 44px; }
.game-card h3 { margin: 0; }
.game-card p { margin: 3px 0 0; font-size: 0.88rem; color: var(--muted); }
.game-card.soon { opacity: 0.62; }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--muted); vertical-align: middle; margin-left: 6px; }
.badge.live { background: var(--primary-soft); color: var(--primary); }
.banner { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); display: flex; align-items: center; gap: 10px; }
.footer { margin-top: 28px; text-align: center; color: var(--muted); font-size: 0.8rem; }

/* toast & dialogs */
.toasts { position: fixed; left: 0; right: 0; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 0.92rem; max-width: 92vw; box-shadow: var(--shadow); animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
dialog { border: 0; border-radius: 18px; padding: 0; max-width: min(520px, 94vw); width: 100%; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 35%); }
dialog::backdrop { background: rgb(10 12 20 / 45%); }
dialog .dlg { padding: 18px; max-height: 80dvh; overflow: auto; }
dialog h2 { margin: 0 0 8px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.rules-text h3 { font-size: 1rem; margin: 14px 0 4px; }
.rules-text ul { margin: 4px 0; padding-left: 20px; }
.rules-text li { margin: 3px 0; }

/* hub greeting */
.hello { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.hello .grow { flex: 1; min-width: 0; }
.hello-av { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.hello-name { font-weight: 800; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nick-dice { white-space: nowrap; }

/* background music: 🎵 chip + popover (public/js/music.mjs) */
.chip-music { padding: 6px 9px; opacity: 0.6; }
.chip-music.on { opacity: 1; background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.music-pop {
  position: absolute; right: max(14px, calc((100vw - 640px) / 2 + 14px)); top: calc(100% + 6px); width: min(290px, calc(100vw - 28px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 36px rgb(0 0 0 / 22%);
  padding: 12px 14px; z-index: 20;
}
.music-pop p { margin: 8px 0 0; }
.mp-row { display: flex; align-items: center; gap: 10px; }
.mp-row + .mp-row { margin-top: 10px; }
.mp-t { flex: 1; font-weight: 700; }
.mp-vol input { flex: 1; min-width: 0; height: 32px; accent-color: var(--primary); }
.mp-pct { width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.86rem; }
.mp-hint { color: var(--primary) !important; }
.switch { appearance: none; border: 0; width: 52px; height: 30px; border-radius: 999px; background: var(--bg2); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 30%); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"] i { transform: translateX(22px); }
.switch:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
@media (max-width: 380px) { .topbar .wrap { gap: 6px; } }
