@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

/* ── Palette ── */
:root {
  --bg:        #0d0b1e;
  --bg-2:      #171530;
  --bg-3:      #211e40;
  --text:      #f0eeff;
  --text-2:    #8a88b8;
  --accent:    #ffd60a;
  --accent-h:  #ffc400;
  --accent-bg: #251f00;
  --border:    #2e2b58;
  --success:   #00f5c4;
  --success-bg:#003a2e;
  --danger:    #ff2d6f;
  --danger-bg: #38001a;
  --warning:   #ff9000;
  --warning-bg:#2c1800;
  --pink:      #ff2d6f;
  --cyan:      #00f5c4;
  --purple:    #b060ff;
  --shadow:    4px 4px 0 #000;
  --shadow-sm: 2px 2px 0 #000;
  --r:         4px;
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --pixel:     'Press Start 2P', monospace;
  --mono:      'Courier New', Courier, monospace;
}

[data-theme="light"] {
  --bg:        #1e1b35;
  --bg-2:      #2a2650;
  --bg-3:      #332f60;
  --text:      #e8e4ff;
  --text-2:    #9490c8;
  --accent:    #ffd60a;
  --accent-h:  #ffc400;
  --accent-bg: #2a2200;
  --border:    #3d3870;
  --success:   #00f5c4;
  --success-bg:#003a2e;
  --danger:    #ff2d6f;
  --danger-bg: #38001a;
  --warning:   #ff9000;
  --warning-bg:#2c1800;
  --pink:      #ff2d6f;
  --cyan:      #00f5c4;
  --purple:    #b060ff;
  --shadow:    4px 4px 0 #000;
  --shadow-sm: 2px 2px 0 #000;
}

/* ── Base ── */
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .2s, color .2s;
}

/* Subtle scanlines on dark mode */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    transparent 0px, transparent 3px,
    rgba(0,0,0,.06) 3px, rgba(0,0,0,.06) 4px
  );
  pointer-events: none;
  z-index: 9999;
}
/* scanlines active on both themes */

/* ── Layout ── */
.container { width: 100%; max-width: 800px; margin: 0 auto; padding: 0 16px; }
.container--wide { max-width: 1100px; }
main { flex: 1; padding: 28px 0 64px; }

/* ── Header ── */
.site-header {
  border-bottom: 3px solid var(--accent);
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 3px 0 var(--accent);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.site-logo {
  font-family: var(--pixel);
  font-size: .75rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: .02em;
  text-shadow: 2px 2px 0 rgba(0,0,0,.5);
  line-height: 1;
}
.site-logo span { color: var(--text); }

.header-right { display: flex; align-items: center; gap: 8px; }

/* ── Nav ── */
.nav-links { display: none; gap: 4px; } /* hidden on mobile — shown via min-width query */
.nav-link {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-2);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--r);
  border: 2px solid transparent;
  text-transform: uppercase;
  letter-spacing: .04em;
  transition: color .12s, border-color .12s, background .12s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.nav-link.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }

