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

:root {
    --bg-primary: #667eea;
    --bg-secondary: #764ba2;
    --text-primary: #333;
    --text-secondary: #718096;
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.2);
    --success-color: #48bb78;
    --error-color: #f56565;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    --gold-color: #ffd700;
}

body {
    font-family: 'Georgia', serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    padding: 10px;
    transition: all 0.3s ease;
}

body.dark-theme {
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --card-bg: rgba(45, 55, 72, 0.95);
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

.theme-toggle-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.theme-icon {
    font-size: 1.5em;
    transition: transform 0.3s ease;
}

.game-container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px var(--shadow-light);
    padding: 40px;
    max-width: 800px;
    width: 100%;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.header {
    margin-bottom: 30px;
}

.title {
    font-size: 2.5em;
    color: #4a5568;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px var(--shadow-light);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.2em;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(45deg, #f7fafc, #edf2f7);
    border-radius: 15px;
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: inset 0 2px 4px var(--shadow-light);
}

.dark-theme .stats-bar {
    background: linear-gradient(45deg, #2d3748, #4a5568);
}

.welcome-screen {
    text-align: center;
    padding: 40px;
}

.welcome-title {
    font-size: 3em;
    color: #4a5568;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px var(--shadow-light);
}

.dark-theme .welcome-title,
.dark-theme .title {
    color: var(--text-primary);
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 1.4em;
    margin-bottom: 40px;
}

.name-input-container {
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    color: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
}

.name-input-label {
    font-size: 1.3em;
    margin-bottom: 20px;
    display: block;
}

.name-input {
    width: 100%;
    max-width: 300px;
    padding: 15px 20px;
    font-size: 1.2em;
    border: none;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
    outline: none;
    transition: all 0.3s ease;
}

.name-input:focus {
    transform: scale(1.05);
    box-shadow: 0 5px 15px var(--shadow-medium);
}

.start-game-btn {
    background: linear-gradient(45deg, var(--success-color), #38a169);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px 40px;
    font-size: 1.3em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-game-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.start-game-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.player-name {
    color: var(--info-color);
    font-weight: bold;
}

.stage-indicator {
    background: linear-gradient(45deg, var(--info-color), #3182ce);
    color: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
    font-size: 1.1em;
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.3);
}

.stage-indicator.advanced {
    background: linear-gradient(45deg, var(--warning-color), #dd6b20);
}

.stage-indicator.expert {
    background: linear-gradient(45deg, var(--error-color), #c53030);
}

.stage-indicator.master {
    background: linear-gradient(45deg, #805ad5, #6b46c1);
}

.stage-progress {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    height: 8px;
    margin-top: 8px;
    overflow: hidden;
}

.stage-progress-bar {
    background: var(--gold-color);
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 10px;
}

.stat {
    text-align: center;
}

.stat-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #2d3748;
}

.dark-theme .stat-value {
    color: var(--text-primary);
}

.streak-fire {
    color: #ff6b35;
    animation: flicker 0.5s ease-in-out infinite alternate;
}

@keyframes flicker {
    0% { opacity: 0.8; }
    100% { opacity: 1; }
}

.question-container {
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    color: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 10px;
    box-shadow: 0 10px 20px var(--shadow-medium);
}

.question-number {
    font-size: 1em;
    opacity: 0.8;
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.4em;
    line-height: 1.6;
    margin-bottom: 10px;
}

.answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 10px;
}

.answer-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 12px;
    padding: 20px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #2d3748;
    font-weight: 500;
}

.answer-btn:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--shadow-medium);
}

.answer-btn.correct {
    background: var(--success-color);
    color: white;
    transform: scale(1.05);
}

.answer-btn.incorrect {
    background: var(--error-color);
    color: white;
    transform: scale(0.95);
}

.answer-btn.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.next-btn {
    background: linear-gradient(45deg, var(--success-color), #38a169);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 15px 30px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

.next-btn.show {
    opacity: 1;
    transform: translateY(0);
}

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.award-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, var(--gold-color), #ffed4e);
    color: #2d3748;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    text-align: center;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.award-popup.show {
    transform: translate(-50%, -50%) scale(1);
}

.award-icon {
    font-size: 4em;
    margin-bottom: 20px;
    animation: bounce 0.6s ease-in-out infinite alternate;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

.award-title {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 10px;
}

.award-description {
    font-size: 1.2em;
    margin-bottom: 20px;
}

.close-award {
    background: #2d3748;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-award:hover {
    background: #4a5568;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(45deg, var(--success-color), #38a169);
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: 0 10px 20px var(--shadow-medium);
    z-index: 1001;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 0;
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-icon {
    font-size: 1.2em;
}

.notification-text {
    font-weight: 500;
}

.game-over {
    text-align: center;
    padding: 40px;
}

.final-score {
    font-size: 3em;
    color: var(--success-color);
    margin-bottom: 20px;
}

.restart-btn {
    background: linear-gradient(45deg, var(--bg-primary), var(--bg-secondary));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px 30px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Mobile Optimization - Progressive breakpoints */

/* Large tablets and small desktops */
@media (max-width: 768px) {
    .game-container {
        padding: 30px 20px;
        margin: 10px;
    }
    
    .title {
        font-size: 2.2em;
    }
    
    .welcome-title {
        font-size: 2.5em;
    }
    
    .stats-bar {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .stat {
        flex: 1;
        min-width: 120px;
    }
    
    .theme-toggle-container {
        top: 15px;
        right: 15px;
    }
    
    .theme-toggle {
        width: 45px;
        height: 45px;
    }
}

/* Standard mobile devices (most smartphones) */
@media (max-width: 480px) {
    body {
        padding: 5px;
        align-items: flex-start;
        padding-top: 20px;
    }
    
    .game-container {
        padding: 20px 15px;
        border-radius: 15px;
        margin: 0;
        min-height: calc(100vh - 40px);
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    
    .theme-toggle-container {
        top: 10px;
        right: 10px;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
    }
    
    .theme-icon {
        font-size: 1.2em;
    }
    
    .title {
        font-size: 1.8em;
        margin-bottom: 8px;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .welcome-title {
        font-size: 2em;
        margin-bottom: 15px;
    }
    
    .welcome-subtitle {
        font-size: 1.1em;
        margin-bottom: 25px;
    }
    
    .welcome-screen,
    .game-over {
        padding: 20px 10px;
    }
    
    .name-input-container {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .name-input-label {
        font-size: 1.1em;
        margin-bottom: 15px;
    }
    
    .name-input {
        max-width: 100%;
        font-size: 1.1em;
        padding: 12px 15px;
    }
    
    .start-game-btn {
        padding: 12px 30px;
        font-size: 1.1em;
    }
    
    .stats-bar {
        padding: 8px;
        margin-bottom: 15px;
        flex-direction: row;
        justify-content: space-between;
    }
    
    .stat {
        flex: 1;
        min-width: auto;
    }
    
    .stat-label {
        font-size: 0.8em;
        margin-bottom: 3px;
    }
    
    .stat-value {
        font-size: 1.4em;
    }
    
    .stage-indicator {
        padding: 12px;
        font-size: 1em;
        margin-bottom: 15px;
    }
    
    .question-container {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .question-text {
        font-size: 1.2em;
        line-height: 1.5;
    }
    
    .answers-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .answer-btn {
        padding: 15px 12px;
        font-size: 1em;
        text-align: center;
        word-wrap: break-word;
        hyphens: auto;
    }
    
    .next-btn {
        padding: 12px 25px;
        font-size: 1em;
    }
    
    .award-popup {
        padding: 25px 20px;
        margin: 0 10px;
        max-width: calc(100vw - 40px);
        border-radius: 15px;
    }
    
    .award-title {
        font-size: 1.6em;
        margin-bottom: 8px;
    }
    
    .award-description {
        font-size: 1em;
        margin-bottom: 15px;
    }
    
    .award-icon {
        font-size: 3em;
        margin-bottom: 15px;
    }
    
    .final-score {
        font-size: 2.2em;
        margin-bottom: 15px;
    }
    
    .restart-btn {
        padding: 12px 25px;
        font-size: 1.1em;
    }
    
    .notification {
        top: 15px;
        padding: 12px 20px;
        border-radius: 20px;
    }
}

/* Very small screens (older smartphones, low-res devices) */
@media (max-width: 360px) {
    .game-container {
        padding: 15px 10px;
    }
    
    .title {
        font-size: 1.6em;
    }
    
    .welcome-title {
        font-size: 1.8em;
    }
    
    .question-text {
        font-size: 1.1em;
    }
    
    .answer-btn {
        padding: 12px 10px;
        font-size: 0.95em;
    }
    
    .stats-bar {
        padding: 6px;
    }
    
    .stat-value {
        font-size: 1.2em;
    }
    
    .award-popup {
        padding: 20px 15px;
    }
    
    .award-title {
        font-size: 1.4em;
    }
    
    .award-icon {
        font-size: 2.5em;
    }
    
    .theme-toggle {
        width: 35px;
        height: 35px;
    }
    
    .theme-icon {
        font-size: 1em;
    }
}

/* Extra small screens and very low resolution */
@media (max-width: 320px) {
    .game-container {
        padding: 12px 8px;
        border-radius: 10px;
    }
    
    .title {
        font-size: 1.4em;
    }
    
    .welcome-title {
        font-size: 1.6em;
    }
    
    .subtitle,
    .welcome-subtitle {
        font-size: 0.9em;
    }
    
    .question-text {
        font-size: 1em;
        line-height: 1.4;
    }
    
    .answer-btn {
        padding: 10px 8px;
        font-size: 0.9em;
    }
    
    .stat-label {
        font-size: 0.7em;
    }
    
    .stat-value {
        font-size: 1.1em;
    }
    
    .name-input {
        padding: 10px 12px;
        font-size: 1em;
    }
    
    .start-game-btn,
    .next-btn,
    .restart-btn {
        padding: 10px 20px;
        font-size: 1em;
    }
    
    .theme-toggle-container {
        top: 8px;
        right: 8px;
    }
    
    .theme-toggle {
        width: 32px;
        height: 32px;
    }
    
    .theme-icon {
        font-size: 0.9em;
    }
}

/* Landscape orientation optimization for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        align-items: flex-start;
        padding-top: 10px;
    }
    
    .game-container {
        min-height: auto;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
    
    .welcome-screen,
    .game-over {
        padding: 15px 10px;
    }
    
    .welcome-title {
        font-size: 1.8em;
        margin-bottom: 10px;
    }
    
    .award-popup {
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .theme-toggle-container {
        top: 5px;
        right: 5px;
    }
}

/* High DPI/Retina display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .game-container {
        backdrop-filter: blur(15px);
    }
    
    .answer-btn,
    .start-game-btn,
    .next-btn,
    .restart-btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

.stage-selection-container {
    background: linear-gradient(135deg, #4a5568, #2d3748);
    color: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
}

.stage-selection-label {
    font-size: 1.2em;
    margin-bottom: 15px;
    display: block;
}

.stage-selector {
    width: 100%;
    max-width: 400px;
    padding: 12px 15px;
    font-size: 1.1em;
    border: none;
    border-radius: 8px;
    background: white;
    color: #2d3748;
    cursor: pointer;
    outline: none;
}

.stage-selector:focus {
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
}

/* Mobile optimization for stage selector */
@media (max-width: 480px) {
    .stage-selection-container {
        padding: 20px 15px;
    }
    
    .stage-selection-label {
        font-size: 1.1em;
    }
    
    .stage-selector {
        font-size: 1em;
        padding: 10px 12px;
    }
}