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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Courier New', Courier, monospace;
    color: #00ffff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Rotate Device Overlay */
.rotate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.rotate-overlay.hidden {
    display: none;
}

.rotate-content {
    text-align: center;
    padding: 40px;
    max-width: 90%;
}

.rotate-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: rotatePhone 2s ease-in-out infinite;
}

.rotate-title {
    font-size: clamp(1.5rem, 6vw, 3rem);
    color: #ff6b00;
    text-shadow: 
        0 0 10px #ff6b00,
        0 0 20px #ff6b00,
        0 0 40px #ff6b00;
    margin-bottom: 20px;
    letter-spacing: 0.2em;
}

.rotate-text {
    font-size: clamp(1rem, 4vw, 1.5rem);
    color: #00ffff;
    margin-bottom: 10px;
}

.rotate-landscape {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    color: #ffff00;
    text-shadow: 0 0 20px #ffff00;
    font-weight: bold;
    letter-spacing: 0.3em;
    margin-top: 10px;
    animation: pulse 1.5s infinite;
}

.rotate-animation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
    font-size: 3rem;
}

.phone-portrait {
    animation: phoneShake 1s ease-in-out infinite;
}

.phone-landscape {
    transform: rotate(90deg);
    color: #0f0;
    text-shadow: 0 0 20px #0f0;
}

.arrow {
    color: #ff6b00;
    animation: arrowBounce 1s ease-in-out infinite;
}

@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

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

@keyframes arrowBounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(10px); }
}

/* Hide rotate overlay on landscape or desktop */
@media (orientation: landscape) {
    .rotate-overlay {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .rotate-overlay {
        display: none !important;
    }
}

/* Game Container */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
}

.screen.hidden {
    display: none;
}

/* Logo */
.logo-container {
    margin-bottom: 30px;
}

.game-logo {
    width: clamp(200px, 40vw, 400px);
    height: auto;
    filter: drop-shadow(0 0 30px rgba(255, 107, 0, 0.6));
    animation: logoFloat 3s ease-in-out infinite;
}

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

.loading-logo {
    width: 150px;
    height: auto;
    margin-bottom: 20px;
    animation: logoFloat 2s ease-in-out infinite;
}

/* Title */
.title {
    font-size: clamp(3rem, 12vw, 8rem);
    color: #00ffff;
    text-shadow:
        0 0 10px #00ffff,
        0 0 20px #00ffff,
        0 0 40px #00ffff,
        0 0 80px #0088ff;
    letter-spacing: 0.2em;
    animation: flicker 3s infinite;
}

.subtitle {
    font-size: clamp(1.5rem, 6vw, 4rem);
    color: #ff00ff;
    text-shadow:
        0 0 10px #ff00ff,
        0 0 20px #ff00ff,
        0 0 40px #ff00ff;
    letter-spacing: 0.5em;
    margin-top: -10px;
    margin-bottom: 40px;
}

