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

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Screen Management ===== */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.overlay-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

/* ===== Topic Selection Screen ===== */
.container {
    max-width: 900px;
    width: 100%;
    text-align: center;
}

.game-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.5rem;
    color: #fff;
    text-shadow: 4px 4px 0px #000, 6px 6px 0px rgba(0,0,0,0.3);
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

.subtitle {
    font-size: 1.5rem;
    color: #ffe66d;
    margin-bottom: 40px;
    font-weight: 600;
}

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.topic-btn {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 4px solid #333;
    border-radius: 20px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 6px 6px 0px #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.topic-btn:hover {
    transform: translateY(-5px);
    box-shadow: 8px 8px 0px #000;
    background: linear-gradient(145deg, #fff, #ffe66d);
}

.topic-btn:active {
    transform: translateY(0);
    box-shadow: 3px 3px 0px #000;
}

.topic-icon {
    font-size: 3rem;
    display: block;
}

.topic-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
}

.topic-desc {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

/* ===== Character Selection Screen ===== */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.character-btn {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 5px solid #333;
    border-radius: 20px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 6px 6px 0px #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.character-btn:hover {
    transform: translateY(-8px);
    box-shadow: 10px 10px 0px #000;
    background: linear-gradient(145deg, #fff, #ffe66d);
}

.character-btn:active {
    transform: translateY(0);
    box-shadow: 3px 3px 0px #000;
}

.hero-preview {
    width: 150px;
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(3px 3px 0px rgba(0,0,0,0.3));
}

.character-name-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

/* ===== Battle Screen ===== */
.battle-container {
    max-width: 1200px;
    width: 100%;
    padding: 20px;
}

.stage-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border: 4px solid #333;
    border-radius: 15px;
    padding: 15px 25px;
    margin-bottom: 20px;
    box-shadow: 4px 4px 0px #000;
    flex-wrap: wrap;
    gap: 15px;
}

.stage-badge, .topic-badge {
    font-weight: 700;
    font-size: 1.2rem;
    color: #333;
    background: #ffe66d;
    padding: 8px 20px;
    border-radius: 25px;
    border: 3px solid #333;
}

.timer-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
}

.timer {
    background: #ff6b6b;
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    border: 3px solid #333;
    min-width: 60px;
    text-align: center;
    animation: pulse 1s infinite;
}

.timer.warning {
    background: #ff3838;
    animation: pulse-fast 0.5s infinite;
}

.sound-toggle-btn {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.3);
    border: 3px solid #333;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.sound-toggle-btn:active {
    transform: scale(0.95);
}

/* ===== Battle Area ===== */
.battle-area {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    align-items: center;
    margin-bottom: 30px;
    min-height: 300px;
}

.character {
    background: rgba(255, 255, 255, 0.95);
    border: 4px solid #333;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 4px 4px 0px #000;
    position: relative;
}

.enemy-side {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.player-side {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.character-sprite {
    font-size: 5rem;
    text-align: center;
    animation: float 3s ease-in-out infinite;
    display: flex;
    justify-content: center;
    align-items: center;
}

.character-sprite img {
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    filter: drop-shadow(3px 3px 0px rgba(0,0,0,0.3));
}

.enemy-sprite img {
    filter: drop-shadow(3px 3px 0px rgba(0,0,0,0.3));
    transform: scaleX(-1); /* Flip horizontally to face right towards Steve */
}

.player-sprite img {
    filter: drop-shadow(3px 3px 0px rgba(0,0,0,0.3));
}

.character-sprite.shake {
    animation: shake 0.5s;
}

.character-sprite.attack {
    animation: attack 0.5s;
}

.player-sprite.attacking {
    animation: player-attack 0.6s ease-out;
}

.enemy-sprite.attacking {
    animation: enemy-attack 0.6s ease-out;
}

.attack-effect {
    position: absolute;
    font-size: 3rem;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));
}

.attack-effect.show {
    animation: slash-effect 0.6s ease-out;
}

@keyframes slash-effect {
    0% {
        opacity: 0;
        transform: translate(-20px, -20px) scale(0.5) rotate(-45deg);
    }
    40% {
        opacity: 1;
        transform: translate(20px, 20px) scale(1.5) rotate(45deg);
    }
    100% {
        opacity: 0;
        transform: translate(40px, 40px) scale(2) rotate(90deg);
    }
}

.character-sprite.hit-flash {
    animation: flash-red 0.3s;
}

@keyframes flash-red {
    0%, 100% { filter: brightness(1); }
    25% { filter: brightness(1.5) drop-shadow(0 0 10px rgba(255, 0, 0, 0.8)); }
    50% { filter: brightness(2) drop-shadow(0 0 15px rgba(255, 0, 0, 1)); }
    75% { filter: brightness(1.5) drop-shadow(0 0 10px rgba(255, 0, 0, 0.8)); }
}

.character-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    text-align: center;
    margin-bottom: 10px;
}

.health-bar-container {
    width: 100%;
}

.health-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border: 3px solid #333;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    transition: width 0.5s ease;
    position: relative;
}

