/* Phoenix: Light Warrior - Bright Heroic Theme */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #FFD700, #FFA500, #FF6B35);
    background-size: 400% 400%;
    animation: gradientShift 8s ease-in-out infinite;
    color: #2C3E50;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

#game-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    padding: 20px;
    border: 3px solid #FFD700;
}

header {
    margin-bottom: 20px;
}

h1 {
    font-size: 2.5em;
    color: #E74C3C;
    text-shadow: 3px 3px 0px #FFD700, 6px 6px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 15px;
    font-weight: bold;
}

#ui {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(45deg, #3498DB, #2980B9);
    padding: 10px;
    border-radius: 15px;
    color: white;
    font-weight: bold;
    font-size: 1.1em;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.stat {
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Highlight the wave counter */
.stat:has(#wave) {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #2C3E50;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    border: 2px solid #FFD700;
}

/* Fallback for browsers that don't support :has() */
.stat:nth-child(3) {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #2C3E50;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    border: 2px solid #FFD700;
}

#gameCanvas {
    border: 4px solid #E74C3C;
    border-radius: 15px;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 100%);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    margin: 20px 0;
}

#game-ui {
    margin: 20px 0;
}

button {
    background: linear-gradient(45deg, #E74C3C, #C0392B);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1.2em;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    margin: 0 10px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button:hover {
    background: linear-gradient(45deg, #C0392B, #A93226);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.4);
}

/* Sound Button Styling */
.sound-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(45deg, #3498DB, #2980B9);
    font-size: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    z-index: 100;
}

.sound-btn:hover {
    background: linear-gradient(45deg, #2980B9, #1F618D);
}

.sound-btn.muted {
    background: linear-gradient(45deg, #E74C3C, #C0392B);
    opacity: 0.7;
}

#instructions {
    background: linear-gradient(135deg, #F39C12, #E67E22);
    color: white;
    padding: 15px;
    border-radius: 15px;
    margin-top: 15px;
    font-size: 1em;
    box-shadow: 0 5px 15px rgba(243, 156, 18, 0.3);
}

#instructions p {
    margin: 5px 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #9B59B6, #8E44AD);
    color: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    border: 3px solid #FFD700;
    z-index: 1000;
}

#game-over h2 {
    font-size: 2.5em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#game-over p {
    font-size: 1.3em;
    margin-bottom: 20px;
    font-weight: bold;
}

/* Light magic effects */
.light-burst {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, #FFD700, #FFA500);
    box-shadow: 0 0 20px #FFD700, 0 0 40px #FFA500;
    animation: lightBurst 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes lightBurst {
    0% {
        width: 10px;
        height: 10px;
        opacity: 1;
    }
    100% {
        width: 60px;
        height: 60px;
        opacity: 0;
    }
}

/* Health bar styling */
.health-low {
    color: #E74C3C !important;
    animation: healthPulse 1s ease-in-out infinite;
}

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

/* Wave transition effect */
.wave-transition {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, #3498DB, #2980B9);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3em;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 999;
    animation: waveTransition 2s ease-in-out forwards;
}

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

/* Mobile Controls */
#mobile-controls {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

#virtual-joystick {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 215, 0, 0.6);
    pointer-events: all;
    touch-action: none;
}

#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#mobile-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: all;
}

.mobile-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    font-size: 24px;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fire-btn {
    background: linear-gradient(45deg, #E74C3C, #C0392B);
}

#weapon-btn {
    background: linear-gradient(45deg, #9B59B6, #8E44AD);
    font-size: 16px;
}

.mobile-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Touch feedback */
.mobile-btn.pressed {
    transform: scale(0.9);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Mobile-specific game container */
@media (max-width: 768px) {
    body {
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
    
    #game-container {
        margin: 0;
        padding: 10px;
        width: 100vw;
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border-radius: 0;
        box-shadow: none;
        border: none;
        background: rgba(255, 255, 255, 0.98);
    }
    
    header {
        margin-bottom: 10px;
    }
    
    h1 {
        font-size: 1.5em;
        margin-bottom: 8px;
    }
    
    #ui {
        flex-wrap: wrap;
        justify-content: center;
        font-size: 0.9em;
        padding: 8px;
        gap: 5px;
    }
    
    .stat {
        padding: 4px 8px;
        font-size: 0.85em;
        min-width: 80px;
        text-align: center;
    }
    
    #gameCanvas {
        width: 100%;
        height: calc(100vh - 120px);
        max-width: none;
        max-height: none;
        margin: 10px 0;
        border-radius: 10px;
        border-width: 2px;
    }
    
    #game-ui {
        margin: 10px 0;
        position: relative;
    }
    
    button {
        padding: 10px 20px;
        font-size: 1em;
        margin: 5px;
        border-radius: 20px;
    }
    
    #instructions {
        padding: 10px;
        font-size: 0.85em;
        margin-top: 10px;
    }
    
    #instructions p {
        margin: 3px 0;
    }
    
    #game-over {
        padding: 20px;
        border-radius: 15px;
    }
    
    #game-over h2 {
        font-size: 2em;
    }
    
    #game-over p {
        font-size: 1.1em;
    }
    
    /* Show mobile controls */
    #mobile-controls {
        display: block;
    }
    
    /* Hide desktop instructions on mobile */
    #instructions {
        display: none;
    }
}

