/* Gauntle — design system
   System fonts only (no font files to license or load). */
:root {
  --bg: #0E1116;
  --surface: #151922;
  --surface-2: #1A1F2A;
  --surface-3: #212735;
  --border: #262D3B;
  --border-strong: #343D50;
  --text: #E7EBF2;
  --muted: #A0A9B8;
  --primary: #A5B4FC;
  --primary-ink: #141833;
  --primary-soft: rgba(165, 180, 252, .12);
  --cyan: #22D3EE;
  --purple: #A78BFA;
  --amber: #FBBF24;
  --red: #FF5C7A;
  --accent: var(--primary);
  --radius: 14px;
  --radius-sm: 10px;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --display: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --maxw: 1180px;
  --topbar-h: 64px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 12px);
}
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(165, 180, 252, .07), transparent 60%),
    radial-gradient(700px 400px at -10% 10%, rgba(34, 211, 238, .05), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.02em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 850; }
h2 { font-size: 1.35rem; font-weight: 800; }
p { margin: 0 0 .9em; }
a { color: var(--cyan); text-underline-offset: 3px; }
a:hover { color: var(--text); }
code, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
kbd { font-family: var(--mono); font-size: .75rem; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: max(16px, 1rem); }
img, svg { display: block; }
[hidden] { display: none !important; }
::selection { background: var(--primary); color: var(--primary-ink); }

:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }
main:focus, h1:focus { outline: none; }

.sr-only, .sr-only-input {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 16px; border-radius: 10px;
  background: var(--primary); color: var(--primary-ink); font-weight: 800; text-decoration: none;
  transform: translateY(-160%); transition: transform 160ms var(--ease-out);
}
.skip-link:focus { transform: none; }
.noscript { padding: 40px; text-align: center; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 14px; }
.row.wrap { flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.accent { color: var(--primary); }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--primary); margin-bottom: 12px; }
.h-sm { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin: 18px 0 8px; }
.h-md { font-size: 1.25rem; margin: 0; }
.h-lg { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 850; margin: 0 0 8px; }

/* accents per game */
.accent-green { --accent: var(--primary); }
.accent-cyan { --accent: var(--cyan); }
.accent-purple { --accent: var(--purple); }
.accent-red { --accent: var(--red); }
.accent-amber { --accent: var(--amber); }

