/* Main Game Styling */
body {
    margin: 0;
    padding: 0;
    background-color: #000;
    font-family: 'Courier New', monospace;
    color: #fff;
    overflow: hidden;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    background-color: #000;
    border: 2px solid #444;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    image-rendering: pixelated; /* For crisp pixel art */
}

/* UI Elements */
#game-ui {
    display: none; /* Hidden by default */
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    color: #0f0;
    text-shadow: 2px 2px 0 #000;
    z-index: 11;
}

/* State-based visibility for Game UI */
body.state-playing #game-ui,
body.state-paused #game-ui,
body.state-playerDying #game-ui {
    display: flex;
}


#score-container {
    text-align: left;
    flex: 1;
}

#lives-container {
    text-align: center;
    flex: 1;
}

#right-ui {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex: 1;
}

#pause-button {
    padding: 5px 10px;
    font-size: 16px;
    margin-left: 20px;
}

/* Level Transition Messages */
#level-message-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 20;
    color: #fff;
    text-shadow: 0 0 15px #0f0, 0 0 25px #0f0;
}

#level-message-container h2 {
    font-size: 48px;
    animation: glow 1.5s infinite;
}

#level-message-container h3 {
    font-size: 32px;
    color: #ff0;
    text-shadow: 0 0 15px #ff0;
    animation: glow 1s infinite;
}


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

.hidden {
    display: none;
}

h1, h2, h3 {
    color: #0f0;
    text-shadow: 0 0 10px #0f0;
    margin-bottom: 20px;
}

h1 {
    font-size: 48px;
    letter-spacing: 4px;
    margin-bottom: 40px;
}

button {
    background-color: #000;
    color: #0f0;
    border: 2px solid #0f0;
    padding: 10px 20px;
    margin: 10px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

button:hover {
    background-color: #0f0;
    color: #000;
    box-shadow: 0 0 10px #0f0;
}

input[type="text"] {
    background-color: #000;
    color: #0f0;
    border: 2px solid #0f0;
    padding: 10px;
    margin: 10px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    text-align: center;
    width: 200px;
}

#scores-list {
    margin: 20px 0;
    width: 300px;
    max-height: 300px;
    overflow-y: auto;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
    padding: 5px;
    border-bottom: 1px solid #0f0;
}

/* Credits Screen */
#credits-video {
    max-width: 90vw;
    max-height: 90vh;
    border: 2px solid #0f0;
}

#close-credits-button {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    width: 40px;
    height: 40px;
    padding: 0;
    line-height: 40px;
    text-align: center;
    z-index: 15;
}


/* Retro CRT effect */
#game-container::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    z-index: 2;
    pointer-events: none;
    opacity: 0.15;
}

/* Animations */
@keyframes glow {
    0% { text-shadow: 0 0 5px #0f0; }
    50% { text-shadow: 0 0 20px #0f0; }
    100% { text-shadow: 0 0 5px #0f0; }
}

h1 {
    animation: glow 2s infinite;
}

#new-high-score h3 {
    animation: glow 1s infinite;
}

/* Energy bar HUD */
#energy-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: 12px;
    gap: 4px;
}
#energy-label {
    font-size: 12px;
    color: #8cf;
    letter-spacing: 2px;
}
#energy-bar {
    width: 240px;
    height: 12px;
    border: 1px solid #3af;
    background: rgba(0,0,0,0.25);
    position: relative;
    overflow: hidden;
}
#energy-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, #4fc3f7, #81d4fa);
    transition: width 80ms linear;
}
body.state-paused #energy-fill { opacity: 0.7; }
