/* ================================
   TypingTest4Me — Stylesheet
   Energetic, fast, game-like feel
   ================================ */

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

:root {
  --ink:         #0f172a;
  --ink-soft:    #334155;
  --ink-mute:    #94a3b8;
  --bg:          #fff7ed;
  --white:       #ffffff;
  --primary:     #ea580c;
  --primary-lt:  #fff7ed;
  --primary-dk:  #c2410c;
  --primary-bdr: #fed7aa;
  --blue:        #2563eb;
  --blue-lt:     #eff6ff;
  --green:       #059669;
  --green-lt:    #ecfdf5;
  --purple:      #7c3aed;
  --purple-lt:   #f5f3ff;
  --amber:       #d97706;
  --amber-lt:    #fffbeb;
  --rose:        #e11d48;
  --rose-lt:     #fff1f2;
  --teal:        #0891b2;
  --teal-lt:     #ecfeff;
  --border:      #fed7aa;
  --border-md:   #fdba74;
  --shadow-sm:   0 1px 3px rgba(15,23,42,0.07);
  --shadow-md:   0 4px 18px rgba(15,23,42,0.10);
  --shadow-lg:   0 12px 40px rgba(15,23,42,0.13);
  --radius:      16px;
  --radius-sm:   10px;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --font-display:'Outfit', system-ui, sans-serif;
  --font-body:   'Outfit', system-ui, sans-serif;

  /* Typing colours */
  --char-correct:  #059669;
  --char-error:    #e11d48;
  --char-cursor:   #ea580c;
}

html { scroll-behavior: smooth; }
body { font-family: var(--font-body); background: var(--bg); color: var(--ink); line-height: 1.6; font-size: 16px; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ---- Header ---- */
.site-header { background: var(--white); border-bottom: 2px solid var(--border); position: sticky; top: 0; z-index: 200; box-shadow: var(--shadow-sm); }
.hdr-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-icon { font-size: 26px; }
.logo-text { font-family: var(--font-display); font-size: 22px; color: var(--primary); font-weight: 800; letter-spacing: -0.5px; }
.site-nav { display: flex; gap: 24px; }
.site-nav a { text-decoration: none; color: var(--ink-soft); font-size: 14px; font-weight: 700; transition: color 0.15s; }
.site-nav a:hover { color: var(--primary); }
.mob-menu-btn { display: none; background: none; border: 1.5px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 18px; cursor: pointer; color: var(--ink-soft); }

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 30%, #fef3c7 70%, #fdf2f8 100%);
  padding: 48px 0 0; position: relative; overflow: hidden; border-bottom: 2px solid var(--border);
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 50% 60% at 90% 30%, rgba(234,88,12,0.10) 0%, transparent 70%),
              radial-gradient(ellipse 40% 50% at 10% 80%, rgba(37,99,235,0.06) 0%, transparent 70%);
}
.hero-inner { display: grid; grid-template-columns: 1fr 1.2fr; gap: 40px; align-items: flex-start; position: relative; z-index: 1; }
.hero-text { padding-bottom: 48px; padding-top: 8px; }
.hero-text h1 { font-family: var(--font-display); font-size: clamp(2.2rem, 4.5vw, 3.4rem); font-weight: 800; line-height: 1.1; color: var(--ink); margin-bottom: 14px; }
.hero-text h1 em { font-style: normal; color: var(--primary); }
.hero-sub { font-size: 16px; color: var(--ink-soft); max-width: 380px; line-height: 1.65; font-weight: 600; }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.badge { display: inline-flex; align-items: center; gap: 5px; background: var(--white); border: 1.5px solid var(--border-md); border-radius: 20px; padding: 5px 13px; font-size: 13px; color: var(--ink-soft); font-weight: 700; box-shadow: var(--shadow-sm); }

/* ---- Test card ---- */
.test-card { background: var(--white); border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow-lg); border: 2px solid var(--border); border-bottom: none; overflow: hidden; }

/* Mode selector */
.mode-bar { display: flex; border-bottom: 2px solid var(--border); background: var(--primary-lt); padding: 12px 20px; gap: 8px; flex-wrap: wrap; align-items: center; }
.mode-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-mute); margin-right: 4px; }
.mode-btn { padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border-md); background: var(--white); color: var(--ink-soft); font-size: 13px; font-weight: 800; cursor: pointer; font-family: var(--font-body); transition: all 0.12s; }
.mode-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.mode-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }
.mode-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* Stats bar */
.stats-bar { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 2px solid var(--border); }
.stat-cell { padding: 14px 16px; text-align: center; border-right: 1px solid var(--border); }
.stat-cell:last-child { border-right: none; }
.stat-cell .s-val { font-family: var(--font-display); font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-cell .s-val.ready { color: var(--ink-mute); }
.stat-cell .s-lab { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-mute); margin-top: 3px; }

