/* Daily Puzzles — one stylesheet, mobile first, light and dark */
:root {
  --bg: #f6f5fb; --surface: #ffffff; --surface-2: #efedf7; --surface-3: #e4e1f0;
  --text: #1c1b29; --muted: #6b6880; --line: #e3e0ee; --shadow: 0 1px 2px rgba(28,27,41,.06), 0 6px 20px rgba(28,27,41,.07);
  --accent: #5b4fe0; --accent-2: #7c6ff0; --accent-soft: #ebe8ff; --on-accent: #fff;
  --hit: #2f9e5f; --near: #d9a520; --miss: #8a879c; --key: #e4e1ee; --key-text: #1c1b29;
  --good: #2f9e5f; --warn: #d9a520; --bad: #e5484d;
  --radius: 16px; --radius-sm: 10px;
  --tabbar-h: 64px; --topbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #121219; --surface: #1c1c26; --surface-2: #262632; --surface-3: #31313f;
  --text: #f1f0f7; --muted: #a09db3; --line: #2f2e3c; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --accent: #8d83ff; --accent-2: #a69eff; --accent-soft: #2b2850; --on-accent: #fff;
  --hit: #3bab6c; --near: #c9981d; --miss: #4a4859; --key: #3a3949; --key-text: #f1f0f7;
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #121219; --surface: #1c1c26; --surface-2: #262632; --surface-3: #31313f;
  --text: #f1f0f7; --muted: #a09db3; --line: #2f2e3c; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --accent: #8d83ff; --accent-2: #a69eff; --accent-soft: #2b2850; --on-accent: #fff;
  --hit: #3bab6c; --near: #c9981d; --miss: #4a4859; --key: #3a3949; --key-text: #f1f0f7;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; min-height: 100dvh; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
#view:focus { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar and navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 16px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.08rem; color: var(--text); letter-spacing: -.02em; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: conic-gradient(from 210deg, #22a06b, #0ea5e9, #8b5cf6, #e5484d, #f59e0b, #22a06b); position: relative; box-shadow: 0 2px 8px rgba(91,79,224,.3); }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border-radius: 4px; background: var(--bg); }
.topnav { display: none; gap: 4px; margin-left: 12px; }
.topnav a { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .95rem; }
.topnav a:hover { color: var(--text); background: var(--surface-2); }
.topnav a.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.avatar-btn { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: .9rem; color: var(--text); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); font-size: 18px; line-height: 1; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 36px; }
.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .7rem; font-weight: 600; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent); }
body.in-game .tabbar, body.in-game .topbar { display: none; }
main { max-width: 1120px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px); }
body.in-game main { padding: 0; max-width: none; }
@media (min-width: 860px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  main { padding: 24px 24px 64px; }
  .topbar { padding: 0 24px; }
}

