/* ═══════════════════════════════════════
   TYPEFAST — Styles (v3 Overhaul)
   High-contrast default, decluttered UI
   ═══════════════════════════════════════ */

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

:root {
  --bg: #000; --bg2: #0a0a0a; --card: #111;
  --text: #f0f0f0; --text2: #bbb; --muted: #777;
  --accent: #818cf8; --accent2: #a78bfa;
  --grad: linear-gradient(135deg, #818cf8, #a78bfa);
  --ok: #34d399; --err: #f87171; --warn: #fbbf24;
  --border: rgba(255,255,255,.1);
  --sh-sm: 0 1px 4px rgba(0,0,0,.4);
  --sh-md: 0 4px 12px rgba(0,0,0,.5);
  --sh-lg: 0 12px 32px rgba(0,0,0,.6);
  --tr: all .2s ease;
  --radius: 12px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.6; min-height: 100vh;
}

body:not(.dark-mode) {
  --bg: #fff; --bg2: #f5f5f5; --card: #f5f5f5;
  --text: #111; --text2: #555; --muted: #999;
  --border: rgba(0,0,0,.1);
  --sh-sm: 0 1px 3px rgba(0,0,0,.08);
  --sh-md: 0 4px 10px rgba(0,0,0,.1);
  --sh-lg: 0 10px 25px rgba(0,0,0,.12);
}

/* ══ LANDING HERO ══════════════════════════════════════════════════ */
.landing-hero {
  min-height: 100vh; width: 100%; display: flex; align-items: center;
  justify-content: center; padding: 40px 20px 60px;
  background: radial-gradient(ellipse at 50% 0%, rgba(129,140,248,.12) 0%, transparent 65%), var(--bg);
  border-bottom: 1px solid var(--border);
}
.landing-inner { max-width: 680px; width: 100%; text-align: center; }
.landing-logo { font-size: 1.1rem; font-weight: 900; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 24px; letter-spacing: -.5px; }
.landing-headline { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 900; color: var(--text); margin-bottom: 14px; letter-spacing: -1.5px; line-height: 1.1; }
.landing-sub { font-size: 1rem; color: var(--text2); line-height: 1.7; max-width: 520px; margin: 0 auto 22px; }
.landing-pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 28px; }
.landing-pill { background: rgba(129,140,248,.1); border: 1px solid rgba(129,140,248,.2); color: var(--accent); border-radius: 100px; padding: 4px 12px; font-size: .72rem; font-weight: 700; }
.landing-start-box { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 24px 28px; margin-bottom: 28px; text-align: left; }
.landing-lang-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.landing-lang-label { font-size: .8rem; font-weight: 600; color: var(--text2); white-space: nowrap; }
.landing-lang-select { flex: 1; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: .85rem; font-weight: 600; cursor: pointer; }
.landing-lang-select:focus { outline: none; border-color: var(--accent); }
.landing-cta {
  width: 100%; padding: 16px 20px; background: var(--grad); color: #fff;
  border: none; border-radius: 12px; font-size: 1.15rem; font-weight: 800;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity .15s, transform .15s;
}
.landing-cta:hover { opacity: .9; transform: translateY(-1px); }
.landing-cta-arrow { font-size: 1.3rem; }
.landing-cta-hint { text-align: center; color: var(--muted); font-size: .7rem; margin-top: 10px; }
.landing-features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.landing-feat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 10px; text-align: center; }
.landing-feat-icon { font-size: 1.4rem; margin-bottom: 6px; }
.landing-feat-name { font-size: .78rem; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.landing-feat-desc { font-size: .65rem; color: var(--muted); line-height: 1.4; }
.landing-scroll-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 100px; padding: 7px 18px; font-size: .75rem; cursor: pointer; font-weight: 600; }
.landing-scroll-btn:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 600px) {
  .landing-features { grid-template-columns: repeat(2, 1fr); }
  .landing-headline { font-size: 2rem; }
  .landing-start-box { padding: 16px; }
}