/* Timer ring */
.timer-wrap { position: relative; width: 56px; height: 56px; margin: 0 auto; }
.timer-svg { transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: var(--border); stroke-width: 4; }
.timer-fg { fill: none; stroke: var(--primary); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: var(--ink); font-family: var(--font-display); }

/* Text display */
.text-display-wrap { padding: 20px 24px 12px; }
.text-display {
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 1.8;
  color: var(--ink-mute);
  max-height: 140px;
  overflow: hidden;
  position: relative;
  user-select: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  cursor: text;
}
.text-display .char { transition: color 0.05s; }
.text-display .char.correct { color: var(--char-correct); }
.text-display .char.incorrect { color: white; background: var(--char-error); border-radius: 3px; }
.text-display .char.cursor { border-left: 2px solid var(--char-cursor); animation: blink 1s step-end infinite; }
@keyframes blink { 0%,100%{border-left-color:var(--char-cursor)} 50%{border-left-color:transparent} }
.text-display-overlay { display: flex; align-items: center; justify-content: center; position: absolute; inset: 0; background: rgba(255,247,237,0.95); border-radius: var(--radius-sm); font-size: 16px; font-weight: 800; color: var(--primary); cursor: pointer; gap: 8px; font-family: var(--font-body); }

/* Input */
.input-area { padding: 12px 24px 20px; }
.typing-input {
  width: 100%; padding: 14px 18px; font-size: 18px; font-weight: 700; font-family: var(--font-mono);
  border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--white);
  color: var(--ink); transition: border-color 0.15s; outline: none; caret-color: var(--primary);
}
.typing-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(234,88,12,0.10); }
.typing-input.error { border-color: var(--rose); background: var(--rose-lt); }
.input-hint { font-size: 12px; color: var(--ink-mute); font-weight: 700; margin-top: 6px; text-align: center; }
.action-btns { display: flex; gap: 10px; margin-top: 10px; }
.btn-primary { flex: 1; padding: 13px; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); font-family: var(--font-display); font-size: 16px; font-weight: 800; cursor: pointer; transition: background 0.15s, box-shadow 0.15s; box-shadow: 0 3px 10px rgba(234,88,12,0.3); }
.btn-primary:hover { background: var(--primary-dk); }
.btn-secondary { padding: 13px 20px; background: var(--white); color: var(--ink-soft); border: 1.5px solid var(--border-md); border-radius: var(--radius-sm); font-family: var(--font-display); font-size: 15px; font-weight: 800; cursor: pointer; transition: all 0.15s; }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ---- Results panel ---- */
.results-panel { border-top: 2px solid var(--border); animation: fadeUp 0.35s ease; }
@keyframes fadeUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.result-banner { background: var(--primary); padding: 20px 24px; color: white; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.result-rating { font-size: 36px; }
.result-main .wpm { font-family: var(--font-display); font-size: 3.5rem; font-weight: 800; line-height: 1; }
.result-main .wpm-label { font-size: 13px; opacity: .8; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.result-meta { margin-left: auto; display: flex; flex-direction: column; gap: 6px; text-align: right; }
.result-meta span { font-size: 14px; font-weight: 700; opacity: .9; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 16px 24px; }
.res-item { background: var(--primary-lt); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.res-item .r-val { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.res-item .r-lab { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-mute); margin-top: 3px; }
.result-actions { display: flex; gap: 10px; padding: 0 24px 16px; flex-wrap: wrap; }
.pb-badge { background: var(--purple-lt); border: 1.5px solid #c4b5fd; border-radius: 10px; padding: 10px 16px; text-align: center; font-size: 13px; font-weight: 800; color: var(--purple); margin: 0 24px 12px; }

/* ---- WPM live chart ---- */
.chart-wrap { padding: 0 24px 16px; }
.chart-wrap h4 { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-mute); margin-bottom: 10px; }

/* ---- Feature cards ---- */
.features-section { padding: 48px 0 40px; }
.section-title { font-family: var(--font-display); font-size: 2rem; font-weight: 800; color: var(--ink); margin-bottom: 6px; }
.section-sub { font-size: 15px; color: var(--ink-soft); font-weight: 600; margin-bottom: 28px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.feature-card { background: var(--white); border: 2px solid var(--border); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--ink); display: block; transition: box-shadow 0.15s, transform 0.15s; }
.feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); border-color: var(--primary); }
.feature-card.active-card { border-color: var(--primary); background: var(--primary-lt); pointer-events: none; }
.feature-card.fc-orange { border-top: 4px solid var(--primary); }
.feature-card.fc-blue   { border-top: 4px solid var(--blue); }
.feature-card.fc-green  { border-top: 4px solid var(--green); }
.feature-card.fc-purple { border-top: 4px solid var(--purple); }
.feature-card.fc-teal   { border-top: 4px solid var(--teal); }
.feature-card.fc-amber  { border-top: 4px solid var(--amber); }
.feature-icon { font-size: 30px; display: block; margin-bottom: 10px; }
.feature-card h3 { font-size: 15px; font-weight: 800; margin-bottom: 5px; }
.feature-card p { font-size: 13px; color: var(--ink-soft); line-height: 1.5; font-weight: 600; }

/* ---- Personal bests section ---- */
.pb-section { background: var(--white); border-radius: var(--radius); border: 2px solid var(--border); padding: 24px; margin-bottom: 32px; }
.pb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.pb-card { background: var(--primary-lt); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; }
.pb-card .pb-wpm { font-family: var(--font-display); font-size: 2rem; font-weight: 800; color: var(--primary); }
.pb-card .pb-dur { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-mute); margin-bottom: 4px; }
.pb-card .pb-acc { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin-top: 3px; }

