:root {
    --bg-dark: #0c1445;
    --bg-light: #1a237e;
    --accent-purple: #7c4dff;
    --accent-pink: #ff4081;
    --accent-yellow: #ffd740;
    --accent-cyan: #00e5ff;
    --accent-green: #00e676;
    --accent-red: #ff5252;
    --text-light: #ffffff;
    --text-muted: #b0bec5;
}

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

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    min-height: 100vh;
    background: var(--bg-dark);
    color: var(--text-light);
    overflow-x: hidden;
}

/* Starry Background */
.stars, .twinkling {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.stars {
    background: #000 url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="10" cy="10" r="1" fill="white"/><circle cx="30" cy="50" r="0.5" fill="white"/><circle cx="70" cy="20" r="1" fill="white"/><circle cx="90" cy="70" r="0.8" fill="white"/><circle cx="50" cy="80" r="0.6" fill="white"/><circle cx="20" cy="90" r="1" fill="white"/><circle cx="80" cy="40" r="0.7" fill="white"/><circle cx="40" cy="30" r="0.9" fill="white"/></svg>') repeat;
    background-size: 200px 200px;
    z-index: 0;
}

.twinkling {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="25" cy="35" r="1.5" fill="white"><animate attributeName="opacity" values="0;1;0" dur="2s" repeatCount="indefinite"/></circle><circle cx="75" cy="65" r="1" fill="white"><animate attributeName="opacity" values="0;1;0" dur="1.5s" repeatCount="indefinite"/></circle><circle cx="45" cy="15" r="1.2" fill="white"><animate attributeName="opacity" values="0;1;0" dur="2.5s" repeatCount="indefinite"/></circle><circle cx="15" cy="75" r="0.8" fill="white"><animate attributeName="opacity" values="0;1;0" dur="1.8s" repeatCount="indefinite"/></circle></svg>') repeat;
    background-size: 300px 300px;
    z-index: 1;
    animation: twinkle 4s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Jungle Background */
.jungle {
    background: linear-gradient(180deg, #1a3a1a 0%, #0d1f0d 100%) !important;
}

.jungle::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(ellipse at 20% 80%, rgba(34, 139, 34, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(34, 139, 34, 0.2) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* Ocean Background */
.ocean {
    background: linear-gradient(180deg, #0a1a2e 0%, #1a3a5e 50%, #2d5a7b 100%) !important;
}

.ocean::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(ellipse at 30% 20%, rgba(0, 150, 200, 0.2) 0%, transparent 40%),
        radial-gradient(ellipse at 70% 60%, rgba(0, 100, 150, 0.2) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: oceanWave 8s ease-in-out infinite;
}

@keyframes oceanWave {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Difficulty-specific backgrounds */
.easy-bg {
    background: linear-gradient(180deg, #0c1445 0%, #1a237e 100%) !important;
}

.medium-bg {
    background: linear-gradient(180deg, #1a0a2e 0%, #2d1b4e 100%) !important;
}

.hard-bg {
    background: linear-gradient(180deg, #2d0a0a 0%, #4e1b1b 100%) !important;
}

.math-bg {
    background: linear-gradient(180deg, #0a1a2e 0%, #1b2d4e 100%) !important;
}

/* Game Container */
.game-container {
    position: relative;
    z-index: 10;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.screen {
    background: linear-gradient(135deg, rgba(26, 35, 126, 0.9), rgba(124, 77, 255, 0.3));
    border-radius: 24px;
    padding: 30px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.screen.hidden {
    display: none;
}

.settings-panel.hidden {
    display: none !important;
}

header {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.settings-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 12px;
    transition: all 0.3s ease;
    z-index: 50;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.settings-panel {
    position: fixed;
    top: 60px;
    right: 10px;
    z-index: 100;
    animation: slideIn 0.3s ease;
}

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

.settings-content {
    background: linear-gradient(135deg, rgba(26, 35, 126, 0.95), rgba(124, 77, 255, 0.9));
    border-radius: 16px;
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    min-width: 200px;
}

.settings-content h3 {
    margin-bottom: 15px;
    color: var(--accent-cyan);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background-color: var(--accent-green);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.timer-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.settings-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 15px 0;
}

.theme-selector {
    margin-bottom: 15px;
}

.theme-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.theme-options {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.3);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-btn:hover:not(.locked) {
    transform: scale(1.1);
    border-color: var(--accent-cyan);
}

.theme-btn.active {
    border-color: var(--accent-green);
    background: rgba(0, 230, 118, 0.3);
    box-shadow: 0 0 15px rgba(0, 230, 118, 0.4);
}

.theme-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.unlock-hint {
    font-size: 0.75rem;
    color: var(--accent-yellow);
    text-align: center;
    margin-top: 10px;
}

.reset-progress-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ff5722, #ff9800);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.reset-progress-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 15px rgba(255, 87, 34, 0.4);
}

.reset-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
    margin-bottom: 15px;
}

.close-settings {
    width: 100%;
    padding: 10px;
    background: var(--accent-purple);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.3s ease;
}

.close-settings:hover {
    background: var(--accent-pink);
}

.high-score {
    background: linear-gradient(135deg, rgba(255, 215, 64, 0.3), rgba(255, 165, 0, 0.2));
    border: 2px solid var(--accent-yellow);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
    animation: popIn 0.5s ease;
}

.high-score span:first-child {
    font-size: 1.2rem;
    margin-right: 5px;
}

#high-score-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-yellow);
    margin: 0 5px;
}

.streak-display {
    background: linear-gradient(135deg, rgba(255, 82, 82, 0.3), rgba(255, 152, 0, 0.2));
    border: 2px solid #ff5722;
    border-radius: 16px;
    padding: 10px 20px;
    margin-bottom: 15px;
    text-align: center;
    animation: popIn 0.5s ease;
    display: inline-block;
}

.streak-display span:first-child {
    font-size: 1.2rem;
    margin-right: 5px;
}

#streak-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #ff5722;
    margin: 0 5px;
}

.mode-selector {
    margin-top: 30px;
    text-align: center;
}

.mode-selector h2 {
    margin-bottom: 20px;
    font-size: 1.3rem;
    color: var(--accent-cyan);
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.two-player-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.player-turn {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 12px;
    text-align: center;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.player-turn.active {
    opacity: 1;
    background: rgba(124, 77, 255, 0.4);
    border: 2px solid var(--accent-purple);
    transform: scale(1.05);
}

.player-label {
    display: block;
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.player-score {
    font-size: 0.9rem;
    color: var(--accent-cyan);
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(90deg, var(--accent-yellow), var(--accent-pink), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 10px var(--accent-purple)); }
    to { filter: drop-shadow(0 0 20px var(--accent-pink)); }
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-top: 8px;
}

/* Difficulty Selector */
.difficulty-selector {
    text-align: center;
}

.difficulty-selector h2 {
    margin-bottom: 25px;
    font-size: 1.5rem;
    color: var(--accent-cyan);
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    background: linear-gradient(135deg, var(--bg-light), var(--bg-dark));
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 20px 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.diff-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.diff-btn.easy { border-color: var(--accent-green); }
.diff-btn.easy:hover { background: linear-gradient(135deg, rgba(0, 230, 118, 0.3), transparent); }

.diff-btn.medium { border-color: var(--accent-yellow); }
.diff-btn.medium:hover { background: linear-gradient(135deg, rgba(255, 215, 64, 0.3), transparent); }

.diff-btn.hard { border-color: var(--accent-red); }
.diff-btn.hard:hover { background: linear-gradient(135deg, rgba(255, 82, 82, 0.3), transparent); }

.diff-btn .emoji {
    font-size: 2.5rem;
}

.diff-btn .name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-light);
}

.diff-btn .range {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Game Screen */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.mission-info, .guesses-info {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 1rem;
}

.timer-display {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-cyan);
}

.timer-display span:first-child {
    margin-right: 5px;
}

#guesses-left {
    color: var(--accent-yellow);
    font-weight: bold;
}

.character-area {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    margin: 20px 0;
    min-height: 120px;
}

.character {
    font-size: 5rem;
    animation: float 3s ease-in-out infinite;
    display: inline-block;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.character.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-15px) rotate(-5deg); }
    75% { transform: translateX(15px) rotate(5deg); }
}

.character.bounce {
    animation: bounce 0.6s ease-in-out;
}

.character.dance {
    animation: dance 1.5s ease-in-out;
}

@keyframes dance {
    0% { transform: scale(1) rotate(0deg); }
    20% { transform: scale(1.2) rotate(-15deg); }
    40% { transform: scale(1.2) rotate(15deg); }
    60% { transform: scale(1.3) rotate(-15deg); }
    80% { transform: scale(1.3) rotate(15deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Thermometer */
.thermometer {
    width: 30px;
    height: 80px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px 15px 0 0;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.thermometer-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #00e676, #00c853);
    transition: height 0.5s ease, background 0.5s ease;
    border-radius: 0 0 12px 12px;
}

.thermometer-bulb {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #00e676;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.message {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 25px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.message.hint-high { color: var(--accent-red); }
.message.hint-low { color: var(--accent-cyan); }
.message.correct { color: var(--accent-green); }

.input-area {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

#guess-input {
    flex: 1;
    min-width: 150px;
    padding: 15px 20px;
    font-size: 1.2rem;
    border: 2px solid var(--accent-purple);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

#guess-input::placeholder {
    color: var(--text-muted);
}

#guess-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}

.submit-btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.submit-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(124, 77, 255, 0.4);
}

.submit-btn:active {
    transform: scale(0.98);
}

.history {
    margin-top: 25px;
    text-align: center;
}

.history-label {
    color: var(--text-muted);
    display: block;
    margin-bottom: 10px;
}

.guess-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.guess-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 1rem;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.guess-item.too-high {
    border-left: 3px solid var(--accent-red);
}

.guess-item.too-low {
    border-left: 3px solid var(--accent-cyan);
}

/* Win Screen */
.win-content, .lose-content {
    text-align: center;
    padding: 20px;
}

.win-emoji, .lose-emoji {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: bounce 1s ease-in-out infinite;
}

.win-content h2 {
    font-size: 2.5rem;
    color: var(--accent-yellow);
    margin-bottom: 15px;
}

.lose-content h2 {
    font-size: 2rem;
    color: var(--accent-red);
    margin-bottom: 15px;
}

#lose-message-time {
    color: var(--accent-red);
    font-weight: bold;
    font-size: 1.2rem;
}

.win-stats {
    margin: 20px 0;
    font-size: 1.2rem;
}

#final-guesses {
    color: var(--accent-cyan);
    font-weight: bold;
    font-size: 1.5rem;
}

#secret-number {
    color: var(--accent-yellow);
    font-weight: bold;
    font-size: 1.5rem;
}

.play-again-btn {
    margin-top: 25px;
    padding: 18px 40px;
    font-size: 1.3rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    color: var(--bg-dark);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.play-again-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(0, 230, 118, 0.4);
}

/* Level Up Screen */
.levelup-content {
    text-align: center;
    padding: 20px;
}

.levelup-emoji {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: bounce 1s ease-in-out infinite;
}

.levelup-content h2 {
    font-size: 2.5rem;
    color: var(--accent-yellow);
    margin-bottom: 15px;
    animation: glow 1s ease-in-out infinite alternate;
}

.levelup-message {
    font-size: 1.3rem;
    margin-bottom: 25px;
    color: var(--text-light);
    white-space: pre-line;
}

.levelup-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.levelup-btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    width: 100%;
    max-width: 250px;
}

.levelup-btn.yes {
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    color: var(--bg-dark);
}

.levelup-btn.yes:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 230, 118, 0.4);
}

.levelup-btn.no {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.levelup-btn.no:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Confetti Animation */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 15px;
    height: 15px;
    top: -20px;
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 1.8rem;
    }
    
    .screen {
        padding: 20px;
    }
    
    .diff-btn {
        min-width: 100px;
        padding: 15px;
    }
    
    .astronaut {
        font-size: 4rem;
    }
    
    .input-area {
        flex-direction: column;
    }
    
    #guess-input, .submit-btn {
        width: 100%;
    }
    
    .settings-btn {
        position: relative;
        top: auto;
        right: auto;
        display: block;
        margin: 0 auto 15px auto;
        width: fit-content;
    }
    
    .settings-btn:hover {
        transform: scale(1.1);
    }
    
    .settings-panel {
        position: relative;
        top: auto;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 10px;
    }
    
    .settings-content {
        min-width: auto;
    }
    
    header {
        margin-bottom: 20px;
    }
}