.enemy-health .health-fill {
    background: linear-gradient(90deg, #f87171, #dc2626);
}

.health-text {
    text-align: center;
    font-weight: 700;
    color: #333;
    margin-top: 8px;
    font-size: 1.1rem;
}

.damage-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 900;
    color: #ff3838;
    text-shadow: 2px 2px 0px #000;
    opacity: 0;
    pointer-events: none;
}

.damage-indicator.show {
    animation: damage-pop 1s ease-out;
}

.vs-divider {
    font-family: 'Press Start 2P', cursive;
    font-size: 2rem;
    color: #ffe66d;
    text-shadow: 3px 3px 0px #000;
    background: rgba(0, 0, 0, 0.6);
    padding: 20px;
    border-radius: 50%;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid #333;
}

/* ===== Question Area ===== */
.question-area {
    margin-bottom: 20px;
}

.question-box {
    background: rgba(255, 255, 255, 0.95);
    border: 4px solid #333;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 4px 4px 0px #000;
}

.question-text {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    text-align: center;
    margin-bottom: 25px;
}

.answer-input-container {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.answer-input {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    padding: 15px 25px;
    border: 4px solid #333;
    border-radius: 15px;
    text-align: center;
    font-weight: 700;
    width: 250px;
    background: #fff;
    transition: all 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.3);
}

.submit-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    padding: 15px 40px;
    background: linear-gradient(145deg, #4ade80, #22c55e);
    color: white;
    border: 4px solid #333;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 4px 4px 0px #000;
    transition: all 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 6px 6px 0px #000;
}

.submit-btn:active {
    transform: translateY(0);
    box-shadow: 2px 2px 0px #000;
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.feedback-message {
    margin-top: 20px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    min-height: 40px;
    animation: fade-in 0.3s ease;
}

.feedback-message.correct {
    color: #22c55e;
}

.feedback-message.wrong {
    color: #dc2626;
}

/* ===== Progress Info ===== */
.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border: 4px solid #333;
    border-radius: 15px;
    padding: 20px 30px;
    box-shadow: 4px 4px 0px #000;
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    flex-wrap: wrap;
    gap: 15px;
}

.score-display, .questions-remaining {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-display span, .questions-remaining span {
    color: #667eea;
    font-size: 1.5rem;
}

/* ===== Result Screens ===== */
.result-container {
    background: white;
    border: 5px solid #333;
    border-radius: 30px;
    padding: 50px;
    box-shadow: 8px 8px 0px #000;
    text-align: center;
    max-width: 500px;
    margin: auto;
    animation: scale-in 0.5s ease;
}

.result-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 2rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.victory .result-title {
    color: #22c55e;
}

.gameover .result-title {
    color: #dc2626;
}

.result-message {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 30px;
}

.result-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.stat {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    background: #f0f0f0;
    padding: 15px;
    border-radius: 15px;
    border: 3px solid #333;
}

.stat span {
    color: #667eea;
}

.result-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 15px 40px;
    border: 4px solid #333;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 4px 4px 0px #000;
    transition: all 0.2s ease;
    display: inline-block;
    margin: 10px;
    color: white;
}

.next-stage-btn, .retry-btn {
    background: linear-gradient(145deg, #4ade80, #22c55e);
}

.menu-btn {
    background: linear-gradient(145deg, #60a5fa, #3b82f6);
}

.result-btn:hover {
    transform: translateY(-3px);
    box-shadow: 6px 6px 0px #000;
}

.result-btn:active {
    transform: translateY(0);
    box-shadow: 2px 2px 0px #000;
}

/* ===== Animations ===== */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

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

@keyframes pulse-fast {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

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

@keyframes attack {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    50% { transform: scale(1.3) rotate(5deg); }
    75% { transform: scale(1.1) rotate(-2deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes player-attack {
    0% { transform: translateX(0) scale(1); }
    30% { transform: translateX(30px) scale(1.15) rotate(10deg); }
    50% { transform: translateX(35px) scale(1.2) rotate(5deg); }
    70% { transform: translateX(20px) scale(1.1); }
    100% { transform: translateX(0) scale(1) rotate(0deg); }
}

@keyframes enemy-attack {
    0% { transform: translateX(0) scale(1); }
    30% { transform: translateX(-30px) scale(1.15) rotate(-10deg); }
    50% { transform: translateX(-35px) scale(1.2) rotate(-5deg); }
    70% { transform: translateX(-20px) scale(1.1); }
    100% { transform: translateX(0) scale(1) rotate(0deg); }
}

@keyframes damage-pop {
    0% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -100%) scale(1.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(1);
    }
}

@keyframes scale-in {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .game-title {
        font-size: 1.5rem;
    }
    
    .battle-area {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .vs-divider {
        width: 80px;
        height: 80px;
        font-size: 1.5rem;
    }
    
    .character-sprite {
        font-size: 4rem;
    }
    
    .question-text {
        font-size: 2rem;
    }
    
    .answer-input {
        font-size: 1.5rem;
        width: 100%;
    }
    
    .submit-btn {
        width: 100%;
    }
    
    .result-container {
        padding: 30px;
    }
    
    .result-title {
        font-size: 1.5rem;
    }
}