/* ---- Leaderboard / keyboard ---- */
.keyboard-display { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.kb-row-display { display: flex; gap: 5px; justify-content: center; }
.kb-key-display { width: 34px; height: 34px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; font-family: var(--font-display); transition: background 0.3s; border: 1.5px solid var(--border); background: var(--white); color: var(--ink-soft); }

/* ---- FAQ ---- */
.faq-section { padding: 0 0 48px; }
.faq-list { display: flex; flex-direction: column; gap: 8px; max-width: 780px; }
.faq-item { background: var(--white); border: 2px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.faq-item summary { padding: 16px 20px; font-weight: 800; font-size: 15px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 22px; color: var(--primary); font-weight: 300; flex-shrink: 0; transition: transform 0.2s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding: 0 20px 16px; font-size: 14px; color: var(--ink-soft); line-height: 1.7; font-weight: 600; }

/* ---- Ad slots ---- */
.ad-slot { background: var(--white); border: 1.5px dashed var(--border-md); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--ink-mute); font-size: 12px; font-weight: 700; }
.ad-leaderboard { min-height: 90px; margin: 24px auto; }
.ad-rectangle { min-height: 250px; margin: 0 auto 36px; max-width: 700px; }

/* ---- Sub-page ---- */
.page-hero { background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 60%, #fef3c7 100%); padding: 48px 0; border-bottom: 2px solid var(--border); }
.page-hero h1 { font-family: var(--font-display); font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; color: var(--ink); }
.page-hero h1 em { font-style: normal; color: var(--primary); }
.page-hero p { color: var(--ink-soft); font-size: 16px; font-weight: 600; margin-top: 10px; max-width: 500px; }
.page-body { padding: 40px 0 60px; }

/* ---- Legal ---- */
.legal-page { padding: 48px 0 80px; }
.legal-page h1 { font-family: var(--font-display); font-size: 2.5rem; font-weight: 800; margin-bottom: 8px; }
.legal-page .updated { font-size: 13px; color: var(--ink-mute); margin-bottom: 40px; }
.legal-page h2 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; margin: 32px 0 12px; }
.legal-page p, .legal-page li { font-size: 15px; color: var(--ink-soft); line-height: 1.8; margin-bottom: 10px; font-weight: 600; }
.legal-page ul { padding-left: 20px; margin-bottom: 16px; }
.legal-max { max-width: 720px; }

/* ---- Footer ---- */
.site-footer { background: var(--ink); color: rgba(255,255,255,0.6); padding: 48px 0 0; }
.footer-inner { display: grid; grid-template-columns: 1fr 2fr; gap: 48px; padding-bottom: 40px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.footer-brand .logo-text { color: var(--white); font-size: 20px; }
.footer-brand p { font-size: 14px; margin-top: 8px; line-height: 1.6; font-weight: 600; }
.footer-links { display: flex; gap: 40px; flex-wrap: wrap; }
.footer-col { display: flex; flex-direction: column; gap: 10px; min-width: 120px; }
.footer-col h4 { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; color: var(--white); margin-bottom: 4px; }
.footer-col a { font-size: 14px; color: rgba(255,255,255,0.55); text-decoration: none; font-weight: 600; transition: color 0.15s; }
.footer-col a:hover { color: #fed7aa; }
.footer-bottom { padding: 20px 0; font-size: 13px; text-align: center; font-weight: 600; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .hero-inner { grid-template-columns: 1fr; gap: 24px; }
  .hero-text { padding-bottom: 0; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .pb-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; gap: 28px; }
  .site-nav { display: none; flex-direction: column; position: absolute; top: 66px; left: 0; right: 0; background: var(--white); border-bottom: 2px solid var(--border); padding: 16px 24px; gap: 14px; box-shadow: var(--shadow-md); }
  .site-nav.open { display: flex; }
  .mob-menu-btn { display: block; }
  .features-grid { grid-template-columns: 1fr 1fr; }
  .text-display { font-size: 16px; }
}
@media (max-width: 480px) {
  .features-grid { grid-template-columns: 1fr; }
  .result-banner { flex-direction: column; text-align: center; }
  .result-meta { text-align: center; margin-left: 0; }
}