/* ---------- common pieces ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 650; font-size: .95rem; white-space: nowrap; transition: transform .08s, background .15s, box-shadow .15s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: color-mix(in srgb, var(--warn) 80%, var(--text)); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-2); border-radius: 12px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; padding: 7px clamp(9px, 2.6vw, 14px); border-radius: 9px; font-weight: 650; font-size: .875rem; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 650; font-size: .875rem; margin-bottom: 6px; }
.input, select.input { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 1rem; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; cursor: pointer; }
.switch input { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; transition: background .2s; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.error-text { color: var(--bad); font-size: .9rem; font-weight: 600; min-height: 1.2em; margin: 4px 0 10px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 42px; margin-bottom: 8px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 18px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- toast, modal, bottom sheet ---------- */
#toast { position: fixed; left: 50%; top: 18px; z-index: 100; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 700; font-size: .95rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal-wrap { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; background: rgba(10,10,20,.45); animation: fade .2s; }
.modal { position: relative; width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 26px 20px calc(20px + var(--safe-b)); box-shadow: 0 -10px 40px rgba(0,0,0,.2); animation: sheet .28s cubic-bezier(.2,.9,.3,1.1); }
.modal::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--surface-3); }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal h2 { padding-right: 40px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; }
@media (min-width: 640px) {
  .modal-wrap { align-items: center; }
  .modal { border-radius: 22px; padding: 28px; animation: pop .22s cubic-bezier(.2,.9,.3,1.2); }
  .modal::before { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { transform: translateY(100%); } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }

/* ---------- today board ---------- */
.hero { display: grid; gap: 14px; margin-bottom: 20px; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero h1 { font-size: 1.75rem; margin: 0; }
.hero .date-nav { display: flex; align-items: center; gap: 4px; }
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.stat b { display: block; font-size: 1.35rem; font-weight: 800; line-height: 1.15; }
.stat span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #c06cf0); transition: width .5s; }
.late-banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--text); font-size: .9rem; font-weight: 550; }
.games { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .games { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 1000px) { .games { grid-template-columns: repeat(5, 1fr); } }
.gcard { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); color: var(--text); overflow: hidden; transition: transform .15s, box-shadow .15s; min-height: 168px; }
.gcard:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 14px 30px rgba(0,0,0,.1); }
.gcard:active { transform: scale(.98); }
.gcard::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--g); opacity: .9; }
.gicon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(140deg, var(--g), color-mix(in srgb, var(--g) 60%, #000)); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--g) 40%, transparent); flex: none; }
.gicon svg { width: 28px; height: 28px; }
.gcard h3 { margin: 0; font-size: 1.02rem; }
.gcard p { margin: 0; font-size: .8rem; color: var(--muted); line-height: 1.35; }
.gcard .gfoot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.gcard .score { font-weight: 800; font-size: 1.05rem; color: var(--g); }
.gcard.done { background: linear-gradient(180deg, color-mix(in srgb, var(--g) 9%, var(--surface)), var(--surface) 70%); }
.gcard .tick { position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--g); color: #fff; }
.gcard .tick svg { width: 16px; height: 16px; }
.gcard .tick.lost { background: var(--miss); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; }
.board-side { display: grid; gap: 14px; margin-top: 20px; }
@media (min-width: 860px) { .board-side { grid-template-columns: 1fr 1fr; } }
.mini-rank li { padding: 9px 0; }
.mini-rank .pos { width: 26px; text-align: center; font-weight: 800; color: var(--muted); }

/* ---------- calendar ---------- */
.cal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; max-width: 640px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; letter-spacing: .04em; }
.cal-day { position: relative; aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: .95rem; background: var(--surface-2); color: var(--text); border: 0; padding: 0; }
.cal-day:disabled { background: transparent; color: color-mix(in srgb, var(--muted) 50%, transparent); cursor: default; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day svg { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); transform: rotate(-90deg); }
.cal-day .n { position: relative; }
.cal-day.full { background: var(--accent); color: var(--on-accent); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: .8rem; color: var(--muted); }
.cal-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 6px; }
.cal-layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .cal-layout { grid-template-columns: minmax(0, 640px) 1fr; align-items: start; } }

