/* ================= Design tokens ================= */
:root {
  --accent: #7c3aed;
  --accent-soft: #f3ecfe;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a202e;
  --muted: #67708b;
  --border: #e3e6f0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 46, 0.05), 0 8px 24px rgba(20, 24, 46, 0.07);
  --stage-bg: #171a26;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ================= Header ================= */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 19px; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand strong { color: var(--accent); }
.header-nav { display: flex; align-items: center; gap: 20px; }
.header-nav a { color: var(--muted); text-decoration: none; font-size: 14.5px; font-weight: 500; }
.header-nav a:hover { color: var(--text); }

/* ================= Hero ================= */
.hero { padding: 48px 0 34px; text-align: center; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 12px; letter-spacing: -0.02em; }
.hero p { max-width: 620px; margin: 0 auto; color: var(--muted); font-size: 16.5px; }
.hero-cta { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hero-note { color: var(--muted); font-size: 13.5px; }
.hero-disclaimer { font-size: 12.5px; color: #9aa1b8; margin-top: 18px; }

/* ================= Buttons ================= */
.btn {
  font: inherit; font-weight: 600; font-size: 14.5px;
  border-radius: 9px; padding: 10px 18px;
  cursor: pointer; border: 1px solid transparent;
  transition: background .15s, transform .05s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-subtle { background: #fff; color: var(--text); border-color: var(--border); }
.btn-subtle:hover { background: #f5f6fb; }
.btn-ghost-accent { background: var(--accent-soft); color: var(--accent); border: none; }
.btn-ghost-accent:hover { background: color-mix(in srgb, var(--accent) 18%, white); }
.btn-wide { width: 100%; padding: 12px; font-size: 15.5px; }
.btn-big { padding: 14px 32px; font-size: 17px; border-radius: 12px; box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ================= Game stage ================= */
.stage-wrap { margin: 10px auto 34px; }
.stage-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.stage-title { font-weight: 800; font-size: 17px; }
.stage-progress { color: var(--muted); font-size: 13.5px; flex: 1; }
.stage {
  background: var(--stage-bg);
  border-radius: 16px;
  min-height: 440px;
  color: #eef0fa;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(15, 18, 34, 0.25);
  user-select: none;
  -webkit-user-select: none;
}
.stage-inner { text-align: center; padding: 30px; width: 100%; }
.stage h2 { font-size: 26px; margin: 0 0 10px; letter-spacing: -0.01em; }
.stage p { color: #aab1cc; max-width: 520px; margin: 0 auto 12px; font-size: 15.5px; }
.stage .big { font-size: clamp(40px, 8vw, 72px); font-weight: 800; letter-spacing: -0.02em; margin: 10px 0; }
.stage-hud {
  position: absolute; top: 14px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 24px;
  font-size: 13.5px; color: #aab1cc; font-weight: 600;
}
.stage-hud b { color: #fff; }

/* Reaction */
.reaction-area {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  cursor: pointer;
  font-size: 30px; font-weight: 800;
}
.reaction-area small { font-size: 14px; font-weight: 500; opacity: .8; }
.reaction-wait { background: #c92a2a; }
.reaction-go { background: #2f9e44; }
.reaction-early { background: #e8590c; }
.reaction-result { background: var(--stage-bg); }

/* Grids (sequence & visual) */
.tile-grid { display: grid; gap: 10px; margin: 18px auto 0; width: min(78vw, 340px); }
.tile {
  aspect-ratio: 1; border-radius: 12px;
  background: #2a2f45; border: none; cursor: pointer;
  transition: background .12s, transform .08s;
}
.tile:hover { background: #333a57; }
.tile.lit { background: #fff; }
.tile.good { background: #40c057; }
.tile.bad { background: #fa5252; }
.tile:active { transform: scale(0.96); }

/* Number memory */
.num-display { font-size: clamp(38px, 9vw, 64px); font-weight: 800; letter-spacing: 0.14em; margin: 18px 0; }
.num-input {
  font-size: 26px; text-align: center; letter-spacing: 0.12em;
  background: #232840; border: 2px solid #3a4163; color: #fff;
  border-radius: 12px; padding: 12px 16px; width: min(78vw, 340px);
  font-family: inherit; font-weight: 700;
}
.num-input:focus { outline: none; border-color: var(--accent); }
.progress-bar { height: 6px; background: #2a2f45; border-radius: 3px; width: min(70vw, 320px); margin: 14px auto 0; overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* Speed match */
.symbol-card {
  width: 130px; height: 130px; margin: 14px auto;
  background: #232840; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px;
}
.match-btns { display: flex; gap: 14px; justify-content: center; margin-top: 10px; }
.match-btns .btn { min-width: 120px; padding: 13px; font-size: 16px; }
.btn-no { background: #fa5252; color: #fff; }
.btn-no:hover { background: #e03131; }
.btn-yes { background: #40c057; color: #fff; }
.btn-yes:hover { background: #2f9e44; }

/* ================= Results ================= */
.results-wrap { margin: 10px auto 40px; }
.results-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}
.results-headline { font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
.results-score { font-size: clamp(64px, 12vw, 96px); font-weight: 800; letter-spacing: -0.03em; color: var(--accent); line-height: 1.05; }
.results-score-small { font-size: clamp(40px, 9vw, 64px); }
.results-percentile { font-size: 16.5px; color: var(--text); margin-top: 4px; }
.results-bars { margin: 26px auto 4px; max-width: 480px; text-align: left; }
.rbar { margin-bottom: 12px; }
.rbar-top { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.rbar-top span:last-child { color: var(--muted); font-weight: 500; }
.rbar-track { height: 8px; background: #eef0f6; border-radius: 4px; overflow: hidden; }
.rbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.results-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* Report teaser + report */
.report-teaser {
  margin-top: 30px; padding: 24px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 40%, white);
  background: var(--accent-soft);
  border-radius: 14px;
}
.report-teaser-lock { font-size: 26px; }
.report-teaser h3 { margin: 6px 0 6px; }
.report-teaser p { color: var(--muted); font-size: 14.5px; margin: 0 0 14px; }
.report { margin-top: 30px; text-align: left; }
.report h3 { text-align: center; }
.report-skill { padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: #fbfcfe; }
.report-skill b { display: block; margin-bottom: 2px; }
.report-skill span.band { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.report-skill p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.report-tools { margin-top: 22px; }
.cert-row { display: flex; gap: 10px; margin: 10px 0 24px; }
.cert-row input {
  flex: 1; font: inherit; font-size: 14.5px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px; background: #fbfbfe;
}
.cert-row input:focus { outline: none; border-color: var(--accent); }
#historyChart { width: 100%; height: auto; background: #fbfcfe; border: 1px solid var(--border); border-radius: 10px; }
#historyList { margin-top: 10px; font-size: 14px; }
#historyList .hrow { display: flex; justify-content: space-between; padding: 7px 4px; border-bottom: 1px solid var(--border); color: var(--muted); }
#historyList .hrow b { color: var(--text); }

/* ================= Games grid ================= */
.section-title { font-size: 24px; letter-spacing: -0.01em; margin: 8px 0 18px; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.game-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; transition: transform .12s, box-shadow .12s;
  text-align: left; font: inherit;
}
.game-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(20,24,46,.06), 0 14px 34px rgba(20,24,46,.1); }
.game-card .gicon { font-size: 26px; }
.game-card h3 { margin: 0; font-size: 16px; }
.game-card p { margin: 0; color: var(--muted); font-size: 13.5px; flex: 1; }
.game-card .best { font-size: 12.5px; font-weight: 700; color: var(--accent); }

/* ================= Ads / content ================= */
.ad-slot { margin: 18px auto; text-align: center; }
.content-section { padding: 56px 0; }
.content-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.content-section h2 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 26px; }
.content-section h2:not(:first-child) { margin-top: 52px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 800px) { .features { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .features { grid-template-columns: 1fr; } }
.feature h3 { margin: 0 0 4px; font-size: 15.5px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }
.features.tips { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .features.tips { grid-template-columns: 1fr; } }

#faq details {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 18px; margin-bottom: 10px;
}
#faq summary { font-weight: 600; cursor: pointer; font-size: 15px; }
#faq details p { color: var(--muted); margin: 10px 0 2px; font-size: 14.5px; }

.site-footer { padding: 28px 0 36px; text-align: center; color: var(--muted); font-size: 13.5px; }
.site-footer a { color: var(--muted); }

/* ================= Premium modal ================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 18, 34, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: 16px; padding: 30px 30px 26px;
  width: 100%; max-width: 430px; position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.modal h2 { margin: 0 0 4px; font-size: 22px; }
.modal-sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  border: none; background: #f1f2f8; color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 13px;
}
.premium-perks { margin: 0 0 18px; padding: 0 0 0 2px; list-style: none; }
.premium-perks li { padding: 5px 0 5px 26px; position: relative; font-size: 14.5px; }
.premium-perks li::before { content: "✓"; position: absolute; left: 2px; color: var(--accent); font-weight: 800; }
.premium-price { text-align: center; margin-bottom: 14px; }
.premium-price b { font-size: 34px; letter-spacing: -0.02em; }
.premium-price span { color: var(--muted); font-size: 14px; }
.license-row { display: flex; gap: 8px; margin-top: 16px; }
.license-row input {
  flex: 1; font: inherit; font-size: 14px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 8px; background: #fbfbfe;
}
.license-row input:focus { outline: none; border-color: var(--accent); }
.license-status { font-size: 13px; margin: 8px 0 0; min-height: 18px; }
.license-status.ok { color: #18794e; }
.license-status.err { color: #e5484d; }

/* ================= Toast ================= */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 11px 20px; border-radius: 10px; font-size: 14px; font-weight: 500;
  z-index: 120; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

/* ================= Certificate (print) ================= */
.certificate { text-align: center; }
.cert-border {
  border: 3px double var(--accent);
  padding: 60px 40px;
  max-width: 700px; margin: 40px auto;
}
.cert-brand { font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); font-size: 14px; }
.cert-heading { font-size: 30px; font-weight: 800; margin: 18px 0 34px; letter-spacing: -0.01em; }
.cert-name { font-size: 34px; font-weight: 700; border-bottom: 2px solid var(--border); display: inline-block; padding: 0 30px 6px; }
.cert-line { margin: 22px 0 6px; color: var(--muted); }
.cert-score { font-size: 64px; font-weight: 800; color: var(--accent); }
.cert-percentile { color: var(--muted); margin-top: 4px; }
.cert-date { margin-top: 28px; font-weight: 600; }
.cert-foot { margin-top: 36px; font-size: 11px; color: #9aa1b8; }

@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  body.printing-cert > *:not(.certificate) { display: none !important; }
  body.printing-cert .certificate { display: block !important; }
  .cert-border, .cert-brand, .cert-score, .cert-heading {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
