/* =====================================================
   Type Master 2.0 — Core Styles
   ===================================================== */

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

:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --surface: #1e1e3a;
  --surface2: #252545;
  --border: #2a2a4a;
  --text: #d1d0c5;
  --text-muted: #646669;
  --text-dim: #4a4a6a;
  --accent: #e2b714;
  --accent2: #c4a012;
  --correct: #6eb587;
  --error: #ca4754;
  --cursor: #e2b714;
  --font-mono: 'Roboto Mono', 'Courier New', monospace;
  --font-ui: 'Inter', sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --transition: .15s ease;
  --nav-h: 60px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea { font: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =====================================================
   NAVBAR
   ===================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
}
.nav-logo em {
  color: var(--accent);
  font-style: normal;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-links a {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--surface);
}
.nav-links a.active { color: var(--accent); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #1a1a2e;
  font-weight: 600;
  font-size: 14px;
  padding: 7px 18px;
  border-radius: var(--radius);
  transition: opacity var(--transition), transform var(--transition);
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); }

.btn-outline {
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  padding: 6px 16px;
  border-radius: var(--radius);
  transition: border-color var(--transition), color var(--transition);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.btn-icon:hover { color: var(--text); background: var(--surface); }

.btn-small {
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
}

/* ── User Menu ── */
.user-menu { position: relative; }
.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  object-fit: cover;
  transition: border-color var(--transition);
}
.nav-avatar:hover { border-color: var(--accent); }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  min-width: 140px;
  display: none;
  box-shadow: var(--shadow);
  z-index: 200;
}
.user-menu:hover .user-dropdown { display: flex; flex-direction: column; gap: 2px; }
.user-dropdown a, .user-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  width: 100%;
  text-align: left;
  transition: color var(--transition), background var(--transition);
}
.user-dropdown a:hover, .user-dropdown button:hover { color: var(--text); background: var(--bg2); }

/* =====================================================
   AD SLOTS
   ===================================================== */
.ad-container { display: flex; justify-content: center; padding: 8px 0; }
.ad-728x90-wrap { min-height: 98px; }

.ad-slot {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  color: var(--text-dim);
  font-size: 11px;
}
.ad-slot[data-slot="728x90"] { width: 728px; height: 90px; max-width: 100%; }
.ad-slot[data-slot="300x250"] { width: 300px; height: 250px; }
.ad-slot[data-slot="160x600"] { width: 160px; height: 600px; }
.ad-slot[data-slot="160x300"] { width: 160px; height: 300px; }

.ad-slot img { width: 100%; height: 100%; object-fit: cover; }
.ad-slot a { display: block; width: 100%; height: 100%; }

.ad-side {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
}
.ad-left-side { left: 8px; }
.ad-right-side { right: 8px; }

@media (max-width: 1440px) { .ad-side { display: none; } }

/* =====================================================
   MAIN CONTAINER
   ===================================================== */
.main-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ── Test Config ── */
.test-config {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 52px;
}
.config-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.config-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.config-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.pill:hover { color: var(--text); background: var(--surface2); }
.pill.active { color: var(--accent); background: transparent; border-color: var(--accent); }
.config-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Daily Challenge Banner ── */
.challenge-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(226,183,20,.1), rgba(106,142,217,.1));
  border: 1px solid rgba(226,183,20,.3);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--accent);
}
.challenge-banner svg { flex-shrink: 0; }
.challenge-banner .btn-small {
  margin-left: auto;
  background: var(--accent);
  color: #1a1a2e;
  font-weight: 600;
}