/* Very small screens (phones in portrait) */
@media (max-width: 480px) and (max-height: 800px) {
    h1 {
        font-size: 1.2em;
    }
    
    #ui {
        font-size: 0.8em;
    }
    
    .stat {
        font-size: 0.75em;
        padding: 3px 6px;
        min-width: 70px;
    }
    
    #gameCanvas {
        height: calc(100vh - 100px);
        border-radius: 8px;
    }
    
    #virtual-joystick {
        width: 100px;
        height: 100px;
        bottom: 15px;
        left: 15px;
    }
    
    #joystick-knob {
        width: 35px;
        height: 35px;
    }
    
    .mobile-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    #weapon-btn {
        font-size: 14px;
    }
    
    #mobile-buttons {
        bottom: 15px;
        right: 15px;
        gap: 12px;
    }
}

/* High Score System Styling */
#high-scores-section {
    background: linear-gradient(135deg, #3498DB, #2980B9);
    color: white;
    padding: 15px;
    border-radius: 15px;
    margin-top: 15px;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

#high-scores-section h3 {
    margin: 0 0 15px 0;
    font-size: 1.3em;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    color: #FFD700;
}

#high-scores-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-entry {
    display: grid;
    grid-template-columns: 30px 1fr auto auto;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9em;
    border-left: 3px solid rgba(255, 215, 0, 0.3);
}

.score-entry.first-place {
    background: linear-gradient(45deg, rgba(255, 215, 0, 0.3), rgba(255, 165, 0, 0.2));
    border-left-color: #FFD700;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.2);
}

.score-entry .rank {
    font-weight: bold;
    color: #FFD700;
    font-size: 0.85em;
}

.score-entry .name {
    font-weight: bold;
    text-align: left;
}

.score-entry .wave {
    color: #FFA500;
    font-size: 0.85em;
}

.score-entry .score {
    font-weight: bold;
    color: #4CAF50;
    text-align: right;
}

.no-scores {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    padding: 20px;
}

/* High Score Entry Screen */
#high-score-entry {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #E74C3C, #C0392B);
    color: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    border: 3px solid #FFD700;
    z-index: 1000;
    min-width: 300px;
}

#high-score-entry h2 {
    font-size: 2.2em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    color: #FFD700;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 10px #FFD700; }
    to { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 20px #FFD700, 0 0 30px #FFD700; }
}

#high-score-entry p {
    font-size: 1.2em;
    margin-bottom: 20px;
    font-weight: bold;
}

