*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #050510;
  color: #f0f0f0;
  font-family: 'Syne', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── PARTICLES ── */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg span {
  position: absolute;
  width: 2px; height: 2px;
  background: #b060ff;
  border-radius: 50%;
  opacity: 0;
  animation: float linear infinite;
}
@keyframes float {
  0%   { opacity: 0; transform: translateY(100vh) scale(0); }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { opacity: 0; transform: translateY(-10vh) scale(1.5); }
}

/* ── BACK LINK ── */
.back {
  position: relative;
  z-index: 2;
  align-self: flex-start;
  margin: 1.5rem 1.5rem 0;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #7040c0;
  text-decoration: none;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}
.back:hover { color: #d0a0ff; }

/* ── PAGE ── */
.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 700px;
  padding: 2rem 1.5rem 5rem;
}

/* ── HEADER ── */
.hdr { margin-bottom: 2rem; }

.tag {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: #333;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.tag span { color: #b060ff; }

.hdr h1 {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 800;
  color: #fff;
}
.hdr h1 .accent {
  color: #b060ff;
  text-shadow: 0 0 30px rgba(176,96,255,0.5);
}
.hdr p {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #444;
  margin-top: 0.4rem;
}

/* ── STATS ── */
.stats {
  display: flex;
  gap: 12px;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}
.stat-box {
  background: #0a0a1e;
  border: 1px solid #1e1040;
  border-radius: 14px;
  padding: 1rem 1.6rem;
  flex: 1;
  min-width: 100px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}
.stat-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #b060ff, transparent);
}
.stat-box span {
  font-size: 2rem;
  font-weight: 800;
  color: #b060ff;
  display: block;
  font-family: 'Space Mono', monospace;
  text-shadow: 0 0 20px rgba(176,96,255,0.4);
  transition: color 0.3s, text-shadow 0.3s;
}
.stat-box label {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: #3a2870;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
  display: block;
}

/* Timer danger state */
.stat-box.danger { border-color: rgba(239,68,68,0.4); }
.stat-box.danger span {
  color: #ef4444;
  text-shadow: 0 0 20px rgba(239,68,68,0.5);
  animation: pulse-red 0.6s ease-in-out infinite alternate;
}
@keyframes pulse-red {
  from { opacity: 1; }
  to   { opacity: 0.6; }
}

/* ── PROGRESS BAR ── */
.progress-wrap {
  background: #0a0a1e;
  border: 1px solid #1e1040;
  border-radius: 999px;
  height: 6px;
  margin-bottom: 1.4rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5b21b6, #b060ff, #e879f9);
  transition: width 0.15s ease, background 0.4s;
  box-shadow: 0 0 10px rgba(176,96,255,0.5);
}
.progress-fill.danger {
  background: linear-gradient(90deg, #7f1d1d, #ef4444, #f87171);
  box-shadow: 0 0 10px rgba(239,68,68,0.5);
}

/* ── PARAGRAPH DISPLAY ── */
#paragraph-display {
  background: #0a0a1e;
  border: 1px solid #1e1040;
  border-radius: 14px;
  padding: 1.4rem 1.6rem;
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  line-height: 2.2;
  margin-bottom: 1.2rem;
  min-height: 100px;
  letter-spacing: 0.5px;
  color: #2e2060;
  position: relative;
  overflow: hidden;
  word-break: break-word;
}
#paragraph-display::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #b060ff, transparent);
}
#paragraph-display .correct { color: #7c3aed; }
#paragraph-display .wrong   { color: #ef4444; background: rgba(239,68,68,0.1); border-radius: 2px; }
#paragraph-display .current {
  background: rgba(176,96,255,0.35);
  color: #fff;
  border-radius: 3px;
  box-shadow: 0 0 0 1.5px #b060ff, 0 0 12px rgba(176,96,255,0.6);
  animation: blink-cursor 0.9s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { background: rgba(176,96,255,0.35); }
  50%       { background: rgba(176,96,255,0.15); }
}

/* ── INPUT ── */
#input-box {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid #1e1040;
  background: #0a0a1e;
  color: #e8d8ff;
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  resize: none;
  height: 90px;
  margin-bottom: 1.2rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#input-box:focus   { border-color: rgba(176,96,255,0.5); box-shadow: 0 0 0 3px rgba(176,96,255,0.08); }
#input-box:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── HINT ── */
.hint {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: #2a1a50;
  text-align: center;
  margin-bottom: 1.2rem;
  letter-spacing: 0.5px;
}
.hint kbd {
  background: #0f0f28;
  border: 1px solid #2a1060;
  border-radius: 4px;
  padding: 1px 6px;
  color: #5040a0;
  font-size: 10px;
}

/* ── START BUTTON ── */
#start-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #5b21b6, #7c3aed);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(124,58,237,0.3);
}
#start-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 8px 28px rgba(124,58,237,0.4); }
#start-btn:active    { transform: scale(0.98); }
#start-btn:disabled  { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── RESULT OVERLAY ── */
#result-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5,5,16,0.85);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
#result-overlay.show { display: flex; animation: fade-in 0.3s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.result-box {
  background: #0a0a1e;
  border: 1px solid rgba(176,96,255,0.35);
  border-radius: 20px;
  padding: 2.4rem 2rem;
  text-align: center;
  width: 100%;
  max-width: 420px;
  position: relative;
  overflow: hidden;
  animation: pop 0.45s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.88) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.result-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #b060ff, transparent);
}

.result-emoji  { font-size: 56px; margin-bottom: 0.8rem; display: block; }
.result-title  { font-size: 22px; font-weight: 800; color: #e8d8ff; margin-bottom: 0.3rem; }
.result-sub    { font-family: 'Space Mono', monospace; font-size: 11px; color: #5040a0; margin-bottom: 2rem; }

.result-nums {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.result-num {
  background: #050510;
  border: 1px solid #1e1040;
  border-radius: 12px;
  padding: 1rem 1.4rem;
  min-width: 100px;
}
.result-num strong {
  font-family: 'Space Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: #b060ff;
  display: block;
  text-shadow: 0 0 20px rgba(176,96,255,0.4);
}
.result-num span {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: #3a2870;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.result-grade {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #6040a0;
  background: rgba(176,96,255,0.07);
  border: 1px solid #1e1040;
  border-radius: 8px;
  padding: 8px 16px;
  display: inline-block;
  margin-bottom: 2rem;
  letter-spacing: 1px;
}

.result-btns { display: flex; gap: 10px; justify-content: center; }
.result-btn {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  padding: 10px 22px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  border: none;
}
.result-btn.primary {
  background: linear-gradient(135deg, #5b21b6, #7c3aed);
  color: #fff;
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}
.result-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,0.4); }
.result-btn.secondary {
  background: transparent;
  color: #7040c0;
  border: 1px solid #1e1040;
}
.result-btn.secondary:hover { color: #d0a0ff; border-color: rgba(176,96,255,0.4); background: rgba(176,96,255,0.07); }