/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 100%);
    overflow: hidden;
    height: 100vh;
}

/* Allow scrolling specifically for habitat selection on mobile */
body.habitat-select-mode {
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screen Management */
.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Special handling for habitat selection screen */
#habitatSelect.screen {
    position: absolute;
    height: 100vh;
    overflow-y: auto;
    align-items: flex-start;
    padding: 2rem 0;
}

/* Enable scrolling for mobile habitat selection */
body.habitat-select-mode #habitatSelect.screen {
    position: static !important;
    height: auto !important;
    min-height: 100vh;
    overflow-y: visible !important;
    display: block !important;
    padding: 1rem 0;
}

body.habitat-select-mode #gameContainer {
    height: auto !important;
    min-height: 100vh;
}

/* Loading Screen */
#loadingScreen {
    background: linear-gradient(135deg, #FFE4B5 0%, #FFA07A 100%);
    color: #8B4513;
}

.loading-content {
    text-align: center;
}

.loading-content h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.loading-content h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #CD853F;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #DEB887;
    border-top: 5px solid #8B4513;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main Menu */
#mainMenu {
    background: linear-gradient(135deg, #98FB98 0%, #87CEEB 100%);
}

.menu-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.menu-content h1 {
    font-size: 3.5rem;
    color: #228B22;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.menu-content h2 {
    font-size: 2rem;
    color: #4169E1;
    margin-bottom: 2rem;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-btn {
    font-family: inherit;
    font-size: 1.2rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.menu-btn.primary {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.menu-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.6);
}

.menu-btn.secondary {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4);
}

.menu-btn.secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(78, 205, 196, 0.6);
}

/* Settings Menu */
#settingsMenu {
    background: linear-gradient(135deg, #DDA0DD 0%, #98FB98 100%);
}

.settings-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    min-width: 400px;
}

.settings-content h2 {
    font-size: 2.5rem;
    color: #8A2BE2;
    margin-bottom: 1rem;
    text-align: center;
}

/* Language Selector */
.language-selector-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    position: relative;
}

.language-selector {
    position: relative;
    display: inline-block;
}

.language-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(45deg, #8A2BE2, #9370DB);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

.language-selector-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(138, 43, 226, 0.4);
    background: linear-gradient(45deg, #9370DB, #8A2BE2);
}

.language-selector-btn:active {
    transform: translateY(0);
}

.language-flag {
    font-size: 1.2rem;
    line-height: 1;
}

.language-name {
    font-size: 1rem;
    font-weight: bold;
}

.language-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.language-selector-btn.active .language-arrow {
    transform: rotate(180deg);
}

.language-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.5rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 180px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
    transition: all 0.3s ease;
}

.language-dropdown:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.language-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.language-option:last-child {
    border-bottom: none;
}

.language-option:hover {
    background: linear-gradient(45deg, #8A2BE2, #9370DB);
    color: white;
}

.language-option .language-flag {
    font-size: 1.1rem;
}

.language-option .language-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.language-option.selected {
    background: rgba(138, 43, 226, 0.1);
    color: #8A2BE2;
    font-weight: bold;
}

.language-option.selected:hover {
    background: linear-gradient(45deg, #8A2BE2, #9370DB);
    color: white;
}

/* Difficulty Selector */
.difficulty-selector-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    position: relative;
}

.difficulty-selector {
    position: relative;
    display: inline-block;
}

.difficulty-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.difficulty-selector-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
    background: linear-gradient(45deg, #FF8E53, #FF6B6B);
}

.difficulty-selector-btn:active {
    transform: translateY(0);
}

.difficulty-icon {
    font-size: 1rem;
    line-height: 1;
}

.difficulty-name {
    font-size: 1rem;
    font-weight: bold;
}

.difficulty-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.difficulty-selector-btn.active .difficulty-arrow {
    transform: rotate(180deg);
}

.difficulty-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.5rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 180px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
    transition: all 0.3s ease;
}

.difficulty-dropdown:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.difficulty-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.difficulty-option:last-child {
    border-bottom: none;
}

.difficulty-option:hover {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
}

.difficulty-option .difficulty-icon {
    font-size: 1.1rem;
}

.difficulty-option .difficulty-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.difficulty-option.selected {
    background: rgba(255, 107, 107, 0.1);
    color: #FF6B6B;
    font-weight: bold;
}

