:root {
    /* Modern Palette */
    --bg-page: #F3F4F6;
    /* Cool gray background */
    --bg-card: #ffffff;
    --text-primary: #111827;
    /* Near black */
    --text-secondary: #6B7280;
    /* Muted gray */
    --text-tertiary: #9CA3AF;

    /* Brand Accent - Vibrant Violet/Indigo */
    --accent-primary: #6366f1;
    --accent-light: #e0e7ff;
    --accent-glow: rgba(99, 102, 241, 0.25);

    /* Functional Colors */
    --error: #ef4444;
    --success: #10b981;
    --border: #e5e7eb;

    /* Effects */
    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.05);
    /* Very diffuse shadow */
    --shadow-sharp: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;

    /* Typography */
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, monospace;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Subtle mesh gradient background */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 40%);
}

.app-container {
    max-width: 1080px;
    /* Slightly tighter width for focus */
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* Header - Ultra Minimal */
.main-header {
    display: flex;
    justify-content: center;
    /* Center logo for premium feel */
    margin-bottom: 3rem;
    position: relative;
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.9;
}

/* Layout - CSS Grid for Desktop */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Badge - Pill Design */
.badge {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    background: var(--text-primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Language Selector - Floating & Glassy */
.language-selector {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10;
}

.language-selector select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.language-selector select:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Game Section - The Centerpiece */
.game-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 5rem 2rem 4rem;
    /* Deep padding */
    box-shadow: var(--shadow-soft);
    position: relative;
    text-align: center;
    border: 1px solid white;
    /* Subtle highlight */
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease;
}

.timer-display {
    font-size: clamp(3rem, 5vw, 4.5rem);
    /* Responsive massive type */
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -2px;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stage-indicator {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2rem;
}

.quote-container {
    margin-bottom: 2.5rem;
    max-width: 90%;
}

.quote-text {
    font-size: clamp(1.2rem, 3vw, 1.75rem);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    letter-spacing: -0.02em;
}

/* Input Area - Clean & Focused */
.input-container {
    width: 100%;
    max-width: 580px;
    position: relative;
    margin-bottom: 1.5rem;
}

.typing-input {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    border: 2px solid transparent;
    /* Hide border initially or keep subtle */
    background: #f8fafc;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.typing-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.typing-input:focus {
    background: white;
    outline: none;
    box-shadow: 0 0 0 4px var(--accent-glow), 0 4px 12px rgba(0, 0, 0, 0.05);
    border-color: var(--accent-primary);
}

.typing-input.error {
    background: #fff5f5;
    border-color: var(--error);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.input-hint {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.feedback-message {
    height: 1.5rem;
    color: var(--error);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.btn-secondary {
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: var(--text-secondary);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-text {
    background: none;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.btn-text:hover {
    color: var(--error);
}

/* Statistics - Sidebar Style */
.stats-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid white;
}

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

.stats-header h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    font-weight: 700;
    margin: 0;
}

.stats-card {
    background: var(--bg-page);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: 2rem;
}

.stats-card h3 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.rank-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--accent-primary);
    letter-spacing: -1px;
    margin-bottom: 0.25rem;
}

.rank-subtext {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Ranking Board */
.ranking-board h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    margin-bottom: 1rem;
    font-weight: 700;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: transform 0.1s;
}

.ranking-item:hover {
    transform: scale(1.02);
    border-color: var(--accent-light);
}

/* Medal Colors aligned with modern muted tones */
.ranking-item:nth-child(1) {
    border-color: #fbbf24;
    background: #fffbeb;
}

.ranking-item:nth-child(1) .rank-index {
    color: #d97706;
}

.ranking-item:nth-child(2) {
    border-color: #94a3b8;
    background: #f8fafc;
}

.ranking-item:nth-child(2) .rank-index {
    color: #64748b;
}

.ranking-item:nth-child(3) {
    border-color: #fdba74;
    background: #fff7ed;
}

.ranking-item:nth-child(3) .rank-index {
    color: #ea580c;
}

.rank-index {
    font-weight: 700;
    color: var(--text-tertiary);
    width: 28px;
    font-size: 0.9rem;
}

.rank-details {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 0.9rem;
    font-weight: 500;
}

.rank-percent {
    color: var(--accent-primary);
    font-weight: 700;
}

/* Guide Section - Subtle & Clean */
.guide-section {
    background: var(--bg-card);
    /* Should match stats color if we want grid logic */
    /* Wait, guide sits in column 1. Let's make it blend or stand out? */
    /* Let's keep it white card. */
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-soft);
}

.guide-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-primary);
    margin-bottom: 1.25rem;
    font-weight: 700;
}

.guide-section ul {
    list-style: none;
    padding: 0;
}

.guide-section li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.guide-section li::before {
    content: "";
    /* Dot style */
    position: absolute;
    left: 0.25rem;
    top: 0.6rem;
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0.5;
}

.guide-section li:last-child {
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1rem;
}

/* Desktop Logic */
@media (min-width: 1025px) {
    .main-content {
        display: grid;
        grid-template-columns: 2fr 1.2fr;
        /* Ratio tweak */
        grid-template-rows: auto auto;
        gap: 2rem;
        /* Increased gap for breathability */
        align-items: start;
        align-content: start;
    }

    .game-section {
        grid-column: 1 / 2;
    }

    .guide-section {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
    }

    .stats-section {
        grid-column: 2 / 3;
        grid-row: 1 / 3;
        position: sticky;
        /* Sticky sidebar */
        top: 2rem;
    }
}

/* Mobile Tweaks */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .game-section {
        padding: 4rem 1.5rem 2rem;
    }

    .timer-display {
        font-size: 3.5rem;
    }
}