/* Benchmento — design system */

:root {
  --bg: #0A0C10;
  --bg-elevated: #12151D;
  --bg-hover: #181C26;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #F2F4F8;
  --text-muted: #8B93A7;
  --accent: #7C5CFF;
  --accent-glow: rgba(124, 92, 255, 0.35);
  --success: #22E07A;
  --danger: #FF4D6A;
  --warning: #FFB020;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  --bloom: rgba(124, 92, 255, 0.10);
  --dot: rgba(255, 255, 255, 0.035);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --maxw: 1120px;
  --readw: 68ch;
}

[data-theme="light"] {
  --bg: #F7F7F9;
  --bg-elevated: #FFFFFF;
  --bg-hover: #F0F0F4;
  --border: rgba(16, 18, 27, 0.10);
  --border-strong: rgba(16, 18, 27, 0.18);
  --text: #14161F;
  --text-muted: #5A6072;
  --accent: #6B45F5;
  --accent-glow: rgba(107, 69, 245, 0.20);
  --success: #12A45C;
  --danger: #D62B4C;
  --warning: #B5761A;
  --shadow-card: 0 1px 2px rgba(16, 18, 27, 0.04), 0 4px 12px rgba(16, 18, 27, 0.06);
  --bloom: rgba(107, 69, 245, 0.07);
  --dot: rgba(16, 18, 27, 0.05);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1000px 520px at 50% -12%, var(--bloom), transparent 70%),
    radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: auto, 22px 22px;
}

body > * { position: relative; z-index: 1; }

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

h1, h2, h3 { letter-spacing: -0.03em; line-height: 1.15; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: clamp(2rem, 6vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3.4vw, 1.9rem); margin-top: 2.4em; }
h3 { font-size: 1.08rem; font-weight: 600; letter-spacing: -0.015em; margin-top: 1.8em; }
p { margin: 0 0 1.1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip:focus { left: 0; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  position: sticky; top: 0; z-index: 40;
}
.header-inner {
  display: flex; align-items: center; gap: 12px;
  height: 60px;
  max-width: var(--maxw); margin: 0 auto; padding: 0 20px;
}
.logo {
  font-weight: 700; font-size: 1.06rem; letter-spacing: -0.035em;
  color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent); box-shadow: 0 0 16px var(--accent-glow);
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
}

.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-link {
  color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
  padding: 8px 10px; border-radius: 8px; text-decoration: none;
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }

.dropdown { position: relative; }
.dropdown-toggle {
  font: inherit; font-size: 0.9rem; font-weight: 500;
  color: var(--text-muted); background: none; border: 0; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; gap: 5px;
}
.dropdown-toggle:hover { color: var(--text); background: var(--bg-hover); }
.dropdown-toggle svg { transition: transform 160ms var(--ease); }
.dropdown[data-open="true"] .dropdown-toggle svg { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow-card);
  padding: 8px; min-width: 260px; display: none;
}
.dropdown[data-open="true"] .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block; padding: 9px 12px; border-radius: 9px;
  color: var(--text); font-size: 0.9rem; text-decoration: none;
}
.dropdown-menu a:hover { background: var(--bg-hover); text-decoration: none; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 9px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }
[data-theme="light"] .moon { display: none; }
[data-theme="dark"] .sun { display: none; }
:root:not([data-theme="light"]) .sun { display: none; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  padding: 12px 20px; min-height: 44px;
  border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none;
  transition: transform 140ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn-secondary {
  background: var(--bg-elevated); color: var(--text); border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); }

/* ---------- Hero ---------- */

.hero { padding: clamp(36px, 7vw, 76px) 0 clamp(24px, 4vw, 40px); max-width: 720px; }
.hero h1 { font-size: clamp(2rem, 8vw, 3.4rem); margin-bottom: 14px; }
.hero p { color: var(--text-muted); font-size: clamp(1rem, 2.4vw, 1.15rem); max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* ---------- Game grid ---------- */

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  margin: 0 0 32px; padding: 0; list-style: none;
}
.card {
  display: block; position: relative; overflow: hidden;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; color: var(--text); text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: transform 180ms var(--ease), border-color 180ms var(--ease);
}
.card:hover { transform: translateY(-2px); border-color: var(--border-strong); text-decoration: none; }
.card-icon { color: var(--accent); margin-bottom: 12px; display: block; }
.card-icon svg { width: 26px; height: 26px; display: block; }
.card h3 { margin: 0 0 5px; font-size: 1rem; font-weight: 600; }
.card p { color: var(--text-muted); font-size: 0.875rem; margin: 0 0 12px; line-height: 1.5; }
.card-stat {
  font-size: 0.8rem; color: var(--text-muted);
  border-top: 1px solid var(--border); padding-top: 10px; display: flex; justify-content: space-between;
}
.card-stat b { color: var(--text); font-weight: 600; }

