/* TypingGames — dark, consistent with the AdSense utility-site family */

:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --panel: #121722;
  --line: rgba(120, 150, 220, 0.16);
  --text: #eef2ff;
  --muted: #9aa7c4;
  --dim: #7d8bb0;
  --accent: #ff5c33;
  --ok: #2dd4bf;
  --bad: #ff5c6a;
  --chip: rgba(125, 139, 176, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  padding: 20px 14px 60px;
}

.wrap { max-width: 760px; margin: 0 auto; }

/* ---------- header ---------- */
header.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.brand { font-size: 26px; font-weight: 800; }
.brand span { color: var(--accent); }
.topnav { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.topnav a { color: var(--muted); font-size: 14px; text-decoration: none; }
.topnav a:hover { color: var(--text); text-decoration: underline; }
.topnav .donate { color: #c4b5fd; font-weight: 700; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  appearance: none; background: var(--chip); color: var(--muted);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 18px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.tab.active { background: rgba(255, 92, 51, 0.14); color: #c4b5fd; border-color: var(--accent); }
.tab:hover { border-color: var(--accent); }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
}
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { font-size: 22px; }
.challenge-badge {
  margin-left: auto; font-size: 13px; color: var(--accent); font-weight: 700;
  background: rgba(255, 92, 51, 0.12); padding: 5px 12px; border-radius: 999px;
}
.hint { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 14px; }

/* ---------- config ---------- */
.test-config { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.test-config label { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.test-config select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: 14px;
}
.checkline { cursor: pointer; }

/* ---------- quote + typing ---------- */
.quote {
  font-size: 20px; line-height: 1.8; letter-spacing: 0.02em;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 12px; min-height: 4.4em;
  user-select: none;
  /* Preserve consecutive spaces (spans are plain spaces now) while letting a
     long quote wrap instead of forcing an unbreakable overflowing line. */
  white-space: pre-wrap;
  overflow-wrap: normal;
  word-break: normal;
}
.qc { color: var(--dim); border-radius: 3px; }
.qc.ok { color: var(--ok); }
.qc.bad { color: var(--bad); background: rgba(255, 92, 106, 0.12); }
.qc.cur { background: rgba(45, 212, 191, 0.16); color: var(--text); }

.wpm-input {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; resize: none; outline: none;
}
.wpm-input:focus { border-color: var(--accent); }

.live-stats { display: flex; gap: 22px; margin: 12px 0 8px; color: var(--muted); font-size: 15px; }
.live-stats b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border-radius: 12px; padding: 11px 18px;
  font-size: 14px; font-weight: 700; cursor: pointer; border: 1px solid var(--line);
  background: var(--chip); color: var(--text);
}
.btn:hover { filter: brightness(1.15); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-secondary { background: var(--chip); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-big { width: 100%; padding: 14px; font-size: 16px; margin-top: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- pressed / clicked feedback ---------- */
.btn:active, .tab:active {
  transform: translateY(1px) scale(0.98);
  filter: brightness(1.35);
}
.btn.clicked, .tab.clicked { animation: click-flash 0.3s ease-out; }
@keyframes click-flash {
  0% { transform: scale(0.96); filter: brightness(1.6); }
  100% { transform: scale(1); filter: brightness(1); }
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- result card ---------- */
.result-card {
  margin-top: 16px; background: rgba(45, 212, 191, 0.07);
  border: 1px solid rgba(45, 212, 191, 0.3); border-radius: 14px; padding: 16px;
}
.result-card h3 { margin-bottom: 12px; }
.result-card p { color: var(--muted); margin-top: 10px; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.result-grid > div { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; }
.r-num { display: block; font-size: 24px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.r-lbl { font-size: 12px; color: var(--muted); }

/* ---------- high scores ---------- */
.scores { margin-top: 18px; }
.scores h3 { font-size: 15px; color: var(--muted); margin-bottom: 8px; }
.scores ol { list-style: none; }
.scores li { font-size: 14px; color: var(--text); padding: 6px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.scores li.empty { color: var(--dim); font-style: italic; border-bottom: none; }
.scores li:first-child { color: var(--accent); font-weight: 800; }

/* ---------- race ---------- */
.race-track { margin: 12px 0 10px; }
.lane { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.racer-label { width: 92px; font-size: 14px; color: var(--muted); }
.lane-bg { flex: 1; height: 22px; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.lane-fill { height: 100%; border-radius: 11px; transition: width 0.35s ease; }
.lane-fill.player { background: linear-gradient(90deg, #0f766e, var(--ok)); }
.lane-fill.bot { background: linear-gradient(90deg, #9a3412, var(--accent)); }
.pct { width: 44px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
#race-canvas { width: 100%; height: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; margin: 4px 0 8px; display: block; }
#race-status { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

/* ---------- snake ---------- */
.snake-wrap { text-align: center; margin-bottom: 10px; }
#snake-canvas { width: 100%; max-width: 400px; height: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; display: block; margin: 0 auto; }
.snake-status { display: flex; justify-content: center; gap: 28px; margin-top: 8px; color: var(--muted); font-size: 15px; }
.snake-status b { color: var(--text); }

/* ---------- snake touch dpad (coarse pointers only) ---------- */
.snake-dpad {
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-areas:
    '. up .'
    'left down right';
  gap: 8px;
  justify-content: center;
  margin: 14px auto;
  touch-action: manipulation;
}
.dpad-btn {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--chip); color: var(--text);
  border: 1px solid var(--line); font-size: 22px; font-weight: 700;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.dpad-btn:active { background: var(--accent); color: #fff; transform: scale(0.95); }
#snake-btn-up { grid-area: up; }
#snake-btn-down { grid-area: down; }
#snake-btn-left { grid-area: left; }
#snake-btn-right { grid-area: right; }
@media (pointer: coarse) {
  .snake-dpad { display: grid; }
}

/* ---------- news paragraphs ---------- */
.news-source {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 10px; font-size: 13px; color: var(--muted);
}
.news-source[data-status="fresh"] { border-color: rgba(45, 212, 191, 0.5); }
.news-source[data-status="cached"] { border-color: rgba(251, 191, 36, 0.5); }
.news-source[data-status="curated"] { border-color: rgba(125, 139, 176, 0.5); }
.news-source a { color: var(--brand, #67e8f9); text-decoration: underline; }
.news-config { margin-top: 0; }

/* ---------- arcade games (tetris / pac-man / invaders) ---------- */
.arcade-wrap { text-align: center; margin-bottom: 10px; }
.arcade-wrap canvas {
  width: 100%; max-width: 420px; height: auto; background: var(--bg);
  border: 1px solid var(--line); border-radius: 14px; display: block; margin: 0 auto;
  image-rendering: pixelated;
}
#tetris-canvas { max-width: 260px; }
.arcade-status { display: flex; justify-content: center; gap: 24px; margin-top: 8px; color: var(--muted); font-size: 15px; flex-wrap: wrap; }
.arcade-status b { color: var(--text); font-variant-numeric: tabular-nums; }
.next-preview { display: inline-flex; align-items: center; gap: 8px; }
#tetris-next-canvas {
  width: 48px; height: 48px; display: inline-block; vertical-align: middle;
  border: 1px solid var(--line); border-radius: 8px; image-rendering: pixelated;
}
#bejeweled-canvas { max-width: 360px; touch-action: manipulation; cursor: pointer; }
kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid var(--line);
  border-radius: 5px; background: var(--bg); font: inherit; font-size: .9em;
}
@media (max-width: 520px) {
  .arcade-status { gap: 10px 18px; font-size: 13px; }
  .arcade-dpad .dpad-btn { width: 48px; height: 48px; font-size: 19px; }
}
.arcade-dpad {
  display: grid; grid-template-columns: repeat(4, 56px); gap: 8px;
  justify-content: center; margin: 14px auto; touch-action: manipulation;
}
.arcade-dpad .dpad-btn { width: 56px; height: 56px; }
.game-over {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  flex-wrap: wrap; margin: 10px auto; padding: 12px 16px; border-radius: 12px;
  border: 1px solid rgba(248, 113, 113, 0.55); background: rgba(127, 29, 29, 0.18);
  color: var(--text); text-align: center;
}
.game-over[hidden] { display: none; }

/* ---------- ad / hub / footer ---------- */
.ad {
  min-height: 90px; margin: 4px 0 16px; border-radius: 14px;
  border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 12px;
}
.hub { margin: 20px 0 14px; font-size: 13px; color: var(--muted); line-height: 1.8; text-align: center; }
.hub a { color: var(--text); opacity: 0.92; margin-right: 12px; text-decoration: none; font-size: 14px; }
.hub a:hover { color: var(--text); text-decoration: underline; }
footer { font-size: 13px; color: var(--dim); }
footer a { color: var(--dim); margin-right: 14px; text-decoration: none; }
footer a:hover { color: var(--text); text-decoration: underline; }

/* ---------- celebration ---------- */
#confetti {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden;
  z-index: 60;
}
.confetti-piece {
  position: absolute; top: -14px; width: 8px; height: 12px; border-radius: 2px;
  animation: confetti-fall 2.6s ease-in forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(-14px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(108vh) rotate(720deg); opacity: 0; }
}
.result-card.celebrating { animation: celebrate-pulse 1.6s ease-out; }
@keyframes celebrate-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 92, 51, 0.55); transform: scale(1); }
  40%  { box-shadow: 0 0 0 18px rgba(255, 92, 51, 0); transform: scale(1.03); }
  100% { box-shadow: 0 0 0 0 rgba(255, 92, 51, 0); transform: scale(1); }
}
.challenge-badge.streak-flash { animation: streak-flash 1.8s ease-in-out; }
@keyframes streak-flash {
  0%, 100% { background: rgba(255, 92, 51, 0.12); color: var(--accent); transform: scale(1); }
  50%      { background: rgba(45, 212, 191, 0.55); color: #04211d; transform: scale(1.12); }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1a2030; color: var(--text); border: 1px solid var(--line);
  padding: 12px 20px; border-radius: 12px; font-size: 14px; z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

@media (max-width: 520px) {
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .challenge-badge { margin-left: 0; }
  .quote { font-size: 17px; }
}

/* >>> theme-by-name (2026-11-02) >>> */
/* Theme derived from the site's MEANING, not a random variant.
 * Speed and keystrokes = terminal black with cyan mono. The product IS a keyboard.
 * Ad layout is deliberately NOT set here — container width and rail geometry are
 * measured and verified separately by check-ad-layout.mjs.
 */
:root {
  --bg: #101317;
  --card: #191d23;
  --ink: #eef1f6;
  --muted: #98a1b0;
  --line: #272c34;
  --brand: #22d3ee;
  --brand-strong: #22d3ee;
  --accent: #67e8f9;
  --radius: 8px;
  --font-sans: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  --panel: #121722;
}
body { font-family: var(--font-sans); background: var(--bg); color: var(--ink); }
h1, h2, h3 { font-family: var(--font-sans); font-weight: 500; letter-spacing: -0.015em; }
.card, .panel, section[class*="card"] { border-radius: var(--radius); }
/* <<< theme-by-name <<< */

/* Privacy architecture section (2026-11-08) — the selling point of every site. */
.privacy-section{margin-top:34px;padding-top:24px;border-top:2px solid #e2e8f0}
.privacy-section h2{font-size:1.35em;margin-bottom:10px}
.privacy-section h3{font-size:1.05em;margin:20px 0 8px}
.privacy-steps{margin:10px 0 14px;padding-left:22px}
.privacy-steps li{margin-bottom:8px;line-height:1.6}
.privacy-section kbd{background:#f1f5f9;border:1px solid #cbd5e1;border-bottom-width:2px;
  border-radius:4px;padding:1px 5px;font-size:.85em;font-family:ui-monospace,Menlo,monospace}

/* screen-reader-only: names the page for AT users and search engines
   without altering the designed layout (heading sits inside panels). */
.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;
}
