*, *::before, *::after { box-sizing: border-box; }
body { background: #020617; color: #fff; font-family: 'Inter', sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; margin: 0; text-align: center; overflow: hidden; }
#particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bg-glow { position: fixed; inset: 0; background: radial-gradient(ellipse 80% 60% at 50% 40%, #1e3a8a44 0%, transparent 70%); z-index: 0; pointer-events: none; }
.back-home { position: fixed; top: 20px; left: 24px; font-size: 0.85rem; color: #475569; text-decoration: none; transition: color 0.2s; z-index: 10; }
.back-home:hover { color: #fff; }
.container { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; padding: 40px 24px; max-width: 640px; width: 100%; }

h1 { font-family: 'Syne', sans-serif; font-size: clamp(2rem,8vw,3rem); font-weight: 900; margin: 0 0 6px; letter-spacing: -2px; }
.subtitle { font-size: 0.95rem; color: #64748b; margin-bottom: 32px; }

/* stats */
.stats-row { display: flex; gap: 24px; margin-bottom: 28px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.stat-val { font-family: 'Syne', sans-serif; font-size: 1.8rem; font-weight: 900; color: #f8fafc; transition: color 0.3s; }
.stat-label { font-size: 0.7rem; color: #475569; text-transform: uppercase; letter-spacing: 1.5px; }

/* timer bar */
.timer-wrap { width: 100%; height: 8px; background: rgba(30,58,138,0.25); border-radius: 999px; overflow: hidden; margin-bottom: 24px; }
.timer-bar { height: 100%; border-radius: 999px; background: #3b82f6; transition: width 0.1s linear, background 0.3s; width: 100%; }
.timer-bar.warn { background: #fbbf24; }
.timer-bar.danger { background: #ef4444; }

/* text display */
.text-display {
    background: rgba(15,23,42,0.7); border: 1px solid rgba(51,65,85,0.6);
    border-radius: 16px; padding: 24px 28px; width: 100%;
    margin-bottom: 18px; backdrop-filter: blur(14px);
    font-size: 1.15rem; line-height: 1.8; text-align: left;
    min-height: 100px;
}
.char-correct { color: #10b981; }
.char-wrong   { color: #f87171; background: rgba(239,68,68,0.15); border-radius: 2px; }
.char-pending { color: #475569; }
.char-current { color: #f8fafc; background: rgba(96,165,250,0.25); border-radius: 2px; border-bottom: 2px solid #60a5fa; }

/* input */
.type-input {
    width: 100%; padding: 14px 18px;
    background: rgba(30,58,138,0.2);
    border: 1.5px solid rgba(96,165,250,0.3);
    border-radius: 12px; color: #fff;
    font-family: 'Inter', sans-serif; font-size: 1rem;
    outline: none; margin-bottom: 20px;
    transition: border-color 0.2s;
}
.type-input:focus { border-color: #60a5fa; }
.type-input:disabled { opacity: 0.4; cursor: not-allowed; }

.hint { font-size: 0.85rem; color: #334155; margin-bottom: 0; }

/* results */
.results-panel {
    position: fixed; inset: 0; background: rgba(2,6,23,0.92);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.4s; backdrop-filter: blur(8px);
    padding: 24px;
}
.results-panel.show { opacity: 1; pointer-events: all; }
.res-emoji { font-size: 3.5rem; margin-bottom: 12px; }
.res-title { font-family: 'Syne', sans-serif; font-size: clamp(1.6rem,6vw,2.4rem); font-weight: 900; margin: 0 0 6px; }
.res-wpm { font-family: 'Syne', sans-serif; font-size: clamp(3rem,12vw,5rem); font-weight: 900; color: #60a5fa; line-height: 1; margin-bottom: 4px; }
.res-wpm-label { font-size: 0.8rem; color: #475569; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 18px; }
.res-stats { display: flex; gap: 24px; margin-bottom: 24px; }
.res-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.res-stat-val { font-family: 'Syne', sans-serif; font-size: 1.4rem; font-weight: 700; color: #f8fafc; }
.res-stat-label { font-size: 0.7rem; color: #475569; text-transform: uppercase; letter-spacing: 1.5px; }

/* TWIST box */
.twist-box {
    background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3);
    border-radius: 14px; padding: 16px 20px; margin-bottom: 24px; max-width: 420px;
    font-size: 0.9rem; color: #fbbf24; line-height: 1.5;
}
.twist-box strong { font-family: 'Syne', sans-serif; display: block; margin-bottom: 6px; font-size: 1rem; }

.res-btn { padding: 13px 36px; background: rgba(37,99,235,0.3); border: 1.5px solid rgba(96,165,250,0.45); border-radius: 999px; color: #fff; font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700; cursor: pointer; transition: background 0.2s; }
.res-btn:hover { background: rgba(37,99,235,0.5); }