.difficulty-option.selected:hover {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(138, 43, 226, 0.1);
    border-radius: 10px;
}

.setting-item label {
    font-size: 1.2rem;
    color: #8A2BE2;
    font-weight: bold;
}

/* Toggle Switches */
input[type="checkbox"] {
    position: relative;
    width: 50px;
    height: 25px;
    appearance: none;
    background: #ccc;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s;
}

input[type="checkbox"]:checked {
    background: #4ECDC4;
}

input[type="checkbox"]:before {
    content: '';
    position: absolute;
    width: 21px;
    height: 21px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

input[type="checkbox"]:checked:before {
    transform: translateX(25px);
}

/* Volume Slider */
input[type="range"] {
    width: 150px;
    height: 8px;
    background: #ddd;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: #4ECDC4;
    border-radius: 50%;
    cursor: pointer;
}

/* Game Canvas */
#gameScreen {
    background: #87CEEB;
    justify-content: flex-start;
    align-items: flex-start;
}

#gameCanvas {
    border: 3px solid #228B22;
    border-radius: 10px;
    background: white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

/* Game UI Overlay */
#gameUI {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#topBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(34, 139, 34, 0.9);
    color: white;
    padding: 1rem;
    pointer-events: all;
}

#playerInfo {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.2rem;
}

#badgeCount {
    background: rgba(255, 215, 0, 0.9);
    color: #8B4513;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: bold;
}

#currentHabitat {
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#gameControls {
    display: flex;
    gap: 0.5rem;
}

#gameControls button {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    pointer-events: all;
}

#gameControls button:hover {
    transform: scale(1.1);
    background: white;
}

/* Math Problem UI */
#mathProblem {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 600px;
    pointer-events: all;
}

#mathProblem.hidden {
    display: none;
}

.problem-container {
    text-align: center;
}

.progress-indicator {
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(76, 205, 196, 0.1);
    border-radius: 10px;
}

.progress-indicator .progress-bar {
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-indicator .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ECDC4, #44A08D);
    border-radius: 6px;
    transition: width 0.3s ease;
    width: 0%;
}

#progressText {
    font-size: 14px;
    color: #666;
    font-weight: 600;
}

#problemTitle {
    font-size: 2rem;
    color: #FF6B6B;
    margin-bottom: 1rem;
}

#problemText {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* Highlighted numbers in problem text */
.highlighted-number {
    font-weight: bold;
    font-size: 1.2em;
    color: #FF6B6B;
    text-shadow: 1px 1px 2px rgba(255, 107, 107, 0.3);
    display: inline-block;
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(255, 107, 107, 0.1);
    animation: numberHighlight 0.8s ease-in-out;
}

@keyframes numberHighlight {
    0% {
        transform: scale(1);
        background: rgba(255, 107, 107, 0.1);
    }
    50% {
        transform: scale(1.1);
        background: rgba(255, 107, 107, 0.2);
    }
    100% {
        transform: scale(1);
        background: rgba(255, 107, 107, 0.1);
    }
}

#problemVisual {
    margin: 2rem 0;
    min-height: 100px;
    background: rgba(135, 206, 235, 0.1);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
}

#answerSection {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

.answer-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    max-width: 500px;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
    border: 3px solid transparent;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    font-family: inherit;
    min-height: 60px;
}

.answer-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(78, 205, 196, 0.4);
    border-color: #FFD700;
}

.answer-option:active {
    transform: translateY(0);
}

.answer-option.selected {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.answer-option.correct {
    background: linear-gradient(45deg, #32CD32, #228B22);
    animation: correctAnswer 0.6s ease;
}

.answer-option.incorrect {
    background: linear-gradient(45deg, #DC143C, #8B0000);
    animation: incorrectAnswer 0.6s ease;
}

.option-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2rem;
}

.option-text {
    flex: 1;
    text-align: center;
    font-weight: bold;
}

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

@keyframes incorrectAnswer {
    0% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
    100% { transform: translateX(0); }
}

#feedback {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 10px;
    font-size: 1.2rem;
}

#feedback.correct {
    background: rgba(152, 251, 152, 0.8);
    color: #228B22;
}

#feedback.incorrect {
    background: rgba(255, 182, 193, 0.8);
    color: #DC143C;
}

#nextProblem {
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#nextProblem:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4);
}

/* Habitat Selection */
#habitatSelect {
    background: linear-gradient(135deg, #FFE4B5 0%, #98FB98 100%);
}