/* ---------- rankings ---------- */
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.filters .row { gap: 8px; }
.rank-table { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.rank-row { display: grid; grid-template-columns: 40px 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-row.head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); padding: 10px 14px; background: var(--surface-2); }
.rank-row .pos { font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.rank-row .pos.p1 { color: #d4a017; } .rank-row .pos.p2 { color: #9aa0a6; } .rank-row .pos.p3 { color: #c47a3a; }
.rank-row .who { font-weight: 650; }
.rank-row .who.anon { color: var(--muted); font-weight: 500; font-style: italic; }
.rank-row .nums { display: flex; gap: 16px; font-variant-numeric: tabular-nums; text-align: right; }
.rank-row .nums span { min-width: 44px; }
.rank-row .nums .main { font-weight: 800; }
.rank-row.me { background: var(--accent-soft); }
.rank-row.gap { padding: 2px; text-align: center; color: var(--muted); display: block; }
.my-rank { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); margin-bottom: 14px; background: linear-gradient(120deg, var(--accent), #b05ce8); color: #fff; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent); }
.my-rank .big { font-size: 2rem; font-weight: 800; line-height: 1; }
.my-rank .small { opacity: .9; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 8px; margin: 6px 0 16px; }
.podium > div { text-align: center; }
.podium .stand { margin-top: 8px; border-radius: 12px 12px 4px 4px; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 1.2rem; }
.podium .p1 .stand { height: 76px; background: linear-gradient(#f2c94c, #d4a017); }
.podium .p2 .stand { height: 56px; background: linear-gradient(#cfd4d9, #9aa0a6); }
.podium .p3 .stand { height: 42px; background: linear-gradient(#e0a66b, #c47a3a); }
.podium .name { font-weight: 700; font-size: .85rem; margin-top: 4px; }
.podium .name.anon { color: var(--muted); font-style: italic; font-weight: 500; }
.podium .pts { font-size: .78rem; color: var(--muted); font-weight: 600; }

/* ---------- groups ---------- */
.group-list { display: grid; gap: 12px; }
@media (min-width: 700px) { .group-list { grid-template-columns: repeat(2, 1fr); } }
.group-card { display: flex; align-items: center; gap: 14px; color: var(--text); }
.group-badge { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; color: #fff; flex: none; }
.invite-box { display: flex; gap: 8px; align-items: center; padding: 10px 10px 10px 14px; border-radius: 12px; background: var(--surface-2); font-family: ui-monospace, monospace; font-size: .9rem; }
.code-big { font-size: 1.6rem; font-weight: 800; letter-spacing: .18em; font-family: ui-monospace, monospace; }
.two-col { display: grid; gap: 16px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1.4fr 1fr; align-items: start; } }

/* ---------- me / stats ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.profile-head h1 { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.game-stats { display: grid; gap: 12px; }
@media (min-width: 700px) { .game-stats { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1050px) { .game-stats { grid-template-columns: repeat(3, 1fr); } }
.gs-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.gs-head .gicon { width: 38px; height: 38px; border-radius: 11px; }
.gs-head .gicon svg { width: 22px; height: 22px; }
.gs-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.gs-nums b { display: block; font-size: 1.1rem; font-weight: 800; }
.gs-nums span { font-size: .7rem; color: var(--muted); font-weight: 600; }
.dist { margin-top: 12px; display: grid; gap: 4px; }
.dist-row { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: center; font-size: .78rem; font-weight: 700; }
.dist-row i { display: block; height: 18px; min-width: 22px; border-radius: 5px; background: var(--surface-3); color: var(--text); font-style: normal; text-align: right; padding-right: 6px; line-height: 18px; font-size: .72rem; }
.dist-row i.top { background: var(--g, var(--accent)); color: #fff; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 14px 10px; border-radius: 14px; background: var(--surface-2); }
.badge .ic { font-size: 30px; line-height: 1; filter: grayscale(1); opacity: .35; }
.badge.got { background: linear-gradient(160deg, var(--accent-soft), var(--surface)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 40%, transparent); }
.badge.got .ic { filter: none; opacity: 1; }
.badge b { font-size: .85rem; }
.badge span { font-size: .72rem; color: var(--muted); line-height: 1.3; }
.avatar-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.avatar-pick button { aspect-ratio: 1; border-radius: 12px; border: 2px solid transparent; background: var(--surface-2); font-size: 24px; }
.avatar-pick button.on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- auth ---------- */
.auth { max-width: 420px; margin: 4vh auto 0; }
.auth .card { padding: 26px 22px; }
.auth h1 { text-align: center; }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: .92rem; }
.invite-banner { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--accent-soft); margin-bottom: 16px; }

/* ---------- game screen ---------- */
.game { --g: var(--accent); min-height: 100dvh; display: flex; flex-direction: column; }
.game-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.game-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.game-title .gicon { width: 34px; height: 34px; border-radius: 10px; }
.game-title .gicon svg { width: 20px; height: 20px; }
.game-title b { display: block; font-size: 1rem; line-height: 1.2; }
.game-title span { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9rem; color: var(--muted); padding: 0 8px; }
.game-body { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 14px 12px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.game-body.wide { max-width: 980px; }
.game-note { text-align: center; color: var(--muted); font-weight: 600; font-size: .9rem; min-height: 1.4em; margin: 0; }
.game-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.done-bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--g) 12%, var(--surface)); font-weight: 650; }
.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.pop-in { animation: popin .25s; }
@keyframes popin { 50% { transform: scale(1.08); } }

/* result sheet */
.result-top { text-align: center; padding: 8px 0 4px; }
.result-top .emoji { font-size: 52px; line-height: 1; }
.result-top .pts { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--g, var(--accent)); margin: 10px 0 2px; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.result-stats div { text-align: center; padding: 10px 4px; border-radius: 12px; background: var(--surface-2); }
.result-stats b { display: block; font-size: 1.15rem; font-weight: 800; }
.result-stats span { font-size: .7rem; color: var(--muted); font-weight: 600; }
.reveal { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-weight: 600; margin-top: 8px; }
.guest-nudge { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--accent-soft); font-size: .92rem; }
canvas.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

/* ---------- on-screen keyboard ---------- */
.kb { display: grid; gap: 7px; user-select: none; margin: auto -12px calc(-16px - var(--safe-b)); padding: 8px 6px calc(8px + var(--safe-b)); position: sticky; bottom: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.kb-row { display: flex; gap: 5px; justify-content: center; }
.key { flex: 1; max-width: 46px; height: clamp(44px, 7dvh, 56px); border: 0; border-radius: 8px; background: var(--key); color: var(--key-text); font-weight: 700; font-size: 1.05rem; display: grid; place-items: center; padding: 0; transition: background .2s; touch-action: manipulation; }
.key.wide { max-width: 72px; flex: 1.6; font-size: .8rem; }
.key:active { filter: brightness(.9); transform: translateY(1px); }
.key.c { background: var(--hit); color: #fff; } .key.p { background: var(--near); color: #fff; } .key.a { background: var(--miss); color: #fff; }
.key svg { width: 22px; height: 22px; }

/* ---------- word rows ---------- */
.wg-boards { display: grid; gap: 10px; justify-content: center; }
.wg-boards.b4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wg-board { display: grid; gap: 5px; align-content: start; }
.wg-board.solved { opacity: .85; }
.wg-row { display: grid; grid-template-columns: repeat(var(--len), 1fr); gap: 5px; }
.wg-cell { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; border: 2px solid var(--line); font-weight: 800; text-transform: uppercase; font-size: clamp(1.1rem, 6vw, 1.9rem); background: var(--surface); transition: transform .15s; }
.b1 .wg-board { width: min(340px, 86vw, calc((100dvh - 330px) * .82)); min-width: 200px; }
.b1.len8 .wg-board { width: min(440px, 94vw, calc((100dvh - 330px) * 1.3)); }
.b1.len8 .wg-cell { font-size: clamp(1rem, 5vw, 1.5rem); }
.b4 .wg-cell { border-width: 1.5px; border-radius: 5px; font-size: clamp(.75rem, 3.6vw, 1.05rem); }
.b4 .wg-row { gap: 3px; } .b4 .wg-board { gap: 3px; padding: 6px; border-radius: 10px; background: var(--surface-2); }
.b4 .wg-board.solved { background: color-mix(in srgb, var(--hit) 18%, var(--surface-2)); }
.wg-cell.typed { border-color: var(--muted); animation: popin .12s; }
.wg-cell.c, .wg-cell.p, .wg-cell.a { color: #fff; border-color: transparent; }
.wg-cell.c { background: var(--hit); } .wg-cell.p { background: var(--near); } .wg-cell.a { background: var(--miss); }
.wg-cell.flip { animation: flip .45s both; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.wg-row.live .wg-cell:empty { border-color: var(--line); }

/* ---------- clusters ---------- */
.cl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cl-tile { aspect-ratio: 1.15; border: 0; border-radius: 12px; background: var(--surface-2); font-weight: 800; font-size: clamp(.62rem, 3.1vw, .95rem); text-transform: uppercase; padding: 4px 2px; overflow-wrap: anywhere; line-height: 1.1; color: var(--text); transition: transform .1s, background .15s; touch-action: manipulation; }
.cl-tile.long { font-size: clamp(.52rem, 2.5vw, .8rem); }
.cl-tile.xlong { font-size: clamp(.46rem, 2.15vw, .72rem); letter-spacing: -.02em; }
.cl-tile.on { background: var(--text); color: var(--bg); transform: scale(.96); }
.cl-bar { border-radius: 12px; padding: 12px; text-align: center; animation: popin .3s; color: #1c1b29; }
.cl-bar strong { display: block; text-transform: uppercase; font-size: .92rem; letter-spacing: .02em; }
.cl-bar span { font-size: .85rem; font-weight: 600; text-transform: uppercase; }
.cl-bar.g0 { background: #f7d774; } .cl-bar.g1 { background: #a8d672; } .cl-bar.g2 { background: #a5c3f0; } .cl-bar.g3 { background: #c9a7e8; }
.cl-bar.missed { opacity: .7; }
.cl-solved { display: grid; gap: 8px; }
.lives { display: flex; gap: 8px; justify-content: center; align-items: center; font-weight: 600; color: var(--muted); font-size: .9rem; }
.lives i { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-3); }
.lives i.on { background: var(--text); }

/* ---------- threadline ---------- */
.tl-theme { text-align: center; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--g) 14%, var(--surface)); }
.tl-theme small { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
.tl-theme b { font-size: 1.15rem; }
.tl-current { text-align: center; font-weight: 800; font-size: 1.3rem; letter-spacing: .08em; min-height: 1.6em; }
.tl-board { position: relative; width: min(100%, 360px, calc((100dvh - 300px) * .75)); min-width: 230px; margin: 0 auto; aspect-ratio: 6 / 8; touch-action: none; user-select: none; }
.tl-board svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.tl-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(8, 1fr); }
.tl-cell { display: grid; place-items: center; }
.tl-cell span { width: 78%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: clamp(1rem, 5vw, 1.35rem); transition: background .15s, color .15s; }
.tl-cell.sel span { background: var(--surface-3); }
.tl-cell.found span { background: #a5c3f0; color: #1c1b29; }
.tl-cell.span span { background: #f7d774; color: #1c1b29; }
.tl-cell.hint span { box-shadow: inset 0 0 0 2.5px var(--g); }
.tl-found { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* ---------- pocket crossword ---------- */
.mini-wrap { display: grid; gap: 12px; }
@media (min-width: 900px) { .game-body.wide .mini-wrap { grid-template-columns: minmax(0, 380px) 1fr; align-items: start; } }
.clue-bar { display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: 12px; background: color-mix(in srgb, var(--g) 14%, var(--surface)); min-height: 60px; }
.clue-bar .txt { flex: 1; font-weight: 650; text-align: center; font-size: .98rem; line-height: 1.3; }
.clue-bar .txt b { color: var(--g); margin-right: 6px; }
.mini-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; width: min(100%, 380px, calc(100dvh - 420px)); min-width: 230px; margin: 0 auto; border: 2.5px solid var(--text); border-radius: 6px; overflow: hidden; background: var(--text); }
.mini-cell { position: relative; aspect-ratio: 1; background: var(--surface); border: 1px solid color-mix(in srgb, var(--text) 30%, transparent); display: grid; place-items: center; font-weight: 700; font-size: clamp(1.4rem, 8vw, 2.1rem); text-transform: uppercase; cursor: pointer; }
.mini-cell.block { background: var(--text); cursor: default; }
.mini-cell .num { position: absolute; top: 2px; left: 4px; font-size: .62rem; font-weight: 700; color: var(--muted); }
.mini-cell.word { background: color-mix(in srgb, var(--g) 16%, var(--surface)); }
.mini-cell.cur { background: color-mix(in srgb, var(--g) 45%, var(--surface)); }
.mini-cell.wrong { color: var(--bad); }
.mini-cell.wrong::after { content: ""; position: absolute; inset: auto 20% 10%; height: 2px; background: var(--bad); }
.mini-cell.revealed::before { content: ""; position: absolute; top: 0; right: 0; border: 7px solid transparent; border-top-color: var(--g); border-right-color: var(--g); }
.mini-cell.solved { color: var(--g); }
.clue-lists { display: none; }
@media (min-width: 900px) { .game-body.wide .clue-lists { display: grid; gap: 12px; } }
.clue-lists h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.clue-lists li { padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: .92rem; display: flex; gap: 8px; }
.clue-lists li b { min-width: 16px; }
.clue-lists li.on { background: color-mix(in srgb, var(--g) 16%, var(--surface)); }
.clue-lists li.done { color: var(--muted); text-decoration: line-through; }

/* ---------- sudoku ---------- */
.sd-grid { display: grid; grid-template-columns: repeat(9, 1fr); width: min(100%, 460px, calc(100dvh - 300px)); min-width: 280px; margin: 0 auto; border: 2.5px solid var(--text); border-radius: 8px; overflow: hidden; background: var(--surface); user-select: none; }
.sd-cell { position: relative; aspect-ratio: 1; display: grid; place-items: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: clamp(1.1rem, 5.6vw, 1.7rem); font-weight: 600; color: var(--accent); cursor: pointer; }
.sd-cell:nth-child(9n) { border-right: 0; }
.sd-cell:nth-child(9n+3), .sd-cell:nth-child(9n+6) { border-right: 2px solid var(--text); }
.sd-cell.r2, .sd-cell.r5 { border-bottom: 2px solid var(--text); }
.sd-cell.r8 { border-bottom: 0; }
.sd-cell.given { color: var(--text); font-weight: 800; }
.sd-cell.peer { background: color-mix(in srgb, var(--g) 7%, var(--surface)); }
.sd-cell.same { background: color-mix(in srgb, var(--g) 22%, var(--surface)); }
.sd-cell.cur { background: color-mix(in srgb, var(--g) 38%, var(--surface)); }
.sd-cell.clash { color: var(--bad); }
.sd-cell.wrong { color: var(--bad); text-decoration: underline wavy; }
.sd-cell.hinted { color: var(--good); }
.sd-notes { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, 1fr); font-size: clamp(.45rem, 2vw, .66rem); color: var(--muted); font-weight: 600; line-height: 1; }
.sd-notes span { display: grid; place-items: center; }
.numpad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; width: min(100%, 460px); margin: 0 auto; }
.numpad button { height: clamp(44px, 7dvh, 54px) !important; }
.numpad button { height: 54px; border: 0; border-radius: 10px; background: var(--surface-2); font-size: 1.35rem; font-weight: 700; color: var(--text); position: relative; touch-action: manipulation; }
.numpad button.used { opacity: .3; }
.numpad.notes button { color: var(--muted); font-size: 1rem; }
.tools { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 60px; padding: 4px 8px; border: 0; border-radius: 12px; background: transparent; font-size: .72rem; font-weight: 700; color: var(--muted); }
.tool svg { width: 24px; height: 24px; color: var(--text); }
.tool.on { background: var(--accent-soft); color: var(--accent); }
.tool.on svg { color: var(--accent); }
.tool:hover { background: var(--surface-2); }

/* ---------- tiles ---------- */
.mj-wrap { width: 100%; display: grid; place-items: center; padding: 8px 0; }
.mj-board { position: relative; isolation: isolate; z-index: 0; }
.mj-tile { position: absolute; border: 0; padding: 0; border-radius: 7px; background: linear-gradient(160deg, #fffdf6, #f1ead6); box-shadow: 2px 3px 0 #cdbf9b, 3px 5px 0 #a8996f, 0 6px 10px rgba(0,0,0,.18); display: grid; place-items: center; line-height: 1; transition: transform .12s, filter .15s, opacity .25s; color: #000; }
:root[data-theme="dark"] .mj-tile { filter: brightness(.94); }
.mj-tile.blocked { filter: brightness(.82) saturate(.7); }
.mj-tile.sel { transform: translate(-2px, -3px); background: linear-gradient(160deg, #fff6c4, #ffd76a); box-shadow: 2px 3px 0 #d3a93b, 3px 5px 0 #a47d20, 0 8px 14px rgba(0,0,0,.25); }
.mj-tile.hint { animation: glow 1s 2; }
.mj-tile.gone { opacity: 0; transform: scale(.6); pointer-events: none; }
@keyframes glow { 50% { background: linear-gradient(160deg, #e8f9ec, #a6e3b5); } }

/* ---------- map games ---------- */
.map-box { position: relative; width: 100%; aspect-ratio: 2 / 1.08; border-radius: 16px; overflow: hidden; background: color-mix(in srgb, #3b82f6 10%, var(--surface)); touch-action: none; box-shadow: inset 0 0 0 1px var(--line); }
.map-box svg { width: 100%; height: 100%; display: block; cursor: grab; }
.map-box path { fill: var(--surface-3); stroke: var(--surface); stroke-width: .5; vector-effect: non-scaling-stroke; transition: fill .3s; }
.map-box path.start { fill: #3b82f6; }
.map-box path.target { fill: #e5484d; }
.map-box path.g { fill: #2f9e5f; } .map-box path.o { fill: #f59e0b; } .map-box path.r { fill: #9ca3af; }
.map-box path.answer { fill: #2f9e5f; }
.map-zoom { position: absolute; right: 8px; bottom: 8px; display: grid; gap: 6px; }
.map-zoom button { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--surface); box-shadow: var(--shadow); font-weight: 800; font-size: 1.1rem; }
.guess-box { position: relative; }
.guess-box .input { padding-right: 96px; }
.guess-box .btn { position: absolute; right: 4px; top: 4px; min-height: 40px; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; max-height: 240px; overflow-y: auto; }
.suggest button { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; background: transparent; font-weight: 600; }
.suggest button.on, .suggest button:hover { background: var(--surface-2); }
.guess-list { display: grid; gap: 6px; }
.guess-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.05); font-weight: 650; animation: popin .25s; }
.guess-item .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.guess-item .km { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; font-size: .9rem; }
.route-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-weight: 700; }
.route-line .end { padding: 6px 12px; border-radius: 999px; color: #fff; }
.route-line .end.a { background: #3b82f6; } .route-line .end.b { background: #e5484d; }
.legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: .78rem; color: var(--muted); font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.heat { height: 10px; border-radius: 999px; background: linear-gradient(90deg, #7f1d1d, #e5484d, #f59e0b, #fde68a, #e0f2fe); }

/* ---------- admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.admin-table th, .admin-table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table-scroll { overflow-x: auto; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.bars div { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.board-side .card + .card { margin-top: 0; }

svg { flex: none; }
.b4 .wg-cell { aspect-ratio: 1.18; }
