/* ============================================================
   BrainReflex · Global Style System
   Goal: SEO landing pages + comfortable long-form reading
   ============================================================ */

:root {
  --bg: #f8f9fc;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --ink: #1a1f36;
  --ink-2: #4f5b72;
  --ink-3: #8b95ad;
  --line: #e2e6f0;
  --brand: #4c6ef5;
  --brand-2: #7c5cfc;
  --accent: #ff8a3d;
  --good: #22b56b;
  --shadow: 0 12px 32px rgba(23, 32, 58, 0.07);
  --shadow-sm: 0 4px 16px rgba(23, 32, 58, 0.05);
  --radius: 16px;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #0f1219;
  --bg-soft: #161b27;
  --card: #1a2035;
  --ink: #e8ecf5;
  --ink-2: #98a4be;
  --ink-3: #64718a;
  --line: #252e42;
  --brand: #7b93ff;
  --brand-2: #a78bfa;
  --accent: #ffa76a;
  --good: #3bd98b;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s, color 0.3s;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1000px; margin: 0 auto; padding: 0 24px; }

/* ─── Header ─────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  background: color-mix(in srgb, var(--bg-soft) 85%, transparent);
  border-bottom: 1px solid var(--line);
}

.site-header .container {
  height: 100%; display: flex; align-items: center; gap: 24px;
}

.logo {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 17px; color: var(--ink);
  text-decoration: none !important; white-space: nowrap;
}

.logo-badge {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 16px; box-shadow: var(--shadow-sm);
}

.site-nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }

.site-nav a {
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  padding: 6px 14px; border-radius: 999px;
  transition: all 0.2s; white-space: nowrap;
}

.site-nav a:hover {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  text-decoration: none;
}

.theme-toggle {
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink-2); width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; font-size: 15px;
  display: grid; place-items: center;
  transition: all 0.2s; flex: none;
}

.theme-toggle:hover { color: var(--brand); border-color: var(--brand); }

/* ─── Hero ───────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  padding: 80px 0 64px; text-align: center;
}

.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.3; pointer-events: none;
}

.hero::before {
  width: 400px; height: 400px; background: var(--brand);
  top: -140px; left: -100px;
}

.hero::after {
  width: 360px; height: 360px; background: var(--brand-2);
  top: -100px; right: -80px;
}

.hero > * { position: relative; }

.hero-kicker {
  display: inline-block; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  padding: 5px 16px; border-radius: 999px; margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(32px, 5.5vw, 50px);
  line-height: 1.2; margin: 0 0 18px; letter-spacing: -0.02em;
}

.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand), var(--brand-2) 60%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.hero-sub {
  max-width: 600px; margin: 0 auto 32px;
  color: var(--ink-2); font-size: 17.5px; line-height: 1.7;
}

.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 28px; border-radius: 999px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none !important;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 30%, transparent);
}

.btn-primary:hover {
  box-shadow: 0 10px 28px color-mix(in srgb, var(--brand) 45%, transparent);
}

.btn-ghost {
  background: var(--card); border-color: var(--line); color: var(--ink);
}

.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

.hero-stats {
  display: flex; justify-content: center; gap: 40px;
  margin-top: 44px; flex-wrap: wrap;
}

.hero-stats .stat b {
  display: block; font-size: 22px;
  background: linear-gradient(100deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.hero-stats .stat span { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }

/* ─── Sections ───────────────────────────────────────────── */
.section { padding: 56px 0; }

.section-head { text-align: center; margin-bottom: 36px; }

.section-head h2 {
  font-size: clamp(22px, 3.5vw, 30px);
  margin: 0 0 10px; letter-spacing: -0.01em;
}

.section-head p { color: var(--ink-2); margin: 0; font-size: 16px; }

/* ─── Cards ──────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

@media (max-width: 860px) { .cards { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  display: flex; flex-direction: column;
}

.card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}

.card-cover {
  aspect-ratio: 16 / 9; overflow: hidden;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--brand) 12%, var(--card)),
    color-mix(in srgb, var(--brand-2) 12%, var(--card)));
}

.card-cover img { width: 100%; height: 100%; object-fit: cover; }

.card-body { padding: 20px 22px 24px; flex: 1; display: flex; flex-direction: column; }

.card-body h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: -0.01em; }
.card-body h3 a { color: var(--ink); text-decoration: none !important; }
.card-body h3 a:hover { color: var(--brand); }

.card-body p {
  margin: 0 0 18px; color: var(--ink-2);
  font-size: 14.5px; line-height: 1.6; flex: 1;
}

.card-meta {
  display: flex; align-items: center;
  justify-content: space-between; font-size: 13px; color: var(--ink-3);
}

.tag {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  padding: 3px 10px; border-radius: 999px;
}

.card-link { font-weight: 600; font-size: 14px; }

/* ─── Prose (article content) ────────────────────────────── */
.prose { max-width: 720px; margin: 0 auto; }

.prose h2 {
  font-size: 24px; font-weight: 700;
  margin: 48px 0 16px; letter-spacing: -0.01em;
  padding-left: 14px;
  border-left: 4px solid var(--brand);
  line-height: 1.4;
}

.prose h2:first-child { margin-top: 0; }

.prose h3 {
  font-size: 18px; font-weight: 700; margin: 32px 0 12px;
}

.prose p {
  margin: 0 0 16px; color: var(--ink-2); line-height: 1.75; font-size: 16px;
}

.prose ul, .prose ol {
  color: var(--ink-2); padding-left: 24px; margin: 0 0 16px;
}

.prose li { margin: 8px 0; line-height: 1.65; }
.prose strong { color: var(--ink); font-weight: 600; }

.prose blockquote {
  margin: 24px 0; padding: 16px 20px;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-radius: 0 12px 12px 0;
  color: var(--ink-2);
}

.prose blockquote p { margin: 0; font-size: 15px; }

/* ─── Data Tables ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 20px 0; }

table.data {
  width: 100%; border-collapse: collapse;
  background: var(--card); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow-sm); font-size: 14.5px;
}

table.data th, table.data td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}

table.data th {
  background: color-mix(in srgb, var(--brand) 7%, transparent);
  color: var(--ink); font-weight: 700; font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.04em;
}

table.data tr:last-child td { border-bottom: none; }
table.data td { color: var(--ink-2); }

/* ─── FAQ ────────────────────────────────────────────────── */
.faq { max-width: 720px; margin: 0 auto; }

.faq details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 10px; overflow: hidden;
}