/* ── Live Stats ── */
.live-stats {
  display: flex;
  gap: 32px;
  justify-content: center;
  margin-bottom: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.stat-val {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
  transition: color .1s;
}
.stat-lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.timer-item .stat-val { color: var(--text); font-size: 42px; }
.timer-item .stat-lbl { font-size: 12px; letter-spacing: .12em; }
.timer-item.warning .stat-val { color: var(--error); }

/* ── Custom Text Input ── */
.custom-input-wrap {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.custom-input-wrap textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}
.custom-input-wrap textarea:focus { border-color: var(--accent); }
.custom-input-wrap .btn-primary { align-self: flex-start; }

/* ── TEST BOX ── */
.test-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  cursor: text;
  min-height: 140px;
  transition: border-color var(--transition);
  user-select: none;
}
.test-box:focus-within,
.test-box.active { border-color: var(--accent); }
.test-box.blurred::after {
  content: 'Click to focus';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26,26,46,.85);
  color: var(--text-muted);
  font-size: 16px;
  border-radius: var(--radius-lg);
  backdrop-filter: blur(2px);
}

.test-words {
  font-family: var(--font-mono);
  font-size: 22px;
  line-height: 2;
  color: var(--text-muted);
  letter-spacing: .02em;
  position: relative;
  overflow: hidden;
  max-height: 132px; /* 3 lines visible */
}
.loader-text {
  font-size: 15px;
  color: var(--text-dim);
  font-family: var(--font-ui);
}

/* Word spans */
.word {
  display: inline-block;
  margin-right: 12px;
  position: relative;
}
.word.current .char.cursor-char::before { display: block; }

/* Character spans */
.char {
  position: relative;
  transition: color .05s;
}
.char.correct { color: var(--correct); }
.char.incorrect { color: var(--error); text-decoration: underline; text-decoration-color: var(--error); }
.char.extra { color: var(--error); opacity: .7; }

/* Caret */
.caret {
  position: absolute;
  width: 2px;
  height: 1.4em;
  background: var(--cursor);
  border-radius: 1px;
  pointer-events: none;
  animation: blink 1s step-start infinite;
  transition: left .07s ease, top .1s ease;
  display: none;
}
.caret.visible { display: block; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
.caret.typing { animation: none; opacity: 1; }

.hidden-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* ── Test Controls ── */
.test-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  justify-content: center;
}
.control-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  border: 1px solid transparent;
  width: auto;
  transition: all var(--transition);
}
.control-btn:hover { color: var(--accent); border-color: var(--border); }
.hint-text {
  font-size: 12px;
  color: var(--text-dim);
}

/* =====================================================
   RESULT SCREEN
   ===================================================== */
.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 32px 24px;
  animation: fadeInUp .3s ease;
}
@keyframes fadeInUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }

.result-title {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 500;
}
.result-main {
  display: flex;
  align-items: center;
  gap: 48px;
  width: 100%;
  max-width: 700px;
  flex-wrap: wrap;
  justify-content: center;
}
.result-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.result-number {
  font-family: var(--font-mono);
  font-size: 80px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}
.result-unit {
  font-size: 20px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}
.rs-val {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.rs-lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.result-chart-wrap {
  width: 100%;
  max-width: 700px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}
.pb-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: linear-gradient(135deg, rgba(226,183,20,.15), rgba(226,183,20,.05));
  border: 1px solid rgba(226,183,20,.4);
  border-radius: 20px;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  animation: popIn .4s ease;
}
@keyframes popIn { 0%{transform:scale(.5);opacity:0} 80%{transform:scale(1.1)} 100%{transform:scale(1);opacity:1} }

.achievement-unlock {
  padding: 10px 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  animation: fadeInUp .3s ease;
}
.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.result-actions .btn-outline, .result-actions .btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
}

/* =====================================================
   ON-SCREEN KEYBOARD
   ===================================================== */
