:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f2f0ea;
  --text: #17161a;
  --muted: #5d5a66;
  --line: #e4e1d8;
  --accent: #ff5a1f;
  --accent-ink: #ffffff;
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --wait: #dc2626;
  --go: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121116;
    --surface: #1b1a21;
    --surface-2: #24232b;
    --text: #f1eff5;
    --muted: #a7a3b3;
    --line: #2f2d37;
    --accent: #ff6a33;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-head { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.site-head .wrap { display: flex; align-items: center; gap: 20px; height: 58px; }
.logo { font-weight: 800; font-size: 21px; color: var(--text); text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
.logo b { color: var(--accent); }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 600; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover, .nav a[aria-current] { color: var(--text); background: var(--surface-2); }

/* page */
.page-top { padding: 28px 0 8px; }
h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; margin: 0 0 6px; letter-spacing: -.02em; }
.lead { color: var(--muted); margin: 0 0 18px; font-size: 18px; }
h2 { font-size: 26px; line-height: 1.25; margin: 40px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 20px; margin: 26px 0 6px; }
.article { max-width: 720px; }
.article table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 16px; display: block; overflow-x: auto; }
.article th, .article td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.article th { background: var(--surface-2); }
.article blockquote { margin: 16px 0; padding: 4px 16px; border-left: 4px solid var(--accent); color: var(--muted); }
.faq details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0; background: var(--surface); }
.faq summary { font-weight: 650; cursor: pointer; }
.faq details p { margin: 8px 0 2px; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.meta { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* tool shell */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 8px 0 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.btn { border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 10px; cursor: pointer; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn:focus-visible, .seg button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 8px 14px; min-width: 96px; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.big { font-size: clamp(44px, 9vw, 72px); font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.muted { color: var(--muted); }
.result { text-align: center; padding: 18px 8px; }
.result .title { font-size: 22px; font-weight: 800; margin: 10px 0 4px; }
.result .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.hidden { display: none !important; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 50; }

/* typing */
.typer { position: relative; height: 141px; overflow: hidden; cursor: text; font-family: var(--mono); font-size: 27px; }
.typer .words { line-height: 47px; position: relative; color: var(--muted); opacity: .55; transition: transform .14s ease, opacity .2s; user-select: none; display: flex; flex-wrap: wrap; column-gap: 15px; }
.typer.focus .words { opacity: 1; }
.typer .w { white-space: nowrap; border-bottom: 2px solid transparent; line-height: 1.2; height: 47px; display: flex; align-items: center; }
.typer .w.err { border-bottom-color: var(--bad); height: 36px; margin-bottom: 11px; }
.typer .w span.ok { color: var(--text); }
.typer .w span.bad { color: var(--bad); }
.typer .w span.extra { color: #9b1c1c; }
.caret { position: absolute; left: 0; top: 0; width: 3px; height: 30px; border-radius: 2px; background: var(--accent); transition: transform .085s linear; animation: blink 1s step-end infinite; pointer-events: none; }
.typer.live .caret { animation: none; }
.typer:not(.focus) .caret { opacity: 0; }
@keyframes blink { 50% { opacity: 0; } }
.ghost-in { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; border: 0; padding: 0; cursor: text; z-index: 2; }
.veil { position: absolute; inset: 0; display: grid; place-items: center; font: 600 17px system-ui, sans-serif; color: var(--text); background: color-mix(in srgb, var(--surface) 55%, transparent); backdrop-filter: blur(3px); z-index: 1; pointer-events: none; transition: opacity .15s; }
.typer.focus .veil { opacity: 0; }
.live-row { display: flex; gap: 16px; align-items: baseline; height: 34px; }
.live-timer { color: var(--accent); font-weight: 800; font-size: 26px; font-variant-numeric: tabular-nums; }
.live-wpm { color: var(--muted); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
kbd { font: 600 12px var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--text); }
.btn kbd { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.35); color: inherit; margin-left: 4px; }
.daily-bar { font-size: 24px; letter-spacing: 2px; }

/* results */
.pop { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pct { max-width: 420px; margin: 12px auto 6px; }
.pct-text { font-size: 18px; }
.pct-text strong { color: var(--accent); font-size: 22px; }
.pct-bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 6px 0 2px; }
.pct-bar span { display: block; height: 100%; background: linear-gradient(90deg, #ffb38a, var(--accent)); border-radius: 99px; animation: grow .8s ease-out; }
@keyframes grow { from { width: 0 !important; } }
.pct-note { font-size: 12px; color: var(--muted); }
.pb { font-weight: 650; margin: 12px 0 4px; }
.pb.win { color: var(--good); font-size: 19px; }
.spark { display: flex; align-items: flex-end; gap: 10px; justify-content: center; margin: 10px 0; font-size: 13px; }
.spark .bars { display: flex; gap: 4px; align-items: flex-end; height: 40px; }
.spark i { display: block; width: 12px; background: var(--line); border-radius: 3px 3px 0 0; }
.spark i.best { background: var(--good); }
.spark i.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.next { display: inline-block; margin-top: 16px; font-weight: 700; text-decoration: none; }
.chart-wrap { margin: 14px auto 0; max-width: 640px; }
.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; }
.chart .ln { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.a { stroke: var(--accent); }
.chart .ln.b { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-wrap figcaption { display: flex; gap: 14px; justify-content: center; font-size: 13px; color: var(--muted); }
.chart-wrap .key::before { content: ""; display: inline-block; width: 14px; height: 3px; margin-right: 5px; vertical-align: middle; background: var(--accent); }
.chart-wrap .key.b::before { background: var(--muted); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.btn.icon { padding: 8px 11px; }

/* sharing + challenges */
.sharebar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin: 12px 0; }
.page-share .sharebar { justify-content: flex-start; margin: 0 0 10px; }
.sb-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.sb { border: 0; font: 700 13px system-ui, sans-serif; color: #fff; text-decoration: none; padding: 6px 11px; border-radius: 99px; cursor: pointer; }
.sb:hover { filter: brightness(1.1); }
.sb.wa { background: #1fa855; } .sb.x { background: #111; } .sb.fb { background: #1877f2; } .sb.rd { background: #ff4500; }
.sb.tg { background: #229ed9; } .sb.li { background: #0a66c2; } .sb.cp, .sb.more { background: var(--surface-2); color: var(--text); }
@media (prefers-color-scheme: dark) { .sb.x { background: #000; border: 1px solid #444; } }
.challenge { background: linear-gradient(90deg, #ff5a1f, #ff8a3d); color: #fff; font-weight: 650; border-radius: 12px; padding: 12px 16px; margin: 0 0 10px; font-size: 17px; }
.verdict { font-weight: 750; font-size: 18px; margin: 10px 0; }
.verdict.win { color: var(--good); }
.verdict.lose { color: var(--warn); }

/* click areas */
.pad { display: grid; place-items: center; text-align: center; min-height: 300px; border-radius: 12px; background: var(--surface-2); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; font-weight: 700; font-size: 20px; padding: 16px; -webkit-tap-highlight-color: transparent; }
.pad:focus-visible { outline: 3px solid var(--accent); }
.pad.live { background: var(--accent); color: var(--accent-ink); }
.pad.wait { background: var(--wait); color: #fff; }
.pad.go { background: var(--go); color: #fff; }
.pad.early { background: var(--warn); color: #fff; }
.pad .sub { font-weight: 500; font-size: 16px; opacity: .9; }

/* game feel */
.pad { position: relative; overflow: hidden; }
.ripple { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: rgba(255,255,255,.7); pointer-events: none; animation: ripple .45s ease-out forwards; }
@keyframes ripple { to { transform: scale(7); opacity: 0; } }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.35); }
.dots i.on { background: #fff; }
.pad:not(.wait):not(.go):not(.early):not(.live) .dots i { background: var(--line); }
.pad:not(.wait):not(.go):not(.early):not(.live) .dots i.on { background: var(--accent); }
.hud { position: absolute; top: 10px; right: 14px; font-weight: 800; color: var(--muted); pointer-events: none; font-variant-numeric: tabular-nums; }
.burst { position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; border: 3px solid var(--accent); pointer-events: none; animation: ripple .4s ease-out forwards; }
.target.spawn { animation: spawn .12s ease-out; }
@keyframes spawn { from { transform: translate(-50%, -50%) scale(.3); } to { transform: translate(-50%, -50%) scale(1); } }
.spacekey { margin: 16px auto 0; width: min(320px, 70vw); padding: 12px; border-radius: 10px; border: 2px solid rgba(255,255,255,.6); border-bottom-width: 6px; font-weight: 800; letter-spacing: .2em; }
.spacekey.hit { animation: press .1s ease-out; }
@keyframes press { 50% { transform: translateY(4px); border-bottom-width: 2px; } }

/* aim */
.arena { position: relative; height: 420px; border-radius: 12px; background: var(--surface-2); overflow: hidden; cursor: crosshair; touch-action: manipulation; user-select: none; }
.target { position: absolute; border-radius: 50%; background: radial-gradient(circle, #fff 0 18%, var(--accent) 19% 42%, #fff 43% 60%, var(--accent) 61%); transform: translate(-50%, -50%); cursor: pointer; border: 0; padding: 0; }
.arena .center-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-weight: 700; pointer-events: none; padding: 16px; }

/* keyboard */
.kb { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 6px; font-size: 12px; }
.kb .block { display: flex; flex-direction: column; gap: 4px; flex: none; }
.kb .row { display: flex; gap: 4px; height: 40px; }
.kb .row.gap { margin-bottom: 8px; }
.kb .key { width: calc(var(--u, 1) * 37px + (var(--u, 1) - 1) * 4px); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; background: var(--surface); display: grid; place-items: center; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; transition: background .05s; }
.kb .key.blank { visibility: hidden; }
.kb .key.tall { height: 84px; }
.kb .key.done { background: rgba(22,163,74,.16); color: var(--text); border-color: rgba(22,163,74,.5); }
.kb .key.down { background: var(--accent); color: #fff; border-color: var(--accent); }

/* mouse */
.mouse-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.panel { background: var(--surface-2); border-radius: 12px; padding: 14px; }
.panel h3 { margin: 0 0 8px; font-size: 17px; }
.mbtns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.mbtn { border-radius: 8px; padding: 10px 4px; text-align: center; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.mbtn.done { background: rgba(22,163,74,.16); border-color: rgba(22,163,74,.5); }
.mbtn.down { background: var(--accent); color: #fff; border-color: var(--accent); }
.log { font-family: var(--mono); font-size: 13px; max-height: 140px; overflow-y: auto; margin-top: 8px; }
.log .flag { color: var(--bad); font-weight: 700; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 14px 0 28px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .1s, border-color .1s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .ico { font-size: 30px; line-height: 1; }
.card .name { font-weight: 800; font-size: 19px; margin: 10px 0 2px; }
.card .desc { color: var(--muted); font-size: 15px; }
.card.feature { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.card.feature .desc { color: inherit; opacity: .9; }
.hero { padding: 40px 0 10px; }
.hero h1 { font-size: clamp(36px, 7vw, 60px); }
.list { list-style: none; padding: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list a { font-weight: 700; font-size: 19px; text-decoration: none; }
.list p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

.card { position: relative; }
.card .mybest { margin-top: 10px; font-size: 14px; font-weight: 700; color: var(--good); }
.card.feature .mybest { color: #fff; }
.card .newtag { position: absolute; top: 14px; right: 14px; font-size: 12px; font-weight: 800; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 99px; }
.card.feature .newtag { background: #fff; color: var(--accent); }

/* ads */
.ad { margin: 26px 0; min-height: 100px; text-align: center; }
.ad::before { content: "Advertisement"; display: block; font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; }

.site-foot { border-top: 1px solid var(--line); margin-top: 50px; padding: 24px 0 40px; color: var(--muted); font-size: 15px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; }
.site-foot a { color: var(--muted); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .typer { font-size: 21px; height: 120px; }
  .typer .words { line-height: 40px; column-gap: 11px; }
  .typer .w { height: 40px; }
  .typer .w.err { height: 31px; margin-bottom: 9px; }
  .caret { height: 24px; }
  .arena { height: 360px; }
  .pad { min-height: 260px; }
  .tool { padding: 12px; }
}
