/* Custom Properties */
:root {
    --fa-navy: #0b2f48;
    --fa-green: #28a745;
    --fa-light-gray: #f7f9fa;
    --fa-white: #ffffff;
    --fa-text: #333333;
    --fa-border: #e0e0e0;
    --fa-gold: #FFD700;
    --fa-danger: #DC143C;
    --pixel-font: 'Press Start 2P', cursive;
    --main-font: 'Inter', sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--main-font);
    background: linear-gradient(135deg, #0a1929 0%, var(--fa-navy) 100%);
    color: var(--fa-white);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Background Effects */
.bg-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.grid-lines {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(40, 167, 69, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(40, 167, 69, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: grid-move 10s linear infinite;
}

@keyframes grid-move {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.floating-symbols {
    position: absolute;
    width: 100%;
    height: 100%;
}

.floating-symbols span {
    position: absolute;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: rgba(40, 167, 69, 0.2);
    animation: float-up 15s infinite linear;
    animation-delay: var(--delay);
}

@keyframes float-up {
    0% {
        transform: translateY(100vh) rotate(0deg);
        left: calc(var(--delay) * 12%);
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        left: calc(var(--delay) * 12% + 20px);
    }
}

/* Game Wrapper - Fixed to viewport */
.game-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    max-width: 100%;
    margin: 0 auto;
}

/* Header - Compact */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(11, 47, 72, 0.9);
    border: 2px solid var(--fa-green);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.3);
    flex-shrink: 0;
}

.logo {
    display: flex;
    flex-direction: column;
}

.logo-text {
    font-family: var(--pixel-font);
    font-size: clamp(0.8rem, 2vw, 1.5rem);
    color: var(--fa-green);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5), 0 0 10px var(--fa-green); }
    50% { text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5), 0 0 20px var(--fa-green); }
}

.logo-subtitle {
    font-size: clamp(0.5rem, 1vw, 0.8rem);
    color: var(--fa-gold);
    margin-top: 0.25rem;
    letter-spacing: 2px;
}

.game-timer {
    font-family: var(--pixel-font);
    font-size: clamp(0.6rem, 1.5vw, 0.9rem);
    color: var(--fa-gold);
}

/* Game Container - Fills remaining space */
.game-container {
    flex: 1;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid var(--fa-green);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 40px rgba(40, 167, 69, 0.4), inset 0 0 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for Firefox */
}

/* Game Screens - Scrollable when needed */
.game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* Start Screen - Responsive */
.start-screen {
    text-align: center;
    background: radial-gradient(circle at center, rgba(40, 167, 69, 0.1) 0%, transparent 70%);
}

.pixel-art-logo {
    font-size: clamp(3rem, 8vw, 5rem);
    margin-bottom: 0.5rem;
    animation: bounce 2s infinite;
}

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

.game-title {
    font-family: var(--pixel-font);
    font-size: clamp(1.5rem, 5vw, 3rem);
    color: var(--fa-green);
    margin-bottom: 0.5rem;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
    animation: pulse 2s infinite;
}

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

.game-tagline {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--fa-gold);
    margin-bottom: 1rem;
}

.instructions {
    background: rgba(11, 47, 72, 0.6);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid var(--fa-green);
    max-width: 90%;
}

.instructions h3 {
    color: var(--fa-green);
    margin-bottom: 0.5rem;
    font-family: var(--pixel-font);
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
}

.control-keys {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.key-instruction {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--fa-white);
    font-size: clamp(0.7rem, 1.5vw, 1rem);
}

.key {
    display: inline-block;
    background: var(--fa-navy);
    color: var(--fa-green);
    padding: 0.3rem 0.5rem;
    border-radius: 5px;
    border: 2px solid var(--fa-green);
    font-weight: bold;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
    font-size: clamp(0.7rem, 1.5vw, 1rem);
}

.scoring-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.item-score {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--fa-light-gray);
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
}

.item-score .item {
    font-size: clamp(1.2rem, 2vw, 1.5rem);
}

.play-button {
    font-family: var(--pixel-font);
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    background: linear-gradient(135deg, var(--fa-green), #20c997);
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem auto;
    transition: all 0.3s ease;
    box-shadow: 0 5px 0 #1a7f3f, 0 10px 20px rgba(0, 0, 0, 0.3);
    animation: pulse-button 2s infinite;
}

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

.play-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 0 #1a7f3f, 0 15px 30px rgba(0, 0, 0, 0.4);
}

.play-button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1a7f3f, 0 5px 10px rgba(0, 0, 0, 0.3);
}

.coming-soon-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 10px;
    border: 1px dashed var(--fa-gold);
}

.coming-text {
    color: var(--fa-light-gray);
    margin-bottom: 0.25rem;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
}

.coming-subtext {
    color: var(--fa-gold);
    font-weight: bold;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
}

