:root {
    --bg-gradient-start: #141E30;
    --bg-gradient-end: #243B55;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.9);
    --success: rgba(76, 175, 80, 0.9);
    --error: rgba(244, 67, 54, 0.9);
    --primary-blue: #4c669f;
}

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    background: #121212;
    /* Dark background for desktop view */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(46, 49, 146, 0.3) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(27, 255, 255, 0.15) 0%, transparent 40%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Themes apply to the CONTAINER now, simulatiing phone screen content */
#app-container.theme-home {
    background: linear-gradient(180deg, #2E3192 0%, #1BFFFF 100%);
}

#app-container.theme-quiz {
    background: linear-gradient(135deg, #141E30, #243B55);
}

#app-container {
    width: 100%;
    max-width: 420px;
    height: 90vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
    justify-content: flex-start;
    /* Flow from top */

    /* Phone Frame Visuals */
    background: rgba(255, 255, 255, 0.02);
    border-radius: 40px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.5);
    /* Drop Shadow only */
    /* Drop Shadow */
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hide scrollbar but allow scroll if needed */
#app-container::-webkit-scrollbar {
    display: none;
}

/* Home Screen */
#start-screen {
    /* display: flex handled by .screen.active */
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    justify-content: center;
    gap: 15px;
    /* Reduced gap */
}

.hero-title {
    font-size: 42px;
    /* Reduced from 48px */
    font-weight: 800;
    text-align: center;
    margin-bottom: 0px;
    /* Reduced from 5px */
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.hero-subtitle {
    font-size: 16px;
    /* Reduced from 18px */
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 10px;
    /* Reduced from 20px */
}

.section-label {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    /* Reduced from 8px */
    width: 100%;
    text-align: left;
    padding-left: 10px;
}

.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    /* Reduced from 10px */
    width: 100%;
    margin-bottom: 15px;
    /* Reduced from 20px */
}

.chip {
    padding: 10px 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

/* Settings Button */
.settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s;
}

.chip.selected {
    background: white;
    color: #333;
    border-color: white;
    transform: scale(1.05);
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(45deg);
}

.settings-btn svg {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #4CAF50;
}

input:focus+.slider {
    box-shadow: 0 0 1px #4CAF50;
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.big-btn {
    width: 100%;
    padding: 18px;
    border-radius: 30px;
    font-size: 20px;
    font-weight: bold;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: transform 0.1s;
}

.big-btn:active {
    transform: scale(0.98);
}

.btn-start {
    background: #FF9800;
}

.btn-duel {
    background: #E91E63;
}

.btn-survival {
    background: #F44336;
    /* Red Alarm Color */
    font-size: 18px;
    /* Slightly smaller to fit 3 buttons */
}

/* Screens Toggle */
.screen {
    display: none;
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Adjust UI Layer for new layout */
#ui-layer {
    width: 100%;
    max-width: 100%;
    /* Reset max-width as app-container handles it */
    padding: 0;
}

/* Glass Panel (Quiz Card) */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* Header Section */
.card-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.progress-text {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.badges {
    display: flex;
    gap: 8px;
}

/* Badges */
.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.8px;
    color: white;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Specific Badge Colors */
#badge-score {
    background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%);
    /* Gold/Orange */
}

#badge-category {
    background: linear-gradient(135deg, #00C6FF 0%, #0072FF 100%);
    /* Blue */
}

#badge-difficulty {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    /* Green */
}

/* Question Typography */
#question-box {
    font-size: 84px;
    /* Big & Bold */
    font-weight: 800;
    text-align: center;
    margin-bottom: 40px;
    margin-top: 10px;
    color: #fff;
    text-shadow:
        0 4px 0 #000,
        0 0 20px rgba(255, 255, 255, 0.2);
    letter-spacing: -2px;
    line-height: 1.1;
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
}

.option-btn {
    height: 90px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 36px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.1),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.option-btn:active {
    transform: scale(0.96);
}

.option-btn.correct {
    background: var(--success);
}

.option-btn.incorrect {
    background: var(--error);
}

