* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 32px;
    width: 100%;
    max-width: 560px;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

h1 {
    text-align: center;
    color: #1a1a1a;
    margin-bottom: 24px;
    font-size: 1.75rem;
    font-weight: 600;
}

.level-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.level-btn {
    width: 100%;
    height: 100px;
    font-size: 2rem;
    font-weight: 600;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    color: #1a1a1a;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.level-btn:hover {
    border-color: #0066cc;
    background: #f0f7ff;
}

.level-btn:active {
    background: #e0eaff;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

#current-level-display {
    font-size: 1rem;
    font-weight: 500;
    color: #0066cc;
}

.back-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.back-btn:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.question-text {
    font-size: 1.2rem;
    color: #1a1a1a;
    margin-bottom: 20px;
    line-height: 1.5;
}

.answers-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-btn {
    padding: 14px 18px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #1a1a1a;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}

.answer-btn:hover:not(.disabled) {
    border-color: #0066cc;
    background: #f0f7ff;
}

.answer-btn.correct {
    border-color: #28a745;
    background: #d4edda;
    color: #155724;
}

.answer-btn.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
    color: #721c24;
}

.answer-btn.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.feedback {
    margin-top: 16px;
    padding: 12px;
    border-radius: 6px;
    font-weight: 500;
    text-align: center;
}

.feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.hidden {
    display: none !important;
}

.next-btn {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    background: #0066cc;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
}

.next-btn:hover:not(.hidden) {
    background: #0052a3;
}

#completion-screen h1 {
    color: #28a745;
}

#completion-message {
    text-align: center;
    font-size: 1rem;
    color: #666;
    margin-bottom: 24px;
}

.restart-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    background: #28a745;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
}

.restart-btn:hover {
    background: #218838;
}

.rules-btn {
    display: block;
    margin: 24px auto 0;
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 2px solid #0066cc;
    border-radius: 20px;
    background: transparent;
    color: #0066cc;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.rules-btn:hover {
    background: #0066cc;
    color: white;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 10px;
    padding: 0;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    border-radius: 10px 10px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: #1a1a1a;
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}

.close-btn:hover {
    color: #333;
}

.rules-content {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.rules-content ul {
    margin: 0;
    padding-left: 20px;
}

.rules-content li {
    margin-bottom: 10px;
    line-height: 1.5;
    color: #444;
}

.rules-content li:last-child {
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .container {
        padding: 24px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .level-btn {
        height: 85px;
        font-size: 1.75rem;
    }
    
    .question-text {
        font-size: 1.1rem;
    }
    
    .answer-btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .rules-content {
        padding: 16px;
    }
}