/* Play Screen - Responsive Canvas */
.play-screen {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-stats {
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: rgba(11, 47, 72, 0.9);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--fa-green);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.stat-label {
    font-size: clamp(0.6rem, 1vw, 0.8rem);
    color: var(--fa-green);
    margin-bottom: 0.25rem;
    font-family: var(--pixel-font);
}

.stat-value {
    font-size: clamp(0.8rem, 1.5vw, 1.2rem);
    color: var(--fa-white);
    font-weight: bold;
    font-family: var(--pixel-font);
}

.stat-value.hearts {
    font-size: clamp(1rem, 2vw, 1.5rem);
}

/* Canvas - Responsive */
#gameCanvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    flex: 1;
    min-height: 300px;
    background: linear-gradient(180deg, #001122 0%, #003366 100%);
    border: 2px solid var(--fa-green);
    border-radius: 10px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    display: block;
}

.power-bar {
    width: 100%;
    height: 25px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--fa-green);
    border-radius: 15px;
    margin-top: 0.5rem;
    position: relative;
    overflow: hidden;
}

.power-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fa-green), var(--fa-gold));
    width: 100%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
}

.power-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--pixel-font);
    font-size: clamp(0.5rem, 1vw, 0.7rem);
    color: white;
    text-shadow: 1px 1px 0 black;
}

/* Game Over Screen - Scrollable */
.gameover-screen {
    text-align: center;
    background: radial-gradient(circle at center, rgba(220, 20, 60, 0.1) 0%, transparent 70%);
    overflow-y: auto;
}

.gameover-title {
    font-family: var(--pixel-font);
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--fa-danger);
    margin-bottom: 1rem;
    animation: shake 0.5s ease infinite;
}

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

.final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
}

.score-label {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--fa-green);
    margin-bottom: 0.5rem;
}

.score-value {
    font-family: var(--pixel-font);
    font-size: clamp(1.5rem, 5vw, 3rem);
    color: var(--fa-gold);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.achievement {
    background: linear-gradient(135deg, var(--fa-gold), #FFE55C);
    color: var(--fa-navy);
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: achievement-pop 0.5s ease;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
}

.achievement-icon {
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.leaderboard {
    background: rgba(11, 47, 72, 0.6);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid var(--fa-green);
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.leaderboard h3 {
    font-family: var(--pixel-font);
    color: var(--fa-green);
    margin-bottom: 0.5rem;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
}

#leaderboardList {
    list-style: none;
    text-align: left;
}

#leaderboardList li {
    padding: 0.25rem;
    color: var(--fa-light-gray);
    font-family: var(--pixel-font);
    font-size: clamp(0.6rem, 1.2vw, 0.9rem);
    border-bottom: 1px dashed rgba(40, 167, 69, 0.3);
}

.email-signup {
    background: rgba(40, 167, 69, 0.1);
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid var(--fa-green);
    margin-bottom: 1rem;
}

.signup-congrats {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    margin-bottom: 0.5rem;
    color: var(--fa-green);
}

#signupForm {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 250px;
    margin: 0 auto;
}

.name-input, .email-input {
    padding: 0.5rem;
    border: 2px solid var(--fa-green);
    background: var(--fa-navy);
    color: white;
    border-radius: 5px;
    font-family: var(--pixel-font);
    font-size: clamp(0.6rem, 1.2vw, 0.8rem);
}

.submit-button {
    font-family: var(--pixel-font);
    background: var(--fa-green);
    color: white;
    padding: 0.75rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
}

.game-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.play-again-button, .share-button {
    font-family: var(--pixel-font);
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--fa-green);
    background: transparent;
    color: var(--fa-green);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
}

.play-again-button:hover, .share-button:hover {
    background: var(--fa-green);
    color: var(--fa-navy);
    transform: scale(1.05);
}

/* Info Bar - Compact */
.info-bar {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(11, 47, 72, 0.9);
    border: 2px solid var(--fa-green);
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.ticker {
    white-space: nowrap;
    animation: ticker 20s linear infinite;
}

@keyframes ticker {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

.ticker-text {
    color: var(--fa-gold);
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
}

/* Sound Toggle */
.sound-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--fa-navy);
    border: 2px solid var(--fa-green);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
}

.sound-toggle:hover {
    transform: scale(1.1);
    background: var(--fa-green);
}

/* Easter Egg */
.easter-egg-progress {
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: rgba(255, 215, 0, 0.9);
    color: var(--fa-navy);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-family: var(--pixel-font);
    font-size: clamp(0.6rem, 1.2vw, 0.8rem);
    animation: easter-glow 1s ease infinite;
    z-index: 100;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .game-wrapper {
        padding: 0.25rem;
    }

    .game-header {
        padding: 0.5rem;
    }

    .control-keys {
        flex-direction: column;
        gap: 0.25rem;
    }

    .game-stats {
        gap: 0.5rem;
    }

    .stat-item {
        min-width: 50px;
    }

    .scoring-info {
        grid-template-columns: 1fr 1fr;
    }

    .instructions {
        max-width: 100%;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .logo-subtitle {
        display: none;
    }

    .game-timer {
        font-size: 0.6rem;
    }

    .game-screen {
        padding: 0.5rem;
    }

    .play-button {
        padding: 0.75rem 1.5rem;
    }

    #gameCanvas {
        min-height: 200px;
    }
}

/* Landscape mode */
@media (max-height: 600px) and (orientation: landscape) {
    .game-header {
        padding: 0.5rem;
        margin-bottom: 0.25rem;
    }

    .info-bar {
        display: none;
    }

    .game-screen {
        padding: 0.5rem;
    }

    .instructions {
        max-height: 60vh;
        overflow-y: auto;
    }

    #gameCanvas {
        min-height: 200px;
    }
}