/* ── Mobile Nav Drawer ── */
.nav-mobile {
  display: none;
  border-top: 2px solid var(--border);
  background: var(--bg-2);
  padding: 10px 16px 14px;
  box-shadow: 0 6px 0 rgba(0,0,0,.4);
}
.nav-mobile.open {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.nav-mobile .nav-link {
  text-align: center;
  padding: 10px 6px;
  font-size: .5rem;
  border: 2px solid var(--border);
  background: var(--bg-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  line-height: 1.8;
}

/* ── Btn icon ── */
.btn-icon {
  width: 36px; height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-3);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, transform .08s, box-shadow .08s;
}
.btn-icon:active { transform: translate(2px,2px); box-shadow: none; }
.btn-icon:hover { border-color: var(--accent); background: var(--accent-bg); }
/* .btn-menu visible by default (mobile); hidden on desktop via min-width query */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--pixel);
  font-size: .6rem;
  letter-spacing: .04em;
  border: 3px solid rgba(0,0,0,.5);
  border-radius: var(--r);
  cursor: pointer;
  text-decoration: none;
  text-transform: uppercase;
  padding: 12px 20px;
  box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s;
  -webkit-user-select: none;
  user-select: none;
  line-height: 1.5;
}
.btn:active { transform: translate(4px, 4px); box-shadow: none; }
.btn--primary { background: var(--accent); color: #000; }
.btn--primary:hover { background: var(--accent-h); }
.btn--secondary { background: var(--bg-3); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn--secondary:active { transform: translate(2px,2px); box-shadow: none; }
.btn--lg { font-size: .7rem; padding: 14px 28px; }
.btn--sm { font-size: .5rem; padding: 8px 14px; box-shadow: var(--shadow-sm); }
.btn--danger { background: var(--danger); color: #fff; }

/* ── Cards ── */
.card {
  background: var(--bg-2);
  border: 3px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ── Game area ── */
.game-area {
  background: var(--bg-2);
  border: 3px solid var(--border);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  gap: 16px;
  padding: 32px 24px;
  transition: background .15s, border-color .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: var(--shadow);
}
.game-area--go    { background: var(--success-bg); border-color: var(--success); box-shadow: 4px 4px 0 var(--success); }
.game-area--wait  { background: var(--warning-bg); border-color: var(--warning); box-shadow: 4px 4px 0 var(--warning); }
.game-area--early { background: var(--danger-bg);  border-color: var(--danger);  box-shadow: 4px 4px 0 var(--danger); }
.game-area--result{ background: var(--accent-bg);  border-color: var(--accent);  box-shadow: 4px 4px 0 var(--accent); }

/* ── Game status text ── */
.game-status {
  font-family: var(--pixel);
  font-size: .75rem;
  color: var(--text-2);
  text-align: center;
  line-height: 1.8;
}
.game-status--go    { color: var(--success); }
.game-status--wait  { color: var(--warning); }
.game-status--early { color: var(--danger); }
.game-status--result{ color: var(--accent); }

/* ── Score ── */
.score-display {
  font-family: var(--pixel);
  font-size: 2.5rem;
  letter-spacing: -0.01em;
  color: var(--accent);
  line-height: 1;
  text-shadow: 3px 3px 0 rgba(0,0,0,.5);
  font-variant-numeric: tabular-nums;
}
.score-display .unit { font-size: .9rem; color: var(--text-2); margin-left: 8px; text-shadow: none; }

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.stat-box {
  background: var(--bg-2);
  border: 3px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-box .stat-val {
  font-family: var(--pixel);
  font-size: .85rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 2px 2px 0 rgba(0,0,0,.3);
}
.stat-box .stat-label {
  font-size: .7rem;
  color: var(--text-2);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Leaderboard ── */
.leaderboard { margin-top: 32px; }
.leaderboard h2 {
  font-family: var(--pixel);
  font-size: .65rem;
  margin-bottom: 12px;
  color: var(--accent);
  text-shadow: 2px 2px 0 rgba(0,0,0,.4);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r);
  font-size: .875rem;
  border: 2px solid transparent;
  transition: background .1s, border-color .1s;
}
.lb-row:nth-child(odd) { background: var(--bg-2); }
.lb-row:hover { background: var(--bg-3); border-color: var(--border); }
.lb-rank { width: 28px; font-weight: 800; font-size: .75rem; color: var(--text-2); text-align: center; flex-shrink: 0; font-family: var(--pixel); }
.lb-rank.gold   { color: var(--accent); text-shadow: 1px 1px 0 #000; }
.lb-rank.silver { color: #aaa; }
.lb-rank.bronze { color: #c87040; }
.lb-name  { flex: 1; font-weight: 600; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--cyan); font-family: var(--pixel); font-size: .65rem; }
.lb-empty { padding: 24px; text-align: center; color: var(--text-2); font-size: .875rem; font-family: var(--pixel); font-size: .5rem; line-height: 2; }

/* ── Submit score ── */
.submit-score { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.submit-score input {
  flex: 1; min-width: 140px;
  padding: 10px 12px;
  border: 3px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: .9375rem;
  outline: none;
  transition: border-color .15s;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,.2);
}
.submit-score input:focus { border-color: var(--accent); }

/* ── Ad slot ── */
.ad-slot {
  background: var(--bg-2);
  border: 2px dashed var(--border);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-family: var(--pixel);
}
.ad-slot--banner { height: 90px; margin-bottom: 24px; }
.ad-slot--side   { min-height: 250px; }

/* ── Page hero ── */
.page-hero { margin-bottom: 24px; }
.page-hero h1 {
  font-family: var(--pixel);
  font-size: 1rem;
  letter-spacing: .04em;
  margin-bottom: 10px;
  color: var(--text);
  text-shadow: 3px 3px 0 rgba(0,0,0,.4);
  line-height: 1.6;
}
.page-hero p { color: var(--text-2); font-size: .9rem; max-width: 520px; }

/* ── Typing test ── */
.typing-text {
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 2;
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
  user-select: none;
  -webkit-user-select: none;
  cursor: text;
  overflow: hidden;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,.2);
}
.word { display: inline-block; }
.char { position: relative; }
.char.correct { color: var(--cyan); }
.char.wrong   { color: var(--danger); background: var(--danger-bg); border-radius: 2px; }
.char.cursor::after {
  content: '';
  position: absolute;
  left: 0; top: 10%; bottom: 10%;
  width: 2px;
  background: var(--accent);
  animation: blink .7s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.typing-input {
  width: 100%;
  padding: 12px 14px;
  border: 3px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,.2);
  caret-color: var(--accent);
}
.typing-input:focus { border-color: var(--accent); }
.typing-input:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 480px) {
  .typing-text { font-size: .875rem; line-height: 1.85; padding: 12px; }
}

/* ── Timer / progress ── */
.timer-display {
  font-family: var(--pixel);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-shadow: 2px 2px 0 rgba(0,0,0,.4);
}
.timer-display.urgent { color: var(--danger); }

.progress-bar { width: 100%; height: 8px; background: var(--bg-3); border-radius: 2px; overflow: hidden; border: 2px solid var(--border); }
.progress-fill { height: 100%; background: var(--accent); border-radius: 1px; transition: width .1s linear; }

/* ── HUD pills ── */
.info-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-2);
}
.info-pill .val {
  font-family: var(--pixel);
  font-size: .85rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-shadow: 1px 1px 0 rgba(0,0,0,.3);
}
.info-pill.urgent .val { color: var(--danger); }

/* ── Click / aim zone ── */
.click-area {
  width: 100%;
  min-height: 200px;
  border-radius: var(--r);
  background: var(--accent-bg);
  border: 3px solid var(--accent);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background .1s, transform .06s, box-shadow .06s;
  -webkit-user-select: none;
  user-select: none;
}
.click-area:active { transform: translate(4px, 4px); box-shadow: none; }
.click-area .click-count { font-family: var(--pixel); font-size: 2.5rem; color: var(--accent); line-height: 1; text-shadow: 3px 3px 0 rgba(0,0,0,.4); }
.click-area .click-hint  { font-size: .8125rem; color: var(--text-2); font-weight: 500; }

/* ── Footer ── */
.site-footer {
  border-top: 3px solid var(--border);
  padding: 20px 0;
  color: var(--text-2);
  font-size: .8125rem;
  background: var(--bg-2);
}
.site-footer .container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.footer-brand {
  font-family: var(--pixel);
  font-size: .6rem;
  color: var(--accent);
  text-shadow: var(--shadow-sm);
}
.footer-brand span { color: var(--text); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.footer-links a {
  color: var(--text-2);
  text-decoration: none;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  transition: color .12s;
  padding: 2px 0;
}
.footer-links a:hover { color: var(--accent); }
.footer-copy { font-size: .7rem; color: var(--text-2); opacity: .6; }

/* ── SEO content ── */
.seo-content {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 3px solid var(--border);
  color: var(--text-2);
}
.seo-content h2 {
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  margin-top: 24px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.seo-content h2:first-child { margin-top: 0; }
.seo-content p { font-size: .9375rem; line-height: 1.75; margin-bottom: 12px; }

/* ── Homepage ── */
.hero {
  padding: 32px 0 24px;
  text-align: center;
}
.hero h1 {
  font-family: var(--pixel);
  font-size: .85rem;
  letter-spacing: .04em;
  margin-bottom: 16px;
  color: var(--accent);
  text-shadow: 4px 4px 0 rgba(0,0,0,.5);
  line-height: 1.9;
}
.hero p { font-size: .9rem; color: var(--text-2); max-width: 440px; margin: 0 auto 24px; }

.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.game-card {
  background: var(--bg-2);
  border: 3px solid var(--border);
  border-radius: var(--r);
  padding: 16px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  cursor: pointer;
  text-decoration: none;
}
.game-card:hover { border-color: var(--accent); box-shadow: 4px 4px 0 var(--accent); transform: translate(-2px,-2px); }
.game-card .icon { font-size: 1.75rem; line-height: 1; }
.game-card h2 { font-family: var(--pixel); font-size: .5rem; color: var(--text); line-height: 1.8; text-transform: uppercase; letter-spacing: .04em; }
.game-card p  { color: var(--text-2); font-size: .8125rem; flex: 1; line-height: 1.6; }
.game-card .btn { align-self: flex-start; margin-top: 6px; }

.tagline-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-bg);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: var(--pixel);
  font-size: .5rem;
  padding: 6px 14px;
  border-radius: var(--r);
  margin-bottom: 20px;
  letter-spacing: .04em;
  box-shadow: var(--shadow-sm);
}

/* ── Result overlay ── */
.result-overlay {
  text-align: center;
  padding: 28px 20px;
  background: var(--bg-2);
  border: 3px solid var(--accent);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.result-wpm {
  font-family: var(--pixel);
  font-size: 2.5rem;
  color: var(--accent);
  line-height: 1;
  text-shadow: 3px 3px 0 rgba(0,0,0,.4);
}
.result-unit { font-size: .75rem; color: var(--text-2); margin-top: 8px; text-transform: uppercase; letter-spacing: .06em; font-family: var(--pixel); }
.result-meta { margin-top: 16px; display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }
.result-meta span { font-size: .875rem; color: var(--text-2); }
.result-meta strong { color: var(--cyan); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: var(--r);
  font-size: .7rem; font-weight: 700;
  border: 2px solid;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge--success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger); }
.badge--accent  { background: var(--accent-bg);  color: var(--accent);  border-color: var(--accent); }

/* ── Animations ── */
.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ── Responsive (mobile-first) ── */

/* Very small phones (< 340px): 1 col */
@media (max-width: 340px) {
  .games-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: .7rem; }
  .site-logo { font-size: .6rem; }
}

/* Tablet (640px): 3-col grid, footer row, no nav change */
@media (min-width: 640px) {
  .games-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .game-card { padding: 18px 14px; }
  .hero h1 { font-size: 1rem; }
  .page-hero h1 { font-size: 1rem; }
  .site-footer .container { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* Desktop (900px): keep hamburger, just adjust spacing */
@media (min-width: 900px) {
  .games-grid { gap: 14px; }
  .game-card { padding: 20px 16px; }
  .hero { padding: 48px 0 32px; }
  .hero h1 { font-size: 1.15rem; }
  main { padding: 32px 0 72px; }
}

/* Wide (1100px): full padding */
@media (min-width: 1100px) {
  .nav-link { padding: 5px 10px; font-size: .75rem; }
  .games-grid { gap: 16px; }
  .game-card { padding: 24px 20px; }
}

/* Typing test small screen */
@media (max-width: 480px) {
  .typing-text { font-size: .875rem; line-height: 1.85; padding: 12px; }
  .score-display { font-size: 1.75rem; }
  .result-wpm { font-size: 1.75rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .page-hero h1 { font-size: .75rem; }
}

/* ── Pixel corner decoration ── */
.pixel-corners {
  position: relative;
}
.pixel-corners::before, .pixel-corners::after {
  content: '★';
  font-size: .5rem;
  color: var(--accent);
  position: absolute;
  top: 8px;
}
.pixel-corners::before { left: 8px; }
.pixel-corners::after  { right: 8px; }
