:root {
    --retro-font: 'Press Start 2P', cursive;
    --p1-color: #f0e68c;
    --p2-color: #dda0dd;
    --danger-color: #ff4757;
    --safe-color: #7cfc00;
}

body {
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #1a1a1a;
    font-family: var(--retro-font);
    color: #fff;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative; /* Needed for positioning the help button */
}

#screen {
    width: 90vw;
    height: 70vw;
    max-width: 1024px;
    max-height: 768px;
    background-color: #0d0d1a;
    border-radius: 2em;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.7), inset 0 0 20px rgba(0, 0, 0, 0.9);
    padding: 1.5em;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#screen::after {
    content: '';
    position: absolute;
    top: 1.5em;
    left: 1.5em;
    right: 1.5em;
    bottom: 1.5em;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.04));
    background-size: 100% 4px, 6px 100%;
    pointer-events: none;
    z-index: 100;
}

/* This rule hides the interlacing pattern when the help or options menu is active */
#screen.help-menu-active::after,
#screen.options-menu-active::after {
    display: none;
}

#game-area {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    user-select: none;
}

#game-canvas {
    width: 100%;
    height: 100%;
    background-color: #050508;
}

/* Overlays */
#message-screen, #level-message-screen, #pause-screen, #help-screen, #options-screen, #map-screen {
    position: absolute;
    top: 1.5em;
    left: 1.5em;
    right: 1.5em;
    bottom: 1.5em;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 50;
    transition: opacity 0.5s;
    padding: 2em;
    box-sizing: border-box;
}

#message-screen.hidden, #level-message-screen.hidden, #pause-screen.hidden, #help-screen.hidden, #options-screen.hidden, #map-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#message-screen h1 { font-size: 2em; color: var(--safe-color); margin-bottom: 20px; }
#message-screen .instructions { font-size: 0.8em; line-height: 2; }
#message-screen .small-text { font-size: 0.6em; margin-top: 25px; opacity: 0.7; }
#level-message-screen { font-size: 2.5em; color: var(--safe-color); text-shadow: 3px 3px 0 #000; }
#pause-screen h2 { font-size: 2em; color: #fff; }
#pause-screen p { font-size: 0.8em; }

/* Map Screen Specific Styles */
#map-screen {
    justify-content: flex-start;
    padding-top: 2em;
    background-color: rgba(0, 0, 0, 0); /* Transparent background */
    pointer-events: none; /* Let clicks/drags pass through to the canvas */
}
#map-screen h2, #map-screen p {
    text-shadow: 2px 2px 4px #000;
}

/* Options Screen Specific Styles */
#options-screen {
    z-index: 60;
    text-align: left;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9em;
    padding: 2em;
}
#options-screen > div {
    overflow-y: auto;
    max-height: 90%;
    width: 100%;
    padding-right: 1em;
}
#options-screen h2 { font-size: 1.5em; color: var(--safe-color); margin-bottom: 20px; text-align: center; }
#options-screen h3 { font-size: 1.1em; color: var(--p1-color); margin-top: 30px; margin-bottom: 15px; border-bottom: 2px dashed #555; padding-bottom: 10px; }
#options-content { display: flex; flex-direction: column; gap: 12px; }
.options-row { display: grid; grid-template-columns: 1fr 1fr 100px; gap: 15px; align-items: center; font-size: 0.7em; }
.options-row label { text-align: right; }
.options-row input, .options-row select { font-family: var(--retro-font); font-size: 0.9em; background: #222; color: #eee; border: 2px solid #555; padding: 5px; }
.options-row input[type="range"] { padding: 0; }

/* NEW: Styles for the button container at the bottom */
#options-button-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 3px double #555;
}

/* General Settings Buttons in Options */
.options-button-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}
.options-button-row button {
    font-size: 0.7em;
}