/* ---------- Game stage ---------- */

.stage-shell { margin: 8px 0 20px; }
.breadcrumb { font-size: 0.82rem; color: var(--text-muted); margin: 18px 0 10px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }

.game-intro { max-width: var(--readw); color: var(--text-muted); }

.stage {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  min-height: 440px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 0 60px rgba(0,0,0,0.25);
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
[data-theme="light"] .stage { box-shadow: inset 0 2px 8px rgba(16,18,27,0.05); }

.stage-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--border); min-height: 56px;
}
.modes { display: flex; gap: 5px; flex-wrap: wrap; }
.mode {
  font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 7px 11px; min-height: 34px;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
  transition: all 150ms var(--ease);
}
.mode:hover { color: var(--text); border-color: var(--border-strong); }
.mode[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.readout { margin-left: auto; display: flex; gap: 16px; }
.readout div { text-align: right; }
.readout span { display: block; font-size: 0.68rem; color: var(--text-muted); letter-spacing: 0.02em; }
.readout b { font-size: 1.05rem; font-weight: 600; }

.progress { height: 2px; background: var(--border); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 100ms linear; }

.play {
  flex: 1; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; text-align: center; min-height: 380px;
}

/* Panels */
.panel { display: none; width: 100%; }
.panel.active { display: block; }

.big-num {
  font-size: clamp(3.2rem, 12vw, 6.4rem); font-weight: 700;
  line-height: 1; letter-spacing: -0.04em; margin: 0;
}
.big-label { color: var(--text-muted); font-size: 0.9rem; margin-top: 6px; }

/* Reaction pad */
.hit-area {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; cursor: pointer; padding: 20px; text-align: center;
}
.hit-area.wait { background: var(--danger); color: #fff; }
.hit-area.go { background: var(--success); color: #06210f; }
.hit-area h2 { margin: 0; color: inherit; font-size: clamp(1.3rem, 4vw, 2rem); }
.hit-area p { color: inherit; opacity: 0.85; margin: 8px 0 0; }

/* Click pad */
.click-pad {
  position: absolute; inset: 0; cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: radial-gradient(120% 90% at 50% 40%, var(--bg-hover), var(--bg-elevated) 78%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.click-pad::after {
  content: ""; position: absolute; inset: 14px; border-radius: 14px;
  border: 1px dashed var(--border); pointer-events: none;
}
.click-pad h2 { font-size: clamp(1.6rem, 5vw, 2.4rem); margin: 0; }
.click-pad p { color: var(--text-muted); margin: 8px 0 0; font-size: 0.9rem; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: var(--accent-glow);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 420ms var(--ease) forwards;
}
@keyframes ripple {
  to { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Aim */
.target {
  position: absolute; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 24px var(--accent-glow);
  cursor: crosshair; border: 2px solid rgba(255,255,255,0.35);
}

/* Tile grids */
.tile-grid { display: grid; gap: 10px; margin: 0 auto; }
.tile {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-hover); cursor: pointer; padding: 0;
  transition: background 90ms linear, transform 90ms var(--ease);
  min-width: 44px;
}
.tile:hover { border-color: var(--border-strong); }
.tile.lit { background: var(--accent); border-color: var(--accent); }
.tile.flash { background: var(--text); border-color: var(--text); }
.tile.wrong { background: var(--danger); border-color: var(--danger); }
.tile.correct { background: var(--success); border-color: var(--success); }

/* Chimp */
.chimp-cell {
  position: absolute; display: grid; place-items: center;
  background: var(--bg-hover); border: 1px solid var(--border-strong);
  border-radius: 10px; font-size: 1.3rem; font-weight: 700; cursor: pointer;
  color: var(--text); padding: 0;
}
.chimp-cell.hidden-num { color: transparent; background: var(--accent); border-color: var(--accent); }

/* Typing */
.type-box {
  font-size: clamp(1rem, 2.6vw, 1.32rem); line-height: 2;
  max-width: 62ch; margin: 0 auto; text-align: left;
  color: var(--text-muted); word-break: break-word;
}
.type-box b { font-weight: 400; }
.type-box .ok { color: var(--success); }
.type-box .bad { color: var(--danger); text-decoration: underline; text-decoration-color: var(--danger); }
.type-box .cur { border-left: 2px solid var(--accent); margin-left: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.type-input {
  position: absolute; opacity: 0; pointer-events: none;
  width: 1px; height: 1px;
}
.type-tap {
  margin-top: 18px; font-size: 0.85rem; color: var(--text-muted);
}

/* Number memory */
.num-input {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: clamp(1.6rem, 6vw, 2.6rem); font-weight: 700;
  text-align: center; letter-spacing: 0.08em;
  background: var(--bg-hover); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 12px 16px; width: min(100%, 420px); margin-top: 18px;
}

/* ---------- Result ---------- */

.result { text-align: center; }
.result .big-num { color: var(--text); }
.pct-wrap { max-width: 460px; margin: 26px auto 0; text-align: left; }
.pct-label { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 8px; }
.pct-label b { color: var(--text); }
.pct-bar { height: 8px; border-radius: 99px; background: var(--bg-hover); overflow: hidden; border: 1px solid var(--border); }
.pct-bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--success)); transition: width 800ms var(--ease); }
.result-meta { color: var(--text-muted); font-size: 0.88rem; margin-top: 16px; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.share-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.share-row a, .share-row button {
  font: inherit; font-size: 0.82rem; color: var(--text-muted);
  background: none; border: 0; cursor: pointer; padding: 6px 8px; border-radius: 8px;
}
.share-row a:hover, .share-row button:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.support-line { margin-top: 18px; font-size: 0.85rem; color: var(--text-muted); }

/* Hide chrome during play */
body.playing .site-header,
body.playing .site-footer,
body.playing .article,
body.playing .adslot,
body.playing .breadcrumb,
body.playing .game-intro { opacity: 0; pointer-events: none; }
body.playing .site-header, body.playing .site-footer, body.playing .article, body.playing .adslot { transition: opacity 180ms var(--ease); }

/* ---------- Article ---------- */

.article { max-width: var(--readw); margin: 44px auto 0; }
.article p, .article li { color: var(--text-muted); }
.article strong { color: var(--text); font-weight: 600; }
.article ul, .article ol { padding-left: 20px; }
.article li { margin-bottom: 10px; }

.table-wrap { overflow-x: auto; margin: 20px 0; border: 1px solid var(--border); border-radius: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--text); font-weight: 600; font-size: 0.8rem; background: var(--bg-elevated); }
td { color: var(--text-muted); }
tr:last-child td { border-bottom: 0; }
td.mono { color: var(--text); }

.faq details {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 8px; background: var(--bg-elevated);
}
.faq summary { cursor: pointer; font-weight: 600; color: var(--text); font-size: 0.95rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq details[open] summary { margin-bottom: 8px; }
.faq p { margin: 0; font-size: 0.92rem; }

.related { list-style: none; padding: 0; }
.related li { margin-bottom: 8px; }

/* ---------- Ads ---------- */

.adslot {
  margin: 28px auto; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: 12px;
  color: var(--text-muted); font-size: 0.72rem;
  max-width: 728px; overflow: hidden;
}
.adslot-result { min-height: 250px; margin-top: 40px; }
.adslot-content { min-height: 280px; }

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 36px 0 44px; }
.footer-grid { display: grid; gap: 26px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.footer-grid h4 { font-size: 0.78rem; font-weight: 600; color: var(--text); margin: 0 0 10px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 7px; }
.footer-grid a { color: var(--text-muted); font-size: 0.85rem; }
.footer-grid a:hover { color: var(--text); }
.footer-bottom {
  margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.8rem;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* ---------- Cookie banner ---------- */

.cookie {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 90;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 16px; box-shadow: var(--shadow-card);
  padding: 16px 18px; max-width: 620px; margin: 0 auto;
  display: none; gap: 14px; align-items: center; flex-wrap: wrap;
}
.cookie.show { display: flex; }
.cookie p { margin: 0; font-size: 0.85rem; color: var(--text-muted); flex: 1 1 260px; }
.cookie .btn { padding: 9px 16px; font-size: 0.85rem; min-height: 38px; }

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .nav-link.hide-sm { display: none; }
  .hero { padding: 26px 0 18px; }
  .hero h1 { font-size: clamp(2rem, 8vw, 2.75rem); }
  .hero p { font-size: 1rem; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .card p { display: none; }
  .card h3 { font-size: 0.92rem; }
  .card-stat { font-size: 0.72rem; flex-direction: column; gap: 2px; }
  .stage { min-height: 400px; border-radius: 16px; }
  .readout { gap: 12px; }
  .readout b { font-size: 0.95rem; }
}

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

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
caption.sr-only { display: block; }
