:root {
    --bg-dark: #0A0A1A;
    --primary: #6C5CE7;
    --secondary: #A29BFE;
    --accent: #00CEC9;
    --error: #FF7675;
    --success: #55E6C1;
    --text-main: #F8F9FA;
    --text-muted: #A0AEC0;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --radius: 12px;
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: all 0.25s ease;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(108, 92, 231, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 206, 201, 0.1) 0%, transparent 40%);
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glow-effect {
    box-shadow: 0 0 40px rgba(108, 92, 231, 0.2);
    border-color: rgba(108, 92, 231, 0.3);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo i {
    color: var(--primary);
}

.accent-text {
    color: var(--accent);
}

.user-stats {
    display: flex;
    gap: 1rem;
}

.stat-pill {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--glass-border);
}

.stat-pill i {
    color: var(--primary);
}

/* Layout */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--secondary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

select, textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: 8px;
    font-family: var(--font-ui);
    outline: none;
    transition: var(--transition);
}

select:focus, textarea:focus {
    border-color: var(--primary);
}

select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-family: var(--font-ui);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #8e7dfa);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--primary);
    transform: rotate(90deg);
}

.w-full { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }

/* Typing Section */
.typing-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Live Stats */
.live-stats {
    display: flex;
    justify-content: space-around;
    padding: 1rem;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.stat-value.highlight {
    color: var(--accent);
}

/* Text Display */
.typing-container {
    position: relative;
    min-height: 200px;
    padding: 2rem;
    font-family: var(--font-mono);
    font-size: 1.4rem;
    line-height: 1.6;
    letter-spacing: 0.5px;
    cursor: text;
    transition: border-color 0.3s ease;
}

.typing-container.active {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.1);
}

#hidden-typing-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
}

.text-display {
    color: var(--text-muted);
    user-select: none;
}

.word { margin-right: 0.4em; display: inline-block; white-space: pre; }
.char { 
    display: inline-block;
    transition: color 0.1s ease, background 0.1s ease;
    border-radius: 2px;
}

/* Character states */
.char.correct { color: var(--text-main); }
.char.incorrect { 
    color: var(--error); 
    background: rgba(255, 118, 117, 0.2); 
    text-decoration: underline;
}
.char.active {
    color: var(--text-main);
    border-bottom: 2px solid var(--accent);
    animation: blink-border 1s infinite alternate;
}

@keyframes blink-border {
    0% { border-color: transparent }
    100% { border-color: var(--accent) }
}

/* Countdown */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 26, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    z-index: 10;
}

.overlay.hidden { display: none; }

#countdown-text {
    font-size: 6rem;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 30px rgba(108, 92, 231, 0.6);
}

.blinking {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% { transform: scale(1.5); opacity: 0; }
}

/* Heatmap Section */
.heatmap-section {
    padding: 1.5rem;
}

.heatmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.heatmap-header h3 {
    color: var(--secondary);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.heatmap-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.keyboard-layout {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
}

.keyboard-row {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.kbd-key {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.kbd-key.space { min-width: 250px; }
.kbd-key.backspace { min-width: 70px; font-size: 0.75rem; text-transform: lowercase; }

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-backdrop.hidden { display: none; }

.modal-content {
    width: 100%;
    max-width: 450px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-modal:hover { color: var(--text-main); }

.final-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.f-stat {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.f-stat.primary {
    grid-column: span 2;
    background: rgba(108, 92, 231, 0.1);
    border-color: rgba(108, 92, 231, 0.3);
}

.f-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.f-val {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.f-stat.primary .f-val {
    font-size: 2.5rem;
    color: var(--accent);
}

.unlock-message {
    background: rgba(85, 230, 193, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 900px) {
    .main-content { grid-template-columns: 1fr; }
    .kbd-key { min-width: 30px; height: 35px; font-size: 0.8rem; }
    .kbd-key.space { min-width: 150px; }
    .typing-container { font-size: 1.1rem; padding: 1.5rem; }
}
