:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --error: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 600px;
    margin-top: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

.selection-panel, .mode-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

.hidden {
    display: none !important;
}

/* Table Selection */
.table-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 20px 0;
}

.table-btn {
    padding: 16px 8px;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: white;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-btn:hover {
    border-color: var(--primary);
    background: #f0f0ff;
    transform: translateY(-2px);
}

.table-btn.all-btn {
    grid-column: span 5;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    border-color: var(--primary);
    font-size: 1.2rem;
}

.table-btn.all-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover), #6d28d9);
}

.table-btn.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.selection-info {
    text-align: center;
    color: var(--text-light);
    font-size: 0.95rem;
}

/* Mode Header */
.mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.back-btn:hover {
    background: #f0f0ff;
}

#selectedTablesDisplay {
    font-weight: 600;
    color: var(--text);
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin-bottom: 12px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.score-display {
    text-align: center;
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 25px;
}

/* Flash Card */
.card-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.flash-card {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    border-radius: var(--radius);
    padding: 40px 30px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.question {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 25px;
}

.answer-input {
    width: 120px;
    padding: 12px;
    font-size: 1.5rem;
    text-align: center;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.answer-input:focus {
    border-color: white;
}

.submit-btn {
    display: block;
    margin: 18px auto 0;
    padding: 12px 35px;
    font-size: 1.1rem;
    font-weight: 600;
    background: white;
    color: var(--primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Feedback */
.feedback {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.feedback.correct {
    background: #d1fae5;
    color: #065f46;
}

.feedback.incorrect {
    background: #fee2e2;
    color: #991b1b;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 10px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

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

/* Complete Screen */
#completeScreen {
    text-align: center;
}

#completeScreen h2 {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.final-score {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 25px 0;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.shake {
    animation: shake 0.4s ease;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pop {
    animation: pop 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 15px;
        align-items: center;
    }

    .container {
        margin-top: 0;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .selection-panel, .mode-panel {
        padding: 20px;
    }

    .table-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    .table-btn {
        padding: 14px 6px;
        font-size: 1rem;
    }

    .question {
        font-size: 2.5rem;
    }

    .flash-card {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.4rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .table-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .table-btn {
        padding: 12px 4px;
        font-size: 0.95rem;
    }

    .question {
        font-size: 2rem;
    }

    .answer-input {
        width: 100px;
        font-size: 1.3rem;
        padding: 10px;
    }

    .submit-btn {
        padding: 10px 28px;
        font-size: 1rem;
    }

    .mode-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