.habitat-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 800px;
    width: 90%;
    margin: 0 auto;
    min-height: fit-content;
}

/* Ensure habitat content is properly positioned for mobile scrolling */
body.habitat-select-mode .habitat-content {
    position: relative;
    display: block;
    margin: 1rem auto 3rem auto;
}

.habitat-content h2 {
    font-size: 2.5rem;
    color: #228B22;
    margin-bottom: 2rem;
    text-align: center;
}

.habitat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Mobile-specific habitat grid improvements */
@media (max-width: 768px) {
    .habitat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    /* Force proper mobile scrolling layout */
    body.habitat-select-mode {
        position: static !important;
        overflow: auto !important;
    }
    
    body.habitat-select-mode #habitatSelect {
        position: static !important;
        height: auto !important;
        min-height: calc(100vh + 200px) !important; /* Force content to be taller than viewport */
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding: 1rem 0 3rem 0;
    }
    
    body.habitat-select-mode .habitat-content {
        flex-shrink: 0;
        margin: 0 auto 2rem auto;
        padding: 1.5rem;
        width: 95%;
    }
}

@media (max-width: 480px) {
    .habitat-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    body.habitat-select-mode #habitatSelect {
        min-height: calc(100vh + 400px) !important; /* Even more height for single column */
        padding: 0.5rem 0 4rem 0;
    }
    
    body.habitat-select-mode .habitat-content {
        width: 98%;
        padding: 1rem;
        margin: 0 auto 3rem auto;
    }
}

.habitat-card {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    position: relative;
}

.habitat-card.unlocked:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.habitat-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.habitat-image {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.habitat-card h3 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.habitat-card p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ECDC4, #44A08D);
    transition: width 0.3s ease;
}

.lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #999;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .menu-content {
        padding: 2rem;
    }
    
    .menu-content h1 {
        font-size: 2.5rem;
    }
    
    .menu-content h2 {
        font-size: 1.5rem;
    }
    
    #gameCanvas {
        width: 100vw;
        height: 100vh;
        border: none;
        border-radius: 0;
    }
    
    #mathProblem {
        max-width: 90%;
        padding: 1.5rem;
    }
    
    /* Mobile habitat selection improvements */
    #habitatSelect {
        padding: 1rem 0;
        align-items: flex-start;
        justify-content: flex-start;
    }
    
    .habitat-content {
        width: 95%;
        padding: 1.5rem;
        margin-top: 1rem;
        border-radius: 15px;
    }
    
    .habitat-content h2 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }
    
    .habitat-card {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .habitat-card h3 {
        font-size: 1.1rem;
    }
    
    .habitat-card p {
        font-size: 0.85rem;
    }
    
    .habitat-image {
        font-size: 2.5rem;
        margin-bottom: 0.5rem;
    }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
    #habitatSelect {
        padding: 0.5rem 0;
    }
    
    .habitat-content {
        width: 98%;
        padding: 1rem;
        margin-top: 0.5rem;
    }
    
    .habitat-content h2 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }
    
    .habitat-card {
        padding: 0.8rem;
    }
    
    .habitat-image {
        font-size: 2rem;
    }
}