/* Result Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    /* Darker dim */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
    /* Blur background behind modal */
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 85%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 30px;
    padding: 40px 30px;
    text-align: center;
    color: #333;
    transform: translateY(30px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Bouncy enter */
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.modal-overlay.visible .modal-content {
    transform: translateY(0) scale(1);
}

@keyframes bounceEmoji {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-10px) scale(1.1);
    }
}

.modal-emoji {
    font-size: 72px;
    margin-bottom: 15px;
    display: block;
    animation: bounceEmoji 2s infinite ease-in-out;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.modal-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #141E30, #243B55);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.modal-score-label {
    font-size: 16px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.modal-score-value {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(90deg, #E91E63, #3f51b5);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 30px;
}

/* Action Buttons Container */
.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
}

/* Base Action Button */
.action-btn {
    border: none;
    padding: 16px 32px;
    border-radius: 50px;
    /* Pillow shape */
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    color: white;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background-size: 200% auto;
    flex: 1;
    max-width: 160px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.action-btn:hover {
    background-position: right center;
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.action-btn:active {
    transform: scale(0.95);
}

/* Home Button - Cool Blue/Purple */
.action-btn.home-btn {
    background-image: linear-gradient(to right, #4facfe 0%, #00f2fe 51%, #4facfe 100%);
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.4);
}

/* Play Again (Secondary) - Energetic Orange/Red */
.action-btn.secondary {
    background-image: linear-gradient(to right, #FF512F 0%, #F09819 51%, #FF512F 100%);
    box-shadow: 0 4px 15px rgba(255, 81, 47, 0.4);
}

/* ... existing styles ... */

/* Animations */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    60% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
    }
}

@keyframes floatParticle {
    0% {
        transform: translateY(0px);
        opacity: 0.8;
    }

    50% {
        transform: translateY(-20px);
        opacity: 0.4;
    }

    100% {
        transform: translateY(0px);
        opacity: 0.8;
    }
}

/* Apply Animations */
.hero-title {
    animation: slideUpFade 0.6s ease-out;
}

.hero-subtitle {
    animation: slideUpFade 0.6s ease-out 0.1s backwards;
}

.chips-row {
    animation: slideUpFade 0.6s ease-out 0.2s backwards;
}

.big-btn {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.3s backwards;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
    animation: slideUpFade 0.4s ease-out;
}

/* Button Click Effect */
.big-btn:active,
.option-btn:active,
.chip:active {
    transform: scale(0.95) !important;
}

/* Duel Mode Split Screen */
#duel-screen {
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    height: 100%;
}

.duel-half {
    flex: 1;
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

.duel-top {
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    transform: rotate(180deg);
    /* Player 2 faces opposite */
}

.duel-ui {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    box-sizing: border-box;
}

.duel-score {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-blue);
    background: #fff;
    padding: 6px 16px;
    border-radius: 12px;
    align-self: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.duel-question {
    font-size: 42px;
    font-weight: 800;
    text-align: center;
    margin: 10px 0;
}

.duel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.duel-btn {
    height: 60px;
    font-size: 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.duel-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.duel-btn.correct {
    background: var(--success);
}

.duel-btn.incorrect {
    background: var(--error);
}

/* Duel Timer */
.duel-timer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 24px;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.duel-timer.warning {
    background: rgba(255, 0, 0, 0.8);
    animation: popIn 0.5s infinite alternate;
}

/* Shake Animation for Combo */
@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

/* Navigation Button (Home) Inline */
.nav-btn.home-icon {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    /* Circle */
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Header Rows Layout */
.header-top-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-info-row {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.nav-btn.home-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1) rotate(-5deg);
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.nav-btn.home-icon svg {
    width: 26px;
    height: 26px;
    fill: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Timer Bar Polish */
#quiz-timer-bar {
    width: 100%;
    height: 10px;
    /* Thicker */
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 30px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

#quiz-timer-progress {
    height: 100%;
    background: linear-gradient(90deg, #00E676, #00C853);
    /* Gradient Green */
    width: 100%;
    transition: width 1s linear, background 0.3s;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 230, 118, 0.4);
}

#quiz-timer-progress.warning {
    background: linear-gradient(90deg, #FF9800, #F57C00);
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.4);
}

#quiz-timer-progress.danger {
    background: linear-gradient(90deg, #ff4444, #CC0000);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.6);
}