/* Google Fonts: Press Start 2P */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

body {
    background: #000;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    /* Retro crispness */
}

/* CRT Scanline Overlay */
#game-container::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 1000;
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
}

/* CRT curvature effect */
#game-container::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: radial-gradient(circle, rgba(18, 16, 16, 0) 60%, rgba(0, 0, 0, 0.4) 100%);
    z-index: 1001;
    pointer-events: none;
}

/* Mobile Touch Controls */
#touch-controls {
    display: none;
    /* Shown via JS on mobile */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    pointer-events: none;
    flex-direction: column;
    justify-content: flex-end;
}

.touch-areas {
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 40%;
    padding: 20px;
    pointer-events: none;
}

#joystick-area {
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#joystick-area::after {
    content: "";
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 80px);
    gap: 15px;
    pointer-events: auto;
}

.touch-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    text-transform: uppercase;
}

.touch-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

#btn-fire {
    background: rgba(255, 0, 0, 0.3);
    border-color: #ff0000;
}

#btn-bomb {
    background: rgba(255, 255, 0, 0.3);
    border-color: #ffff00;
}

#btn-hyper {
    background: rgba(0, 255, 255, 0.3);
    border-color: #00ffff;
}

#btn-reverse {
    background: rgba(255, 255, 255, 0.3);
    border-color: #ffffff;
}

@media (orientation: portrait) {
    #touch-controls {
        height: 100%;
    }
}

/* Screen Overlays (Title + Game Over) */
#title-overlay,
#gameover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
}

.overlay-content {
    text-align: center;
    max-width: 600px;
    width: 90%;
}

#title-text {
    font-size: clamp(32px, 8vw, 60px);
    color: #ff0000;
    margin-bottom: 50px;
    text-shadow: 0 0 20px #ff0000;
}

#gameover-text {
    font-size: clamp(24px, 6vw, 40px);
    color: #ffffff;
    margin-bottom: 15px;
}

#final-score {
    font-size: clamp(14px, 3vw, 20px);
    color: #ffffff;
    margin-bottom: 30px;
}

.arcade-btn {
    display: block;
    width: 100%;
    max-width: 320px;
    margin: 12px auto;
    padding: 14px 24px;
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(12px, 2.5vw, 18px);
    background: #ff0000;
    color: #fff;
    border: 3px solid #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    transition: background 0.15s, color 0.15s;
}

.arcade-btn:hover {
    background: #fff;
    color: #ff0000;
}

.arcade-btn.secondary {
    background: transparent;
    border-color: #ffff00;
    color: #ffff00;
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.3);
}

.arcade-btn.secondary:hover {
    background: #ffff00;
    color: #000;
}

.controls-hint {
    margin-top: 40px;
    font-size: clamp(8px, 1.5vw, 12px);
    color: #aaa;
    line-height: 2.2;
}

/* Name Entry */
#name-entry {
    margin-bottom: 20px;
}

.name-prompt {
    font-size: clamp(10px, 2vw, 14px);
    color: #ffff00;
    margin-bottom: 12px;
}

.name-input-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    max-width: 360px;
    margin: 0 auto;
}

#player-name {
    flex: 1;
    padding: 10px 12px;
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(12px, 2.5vw, 16px);
    background: #111;
    color: #00ffff;
    border: 2px solid #00ffff;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    max-width: 180px;
}

#player-name::placeholder {
    color: #335;
}

#player-name:focus {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.4);
}

#submit-score-btn {
    display: inline-block;
    width: auto;
    padding: 10px 16px;
    font-size: clamp(10px, 2vw, 14px);
}

.gameover-buttons {
    margin-top: 20px;
}

/* Leaderboard */
.leaderboard-title {
    font-size: clamp(10px, 2vw, 14px);
    color: #ffff00;
    margin-bottom: 15px;
}

#leaderboard-list {
    font-size: clamp(9px, 1.8vw, 13px);
    color: #fff;
    line-height: 2;
    text-align: left;
    max-width: 400px;
    margin: 0 auto 20px;
}

#leaderboard-list .score-row {
    display: flex;
    justify-content: space-between;
}

#leaderboard-list .loading,
#leaderboard-list .error {
    text-align: center;
}

#leaderboard-list .error {
    color: #ff4444;
}