.menu-tagline {
    margin-top: 20px;
    font-size: clamp(0.8rem, 2vw, 1.1rem);
    color: #888;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* Quick Instructions on Landing Page */
.quick-instructions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px 30px;
    margin-top: 30px;
    padding: 20px;
    background: rgba(0, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 10px;
    max-width: 600px;
}

.instruction-item {
    font-size: clamp(0.75rem, 1.5vw, 0.95rem);
    color: #aaffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inst-key {
    background: rgba(255, 107, 0, 0.2);
    border: 1px solid #ff6b00;
    color: #ff9944;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
}

.screen-title {
    font-size: clamp(2rem, 8vw, 5rem);
    color: #00ffff;
    text-shadow:
        0 0 10px #00ffff,
        0 0 20px #00ffff,
        0 0 40px #00ffff;
    margin-bottom: 30px;
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.menu-btn {
    padding: 15px 40px;
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-family: 'Courier New', Courier, monospace;
    color: #00ffff;
    background: transparent;
    border: 2px solid #00ffff;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
    min-width: 250px;
}

.menu-btn:hover, .menu-btn:focus {
    background: #00ffff;
    color: #000;
    box-shadow:
        0 0 10px #00ffff,
        0 0 20px #00ffff,
        inset 0 0 10px rgba(0, 255, 255, 0.5);
    outline: none;
}

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

/* Primary button - orange theme to match logo */
.menu-btn.primary-btn {
    background: linear-gradient(180deg, #ff8c00, #ff5500);
    border-color: #ff6b00;
    color: #fff;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(255, 107, 0, 0.4);
}

.menu-btn.primary-btn:hover, .menu-btn.primary-btn:focus {
    background: linear-gradient(180deg, #ffa500, #ff6b00);
    border-color: #ffa500;
    color: #fff;
    box-shadow:
        0 0 15px #ff6b00,
        0 0 30px #ff6b00,
        inset 0 0 10px rgba(255, 165, 0, 0.3);
}

/* High Score Display */
.high-score-menu {
    margin-top: 40px;
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    color: #ffff00;
    text-shadow: 0 0 10px #ffff00;
}

/* How To Play Screen */
.controls-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    max-width: 800px;
    padding: 20px;
    margin-bottom: 20px;
}

.control-section {
    text-align: left;
    padding: 20px;
    border: 1px solid #00ffff33;
    background: rgba(0, 255, 255, 0.05);
    min-width: 200px;
}

.control-section h3 {
    color: #ff00ff;
    margin-bottom: 15px;
    text-shadow: 0 0 10px #ff00ff;
    font-size: 1.2rem;
}

.control-section p {
    margin: 8px 0;
    font-size: 0.9rem;
    color: #aaffff;
}

.key {
    display: inline-block;
    padding: 3px 8px;
    background: #00ffff22;
    border: 1px solid #00ffff;
    border-radius: 3px;
    font-size: 0.8rem;
    color: #00ffff;
    margin-right: 5px;
}

.bonus {
    color: #ffff00 !important;
    text-shadow: 0 0 10px #ffff00;
    margin-top: 15px !important;
}

/* Game Over Screen */
.final-score {
    text-align: center;
    margin-bottom: 30px;
}

.final-score p {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin: 10px 0;
}

#new-high-score {
    color: #ffff00;
    text-shadow: 0 0 20px #ffff00;
    animation: pulse 0.5s infinite alternate;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 50;
}

#score-display {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: #ffffff;
    text-shadow: 0 0 10px #ffffff;
}

#high-score-display {
    font-size: clamp(0.8rem, 2vw, 1rem);
    color: #888888;
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
}

#lives-display {
    display: flex;
    gap: 5px;
}

.life-icon {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 25px solid #00ffff;
    filter: drop-shadow(0 0 5px #00ffff);
}

#wave-display {
    font-size: clamp(0.8rem, 2vw, 1rem);
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff;
}

/* Touch Controls */
#touch-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 60;
    pointer-events: none;
    padding: 0;
}

#touch-controls.hidden {
    display: none;
}

#left-controls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    pointer-events: auto;
    z-index: 61;
}

#right-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
    z-index: 61;
}

#center-controls {
    display: none; /* Remove center controls - move thrust to left */
}

.touch-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid rgba(0, 255, 255, 0.5);
    color: rgba(0, 255, 255, 0.9);
    font-size: 1.3rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(5px);
}

.touch-btn:active, .touch-btn.active {
    background: rgba(0, 255, 255, 0.35);
    border-color: rgba(0, 255, 255, 1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
    transform: scale(0.95);
}

.thrust-btn {
    grid-column: 1 / -1; /* Span both columns */
    width: 100%;
    font-size: 1.8rem;
    border-radius: 12px; /* Rectangular for thrust */
}

.fire-btn {
    background: rgba(255, 0, 0, 0.1);
    border-color: rgba(255, 68, 68, 0.5);
    color: rgba(255, 68, 68, 0.9);
    font-size: 0.85rem;
    font-weight: bold;
}

.fire-btn:active, .fire-btn.active {
    background: rgba(255, 0, 0, 0.35);
    border-color: rgba(255, 68, 68, 1);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.6);
}

.hyper-btn {
    background: rgba(255, 0, 255, 0.1);
    border-color: rgba(255, 0, 255, 0.5);
    color: rgba(255, 0, 255, 0.9);
    font-size: 0.65rem;
    font-weight: bold;
}

