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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Start Screen */
#start-screen {
    text-align: center;
    padding-top: 15vh;
}

#start-screen h1 {
    font-size: 3rem;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-bottom: 3rem;
}

.start-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 300px;
    margin: 0 auto 2rem;
}

input[type="text"] {
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text);
    text-align: center;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

.btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 2px solid var(--border);
}

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

.link {
    color: var(--primary);
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

/* Quiz Screen */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.player-info {
    font-weight: 500;
}

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

.streak-icon {
    font-size: 1.8rem;
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.question-container {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
}

.question-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.question-id {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.instructions {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.context-box {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.context-box.hidden {
    display: none;
}

.context-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    cursor: pointer;
    user-select: none;
}

.context-toggle:hover {
    background: var(--bg-input);
}

.context-content {
    padding: 1rem;
    font-size: 0.95rem;
    line-height: 1.8;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg);
    display: none;
}

.context-content.expanded {
    display: block;
}

.question-content {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.question-content .sentence-frame {
    font-size: 1.2rem;
    line-height: 2;
}

.question-content .blank {
    display: inline-block;
    min-width: 150px;
    border-bottom: 2px dashed var(--primary);
    margin: 0 0.25rem;
}

.question-content .required-word {
    display: inline-block;
    background: var(--warning);
    color: var(--bg);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    margin-left: 0.5rem;
}

.question-content .original-sentence {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-left: 2px solid var(--text-muted);
}

/* Answer Area */
.answer-area {
    margin-bottom: 1.5rem;
}

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

.option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    width: 100%;
}

.option-btn:hover {
    border-color: var(--primary);
    background: var(--bg-input);
}

.option-btn.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.2);
}

.option-key {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-input);
    border-radius: 8px;
    font-weight: 700;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
}

/* Fill in blank input */
.fill-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}

.fill-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Triple sentences */
.triple-sentences {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.triple-sentence {
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.triple-sentence .blank {
    color: var(--primary);
    font-weight: 700;
}

/* Result Overlay */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.result-overlay.hidden {
    display: none;
}

.result-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    text-align: center;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.result-content.correct {
    border: 3px solid var(--success);
}

.result-content.incorrect {
    border: 3px solid var(--error);
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.result-content h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.result-content.correct h2 {
    color: var(--success);
}

.result-content.incorrect h2 {
    color: var(--error);
}

.correct-answer-box {
    background: var(--bg);
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    text-align: left;
}

.correct-answer-box .label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.correct-answer-box .answer {
    color: var(--success);
    font-weight: 600;
    font-size: 1.1rem;
}

.streak-gained {
    color: var(--warning);
    font-size: 1.2rem;
    font-weight: 600;
}

/* Leaderboard */
#leaderboard-screen {
    text-align: center;
    padding-top: 2rem;
}

#leaderboard-screen h1 {
    margin-bottom: 2rem;
}

.leaderboard-list {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: 700;
    width: 50px;
    text-align: center;
}

.leaderboard-rank.gold { color: #ffd700; }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

.leaderboard-info {
    flex: 1;
    text-align: left;
}

.leaderboard-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.leaderboard-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.leaderboard-streak {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--warning);
}

.loading {
    padding: 2rem;
    color: var(--text-muted);
}

.empty-state {
    padding: 2rem;
    color: var(--text-muted);
}

/* Game Over */
#gameover-screen {
    text-align: center;
    padding-top: 10vh;
}

.final-score {
    margin: 2rem 0;
}

.big-number {
    font-size: 5rem;
    font-weight: 700;
    color: var(--warning);
    text-shadow: 0 0 30px rgba(245, 158, 11, 0.5);
}

.rank-message {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.gameover-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 300px;
    margin: 0 auto;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    #start-screen h1 {
        font-size: 2rem;
    }

    .quiz-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .question-container {
        padding: 1rem;
    }

    .big-number {
        font-size: 3.5rem;
    }
}

/* Idiom styling */
.idiom-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    padding: 1rem;
    background: var(--bg);
    border-radius: 10px;
    margin-bottom: 1rem;
    text-align: center;
}

/* Person matching */
.person-display {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    text-align: center;
}

/* Word bank display */
.word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
}

.word-bank-item {
    padding: 0.25rem 0.5rem;
    background: var(--bg-input);
    border-radius: 4px;
    font-size: 0.85rem;
}