/* ── Layout ── */
.page-container {
  display: flex; justify-content: center; gap: 32px;
  max-width: 1960px; margin: 0 auto; padding: 16px 40px; min-height: 100vh;
}
.sidebar-ad { flex: 0 0 180px; position: sticky; top: 24px; height: fit-content; max-width: 180px; }
.sidebar-ad.left { order: 1; } .sidebar-ad.right { order: 3; }
.wrap { flex: 1; max-width: 880px; order: 2; min-width: 0; }

/* ── Header ── */
.header { text-align: center; margin-bottom: 6px; }
.header-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; padding: 0 4px;
}
.logo {
  font-size: 1.5rem; font-weight: 900; background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; cursor: pointer; letter-spacing: -.5px;
}
.header-controls {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.header-control-row {
  display: flex; align-items: center; gap: 8px;
}
.header-control-label {
  font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; white-space: nowrap;
}
.header-utils { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.header-settings-wrap { position: relative; }
.header-util-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text2); font-size: .72rem; font-weight: 700;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.header-util-btn:hover { background: rgba(129,140,248,.1); color: var(--text); border-color: rgba(129,140,248,.25); }
.header-util-icon { font-size: .85rem; line-height: 1; opacity: .9; }
.header-util-text { line-height: 1; }

.mode-tabs {
  display: flex; gap: 3px; flex-wrap: wrap; justify-content: center;
  background: var(--card); padding: 4px; border-radius: 14px;
  border: 1px solid var(--border);
}
.mode-tabs .sep {
  width: 1px; background: var(--border); margin: 4px 2px; flex-shrink: 0;
}
.tool-btns { display: flex; gap: 4px; margin-left: 2px; flex-wrap: wrap; justify-content: center; }
.btn-tool-txt { padding: 5px 9px; font-size: .68rem; }

.btn-sm {
  padding: 5px 10px; border: none; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: .72rem; display: flex; align-items: center; gap: 4px;
  background: transparent; color: var(--text2); white-space: nowrap;
  transition: background .15s, color .15s;
}
.btn-sm:hover { background: rgba(129,140,248,.12); color: var(--text); }
.btn-sm.active-nav { background: var(--grad); color: #fff; }
.btn-tool { color: var(--muted); font-size: .68rem; }
.btn-tool:hover { color: var(--text); }

.btn-icon {
  background: transparent; color: var(--muted); padding: 5px;
  border: none; border-radius: 8px; cursor: pointer; font-size: .85rem;
  transition: color .15s, background .15s;
}
.btn-icon:hover { background: rgba(129,140,248,.1); color: var(--text); }

/* ── Streak Bar ── */
.streak-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 16px; margin-bottom: 8px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(251,191,36,.08), rgba(239,68,68,.05));
  border: 1px solid rgba(251,191,36,.15); cursor: pointer;
  transition: var(--tr);
}
.streak-bar:hover { border-color: rgba(251,191,36,.3); }
.streak-flame { font-size: 1.4rem; line-height: 1; }
.streak-info { text-align: left; }
.streak-count { font-size: 1rem; font-weight: 800; color: var(--warn); }
.streak-label { font-size: .68rem; color: var(--muted); }

/* ── Settings Popover ── */
.settings-popover {
  position: absolute; top: 100%; right: 0; z-index: 60;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; min-width: 200px; box-shadow: var(--sh-lg);
  display: none;
}
.settings-popover.open { display: block; }
.settings-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.settings-row:last-child { margin-bottom: 0; }
.settings-label { font-size: .75rem; font-weight: 600; color: var(--text2); min-width: 60px; }

.sel-group {
  display: flex; gap: 2px; background: var(--bg); padding: 2px;
  border-radius: 8px; border: 1px solid var(--border);
}
.sel-btn {
  padding: 4px 10px; border: none; background: transparent; color: var(--text2);
  border-radius: 6px; cursor: pointer; font-weight: 600; font-size: .72rem;
  transition: background .15s, color .15s; white-space: nowrap;
}
.sel-btn:hover { background: rgba(129,140,248,.08); color: var(--text); }
.sel-btn.active { background: var(--grad); color: #fff; }

.lang-select {
  padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: .72rem; font-weight: 600; cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--accent); }

