/* ─── Reset & Variables ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f0f17;
    --bg-card: #1a1a2e;
    --bg-key: #16213e;
    --bg-key-hover: #1f3460;
    --bg-key-active: #0f3460;
    --border: #2a2a4a;
    --text: #e0e0ff;
    --text-dim: #6a6a9a;
    --accent: #7c3aed;
    --accent-glow: rgba(124, 58, 237, 0.3);
    --green: #10b981;
    --red: #ef4444;
    --orange: #f59e0b;
    --blue: #3b82f6;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ─── App ─────────────────────────────────────────────────────────────── */
.app {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stats {
    display: flex;
    gap: 16px;
}

.stat {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ─── Controls ────────────────────────────────────────────────────────── */
.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.select {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: border-color 150ms;
}

.select:focus { border-color: var(--accent); }

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: #6d28d9;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
}

.card-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.4;
}

.hint {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--orange);
}

.feedback {
    margin-top: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    animation: fadeIn 200ms ease;
}

.feedback.correct {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--green);
    color: var(--green);
}

.feedback.wrong {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--red);
    color: var(--red);
}

.hidden { display: none; }

/* ─── Pressed Keys ────────────────────────────────────────────────────── */
.pressed-keys {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    padding: 12px;
    color: var(--accent);
    min-height: 48px;
}

/* ─── Visual Keyboard ─────────────────────────────────────────────────── */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    user-select: none;
}

.kb-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.key {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 8px;
    background: var(--bg-key);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: all 100ms;
}

.key.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: scale(0.95);
    box-shadow: 0 0 12px var(--accent-glow);
}

.key.highlight {
    border-color: var(--green);
    color: var(--green);
    animation: pulse 600ms ease infinite alternate;
}

.key-wide { min-width: 70px; }
.key-wider { min-width: 90px; }
.key-widest { min-width: 180px; }
.key-space { flex: 1; max-width: 360px; }

/* ─── Progress ────────────────────────────────────────────────────────── */
.progress-bar {
    height: 8px;
    background: var(--bg-key);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--blue));
    border-radius: 4px;
    transition: width 300ms ease;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
}

/* ─── Animations ──────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    from { box-shadow: 0 0 4px transparent; }
    to { box-shadow: 0 0 12px rgba(16, 185, 129, 0.4); }
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .key { min-width: 28px; height: 34px; font-size: 0.6rem; padding: 0 4px; }
    .key-wide { min-width: 48px; }
    .key-wider { min-width: 60px; }
    .key-widest { min-width: 100px; }
    .question-text { font-size: 1.1rem; }
    .header { flex-direction: column; gap: 12px; }
}