.hyper-btn:active, .hyper-btn.active {
    background: rgba(255, 0, 255, 0.35);
    border-color: rgba(255, 0, 255, 1);
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.6);
}

.pause-btn {
    position: fixed;
    top: 15px;
    right: 20px;
    width: 45px;
    height: 45px;
    font-size: 0.9rem;
    pointer-events: auto;
    z-index: 70;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.9);
}

/* Loading Screen */
#loading-screen {
    background: #000;
}

.loading-text {
    font-size: 2rem;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
    animation: pulse 1s infinite alternate;
}

.loading-bar {
    width: 300px;
    height: 4px;
    background: #333;
    margin-top: 30px;
    border-radius: 2px;
    overflow: hidden;
}

#loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00ffff, #ff00ff);
    box-shadow: 0 0 10px #00ffff;
    transition: width 0.3s ease;
}

/* Animations */
@keyframes flicker {
    0%, 100% { opacity: 1; }
    92% { opacity: 1; }
    93% { opacity: 0.8; }
    94% { opacity: 1; }
    95% { opacity: 0.9; }
    96% { opacity: 1; }
}

@keyframes pulse {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .touch-btn {
        width: 55px;
        height: 55px;
        font-size: 1.1rem;
    }

    .thrust-btn {
        font-size: 1.5rem;
        height: 50px;
    }
    
    .fire-btn, .hyper-btn {
        width: 60px;
        height: 60px;
    }
    
    .pause-btn {
        top: 12px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 0.8rem;
    }
    
    #left-controls, #right-controls {
        bottom: 15px;
    }
    
    #left-controls {
        left: 15px;
        gap: 6px;
    }
    
    #right-controls {
        right: 15px;
        gap: 8px;
    }

    .control-section {
        min-width: 150px;
        padding: 15px;
    }

    .controls-info {
        gap: 15px;
    }

    #hud {
        padding: 10px 15px;
    }

    .life-icon {
        border-left-width: 7px;
        border-right-width: 7px;
        border-bottom-width: 18px;
    }
}

@media (max-width: 400px) {
    .touch-btn {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }
    
    .thrust-btn {
        font-size: 1.3rem;
        height: 45px;
    }
    
    .fire-btn, .hyper-btn {
        width: 55px;
        height: 55px;
        font-size: 0.75rem;
    }
    
    #left-controls, #right-controls {
        bottom: 10px;
    }
    
    #left-controls {
        left: 10px;
    }
    
    #right-controls {
        right: 10px;
    }
}

@media (max-height: 500px) {
    .title {
        font-size: 3rem;
    }

    .subtitle {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .menu-btn {
        padding: 10px 30px;
    }

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

/* Desktop - hide touch controls */
@media (hover: hover) and (pointer: fine) {
    #touch-controls {
        display: none !important;
    }
}

/* Landscape orientation - optimize for gameplay */
@media (orientation: landscape) and (max-height: 500px) {
    .touch-btn {
        width: 50px;
        height: 50px;
        font-size: 1rem;
        background: rgba(0, 255, 255, 0.08);
        border-color: rgba(0, 255, 255, 0.3);
    }
    
    .thrust-btn {
        font-size: 1.2rem;
        height: 45px;
    }
    
    .fire-btn, .hyper-btn {
        width: 50px;
        height: 50px;
        font-size: 0.7rem;
    }
    
    .pause-btn {
        width: 35px;
        height: 35px;
        font-size: 0.75rem;
        top: 10px;
        right: 10px;
    }
    
    #left-controls {
        bottom: 10px;
        left: 10px;
        gap: 5px;
    }
    
    #right-controls {
        bottom: 10px;
        right: 10px;
        gap: 6px;
    }
    
    #hud {
        padding: 8px 12px;
    }
}

/* Scrollbar styling for controls info */
.controls-info::-webkit-scrollbar {
    width: 5px;
}

.controls-info::-webkit-scrollbar-track {
    background: #111;
}

.controls-info::-webkit-scrollbar-thumb {
    background: #00ffff;
    border-radius: 5px;
}