.onscreen-keyboard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 20px;
}
.kb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.kb-layout { display: flex; flex-direction: column; gap: 6px; }
.kb-row { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.kb-key {
  min-width: 38px;
  height: 38px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  padding: 2px 6px;
  cursor: pointer;
  transition: all .1s;
  position: relative;
}
.kb-key.active-key {
  background: var(--accent);
  color: #1a1a2e;
  border-color: var(--accent);
}
.kb-key .urdu-char {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: 14px;
  color: var(--accent);
}
.kb-key .en-char {
  font-size: 9px;
  color: var(--text-dim);
}
.kb-key.kb-wide { min-width: 56px; }
.kb-key.kb-space { min-width: 180px; }
.toggle-kb-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 12px;
}

/* =====================================================
   BOTTOM SECTION
   ===================================================== */
.bottom-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 48px;
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.bottom-stats-wrap { flex: 1; min-width: 260px; }
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 16px;
}
.mini-stats-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.mini-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 80px;
}
.ms-val {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.ms-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

/* =====================================================
   THEMES PANEL
   ===================================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
}
.themes-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 400;
  overflow-y: auto;
  animation: slideIn .2s ease;
}
@keyframes slideIn { from{transform:translateX(100%)} to{transform:translateX(0)} }
.themes-panel-inner { padding: 20px; }
.themes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.themes-header h3 { font-size: 16px; font-weight: 600; }
.themes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.theme-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition);
}
.theme-card.active { border-color: var(--accent); }
.theme-preview {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
}
.theme-dot { width: 10px; height: 10px; border-radius: 50%; }
.theme-label {
  text-align: center;
  font-size: 11px;
  padding: 6px;
  background: var(--bg2);
  color: var(--text-muted);
}
.custom-theme-section h4 { font-size: 13px; margin-bottom: 12px; color: var(--text-muted); }
.custom-theme-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.custom-theme-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  align-items: center;
}
.custom-theme-row input[type="color"] {
  width: 36px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  padding: 2px;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Share card */
.share-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.share-logo {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 12px;
}
.share-wpm {
  font-family: var(--font-mono);
  font-size: 52px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.share-wpm span { font-size: 20px; color: var(--text-muted); }
.share-stats { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

/* =====================================================
   TOAST
   ===================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  z-index: 1000;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =====================================================
   FOOTER
   ===================================================== */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 40px 24px 20px;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}
.footer-brand p { font-size: 13px; color: var(--text-muted); margin-top: 10px; line-height: 1.7; }
.footer-col-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.footer-links { display: flex; flex-direction: column; gap: 10px; }
.footer-links a {
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--accent); }
.admin-link { color: var(--text-dim) !important; }
.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* ── Live stats: only show timer during test, hide WPM/CPM/ACC ── */
#liveStats .stat-item:not(.timer-item) { display: none !important; }

/* ── Timer warning ── */
.stat-item.warning .stat-val { color: var(--error) !important; animation: blink 0.5s ease infinite alternate; }
@keyframes blink { from{opacity:1} to{opacity:.4} }

/* ── Challenge Banner ── */
.challenge-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(226,183,20,.08);
  border: 1px solid rgba(226,183,20,.25);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.btn-small {
  background: var(--accent);
  color: #1a1a2e;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.btn-small:hover { background: var(--accent2); }

/* ── Ad slot base ── */
.ad-slot { min-height: 24px; display: flex; align-items: center; justify-content: center; }
.ad-slot img { max-width: 100%; height: auto; }
.ad-slot a { display: block; }
.ad-container { text-align: center; padding: 6px 0; }
.ad-728x90-wrap .ad-slot { width: 728px; height: 90px; max-width: 100%; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); margin: 0 auto; }
.ad-slot.ad-300x250-slot { width: 300px; height: 250px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.ad-side {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
}
.ad-left-side { left: 8px; }
.ad-right-side { right: 8px; }
.ad-side .ad-slot { width: 160px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); min-height: 300px; }

/* =====================================================
   FOCUS MODE
   ===================================================== */
body.focus-mode .navbar,
body.focus-mode .test-config,
body.focus-mode .bottom-section,
body.focus-mode .footer,
body.focus-mode .ad-container,
body.focus-mode .ad-side,
body.focus-mode .challenge-banner { display: none !important; }
body.focus-mode .main-container { padding-top: 20vh; }

/* =====================================================
   UTILITIES
   ===================================================== */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.mt-4 { margin-top: 4px; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .main-container { padding: 20px 16px; }
  .test-words { font-size: 18px; }
  .test-box { padding: 20px 16px; }
  .result-number { font-size: 56px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .live-stats { gap: 16px; padding: 10px 16px; }
  .stat-val { font-size: 20px; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
  .ad-728x90-wrap { display: none; }
}
@media (max-width: 480px) {
  .result-main { flex-direction: column; gap: 24px; }
  .test-config { gap: 6px; padding: 10px 12px; }
  .pill { font-size: 12px; padding: 3px 10px; }
  .bottom-section { flex-direction: column; }
}

/* ═══════════════════════════════════════════════
   Typing Live Effects & Animations
   ═══════════════════════════════════════════════ */

/* Correct word pop */
@keyframes wordPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.13); }
  100% { transform: scale(1); }
}
.word-pop { animation: wordPop 0.22s ease-out !important; }