/* Settings Actions Layout */
.settings-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* Danger Button Styling */
.menu-btn.danger {
    background: linear-gradient(135deg, #E74C3C, #C0392B);
    color: white;
    border: 2px solid #C0392B;
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.menu-btn.danger:hover {
    background: linear-gradient(135deg, #C0392B, #A93226);
    border-color: #A93226;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.menu-btn.danger:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3);
}

/* Mobile Language Selector */
@media (max-width: 768px) {
    .language-selector-container {
        margin-bottom: 1.5rem;
    }
    
    .language-selector-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .language-dropdown {
        min-width: 160px;
        margin-top: 0.3rem;
    }
    
    .language-option {
        padding: 0.8rem 1.2rem;
    }
    
    .language-option .language-name {
        font-size: 0.9rem;
    }
    
    .difficulty-selector-container {
        margin-bottom: 1.5rem;
    }
    
    .difficulty-selector-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .difficulty-dropdown {
        min-width: 160px;
        margin-top: 0.3rem;
    }
    
    .difficulty-option {
        padding: 0.8rem 1.2rem;
    }
    
    .difficulty-option .difficulty-name {
        font-size: 0.9rem;
    }
    
    .settings-actions {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .language-selector-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .language-dropdown {
        min-width: 140px;
    }
    
    .language-option {
        padding: 0.7rem 1rem;
    }
    
    .difficulty-selector-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .difficulty-dropdown {
        min-width: 140px;
    }
    
    .difficulty-option {
        padding: 0.7rem 1rem;
    }
}

/* Credits Screen */
#creditsScreen {
    background: linear-gradient(135deg, #FFE4E1 0%, #FFA07A 50%, #87CEEB 100%);
    overflow-y: auto;
    align-items: flex-start;
    padding: 2rem 0;
}

/* Enable scrolling for credits screen */
body.credits-mode {
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh;
}

body.credits-mode #creditsScreen {
    position: static !important;
    height: auto !important;
    min-height: 100vh;
    overflow-y: visible !important;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 1rem 0 3rem 0;
}

.credits-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 800px;
    width: 90%;
    margin: 0 auto;
    text-align: center;
    animation: creditsEntrance 0.8s ease-out;
    flex-shrink: 0;
}

/* Ensure credits content is properly positioned for scrolling */
body.credits-mode .credits-content {
    position: relative;
    display: block;
    margin: 1rem auto 3rem auto;
    max-height: none;
}

@keyframes creditsEntrance {
    0% {
        transform: scale(0.8) translateY(50px);
        opacity: 0;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.credits-content h2 {
    font-size: 2.5rem;
    color: #FF6B6B;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.credits-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 107, 107, 0.05);
    border-radius: 15px;
    border-left: 4px solid #FF6B6B;
}

.credits-section h3 {
    font-size: 1.5rem;
    color: #4ECDC4;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.credits-section h3::before,
.credits-section h3::after {
    content: '🌟';
    font-size: 1rem;
}

.credits-team {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.team-member {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.team-member:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.member-avatar {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #FF6B6B, #4ECDC4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    animation: avatarPulse 3s ease-in-out infinite;
}

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

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

.member-info h4 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.member-roles {
    font-size: 1rem;
    color: #FF6B6B;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.member-description {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.credits-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
}

.credits-info p {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.credits-info strong {
    color: #4ECDC4;
}

.credits-thanks {
    text-align: center;
}

.credits-thanks p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    color: #333;
}

.credits-thanks p:last-child {
    font-size: 1.2rem;
    font-weight: bold;
    color: #FF6B6B;
    background: linear-gradient(45deg, #FFE4E1, #FFA07A);
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid #FF6B6B;
    animation: missionGlow 2s ease-in-out infinite;
}

@keyframes missionGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 107, 107, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
    }
}

.credits-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(255, 107, 107, 0.2);
}

/* Responsive Credits */
@media (max-width: 768px) {
    #creditsScreen {
        padding: 1rem 0;
    }
    
    body.credits-mode #creditsScreen {
        min-height: calc(100vh + 200px) !important;
        padding: 0.5rem 0 4rem 0;
    }
    
    .credits-content {
        padding: 1.5rem;
        width: 95%;
    }
    
    body.credits-mode .credits-content {
        margin: 0.5rem auto 2rem auto;
        padding: 1.5rem;
        width: 95%;
    }
    
    .credits-content h2 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }
    
    .credits-section {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .credits-section h3 {
        font-size: 1.3rem;
    }
    
    .team-member {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1.5rem;
    }
    
    .member-info {
        text-align: center;
    }
    
    .member-avatar {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .credits-info {
        max-width: 100%;
    }
    
    .credits-thanks p:last-child {
        font-size: 1rem;
        padding: 0.8rem;
    }
}

@media (max-width: 480px) {
    body.credits-mode #creditsScreen {
        min-height: calc(100vh + 400px) !important;
        padding: 0.5rem 0 5rem 0;
    }
    
    .credits-content {
        padding: 1rem;
    }
    
    body.credits-mode .credits-content {
        width: 98%;
        padding: 1rem;
        margin: 0.5rem auto 3rem auto;
    }
    
    .credits-content h2 {
        font-size: 1.8rem;
    }
    
    .credits-section h3 {
        font-size: 1.2rem;
        flex-direction: column;
        gap: 0.2rem;
    }
    
    .team-member {
        padding: 1rem;
    }
    
    .member-info h4 {
        font-size: 1.2rem;
    }
    
    .member-roles {
        font-size: 0.9rem;
    }
    
    .member-description {
        font-size: 0.85rem;
    }
}