/* Help Screen Specific Styles */
#help-screen {
    z-index: 60;
    text-align: left;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9em;
    padding: 2em;
}
#help-screen > div {
    overflow-y: auto;
    max-height: 90%;
    padding-right: 1em;
}
#help-screen h2 { font-size: 1.5em; color: var(--safe-color); margin-bottom: 20px; text-align: center; }
#help-screen p { font-size: 0.8em; line-height: 1.8; max-width: 95%; margin-bottom: 1em; }
#help-screen p strong { color: var(--p1-color); }
#close-help-button {
    margin-top: 20px;
    align-self: center;
}

/* Rebinding UI Styles */
#rebinding-ui {
    margin-top: 30px;
    border-top: 2px dashed #555;
    padding-top: 15px;
}
#rebinding-ui h3 {
    font-size: 1.1em;
    color: var(--safe-color);
    margin-bottom: 20px;
    text-align: center;
}
.rebind-grid {
    display: flex;
    justify-content: space-around;
    gap: 30px;
}
.rebind-player-col h4 {
    font-size: 0.9em;
    margin-bottom: 15px;
    color: var(--p1-color);
}
.rebind-player-col:last-of-type h4 {
    color: var(--p2-color);
}
.rebind-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 20px;
    font-size: 0.8em;
}
.rebind-button {
    font-family: var(--retro-font);
    font-size: 0.7em;
    min-width: 120px;
    text-align: center;
    padding: 8px 12px;
    border-width: 2px;
    color: #ccc;
    border-color: #777;
    background-color: #222;
}
.rebind-button:hover {
    color: #000;
    background-color: var(--p1-color);
    border-color: var(--p1-color);
}
.rebind-button.is-listening {
    color: #000;
    background-color: var(--safe-color);
    border-color: #fff;
    box-shadow: 0 0 15px var(--safe-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 10px var(--safe-color); }
    50% { box-shadow: 0 0 20px var(--safe-color); }
    100% { box-shadow: 0 0 10px var(--safe-color); }
}

/* Buttons */
.button-container { display: flex; flex-direction: column; gap: 15px; margin-top: 20px; }
button { 
    padding: 15px 30px; font-family: var(--retro-font); font-size: 0.8em; background-color: #0d0d1a; color: white; border: 3px solid white; cursor: pointer;
    transition: all 0.2s;
}
button:hover { background-color: var(--safe-color); color: #0d0d1a; border-color: var(--safe-color); }
.hidden { display: none !important; }

/* Settings container for mode toggle */
#settings-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px dashed #555;
    width: 60%;
}

/* Help Button in Corner */
#help-button-container {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 40;
    display: flex;
    gap: 10px;
}
#toggle-help-button, #toggle-options-button, #mute-button {
    font-size: 0.7em;
    padding: 10px 15px;
    margin: 0;
    background-color: rgba(0,0,0,0.5);
    border: 2px solid #aaa;
    color: #aaa;
}
#toggle-help-button:hover, #toggle-options-button:hover, #mute-button:hover {
    background-color: #fff;
    color: #000;
    border-color: #fff;
}

/* HUD */
#hud {
    position: absolute;
    top: 1.5em;
    left: 1.5em;
    right: 1.5em;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 25px;
    box-sizing: border-box;
    font-size: 0.9em;
    z-index: 10;
    pointer-events: none;
}
.player-hud { text-align: left; }
#p2-hud { text-align: right; }
.hud-item { margin-top: 8px; }
#p1-hud { color: var(--p1-color); text-shadow: 0 0 8px var(--p1-color); }
#p2-hud { color: var(--p2-color); text-shadow: 0 0 8px var(--p2-color); }
#bomb-hud { 
    position: absolute;
    top: 630px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #eee;
}
#bomb-stability { color: var(--safe-color); }

/* Dev Mode HUD Style */
#dev-mode-hud {
    position: absolute;
    top: 700px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--p2-color);
    text-shadow: 0 0 8px var(--p2-color);
    font-size: 0.8em;
}
