:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d1b24; --muted: #6b6878; --line: #e4e0d6;
  --accent: #e8452c; --accent-ink: #fff; --gold: #f5b700; --ok: #1f9d55; --soft: #fff4d6;
  --radius: 16px; --shadow: 0 2px 10px rgba(30, 25, 50, .07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131a; --card: #1f1d27; --ink: #f1eff6; --muted: #a29fb0; --line: #34313f;
    --accent: #ff6a4f; --soft: #2b2617; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] { --bg: #14131a; --card: #1f1d27; --ink: #f1eff6; --muted: #a29fb0; --line: #34313f; --accent: #ff6a4f; --soft: #2b2617; --shadow: none; color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; display: flex; flex-direction: column; }
main { width: 100%; max-width: 560px; margin: 0 auto; padding: 12px 16px 24px; flex: 1; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: .4em 0; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .9rem; }
.ok { color: var(--ok); font-weight: 600; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; letter-spacing: -.02em; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.gtitle { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.gtitle small { color: var(--muted); font-size: .78rem; }
.brand + .gtitle ~ .icon { margin-left: 0; }
.top > .icon:last-child { margin-left: auto; }
.icon { border: 0; background: transparent; font-size: 1.25rem; padding: 6px; border-radius: 10px; cursor: pointer; color: var(--ink); }
.icon:hover { background: var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin: 12px 0; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 12px 16px; border-radius: 12px; font: inherit; font-weight: 650; cursor: pointer; touch-action: manipulation; min-height: 44px; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.row > .btn { flex: 1; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 44px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 8px 0; }
label > input, label > select { margin-top: 4px; font-weight: 400; }
.form { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.form > input, .form > select { flex: 1 1 140px; width: auto; }
.form > .btn { flex: 0 0 auto; }
input.code { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; flex: 0 1 130px; }

.result .big { text-align: center; margin: 6px 0 10px; }
.result .score { font-size: 3rem; font-weight: 900; letter-spacing: -.03em; color: var(--accent); }
.result .max { color: var(--muted); font-weight: 600; }
.submit { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.tabs { display: flex; gap: 4px; margin: 14px 0 8px; background: var(--bg); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .88rem; font-weight: 650; padding: 8px 4px; border-radius: 9px; cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
ol.lb { list-style: none; padding: 0; margin: 0; }
ol.lb li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
ol.lb li.me { background: var(--soft); border-radius: 8px; font-weight: 700; }
ol.lb .rk { width: 28px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
ol.lb .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ol.lb .nm small { color: var(--muted); font-weight: 400; }
ol.lb .sc { font-weight: 800; font-variant-numeric: tabular-nums; }

.notice { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20; max-width: 560px; margin: 0 auto; display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.15); font-size: .85rem; }
.notice p { margin: 0; flex: 1; }
.duel { max-width: 528px; margin: 10px 16px 0; background: var(--soft); border: 1px solid var(--gold); border-radius: 12px; padding: 10px 12px; font-weight: 600; }
@media (min-width: 560px) { .duel { margin: 10px auto 0; } }
.toast { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -20px); opacity: 0; transition: .25s; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 30; font-weight: 600; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal { border: 0; border-radius: 18px; padding: 16px; width: min(480px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
.modal::backdrop { background: rgba(0,0,0,.45); }
.mhead { display: flex; align-items: center; justify-content: space-between; }
.bigcode { font-size: 2.2rem; font-weight: 900; letter-spacing: .25em; text-align: center; margin: 8px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 16px 16px 80px; }

/* hub */
.hero { text-align: center; padding: 8px 0 4px; }
.hero p { color: var(--muted); margin: 4px 0; }
.games { display: grid; gap: 12px; }
.gcard { display: flex; gap: 14px; align-items: center; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.gcard .em { font-size: 2rem; width: 52px; height: 52px; display: grid; place-items: center; background: var(--bg); border-radius: 14px; flex: none; }
.gcard .tx { flex: 1; min-width: 0; }
.gcard b { display: block; font-size: 1.1rem; }
.gcard small { color: var(--muted); }
.pill { font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.done { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.new { background: var(--accent); color: var(--accent-ink); }

/* generic game bits */
.qcard { font-size: 1.25rem; font-weight: 700; }
.cat { display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.big-input { font-size: 1.6rem; font-weight: 800; text-align: center; letter-spacing: .02em; }
.preview { text-align: center; color: var(--muted); min-height: 1.4em; margin: 6px 0; font-variant-numeric: tabular-nums; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: center; margin: 8px 0; }
.compare div { background: var(--bg); border-radius: 12px; padding: 10px 6px; }
.compare b { display: block; font-size: 1.15rem; }
.compare small { color: var(--muted); }
.scale { position: relative; height: 64px; margin: 14px 8px 4px; }
.scale .axis { position: absolute; left: 0; right: 0; top: 30px; height: 4px; border-radius: 2px; background: var(--line); }
.scale .mk { position: absolute; transform: translateX(-50%); font-size: .72rem; font-weight: 700; text-align: center; white-space: nowrap; display: flex; flex-direction: column; align-items: center; }
.scale .mk i { display: block; width: 4px; height: 16px; border-radius: 2px; background: currentColor; }
.scale .mk.you { top: 0; flex-direction: column-reverse; color: var(--accent); }
.scale .mk.ans { top: 24px; color: var(--ok); }
.scale .mk.crowd { top: 22px; color: var(--muted); font-size: 0; }
.scale .mk.crowd i { width: 3px; height: 20px; opacity: .7; }
.src { font-size: .8rem; color: var(--muted); word-break: break-all; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.stats-table th, .stats-table td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: right; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