/* Error word shake */
@keyframes wordShake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(3px); }
}
.word-shake { animation: wordShake 0.28s ease-in-out !important; }

/* Timer urgent pulse (≤ 10 s) */
@keyframes timerPulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.14); }
}
.stat-item.urgent .stat-val {
  animation: timerPulse 0.65s ease-in-out infinite !important;
  color: #ff4757 !important;
}

/* Timer tick on each second */
@keyframes timerTick {
  0%   { transform: scale(1.18); opacity: 0.65; }
  100% { transform: scale(1);    opacity: 1; }
}
.timer-tick { animation: timerTick 0.2s ease-out; }

/* Key-press particles */
@keyframes particleFly {
  0%   { opacity: 0.95; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0;    transform: translate(-50%, -44px) scale(0.1); }
}
.key-particle {
  position: fixed;
  width: 6px; height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  animation: particleFly 0.55s ease-out forwards;
}

/* Combo streak badge */
.combo-badge {
  position: fixed;
  bottom: 90px; right: 24px;
  padding: 7px 18px;
  background: rgba(226,183,20,.13);
  border: 1px solid rgba(226,183,20,.45);
  border-radius: 24px;
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  color: var(--accent);
  opacity: 0;
  transform: translateY(10px) scale(0.85);
  transition: opacity .22s, transform .22s;
  pointer-events: none;
  z-index: 200;
}
.combo-badge.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
@keyframes comboBounce {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.28); }
  100% { transform: scale(1); }
}
.combo-badge.bounce { animation: comboBounce 0.25s ease-out; }

/* Screen flash on test complete */
@keyframes screenFlash {
  0%   { opacity: 0; }
  20%  { opacity: 0.09; }
  100% { opacity: 0; }
}
.screen-flash-el {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9998;
  animation: screenFlash 0.55s ease-out forwards;
}

/* Caret glow */
.caret.visible {
  box-shadow: 0 0 8px 1px var(--cursor), 0 0 2px var(--cursor);
}

/* ── Partner Links (footer) ── */
.partner-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.partner-btn {
  padding: 4px 14px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-decoration: none;
  letter-spacing: .04em;
  transition: color .15s, border-color .15s;
}
.partner-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── AdBlock Overlay ── */
#tm_adblock_overlay {
  position: fixed; inset: 0;
  background: rgba(13,14,26,.96);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.adblock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  max-width: 440px;
  text-align: center;
}
.adblock-icon { color: var(--error); margin-bottom: 16px; }
.adblock-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.adblock-card p  { color: var(--text-muted); font-size: 14px; line-height: 1.7; margin-bottom: 24px; }
.adblock-btn {
  padding: 11px 28px;
  background: var(--accent);
  color: #1a1a2e;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s;
}
.adblock-btn:hover { opacity: .85; }