/* ---------- layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 28px;
}
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.page-head h1 { margin-bottom: 6px; }
.page-head p:last-child { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---------- topbar & nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(7, 11, 18, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { max-width: var(--maxw); margin: 0 auto; height: var(--topbar-h); padding: 0 16px; display: flex; align-items: center; gap: 24px; }
.brand { text-decoration: none; color: var(--text); }
.logo { display: inline-flex; align-items: center; gap: 1px; color: var(--primary); text-decoration: none; }
.logo-mark { width: 1.45rem; height: 1.45rem; flex: none; transform: translateY(1px); }
.logo-text { font: 800 1.6rem/1 var(--display); letter-spacing: -.02em; color: var(--text); }
.nav { margin-left: auto; }
.nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 700; font-size: .95rem;
  transition: color 150ms ease, background-color 150ms ease;
}
.nav-link[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.me { gap: 8px; padding: 5px 8px; }
.me-level { font: 800 .75rem var(--mono); padding: 4px 8px; border-radius: 8px; border: 1px solid rgba(165, 180, 252, .4); color: var(--primary); }


.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 30%;
  color: var(--av);
  background: color-mix(in srgb, var(--av) 16%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--av) 45%, transparent);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid transparent; font-weight: 800; font-size: .95rem; letter-spacing: .01em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(255, 92, 122, .5); }
.btn-lg { min-height: 52px; padding: 12px 24px; font-size: 1.02rem; border-radius: 14px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); cursor: pointer;
  touch-action: manipulation; transition: transform 140ms var(--ease-out), border-color 150ms ease;
}
.icon-btn:active { transform: scale(.94); }
.linklike { background: none; border: 0; padding: 0; color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

@media (hover: hover) and (pointer: fine) {
  .nav-link:hover { color: var(--text); background: var(--surface-2); }
  .nav-link[aria-current="page"]:hover { color: var(--primary); background: var(--primary-soft); }
  .btn-primary:hover { background: #C3CDFD; }
  .btn-secondary:hover, .btn-ghost:hover, .icon-btn:hover { border-color: var(--primary); }
  .btn-danger:hover { background: rgba(255, 92, 122, .1); }
  .linklike:hover { color: var(--text); }
}

/* ---------- chips, badges, progress ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; background: var(--surface-3); color: var(--muted); border: 1px solid var(--border-strong);
}
.chip.xs { font-size: .68rem; padding: 1px 7px; margin-left: 8px; }
.chip-green { color: var(--primary); background: var(--primary-soft); border-color: rgba(165, 180, 252, .35); }
.chip-cyan { color: var(--cyan); background: rgba(34, 211, 238, .1); border-color: rgba(34, 211, 238, .35); }
.chip-amber { color: var(--amber); background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .35); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.diff { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.diff-bars { display: inline-flex; gap: 2px; align-items: flex-end; }
.diff-bars i { width: 4px; border-radius: 2px; background: var(--border-strong); }
.diff-bars i:nth-child(1) { height: 7px; } .diff-bars i:nth-child(2) { height: 11px; } .diff-bars i:nth-child(3) { height: 15px; }
.diff-bars i.on { background: var(--accent); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; border: 1px solid var(--border); }
.progress-lg { height: 12px; }
.progress-fill { height: 100%; background: var(--primary); transform-origin: left; transition: transform 600ms var(--ease-out); }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: .86rem; color: var(--muted); margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(34, 211, 238, .05); border: 1px solid rgba(34, 211, 238, .18); }
.note .icon { color: var(--cyan); flex: none; margin-top: 2px; }

.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.stat-label { display: inline-flex; gap: 6px; align-items: center; font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat-value { font: 800 1.35rem var(--display); font-variant-numeric: tabular-nums; }
.stat-accent .stat-value { color: var(--primary); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-grid-6 { grid-template-columns: repeat(6, 1fr); }




.game-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); flex: none; }
.game-icon.sm { width: 34px; height: 34px; border-radius: 10px; }
.game-icon.lg { width: 60px; height: 60px; }

/* ---------- overview / leaderboard ---------- */
.lb-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.lb-rank { display: inline-flex; align-items: center; gap: 4px; min-width: 44px; font: 800 1rem var(--mono); color: var(--muted); }
.lb-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lb-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { font-size: .78rem; }
.lb-score { font: 800 1.15rem var(--mono); color: var(--text); }
.lb-row.top-1 { border-color: rgba(251, 191, 36, .55); background: linear-gradient(90deg, rgba(251, 191, 36, .1), var(--surface) 55%); }
.lb-row.top-1 .lb-rank, .lb-row.top-1 .lb-score { color: var(--amber); }
.lb-row.top-2 { border-color: rgba(226, 232, 240, .35); }
.lb-row.top-2 .lb-rank { color: #E2E8F0; }
.lb-row.top-3 { border-color: rgba(251, 146, 60, .4); }
.lb-row.top-3 .lb-rank { color: #FB923C; }
.lb-row.is-highlight { box-shadow: inset 3px 0 0 var(--cyan); }
.banner-local { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid rgba(34, 211, 238, .3); background: rgba(34, 211, 238, .06); }
.banner-local .icon { color: var(--cyan); flex: none; margin-top: 3px; }
.banner-local p { margin: 0; color: var(--muted); }
.banner-local b { color: var(--text); }
.lb-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tabs { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.tab { min-height: 40px; padding: 8px 16px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 800; cursor: pointer; transition: color 150ms ease, background-color 150ms ease; }
.tab[aria-selected="true"] { background: var(--primary); color: var(--primary-ink); }
.field-inline { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--muted); }
.select, .input {
  min-height: 44px; padding: 8px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
}
.select:focus-visible, .input:focus-visible { outline: 3px solid var(--cyan); outline-offset: 1px; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 36px 16px; color: var(--muted); }
.empty .icon { color: var(--border-strong); margin-bottom: 8px; }
.empty h3, .empty h1 { color: var(--text); margin: 0; font-size: 1.15rem; }
.empty .btn { margin-top: 10px; }

/* ---------- daily ---------- */
.howto { margin: 0 0 8px; padding-left: 20px; color: var(--text); }
.howto li { margin-bottom: 6px; }
.history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.history-row { display: grid; grid-template-columns: 1.4fr 1fr .8fr auto; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: 0; }
.history-row b { font-family: var(--mono); color: var(--primary); text-align: right; min-width: 70px; }

/* ---------- runner ---------- */
.runner { display: flex; flex-direction: column; gap: 16px; }
.runner-head { display: flex; flex-direction: column; gap: 10px; }
.back-link { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); text-decoration: none; font-weight: 700; font-size: .9rem; align-self: flex-start; padding: 4px 0; }
.back-link:hover { color: var(--text); }
.runner-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.runner-title h1 { margin: 0; }
.challenge-banner { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; background: rgba(167, 139, 250, .1); border: 1px solid rgba(167, 139, 250, .4); color: var(--text); }
.challenge-banner .icon { color: var(--purple); flex: none; }
.challenge-banner.is-win { background: var(--primary-soft); border-color: rgba(165, 180, 252, .45); }
.challenge-banner.is-win .icon { color: var(--primary); }
.challenge-banner.is-loss { background: rgba(255, 92, 122, .08); border-color: rgba(255, 92, 122, .4); }
.challenge-banner.is-loss .icon { color: var(--red); }

.play { display: flex; flex-direction: column; gap: 12px; }
.hud { display: flex; align-items: center; gap: 16px; padding: 10px 12px 10px 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.hud-block { display: flex; flex-direction: column; line-height: 1.1; }
.hud-label { font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.hud-score { font: 800 1.7rem var(--mono); color: var(--primary); min-width: 5ch; }
.hud-timer { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; color: var(--muted); }
.hud-timer-text { font: 800 1.05rem var(--mono); color: var(--text); min-width: 5ch; }
.hud-timer-bar { flex: 1; height: 8px; border-radius: 9px; background: var(--surface-3); overflow: hidden; }
.hud-timer-fill { height: 100%; background: var(--cyan); transform-origin: left; }
.hud-timer.is-low .hud-timer-fill { background: var(--red); }
.hud-timer.is-low .hud-timer-text { color: var(--red); }
.hud-info { font: 700 .92rem var(--mono); color: var(--muted); margin-left: auto; }
.hud-actions { display: flex; gap: 8px; }
.stage-wrap { position: relative; }
.stage { min-height: 420px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); overflow: hidden; position: relative; }
.stage-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(7, 11, 18, .78); backdrop-filter: blur(4px); border-radius: var(--radius); z-index: 5; }
.countdown-num { font: 900 7rem/1 var(--display); color: var(--primary); }
.countdown-num.tick { animation: tick 400ms var(--ease-out); }
@keyframes tick { from { transform: scale(1.25); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.pause-card { display: flex; flex-direction: column; gap: 10px; min-width: 240px; padding: 24px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border-strong); text-align: center; }

/* results */
.results { display: flex; flex-direction: column; gap: 20px; border-color: rgba(165, 180, 252, .25); }
.results-top { text-align: center; display: flex; flex-direction: column; align-items: center; }
.result-score { font: 900 clamp(3.5rem, 12vw, 6rem)/1 var(--display); color: var(--primary); letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 4px 0 14px; }
.results-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; }
.pb-chip { animation: pop 500ms var(--ease-out) 300ms both; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.results-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.results-level { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.results-ach .h-sm { margin-top: 0; }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Click Frenzy */
.cf-arena { position: absolute; inset: 0; cursor: crosshair; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  background-image: radial-gradient(circle at center, rgba(165, 180, 252, .05) 1px, transparent 1px); background-size: 24px 24px; }
.cf-arena.is-miss { animation: miss 220ms ease-out; }
@keyframes miss { 0% { box-shadow: inset 0 0 0 2px rgba(255, 92, 122, .7); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
.cf-target {
  position: absolute; padding: 0; border-radius: 50%; cursor: pointer; border: 0;
  background: radial-gradient(circle, var(--primary-ink) 0 18%, var(--primary) 19% 38%, var(--primary-ink) 39% 55%, var(--primary) 56%);
  box-shadow: 0 0 18px rgba(165, 180, 252, .55);
  animation: target-in 160ms var(--ease-out);
  touch-action: manipulation;
}
.cf-target.is-hit { animation: target-hit 180ms var(--ease-out) forwards; pointer-events: none; }
.cf-target.is-expired { animation: target-out 180ms ease-out forwards; pointer-events: none; }
@keyframes target-in { from { transform: scale(.6); opacity: 0; } }
@keyframes target-hit { to { transform: scale(1.5); opacity: 0; } }
@keyframes target-out { to { transform: scale(.7); opacity: 0; } }
.cf-pop { position: absolute; transform: translate(-50%, -50%); font: 900 1.1rem var(--mono); pointer-events: none; animation: rise 600ms var(--ease-out) forwards; }
.cf-pop.good { color: var(--primary); }
.cf-pop.bad { color: var(--red); }
@keyframes rise { to { transform: translate(-50%, -150%); opacity: 0; } }

/* Color Memory */
.cm-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 16px; }
.cm-status { font-weight: 800; font-size: 1.1rem; min-height: 1.6em; margin: 0; text-align: center; }
.cm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(100%, 380px); padding: 8px; border-radius: 18px; transition: box-shadow 200ms ease; }
.cm-grid.is-ok { box-shadow: 0 0 0 2px var(--primary); }
.cm-grid.is-bad { box-shadow: 0 0 0 2px var(--red); animation: shake 300ms ease; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.cm-tile {
  position: relative; aspect-ratio: 1; border-radius: 16px; cursor: pointer;
  border: 2px solid color-mix(in srgb, var(--tile) 55%, transparent);
  background: color-mix(in srgb, var(--tile) 16%, var(--surface-2));
  transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms var(--ease-out);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.cm-tile:disabled { cursor: default; }
.cm-tile.is-lit, .cm-tile.is-press { background: var(--tile); box-shadow: 0 0 26px var(--tile); transform: scale(1.04); }
.cm-tile.is-press { animation: press 200ms ease-out; }
@keyframes press { to { background: color-mix(in srgb, var(--tile) 16%, var(--surface-2)); box-shadow: none; transform: scale(1); } }
.cm-num { position: absolute; top: 6px; left: 9px; font: 800 .8rem var(--mono); color: var(--muted); }
.cm-tile.is-lit .cm-num { color: var(--primary-ink); }

/* Typing Rush */
.tr-wrap { padding: 28px clamp(16px, 4vw, 40px); display: flex; flex-direction: column; gap: 18px; }
.tr-phrase { font: 600 clamp(1.15rem, 2.6vw, 1.6rem)/1.7 var(--mono); margin: 0; color: var(--muted); word-break: break-word; }
.tr-phrase span.ok { color: var(--primary); }
.tr-phrase span.bad { color: var(--red); background: rgba(255, 92, 122, .16); border-radius: 3px; }
.tr-phrase span.cur { box-shadow: inset 0 -3px 0 var(--cyan); color: var(--text); }
.tr-input { width: 100%; min-height: 54px; padding: 12px 16px; border-radius: 12px; font: 600 1.1rem var(--mono); background: var(--bg); border: 2px solid var(--border-strong); color: var(--text); }
.tr-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.tr-hint { margin: 0; font-size: .88rem; color: var(--muted); }

/* Dodge Zone */
.dz-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; }
.dz-canvas { width: min(100%, 420px, calc((100dvh - 280px) * .75)); min-width: 240px; aspect-ratio: 3 / 4; border-radius: 12px; border: 1px solid var(--border-strong); touch-action: none; cursor: crosshair; }
.dz-pad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 6px; }
.dz-pad-btn { display: grid; place-items: center; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.dz-pad-btn:active { background: var(--primary); color: var(--primary-ink); }
.dz-up { grid-column: 2; grid-row: 1; } .dz-left { grid-column: 1; grid-row: 2; } .dz-down { grid-column: 2; grid-row: 2; } .dz-right { grid-column: 3; grid-row: 2; }
@media (hover: hover) and (pointer: fine) { .dz-pad { display: none; } }

/* Pattern Rush */
.pr-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 28px 16px; }
.pr-kind { margin: 0; font-size: .78rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.pr-seq { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pr-item { display: inline-grid; place-items: center; min-width: 54px; height: 54px; padding: 0 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font: 800 1.6rem var(--mono); color: var(--text); }
.pr-item.is-small { font-size: .95rem; letter-spacing: -.05em; color: var(--cyan); }
.pr-q { color: var(--amber); border: 2px dashed var(--amber); }
.pr-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: min(100%, 560px); }
.pr-choice { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px 12px; border-radius: 14px; background: var(--surface-2); border: 2px solid var(--border-strong); cursor: pointer; touch-action: manipulation; transition: border-color 120ms ease, transform 120ms var(--ease-out); }
.pr-choice .pr-item { background: transparent; border: 0; }
.pr-choice:active:not(:disabled) { transform: scale(.96); }
.pr-choice.is-right { border-color: var(--primary); background: var(--primary-soft); }
.pr-choice.is-wrong { border-color: var(--red); background: rgba(255, 92, 122, .1); }
.pr-choice:disabled { cursor: default; }
@media (hover: hover) and (pointer: fine) { .pr-choice:hover:not(:disabled) { border-color: var(--amber); } .cm-tile:hover:not(:disabled) { border-color: var(--tile); } }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 22px; align-items: center; }
.profile-head h1 { margin: 0 0 2px; word-break: break-word; }
.profile-head .progress { margin: 10px 0 6px; max-width: 520px; }
.profile-head .chip { align-self: flex-start; }
.records { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.record { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.record .grow { display: flex; flex-direction: column; }
.record small { font-size: .78rem; }
.record-score { font-family: var(--mono); color: var(--primary); }
.profile-form { display: flex; flex-direction: column; gap: 8px; }
.profile-form .btn { align-self: flex-start; margin-top: 8px; }
.label { font-weight: 800; font-size: .9rem; }
.hint { font-size: .82rem; color: var(--muted); margin: 0 0 8px; }
.avatar-pick { border: 0; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.avatar-pick legend { margin-bottom: 8px; }
.avatar-opt { position: relative; cursor: pointer; border-radius: 16px; padding: 3px; border: 2px solid transparent; transition: border-color 150ms ease; }
.avatar-opt:has(input:checked) { border-color: var(--primary); }
.avatar-opt:has(input:focus-visible) { outline: 3px solid var(--cyan); outline-offset: 2px; }
.ach-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.ach { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid rgba(251, 191, 36, .4); }
.ach h4 { margin: 0 0 2px; font-size: 1rem; }
.ach p { margin: 0; font-size: .84rem; color: var(--muted); }
.ach .ach-date { color: var(--amber); font-size: .76rem; margin-top: 4px; }
.ach-icon { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 12px; background: rgba(251, 191, 36, .12); color: var(--amber); }
.ach.is-locked { border-color: var(--border); }
.ach.is-locked .ach-icon { background: var(--surface-3); color: var(--muted); }
.ach.is-locked h4 { color: var(--muted); }
.privacy-card { border-color: rgba(34, 211, 238, .25); }
.privacy-status { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 14px; font-weight: 700; }
.privacy-status .icon { color: var(--cyan); }
.privacy-card .row { margin-bottom: 12px; }

/* ---------- account & admin ---------- */
.account-card { border-color: rgba(165, 180, 252, .25); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; margin: 6px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.form-status { color: var(--red); font-weight: 700; margin: 4px 0 0; min-height: 1.2em; }
.form-status:empty { display: none; }
.sent { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; background: var(--primary-soft); border: 1px solid rgba(165, 180, 252, .35); }
.sent .icon { color: var(--primary); flex: none; }
.sent p { margin: 4px 0 0; }
.auth-card { max-width: 520px; margin: 40px auto; width: 100%; }
.admin { display: flex; flex-direction: column; gap: 20px; }
.admin .table td { vertical-align: middle; }
.admin .table .row { gap: 8px; }
.admin-actions { display: flex; gap: 6px; justify-content: flex-end; }
tr.is-banned td { opacity: .6; }
.results-global:empty { display: none; }
.results-global { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.results-global .results-stats { width: 100%; }

/* ---------- legal ---------- */
.legal-layout { display: grid; grid-template-columns: 230px 1fr; gap: 24px; align-items: start; }
.legal-nav { position: sticky; top: calc(var(--topbar-h) + 20px); }
.legal-nav ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.legal-nav a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 700; }
.legal-nav a:hover { color: var(--text); background: var(--surface-2); }
.legal-nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.legal { max-width: 780px; }
.legal h2 { font-size: 1.1rem; margin-top: 1.6em; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal .muted.small { display: inline-flex; gap: 6px; align-items: center; }
.missing { color: var(--amber); font-weight: 700; background: rgba(251, 191, 36, .08); border-radius: 4px; padding: 0 4px; }
.table-wrap { overflow-x: auto; margin: 0 0 16px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; }
.dl dt { color: var(--muted); font-weight: 700; }
.dl dd { margin: 0; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 28px 16px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px 32px; align-items: flex-start; }
.footer-inner .logo { margin-bottom: 8px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.footer-links a, .footer-links .linklike { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

/* ---------- toasts, modal, consent ---------- */
.toasts { position: fixed; z-index: 60; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .6);
  font-weight: 600; font-size: .92rem;
  transition: opacity 200ms ease, transform 200ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(10px); }
}
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
.toast-success .icon { color: var(--primary); }
.toast-error .icon { color: var(--red); }
.toast-info .icon { color: var(--cyan); }

.modal { padding: 0; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface-2); color: var(--text); width: min(440px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8); }
.modal[open] { animation: modal-in 220ms var(--ease-out); }
.modal::backdrop { background: rgba(3, 6, 10, .72); backdrop-filter: blur(3px); }
@keyframes modal-in { from { opacity: 0; transform: scale(.96); } }
.modal-inner { padding: 24px; }
.modal-title { font-size: 1.3rem; }
.modal-body p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.copy-area { width: 100%; padding: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border-strong); resize: vertical; }
.levelup { text-align: center; border-color: rgba(165, 180, 252, .5); }
.levelup .modal-actions { justify-content: center; }
.levelup-body p { color: var(--text) !important; }
.levelup-ring { position: relative; width: 128px; height: 128px; margin: 6px auto 18px; display: grid; place-items: center; border-radius: 50%; border: 4px solid var(--primary); animation: lvl 700ms var(--ease-out); }
.levelup-ring span { font: 900 3.4rem var(--display); color: var(--primary); }
.levelup-ring::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--primary); animation: ring 1.2s var(--ease-out) .2s both; }
@keyframes lvl { from { transform: scale(.7) rotate(-20deg); opacity: 0; } }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }

.consent {
  position: fixed; z-index: 50; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto; display: flex; gap: 18px; align-items: center;
  padding: 18px 20px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border-strong);
  box-shadow: 0 20px 60px -15px rgba(0, 0, 0, .8);
  transition: opacity 240ms ease, transform 240ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(16px); }
}
.consent h2 { display: flex; gap: 8px; align-items: center; font-size: 1.02rem; margin: 0 0 4px; }
.consent h2 .icon { color: var(--cyan); }
.consent p { margin: 0; font-size: .87rem; color: var(--muted); }
.consent-actions { display: flex; flex-direction: column; gap: 8px; flex: none; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .stat-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  :root { --topbar-h: 56px; }
  .legal-layout { grid-template-columns: 1fr; }
  .legal-nav { position: static; }
  .legal-nav ul { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .legal-nav a { white-space: nowrap; background: var(--surface); border: 1px solid var(--border); }
  .consent { flex-direction: column; align-items: stretch; }
  .consent-actions { flex-direction: row; }
  .consent-actions .btn { flex: 1; }
  .history-row { grid-template-columns: 1fr auto; }
  .history-row > :nth-child(2), .history-row > :nth-child(3) { font-size: .8rem; }
}
@media (max-width: 560px) {
  main { gap: 22px; padding-top: 20px; }
  .card { padding: 16px; }
  .stat-grid-6 { grid-template-columns: repeat(2, 1fr); }
  .profile-head { flex-direction: column; align-items: flex-start; }
  .hud { gap: 10px; padding: 8px 10px 8px 14px; }
  .hud-score { font-size: 1.4rem; }
  .hud-info { order: 5; width: 100%; margin-left: 0; font-size: .82rem; }
  .hud-timer { order: 4; flex-basis: 100%; }
  .hud-actions { margin-left: auto; }
  .stage { min-height: 380px; }
  .pr-choices { grid-template-columns: repeat(2, 1fr); }
  .results-actions .btn { flex: 1 1 calc(50% - 10px); }
  .results-actions .btn-lg { flex-basis: 100%; }
  .lb-controls { flex-direction: column; align-items: stretch; }
  .tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
  .section-head { flex-wrap: wrap; }
}

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

/* ---------- Gauntle: calm chrome, one daily focus ---------- */
body { background: radial-gradient(900px 480px at 50% -12%, rgba(165, 180, 252, .07), transparent 70%), var(--bg); }
.topbar { background: transparent; backdrop-filter: none; border-bottom: 0; position: static; }
.nav ul { gap: 2px; align-items: center; }
.nav-link { padding: 8px 10px; }
.nav-label { font-size: .88rem; }
.narrow { width: 100%; max-width: 640px; margin-left: auto; margin-right: auto; }

.gauntlet { width: 100%; max-width: 560px; margin: 2vh auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.g-meta { font: 700 .78rem var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin: 0; }
.g-event { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 6px; }
.g-icon { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 22px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.g-title { font-size: clamp(2.4rem, 9vw, 4rem); font-weight: 900; letter-spacing: -.03em; text-transform: uppercase; margin: 0; line-height: .95; }
.g-tagline { font-size: 1.08rem; color: var(--text); margin: 0; max-width: 46ch; text-wrap: balance; }
.g-rules { font: 600 .74rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0; }
.g-start, .g-done { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 18px; }
.g-cta {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 68px; padding: 16px 24px;
  border-radius: 16px; border: 2px solid var(--primary); background: rgba(165, 180, 252, .1); color: var(--primary);
  font: 900 1.2rem var(--display); letter-spacing: .14em; text-transform: uppercase; text-decoration: none;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, color 150ms ease;
}
.g-cta:active { transform: scale(.98); }
.g-label { font: 700 .74rem var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin: 0; }
.g-score { font: 900 clamp(3.2rem, 14vw, 5rem)/1 var(--display); color: var(--primary); margin: 0; font-variant-numeric: tabular-nums; }
.g-tiles { font-size: 1.6rem; letter-spacing: .1em; margin: 0; }
.g-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.g-next { font-size: .9rem; color: var(--muted); margin: 4px 0 0; }
.g-next .mono { color: var(--text); font-weight: 700; }
.g-streak { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 18px; }
.g-streak p { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.g-streak .icon { color: var(--amber); }
.g-week { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0; }
.g-week li { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font: 700 .72rem var(--mono); color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.g-week li.on { background: rgba(165, 180, 252, .16); border-color: rgba(165, 180, 252, .55); color: var(--primary); }
.g-week li.today { outline: 2px solid var(--border-strong); outline-offset: 2px; }
.g-how { width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 14px; background: rgba(13, 20, 32, .7); padding: 0 16px; margin-top: 10px; }
.g-how summary { cursor: pointer; padding: 14px 0; font: 700 .8rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.g-how ul { padding-left: 18px; margin: 0 0 10px; }
.g-how li { margin-bottom: 6px; }
.g-links { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.g-links a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); text-decoration: none; font: 700 .76rem var(--mono); letter-spacing: .12em; text-transform: uppercase; }

.practice { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.practice-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: rgba(13, 20, 32, .8); border: 1px solid var(--border); color: var(--text); text-decoration: none; transition: border-color 150ms ease; }
.practice-row .grow { display: flex; flex-direction: column; }
.practice-row small { font-size: .84rem; }
.practice-best { display: flex; flex-direction: column; align-items: flex-end; font: 800 1rem var(--mono); color: var(--primary); }
.practice-best small { font: 600 .66rem var(--mono); letter-spacing: .12em; text-transform: uppercase; }

.footer { border-top: 0; background: transparent; }
.footer-inner { justify-content: center; padding: 20px 16px 28px; }
.footer-links { justify-content: center; font-size: .8rem; }
.footer-links a { text-decoration: none; }

@media (hover: hover) and (pointer: fine) {
  .g-cta:hover { background: var(--primary); color: var(--primary-ink); }
  .g-links a:hover { color: var(--text); border-color: var(--border-strong); }
  .practice-row:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
}
@media (max-width: 640px) {
  .me-level { display: none; }
  .gauntlet { margin-top: 0; }
}
.intro { width: 100%; max-width: 560px; margin: 8px auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.intro .g-next { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.intro .note { text-align: left; }
.avatar-img { object-fit: cover; border-radius: 30%; background: var(--surface-2); }
.me { border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 4px; margin-left: 6px; }
.me .avatar, .me .avatar-img { border-radius: 50%; }
.me-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 700; font-size: .9rem; }
.me-signin { color: var(--text); font-weight: 700; font-size: .9rem; }
@media (max-width: 640px) { .me-name { max-width: 9ch; } }

/* ---------- Easy reading: bigger type, plain labels, big targets ---------- */
html { font-size: 112.5%; } /* 18px base; everything in rem scales with it */
body { font-size: 1rem; line-height: 1.6; }
.g-meta, .g-rules, .g-label, .g-how summary, .g-links a, .stat-label, .h-sm, .eyebrow, .hud-label, .practice-best small, .pr-kind, .chip {
  font-family: var(--font); letter-spacing: 0; text-transform: none;
}
.g-meta { font-size: 1rem; font-weight: 600; color: var(--muted); }
.g-rules { font-size: 1rem; font-weight: 400; color: var(--muted); max-width: 40ch; line-height: 1.5; }
.g-label { font-size: 1rem; font-weight: 600; }
.g-how summary { font-size: 1rem; font-weight: 700; color: var(--text); }
.g-links a { font-size: .95rem; font-weight: 600; color: var(--text); padding: 10px 16px; }
.stat-label, .hud-label, .h-sm, .eyebrow { font-size: .85rem; font-weight: 700; }
.g-cta { font-size: 1.25rem; letter-spacing: 0; text-transform: none; min-height: 72px; }
.btn { min-height: 48px; font-size: 1rem; }
.btn-lg { min-height: 56px; font-size: 1.08rem; }
.btn-sm { min-height: 44px; }
.nav-link { min-height: 44px; }
.results-more { max-width: 560px; margin: 0 auto; }
.results-more .results-actions { padding-bottom: 14px; }
@media (max-width: 640px) {
  .topbar-inner { gap: 8px; padding: 10px 10px 0; height: auto; }
  .nav ul { gap: 0; }
  .nav-link { flex-direction: column; gap: 2px; padding: 6px 8px; }
  .nav-link .icon { width: 20px; height: 20px; }
  .nav-label, .me-signin { font-size: .72rem; white-space: nowrap; font-weight: 600; }
  .me-name { display: none; }
  .me { border: 0; border-radius: 10px; padding: 6px 8px; margin-left: 0; }
  .me .avatar, .me .avatar-img { width: 22px !important; height: 22px !important; }
  .me .avatar .icon { width: 13px; height: 13px; }
  .logo-text { font-size: 1.35rem; }
  .logo-mark { width: 1.2rem; height: 1.2rem; }
}
