/* =====================================================
   BoltType — style.css  v1.2
   ===================================================== */

:root {
  --bg:          #0d0f1a;
  --surface:     #13162a;
  --surface2:    #1a1e35;
  --border:      rgba(99, 120, 255, 0.18);
  --cyan:        #4df0d4;
  --violet:      #836fff;
  --pink:        #ff6fba;
  --text:        #e8eaf6;
  --text-muted:  #7a7fa8;
  --correct:     #4df0d4;
  --wrong:       #ff5370;
  --radius-sm:   10px;
  --radius-md:   18px;
  --radius-lg:   28px;
  --font-mono:   'Space Mono', monospace;
  --font-sans:   'Syne', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.app-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px calc(24px + var(--safe-bottom));
  gap: 14px;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
}
.logo-text {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.5px;
  color: var(--text);
}
.logo-accent {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.3s ease;
}
.badge.active { color: var(--cyan);   border-color: var(--cyan);   background: rgba(77,240,212,0.08); }
.badge.done   { color: var(--violet); border-color: var(--violet); background: rgba(131,111,255,0.08); }

/* ── Stats Bar ── */
.stats-bar {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 10px;
}
.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  backdrop-filter: blur(8px);
  transition: border-color 0.3s;
}
.stat-pill--center {
  border-color: rgba(77,240,212,0.3);
  background: rgba(77,240,212,0.05);
}
.stat-icon { font-size: 0.85rem; line-height: 1; }
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-value.large {
  font-size: 2rem;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(77,240,212,0.5);
}
.stat-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── Typing Card ── */
.typing-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  min-height: 200px;
}
.typing-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(131,111,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Idle Screen ── */
.idle-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 16px;
  text-align: center;
}
.idle-hint {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 260px;
}
.idle-hint strong { color: var(--text); }
.bolt-icon {
  font-size: 3.5rem;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(77,240,212,0.6));
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

/* ── Text Display ── */
.text-display {
  font-family: var(--font-mono);
  font-size: 1.12rem;
  line-height: 1.9;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  word-break: keep-all;
  overflow-wrap: normal;
  display: none;
  height: calc(1.12rem * 1.9 * 5);
  overflow: hidden;
  scroll-behavior: smooth;
  /* Prevent zoom inside text area without blocking touch events */
  touch-action: pan-y;
}

.word { display: inline-block; }

/* ── Character states ── */
.text-display span.correct { color: var(--correct); }
.text-display span.wrong   { color: var(--wrong); background: rgba(255,83,112,0.12); border-radius: 3px; }

/* ── Cursor ── */
.text-display span.cursor { position: relative; }
.text-display span.cursor::after {
  content: '';
  position: absolute;
  left: -1px;
  bottom: 0;
  width: 2px;
  height: 85%;
  background: var(--cyan);
  border-radius: 2px;
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Accuracy Bar ── */
.accuracy-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.accuracy-bar-track {
  flex: 1;
  height: 5px;
  background: var(--surface2);
  border-radius: 10px;
  overflow: hidden;
}
.accuracy-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transition: width 0.3s ease, background 0.3s ease;
}
.accuracy-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

/* ── Hidden Input ── */
.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  left: -9999px;
  font-size: 16px;
}

/* ── Controls ── */
.controls { display: flex; gap: 12px; }

/* ── Buttons ── */
.btn {
  flex: 1;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: inherit;
}
.btn:active::after { opacity: 0.08; }

.btn--start {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
  color: #0d0f1a;
  box-shadow: 0 4px 24px rgba(77,240,212,0.25), 0 2px 8px rgba(0,0,0,0.3);
  animation: pulse-glow 2.4s ease-in-out infinite;
}
.btn--start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(77,240,212,0.38), 0 4px 12px rgba(0,0,0,0.3);
}
.btn--start:active { transform: translateY(0); }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 24px rgba(77,240,212,0.25), 0 2px 8px rgba(0,0,0,0.3); }
  50%       { box-shadow: 0 4px 36px rgba(77,240,212,0.5), 0 0 50px rgba(131,111,255,0.25); }
}

.btn--ghost {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  flex: 0 0 auto;
  padding: 16px 20px;
}
.btn--ghost:hover { border-color: var(--violet); color: var(--violet); }

/* ── Results Overlay ── */
.results-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13,15,26,0.85);
  backdrop-filter: blur(16px);
  animation: fade-in 0.35s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.results-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid rgba(131,111,255,0.35);
  border-radius: var(--radius-lg);
  padding: 32px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: slide-up 0.35s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center;
}
@keyframes slide-up {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.results-title {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.result-item {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.result-num {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--cyan);
}
.result-lbl {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.new-best {
  font-weight: 700;
  font-size: 1rem;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
  animation: pop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes pop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 10px; }