.name-entry {
    margin: 20px 0;
}

.name-entry label {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1em;
    font-weight: bold;
}

#player-name-input {
    width: 200px;
    padding: 10px;
    border: 2px solid #FFD700;
    border-radius: 10px;
    font-size: 1.1em;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    color: #2C3E50;
    font-weight: bold;
}

#player-name-input:focus {
    outline: none;
    border-color: #FFA500;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#submit-score-btn {
    background: linear-gradient(45deg, #2ECC71, #27AE60);
    padding: 12px 30px;
    font-size: 1.2em;
    margin-top: 15px;
}

#submit-score-btn:hover {
    background: linear-gradient(45deg, #27AE60, #229954);
}

/* High Score Rank Display */
#high-score-rank {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #2C3E50;
    padding: 10px 20px;
    border-radius: 15px;
    font-size: 1.1em;
    font-weight: bold;
    margin: 15px 0;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    animation: rankPulse 1.5s ease-in-out infinite;
}

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

/* High Score Celebration Animation */
.high-score-celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(255, 215, 0, 0.8),
        rgba(255, 165, 0, 0.8),
        rgba(255, 215, 0, 0.8)
    );
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: celebrationFade 3s ease-in-out forwards;
}

.celebration-text {
    font-size: 4em;
    font-weight: bold;
    color: #2C3E50;
    text-shadow: 3px 3px 0px #FFD700, 6px 6px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    animation: celebrationBounce 1s ease-in-out infinite;
}

.celebration-score,
.celebration-wave {
    font-size: 2em;
    font-weight: bold;
    color: #E74C3C;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 5px 0;
}

@keyframes celebrationFade {
    0% { opacity: 0; transform: scale(0.5); }
    20% { opacity: 1; transform: scale(1.1); }
    80% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1); }
}

@keyframes celebrationBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.05); }
}

/* Mobile Responsive High Scores */
@media (max-width: 768px) {
    #high-scores-section {
        padding: 10px;
        margin-top: 10px;
    }
    
    #high-scores-section h3 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }
    
    .score-entry {
        padding: 6px 8px;
        font-size: 0.8em;
        gap: 6px;
        grid-template-columns: 25px 1fr auto auto;
    }
    
    #high-score-entry {
        padding: 20px;
        min-width: 280px;
    }
    
    #high-score-entry h2 {
        font-size: 1.8em;
    }
    
    .celebration-text {
        font-size: 2.5em;
    }
    
    .celebration-score,
    .celebration-wave {
        font-size: 1.5em;
    }
    
    #player-name-input {
        width: 180px;
        padding: 8px;
        font-size: 1em;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .score-entry {
        font-size: 0.75em;
        grid-template-columns: 20px 1fr auto auto;
        gap: 4px;
    }
    
    #high-score-entry {
        padding: 15px;
        min-width: 250px;
    }
    
    .celebration-text {
        font-size: 2em;
    }
    
    .celebration-score,
    .celebration-wave {
        font-size: 1.2em;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    #game-container {
        padding: 5px;
    }
    
    header {
        margin-bottom: 5px;
    }
    
    h1 {
        font-size: 1.2em;
        margin-bottom: 5px;
    }
    
    #ui {
        padding: 5px;
        font-size: 0.8em;
    }
    
    #gameCanvas {
        height: calc(100vh - 80px);
        margin: 5px 0;
    }
    
    #game-ui {
        margin: 5px 0;
    }
    
    #virtual-joystick {
        width: 90px;
        height: 90px;
        bottom: 10px;
        left: 10px;
    }
    
    #joystick-knob {
        width: 30px;
        height: 30px;
    }
    
    .mobile-btn {
        width: 55px;
        height: 55px;
        font-size: 18px;
    }
    
    #weapon-btn {
        font-size: 12px;
    }
    
    #mobile-buttons {
        bottom: 10px;
        right: 10px;
        gap: 10px;
    }
}