.faq summary {
  cursor: pointer; padding: 16px 20px; font-weight: 600;
  list-style: none; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; font-size: 15.5px;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: "+"; font-size: 20px; color: var(--brand);
  flex: none; transition: transform 0.2s;
}

.faq details[open] summary::after { transform: rotate(45deg); }

.faq details p {
  margin: 0; padding: 0 20px 18px;
  color: var(--ink-2); font-size: 15px; line-height: 1.65;
}

/* ─── Game Stage ─────────────────────────────────────────── */
.game-stage {
  border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  margin: 24px 0;
  user-select: none; -webkit-user-select: none;
}

.game-screen {
  min-height: 360px;
  display: grid; place-items: center; text-align: center;
  cursor: pointer; padding: 32px 20px; color: #fff;
  transition: background-color 0.1s; position: relative;
}

.game-screen.state-idle    { background: linear-gradient(150deg, #3b5bdb, #7048e8); }
.game-screen.state-wait    { background: linear-gradient(150deg, #e8590c, #d9480f); }
.game-screen.state-go      { background: linear-gradient(150deg, #2f9e44, #37b24d); }
.game-screen.state-fail    { background: linear-gradient(150deg, #c92a2a, #a61e1e); }
.game-screen.state-toosoon { background: linear-gradient(150deg, #495057, #343a40); }
.game-screen.state-done    { background: linear-gradient(150deg, #3b5bdb, #7048e8); }

.game-screen .big {
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 800; margin: 0 0 8px; line-height: 1.2;
}

.game-screen .hint { font-size: 15px; opacity: 0.85; margin: 0; line-height: 1.5; }
.game-screen .glyph { font-size: 44px; margin-bottom: 10px; }

.game-screen .score-ms {
  font-size: clamp(42px, 7vw, 64px);
  font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0;
}

/* Score strip (live during game) */
.score-strip {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; margin-top: 14px;
  min-height: 36px;
}

.score-strip .chip {
  border-radius: 10px; padding: 5px 14px;
  font-size: 13px; font-variant-numeric: tabular-nums;
  font-weight: 500;
  animation: chipIn 0.2s ease-out;
}

@keyframes chipIn {
  from { opacity: 0; transform: translateY(6px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

.score-strip .chip b { font-size: 15px; }

.chip--elite { background: #22b56b20; color: #1a9e5a; border: 1px solid #22b56b40; }
.chip--good  { background: var(--brand) 10%; color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.chip--avg   { background: var(--accent) 10%; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.chip--info  { background: var(--ink-3) 8%; color: var(--ink-3); border: 1px solid color-mix(in srgb, var(--ink-3) 18%, transparent); }

/* Legacy result-bar (number memory) */
.result-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; margin-top: 16px;
}

.result-bar .chip {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 14px;
  font-size: 13.5px; font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.result-bar .chip b { font-size: 16px; color: var(--ink); }

/* Number memory */
.num-display {
  font-size: clamp(32px, 6vw, 48px); font-weight: 800;
  letter-spacing: 0.12em; font-variant-numeric: tabular-nums;
  margin: 0 0 10px; word-break: break-all;
}

.num-input {
  width: min(400px, 100%); padding: 14px 18px;
  font-size: 22px; text-align: center;
  letter-spacing: 0.12em; border: none; border-radius: 12px;
  outline: none; margin-top: 16px; color: #17203a;
  font-variant-numeric: tabular-nums;
}

.num-input:focus { box-shadow: 0 0 0 4px rgba(255,255,255,0.35); }

/* ─── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
  font-size: 13px; color: var(--ink-3); padding: 20px 0 0;
}

.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { margin: 0 6px; }

/* ─── Page hero (sub-page) ──────────────────────────────── */
.page-hero { padding: 24px 0 8px; }

.page-hero h1 {
  font-size: clamp(26px, 4.5vw, 38px);
  margin: 0 0 14px; line-height: 1.3; letter-spacing: -0.02em;
}

.page-hero .lead {
  color: var(--ink-2); font-size: 16.5px;
  max-width: 680px; margin: 0; line-height: 1.7;
}

/* ─── Footer ─────────────────────────────────────────────── */
.site-footer {
  margin-top: 64px; border-top: 1px solid var(--line);
  background: var(--bg-soft); padding: 44px 0 28px;
  color: var(--ink-2); font-size: 14px;
}

.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 28px; padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

.footer-grid h4 {
  color: var(--ink); font-size: 14px; font-weight: 700;
  margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.04em;
}

.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin: 7px 0; }

.footer-grid a { color: var(--ink-2); text-decoration: none !important; }
.footer-grid a:hover { color: var(--brand); }

.footer-bottom {
  padding-top: 20px; display: flex;
  justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--ink-3); font-size: 12.5px;
}

/* ─── Related Links ──────────────────────────────────────── */
.related-links { display: flex; gap: 10px; flex-wrap: wrap; }

.related-links a {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 18px;
  font-size: 14px; font-weight: 600; color: var(--ink);
  text-decoration: none !important; transition: all 0.2s;
}

.related-links a:hover { border-color: var(--brand); color: var(--brand); }

/* ─── Page Meta ──────────────────────────────────────────── */
.page-meta {
  color: var(--ink-3);
  font-size: 13px;
  margin: -6px 0 18px;
}

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-nav { display: none; }
  .hero { padding: 56px 0 44px; }
  .section { padding: 40px 0; }
}