.toggle-group { display: flex; gap: 6px; align-items: center; }
.toggle-switch { position: relative; display: inline-block; width: 34px; height: 17px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: rgba(255,255,255,.1); border-radius: 17px; transition: var(--tr);
}
.toggle-slider:before {
  position: absolute; content: ""; height: 11px; width: 11px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: var(--tr);
}
input:checked + .toggle-slider { background: var(--grad); }
input:checked + .toggle-slider:before { transform: translateX(17px); }
.toggle-label { color: var(--text2); font-size: .72rem; font-weight: 600; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
  gap: 5px; margin-bottom: 10px;
}
.stat-card {
  background: var(--card); padding: 7px 5px; border-radius: 10px;
  text-align: center; border: 1px solid var(--border);
}
.stat-label { color: var(--muted); font-size: .6rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 1px; }
.stat-value { font-size: 1.15rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ── Progress Bar ── */
.progress-bar-container { width: 100%; height: 3px; background: rgba(255,255,255,.06); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.progress-bar { height: 100%; background: var(--grad); transition: width 1s linear; border-radius: 10px; }

/* ── Words Card ── */
.words-card {
  background: var(--card); padding: 22px 18px; border-radius: 14px;
  border: 1px solid var(--border); margin-bottom: 10px;
  min-height: 100px; overflow: hidden;
}
#words { user-select: none; overflow: hidden; font-size: 1.3rem; line-height: 2.1; letter-spacing: .3px; font-weight: 500; }

.word-line { display: flex; flex-wrap: nowrap; align-items: center; margin-bottom: 4px; gap: 10px; overflow: hidden; }
.word {
  padding: 3px 6px; border-radius: 6px; display: inline-block;
  color: var(--muted); flex-shrink: 0; transition: background .15s, color .15s;
}
.word.current { background: var(--grad); color: #fff; }
.word.current.typing-error { background: var(--err); }
.word.correct { color: var(--ok); }
.word.wrong { color: var(--err); text-decoration: line-through; text-decoration-thickness: 2px; }

/* ── Input ── */
.input-container { margin-bottom: 10px; }
.input-wrapper { display: flex; gap: 8px; align-items: center; }
#typeInput {
  flex: 1; font-size: 1.05rem; padding: 12px 14px; border-radius: var(--radius);
  border: 2px solid var(--border); background: var(--card); color: var(--text);
  transition: border-color .15s; font-weight: 500;
}
#typeInput:focus { outline: none; border-color: var(--accent); }
#typeInput:disabled { opacity: .4; cursor: not-allowed; }
.btn-restart {
  background: var(--grad); color: #fff; padding: 12px 18px; white-space: nowrap;
  font-size: .85rem; border: none; border-radius: var(--radius);
  cursor: pointer; font-weight: 700; transition: opacity .15s;
  display: flex; align-items: center; gap: 6px;
}
.btn-restart-glyph { font-size: 1.05rem; font-weight: 400; display: inline-block; line-height: 1; }
.btn-restart:hover { opacity: .85; }
.hint { color: var(--muted); font-size: .68rem; margin-top: 5px; text-align: center; }
.hint kbd { background: var(--card); padding: 1px 5px; border-radius: 3px; border: 1px solid var(--border); font-family: monospace; font-weight: 600; font-size: .65rem; }

/* ── Results ── */
.results-card {
  background: var(--card); padding: 22px; border-radius: 14px;
  text-align: center; border: 1px solid rgba(129,140,248,.2);
  scroll-margin-top: 12px;
}
.results-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 10px; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.result-item { padding: 10px 8px; background: var(--bg); border-radius: 10px; border: 1px solid var(--border); }
.result-label { color: var(--muted); font-size: .65rem; text-transform: uppercase; margin-bottom: 3px; font-weight: 600; }
.result-value { font-size: 1.3rem; font-weight: 800; color: var(--accent); }
.result-value-small { font-size: .82rem; font-weight: 700; color: var(--text); display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.result-sublabel { font-size: .68rem; color: var(--muted); margin-top: 2px; }
.keystroke-correct, .word-correct { color: var(--ok); }
.keystroke-incorrect, .word-incorrect { color: var(--err); }
.results-actions { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.btn-share { background: var(--grad); color: #fff; border: none; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: .78rem; cursor: pointer; }
.btn-share:hover { opacity: .85; }
.loading-indicator { padding: 28px; text-align: center; }
.loading-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top: 3px solid var(--accent); border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ── Falling Canvas ── */
#fallingCanvas { width: 100%; border-radius: 14px; background: var(--card); border: 1px solid var(--border); display: block; margin-bottom: 10px; }

/* ── Lives ── */
.lives-display { display: flex; gap: 4px; align-items: center; justify-content: center; margin-bottom: 8px; font-size: 1rem; }
.lives-display .heart.lost { opacity: .15; }

/* ── Banners ── */
.sd-banner { text-align: center; padding: 7px 12px; background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.2); border-radius: 10px; margin-bottom: 10px; font-weight: 700; color: var(--err); font-size: .78rem; }
.mode-banner { text-align: center; padding: 7px 12px; border-radius: 10px; margin-bottom: 10px; font-weight: 700; font-size: .78rem; }
.ghost-banner { background: rgba(129,140,248,.08); border: 1px solid rgba(129,140,248,.15); color: var(--accent); }
.memory-banner { background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.15); color: var(--warn); }

/* ── Ghost Track ── */
.ghost-track { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.track-header { display: flex; justify-content: space-between; font-size: .75rem; font-weight: 600; margin-bottom: 6px; }
.track-header .label { color: var(--muted); } .track-header .pb { color: var(--accent); }
.track-bar { position: relative; height: 26px; background: var(--bg); border-radius: 8px; overflow: hidden; }
.track-indicator { position: absolute; top: 50%; transform: translateY(-50%); font-size: .95rem; transition: left .15s linear; z-index: 2; }
.track-indicator.ghost-ind { z-index: 1; opacity: .5; }
.track-finish { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: .8rem; }

/* ── Bomb ── */
.bomb-area { margin-bottom: 10px; }
.bomb-container { background: var(--card); border-radius: 14px; padding: 22px; border: 1px solid var(--border); text-align: center; overflow: hidden; }
.bomb-header { display: flex; justify-content: center; gap: 24px; margin-bottom: 16px; }
.bomb-stat { text-align: center; }
.bomb-stat-label { font-size: .6rem; text-transform: uppercase; color: var(--muted); display: block; font-weight: 600; }
.bomb-stat-value { font-size: 1.2rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.bomb-visual { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.bomb-fuse-track { flex: 1; max-width: 260px; height: 5px; background: rgba(255,255,255,.06); border-radius: 5px; overflow: hidden; }
.bomb-fuse { height: 100%; width: 100%; border-radius: 5px; background: linear-gradient(90deg, #f87171, #fbbf24, #34d399); }
.bomb-emoji { font-size: 2.5rem; }
.bomb-emoji.exploding { animation: explode .5s ease-out forwards; }
@keyframes explode { 0% { transform: scale(1); } 40% { transform: scale(2.5); } 100% { transform: scale(3); opacity: 0; } }
.bomb-timer { font-size: 1.4rem; font-weight: 900; color: var(--warn); min-width: 50px; font-variant-numeric: tabular-nums; }
.bomb-timer.bomb-critical { color: var(--err); }
.bomb-word { font-size: 1.8rem; font-weight: 800; letter-spacing: 2px; padding: 12px 20px; border-radius: 10px; background: rgba(129,140,248,.06); border: 2px solid var(--border); color: var(--text); display: inline-block; min-width: 160px; }
.bomb-word.bomb-wrong { border-color: var(--err); background: rgba(248,113,113,.06); }
.bomb-hint { font-size: .68rem; color: var(--muted); margin-top: 10px; }
.bomb-lives { font-size: 1rem; display: flex; gap: 2px; }

/* ── Musical ── */
.musical-area { margin-bottom: 10px; }
.musical-container { background: var(--card); border-radius: 14px; padding: 22px; border: 1px solid var(--border); }
.musical-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.musical-melody-name { font-size: .82rem; font-weight: 700; color: var(--accent); background: rgba(129,140,248,.08); padding: 3px 10px; border-radius: 7px; }
.musical-score-display { font-size: .78rem; color: var(--muted); }
.musical-notes-track { display: flex; gap: 4px; padding: 12px; background: var(--bg); border-radius: 10px; margin-bottom: 12px; min-height: 48px; align-items: center; flex-wrap: wrap; }
.musical-note { padding: 5px 10px; border-radius: 6px; font-weight: 700; font-size: .82rem; background: var(--card); color: var(--muted); border: 1px solid var(--border); flex-shrink: 0; }
.musical-note.current-note { background: var(--grad); color: #fff; }
.musical-note.played { color: var(--ok); border-color: rgba(52,211,153,.2); opacity: .5; }
.musical-keyboard { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.musical-key-row { display: flex; gap: 3px; }
.m-key { width: 44px; height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 7px; background: var(--bg); border: 1px solid var(--border); font-weight: 700; font-size: .82rem; color: var(--text); }
.m-key small { font-size: .48rem; color: var(--muted); }
.m-key.active { background: var(--grad); color: #fff; }

/* ── Memory ── */
body.memory-active .word.mem-1 { opacity: .4; }
body.memory-active .word.mem-2 { opacity: .18; }
body.memory-active .word.mem-3 { opacity: .06; }
body.memory-active .word.mem-hidden { opacity: 0; }

/* ── Marathon ── */
.marathon-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.marathon-controls select { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: .78rem; font-weight: 600; cursor: pointer; }
.marathon-progress { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.marathon-bar { flex: 1; height: 5px; background: rgba(255,255,255,.06); border-radius: 5px; overflow: hidden; }
.marathon-fill { height: 100%; background: var(--grad); border-radius: 5px; transition: width .3s; }
.marathon-pct { font-size: .75rem; font-weight: 700; color: var(--accent); }

/* ── Zen ── */
body.zen-active .word.current.typing-error { background: rgba(251,191,36,.12); }
body.zen-active .word.wrong { color: var(--warn); text-decoration: none; opacity: .6; }
.zen-message { text-align: center; color: var(--muted); font-size: .8rem; font-style: italic; margin-bottom: 10px; }

/* ── Panels (overlays) ── */
.panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(4px);
}
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto;
  padding: 26px; position: relative;
}
.panel-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: var(--muted); font-size: 1.3rem; cursor: pointer; padding: 4px 8px;
  border-radius: 6px; line-height: 1;
}
.panel-close:hover { color: var(--text); background: rgba(255,255,255,.06); }
.panel h2 { font-size: 1.2rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 12px; }
.panel h3 { font-size: .9rem; font-weight: 700; margin: 16px 0 6px; color: var(--text); }

/* Heatmap */
.kb-row { display: flex; justify-content: center; gap: 3px; margin-bottom: 3px; }
.kb-key { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: .7rem; font-weight: 700; border: 1px solid var(--border); text-transform: uppercase; }
.kb-key.space { width: 220px; }
.kb-key[data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%); background: var(--bg); color: var(--text); padding: 3px 8px; border-radius: 5px; font-size: .65rem; white-space: nowrap; z-index: 10; border: 1px solid var(--border); font-weight: 400; }
.stat-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; margin: 12px 0; }
.stat-box { background: var(--bg); padding: 12px; border-radius: 10px; text-align: center; border: 1px solid var(--border); }
.stat-box .val { font-size: 1.3rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-box .lbl { font-size: .65rem; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.stat-box[data-info]:hover::after { content: attr(data-info); position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%); background: var(--bg); color: var(--text); padding: 4px 10px; border-radius: 7px; font-size: .7rem; white-space: nowrap; z-index: 10; border: 1px solid var(--border); font-weight: 400; text-transform: none; }
.stat-box[data-info] { cursor: help; position: relative; }
.hs-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.hs-table th, .hs-table td { padding: 6px 8px; text-align: left; font-size: .78rem; border-bottom: 1px solid var(--border); }
.hs-table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .65rem; }
.hs-empty { text-align: center; padding: 24px; color: var(--muted); font-size: .85rem; }
.hs-tabs { display: flex; gap: 3px; margin-bottom: 8px; flex-wrap: wrap; }

/* ── Ads ── */
.sidebar-ad ins { display: block; min-width: 160px; min-height: 600px; }
.bottom-ad-mobile { display: none; margin-top: 16px; text-align: center; }

/* ── Footer ── */
.footer { text-align: center; padding: 16px 16px 10px; color: var(--muted); font-size: .72rem; border-top: 1px solid var(--border); margin-top: 20px; }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-links { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }

/* ══ RICH PAGE CONTENT ══════════════════════════════════════════════ */
.page-content { margin-top: 36px; border-top: 1px solid var(--border); padding-top: 30px; }
.pc-section { margin-bottom: 40px; }
.pc-h2 { font-size: 1.3rem; font-weight: 800; color: var(--text); margin-bottom: 12px; }
.pc-p { font-size: .88rem; color: var(--text2); line-height: 1.8; margin-bottom: 10px; }
.pc-how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.pc-how-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; gap: 12px; align-items: flex-start; }
.pc-how-num { width: 28px; height: 28px; background: var(--grad); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.pc-how-text { font-size: .82rem; color: var(--text2); line-height: 1.6; }
.pc-how-text strong { color: var(--text); }
.pc-table-wrap { overflow-x: auto; margin-top: 12px; }
.pc-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.pc-table th { background: var(--card); color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .65rem; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.pc-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text2); }
.pc-table tr:last-child td { border-bottom: none; }
.pc-table tr:hover td { background: rgba(129,140,248,.03); }
.pc-tips { margin-left: 20px; }
.pc-tips li { font-size: .85rem; color: var(--text2); line-height: 1.7; margin-bottom: 10px; }
.pc-tips li strong { color: var(--text); }
.pc-modes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 12px; }
.pc-mode { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: .82rem; color: var(--text2); line-height: 1.5; }
.pc-mode strong { color: var(--text); }
.pc-mode-icon { margin-right: 4px; }
.pc-faq { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.pc-faq-item { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.pc-faq-item summary { padding: 12px 16px; font-size: .88rem; font-weight: 700; color: var(--text); cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.pc-faq-item summary::after { content: '+'; color: var(--muted); font-size: 1rem; }
.pc-faq-item[open] summary::after { content: '−'; }
.pc-faq-item p { padding: 0 16px 12px; font-size: .82rem; color: var(--text2); line-height: 1.7; }
@media (max-width: 768px) {
  .pc-how-grid { grid-template-columns: 1fr; }
  .pc-modes-grid { grid-template-columns: 1fr; }
}

/* ═══ Tutorial (Full-Screen) ═══ */
.tut-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(6px); }
.tut-card { max-width: 600px; width: 100%; text-align: center; }
.tut-close { position: fixed; top: 16px; right: 20px; background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; z-index: 201; }
.tut-close:hover { color: #fff; }
.tut-step-bar { display: flex; gap: 4px; justify-content: center; margin-bottom: 24px; }
.tut-step-dot { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.15); }
.tut-step-dot.active { background: var(--accent); }
.tut-step-dot.done { background: var(--ok); }
.tut-title { font-size: 1.6rem; font-weight: 900; color: #fff; margin-bottom: 10px; }
.tut-body { font-size: .95rem; color: rgba(255,255,255,.7); line-height: 1.7; margin-bottom: 20px; max-width: 480px; margin-left: auto; margin-right: auto; }
.tut-keyboard { display: flex; flex-direction: column; gap: 5px; align-items: center; margin: 20px 0; }
.tut-kb-row { display: flex; gap: 4px; justify-content: center; }
.tut-key {
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: .9rem; font-weight: 700;
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.4); transition: all .2s;
}
.tut-key.highlight { border-color: transparent; color: #fff; transform: scale(1.08); }
.tut-key.pressed { background: #fff !important; color: #000 !important; transform: scale(.92); }
.tut-space { width: 220px; font-size: .7rem; }
.tut-finger-guide { margin: 16px 0 12px; }
.tut-finger-guide-title { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.4); margin-bottom: 10px; }
.tut-finger-rows { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; }
.tut-finger-hand { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tut-finger-hand-label { font-size: .7rem; font-weight: 700; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: .5px; }
.tut-finger-chips { display: flex; gap: 5px; }
.tut-finger-chip { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tut-finger-chip-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .55rem; font-weight: 800; color: #fff; }
.tut-finger-chip-label { font-size: .6rem; color: rgba(255,255,255,.5); font-weight: 600; }
/* keep old legend as fallback */
.tut-finger-legend { font-size: .72rem; margin-top: 8px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; color: rgba(255,255,255,.6); }
.tut-practice { margin: 20px auto; max-width: 480px; }
.tut-practice-label { font-size: .75rem; color: rgba(255,255,255,.5); margin-bottom: 6px; }
.tut-practice-word { font-size: 1.1rem; font-weight: 700; color: #fff; background: rgba(255,255,255,.06); padding: 12px 16px; border-radius: 10px; margin-bottom: 10px; font-family: monospace; letter-spacing: 1.5px; border: 1px solid rgba(255,255,255,.1); word-break: break-all; }
.tut-input { width: 100%; padding: 12px 16px; border-radius: 10px; border: 2px solid rgba(255,255,255,.15); background: rgba(255,255,255,.04); color: #fff; font-size: 1rem; font-family: monospace; text-align: center; }
.tut-input:focus { outline: none; border-color: var(--accent); }
.tut-success { color: var(--ok); font-weight: 700; font-size: .9rem; margin-top: 8px; }
.tut-nav { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }
.tut-btn { padding: 10px 24px; border: none; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: .9rem; transition: opacity .15s; }
.tut-btn-primary { background: var(--grad); color: #fff; }
.tut-btn-secondary { background: rgba(255,255,255,.08); color: rgba(255,255,255,.6); }
.tut-btn:hover { opacity: .85; }

/* ═══ Streak Popup ═══ */
.streak-popup-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.8); z-index: 190; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.streak-popup {
  text-align: center; padding: 40px 32px; max-width: 380px; width: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  position: relative;
}
.streak-popup-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.streak-popup-flame { font-size: 4rem; margin-bottom: 8px; display: block; }
.streak-popup-count { font-size: 3rem; font-weight: 900; color: var(--warn); margin-bottom: 2px; }
.streak-popup-label { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.streak-popup-msg { font-size: .85rem; color: var(--muted); margin-bottom: 20px; }
.streak-popup-cta { background: var(--grad); color: #fff; border: none; padding: 12px 32px; border-radius: 12px; font-weight: 700; font-size: 1rem; cursor: pointer; }
.streak-popup-cta:hover { opacity: .85; }

/* ═══ Badges ═══ */
.badges-summary { text-align: center; font-size: .82rem; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.badge-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 8px; text-align: center; }
.badge-card.unlocked { border-color: rgba(129,140,248,.25); }
.badge-card.locked { opacity: .35; }
.badge-icon { font-size: 1.5rem; margin-bottom: 4px; }
.badge-name { font-size: .72rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.badge-desc { font-size: .65rem; color: var(--muted); }
.badge-toast { position: fixed; bottom: 20px; right: 20px; z-index: 200; background: var(--card); border: 1px solid rgba(129,140,248,.3); border-radius: var(--radius); padding: 10px 14px; display: flex; gap: 8px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.5); transform: translateX(120%); transition: transform .4s cubic-bezier(.4,0,.2,1); max-width: 280px; }
.badge-toast.show { transform: translateX(0); }
.badge-toast-icon { font-size: 1.6rem; flex-shrink: 0; }
.badge-toast strong { color: var(--text); font-size: .82rem; }
.badge-toast small { color: var(--muted); font-size: .72rem; }

/* ═══ Lessons ═══ */
.lesson-card { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 5px; }
.lesson-card.completed { border-color: rgba(52,211,153,.2); }
.lesson-num { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.lesson-card.completed .lesson-num { background: var(--ok); }
.lesson-info { flex: 1; }
.lesson-name { font-weight: 700; font-size: .85rem; }
.lesson-desc { font-size: .72rem; color: var(--muted); }
.lesson-stats { font-size: .68rem; color: var(--accent); font-weight: 600; }
.lesson-start { padding: 5px 12px; border: none; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: .75rem; background: var(--grad); color: #fff; }
.lesson-words-area { display: flex; flex-wrap: wrap; gap: 5px; padding: 12px; background: var(--bg); border-radius: 10px; margin-bottom: 8px; min-height: 50px; justify-content: center; border: 1px solid var(--border); }
.lesson-word { padding: 3px 7px; border-radius: 5px; font-size: 1rem; font-weight: 600; color: var(--muted); }
.lesson-word.current { background: var(--grad); color: #fff; }
.lesson-word.done { color: var(--ok); }
.lesson-input { width: 100%; padding: 10px; border-radius: 10px; border: 2px solid var(--border); background: var(--card); color: var(--text); font-size: 1rem; text-align: center; }
.lesson-input:focus { outline: none; border-color: var(--accent); }
.lesson-result { text-align: center; margin-top: 8px; padding: 8px; background: rgba(52,211,153,.06); border: 1px solid rgba(52,211,153,.15); border-radius: 8px; color: var(--ok); font-size: .85rem; }

/* ═══ Accessibility ═══ */
.a11y-options { display: flex; flex-direction: column; gap: 8px; }
.a11y-option { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: .85rem; font-weight: 600; color: var(--text); cursor: pointer; border: 1px solid var(--border); }
.a11y-option input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
body.dyslexia-font, body.dyslexia-font * { font-family: 'Lexend', 'OpenDyslexic', sans-serif !important; }
body.large-text #words { font-size: 1.7rem; }
body.large-text .word { padding: 5px 8px; }
body.large-text #typeInput { font-size: 1.2rem; padding: 14px; }
body.reduced-motion, body.reduced-motion * { animation-duration: 0s !important; transition-duration: 0s !important; }

/* ═══ Combo (subtle) ═══ */
.combo-popup {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 1.5rem; font-weight: 900; color: var(--accent);
  pointer-events: none; z-index: 50; animation: comboFade .8s ease-out forwards;
}
@keyframes comboFade { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -70%) scale(1); } }
.error-flash { animation: errorFlash .28s ease-out; }
@keyframes errorFlash {
  0%,100% { box-shadow: 0 0 0 0 transparent; }
  30% { box-shadow: 0 0 0 4px rgba(248,113,113,.5), inset 0 0 20px rgba(248,113,113,.08); }
  70% { box-shadow: 0 0 0 3px rgba(248,113,113,.3), inset 0 0 12px rgba(248,113,113,.05); }
}

/* ═══ Responsive ═══ */
@media (max-width: 1500px) { .page-container { padding: 14px 24px; gap: 24px; } .sidebar-ad { flex: 0 0 160px; max-width: 160px; } }
@media (max-width: 1400px) { .sidebar-ad { flex: 0 0 140px; max-width: 140px; } .sidebar-ad ins { min-width: 120px !important; width: 120px !important; } }
@media (max-width: 1200px) { .page-container { flex-direction: column; } .sidebar-ad { display: none; } .bottom-ad-mobile { display: block; } }
@media (max-width: 768px) {
  .page-container { padding: 12px 14px !important; gap: 12px !important; }
  .header-top { flex-wrap: wrap; gap: 10px; }
  .header-controls { order: 3; width: 100%; justify-content: center; }
  .header-util-btn { padding: 5px 8px; font-size: .65rem; }
  .logo { font-size: 1.2rem; }
  #words { font-size: 1.05rem; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .tut-key { width: 36px; height: 36px; font-size: .75rem; }
  .tut-title { font-size: 1.2rem; }
  .kb-key { width: 28px; height: 28px; font-size: .55rem; }
}
@media (max-width: 480px) {
  .words-card { padding: 14px 10px; }
  #words { font-size: .92rem; }
  .input-wrapper { flex-direction: column; gap: 6px; }
  .btn-restart { width: 100%; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .stat-card { padding: 5px 3px; }
  .stat-value { font-size: .95rem; }
  .btn-sm { padding: 4px 7px; font-size: .65rem; }
  .tut-key { width: 30px; height: 30px; font-size: .65rem; }
  .streak-popup { padding: 28px 20px; }
}
