/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0; padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #0a0a0a;
    font-family: 'Courier New', Courier, monospace;
    overflow: hidden;
}

/* ── Game container ─────────────────────────────────────────────────────── */
#game-container {
    position: relative;
    width: 800px;
    height: 600px;
    box-shadow: 0 0 40px rgba(255, 200, 0, 0.2), 0 0 80px rgba(0,0,0,0.8);
    border: 2px solid #333;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ── UI overlay layer ───────────────────────────────────────────────────── */
#ui {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* ── Shared label style ─────────────────────────────────────────────────── */
.hud-label {
    font-size: 12px;
    color: #aaa;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0 #000;
    margin-right: 6px;
}

/* ── Left HUD ───────────────────────────────────────────────────────────── */
#hud-left {
    position: absolute;
    top: 10px;
    left: 14px;
    line-height: 1.3;
}

#score-label {
    font-size: 11px;
    color: #aaa;
    text-shadow: 1px 1px 0 #000;
    letter-spacing: 2px;
}

#score {
    font-size: 26px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 2px 2px 0 #000, 0 0 8px rgba(255,215,0,0.4);
    letter-spacing: 2px;
}

#lives-row {
    margin-top: 5px;
    font-size: 16px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

/* ── Centre HUD ─────────────────────────────────────────────────────────── */
#hud-center {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

#stage-row {
    font-size: 16px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

#combo-display {
    margin-top: 4px;
    font-size: 30px;
    font-weight: bold;
    color: #ff6b00;
    text-shadow: 2px 2px 0 #000, 0 0 12px rgba(255,107,0,0.7);
    animation: comboPop 0.2s ease-out;
    white-space: nowrap;
}

#combo-display.hidden { display: none; }

@keyframes comboPop {
    0%   { transform: scale(1.6); }
    100% { transform: scale(1.0); }
}

/* ── Right HUD ──────────────────────────────────────────────────────────── */
#hud-right {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

#health-bar {
    width: 190px;
    height: 18px;
    background: #2a2a2a;
    border: 2px solid #aaa;
    border-radius: 2px;
    overflow: hidden;
}

#health-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(to right, #c00 0%, #e53e3e 60%, #fc8181 100%);
    transition: width 0.08s linear;
}

/* ── Stamina bar (run-kick gauge) ────────────────────────────────────────── */
#stamina-bar {
    width: 140px;
    height: 12px;
    background: #2a2a2a;
    border: 2px solid #aaa;
    border-radius: 2px;
    overflow: hidden;
}

#stamina-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(to right, #2b6cb0 0%, #4299e1 60%, #90cdf4 100%);
    transition: width 0.08s linear;
}

#stamina-bar.depleted {
    border-color: #555;
    opacity: 0.55;
}

/* ── Boss HUD ───────────────────────────────────────────────────────────── */
#boss-hud {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: 420px;
    text-align: center;
}

#boss-hud.hidden { display: none; }

#boss-name {
    font-size: 14px;
    color: #fc8181;
    text-shadow: 2px 2px 0 #000;
    letter-spacing: 2px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

#boss-health-bar {
    width: 100%;
    height: 16px;
    background: #2a2a2a;
    border: 2px solid #c00;
    border-radius: 2px;
    overflow: hidden;
}

#boss-health-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(to right, #700 0%, #e53e3e 60%, #fc8181 100%);
    transition: width 0.08s linear;
}

/* ── Full-screen overlay ────────────────────────────────────────────────── */
#overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.78);
}

#overlay.hidden { display: none; }

#overlay-title {
    font-size: 58px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 3px 3px 0 #000, 0 0 20px rgba(255,215,0,0.5);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 3px;
}

#overlay-sub {
    font-size: 22px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    margin: 0 0 24px 0;
}

#overlay-prompt {
    font-size: 20px;
    color: #ffd700;
    text-shadow: 2px 2px 0 #000;
    margin: 0;
    letter-spacing: 2px;
}

/* ── Controls hint ──────────────────────────────────────────────────────── */
#controls-hint {
    position: absolute;
    bottom: 8px;
    left: 10px;
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    pointer-events: none;
    letter-spacing: 0.5px;
}

/* ── Loading screen ─────────────────────────────────────────────────────── */
#loading-screen {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#loading-text {
    font-size: 20px;
    color: #ffd700;
    letter-spacing: 6px;
    animation: blink 0.75s infinite alternate;
}

/* ── Title screen ───────────────────────────────────────────────────────── */
#title-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    z-index: 100;
    font-family: 'Courier New', Courier, monospace;
}

#title-screen.hidden { display: none; }

#title-heading {
    font-size: 64px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 4px 4px 0 #000, 0 0 40px rgba(255,215,0,0.45);
    text-align: center;
    margin: 0 0 52px 0;
    letter-spacing: 5px;
    line-height: 1.1;
    text-transform: uppercase;
}

#title-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.title-btn {
    font-family: 'Courier New', Courier, monospace;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 3px;
    width: 300px;
    padding: 14px 0;
    background: transparent;
    border: 2px solid #ffd700;
    color: #ffd700;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.12s, color 0.12s;
}

.title-btn:hover {
    background: #ffd700;
    color: #000;
}

/* ── Pause button ───────────────────────────────────────────────────────── */
#pause-btn {
    position: absolute;
    top: 50px;
    right: 14px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: bold;
    width: 30px;
    height: 24px;
    background: rgba(0,0,0,0.55);
    border: 1px solid #555;
    color: #888;
    cursor: pointer;
    pointer-events: all;
    letter-spacing: 2px;
}

#pause-btn:hover { border-color: #ffd700; color: #ffd700; }
#pause-btn.hidden { display: none; }

/* ── Pause overlay ──────────────────────────────────────────────────────── */
#pause-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.68);
    z-index: 10;
}

#pause-overlay.hidden { display: none; }

#pause-overlay h2 {
    font-size: 54px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 3px 3px 0 #000, 0 0 20px rgba(255,215,0,0.4);
    margin: 0 0 18px 0;
    letter-spacing: 5px;
}

#pause-overlay p {
    font-size: 18px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    margin: 0;
    letter-spacing: 2px;
}

/* ── Blink animation ────────────────────────────────────────────────────── */
.blink { animation: blink 0.75s infinite alternate; }

@keyframes blink {
    from { opacity: 1; }
    to   { opacity: 0.05; }
}

/* ── Debug left panel (sandbox controls, debug mode only) ───────────── */
#debug-left-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: auto;
    height: 100vh;
    overflow-y: auto;
    background: rgba(5,5,10,0.94);
    border-right: 1px solid #2a2a2a;
    padding: 8px 10px 20px;
    z-index: 50;
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: #bbb;
    box-sizing: border-box;
}

#debug-left-panel.hidden { display: none; }

.dbg-enemy-select {
    width: 100%;
    background: #111;
    color: #ffd700;
    border: 1px solid #555;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    padding: 4px;
    margin-top: 6px;
    box-sizing: border-box;
    cursor: pointer;
}

.dbg-spawn-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px 0;
    background: transparent;
    border: 1px solid #ffd700;
    color: #ffd700;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
}

.dbg-spawn-btn:hover {
    background: #ffd700;
    color: #000;
}

.dbg-status {
    margin-top: 6px;
    font-size: 9px;
    color: #888;
    min-height: 14px;
    word-break: break-all;
}

/* ── Debug panel (right sidebar, debug mode only) ─────────────────────── */
#debug-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    overflow-y: auto;
    background: rgba(5,5,10,0.94);
    border-left: 1px solid #2a2a2a;
    padding: 8px 10px 20px;
    z-index: 50;
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: #bbb;
    box-sizing: border-box;
}

#debug-panel.hidden { display: none; }

#dbg-title {
    font-size: 13px;
    font-weight: bold;
    color: #ffd700;
    letter-spacing: 3px;
    text-align: center;
    padding: 6px 0 10px;
    border-bottom: 1px solid #333;
    margin-bottom: 8px;
}

.dbg-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fc8181;
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 10px;
    cursor: pointer;
}

.dbg-section {
    font-size: 9px;
    letter-spacing: 2px;
    color: #ffd700;
    opacity: 0.7;
    margin: 10px 0 4px;
    text-transform: uppercase;
    border-bottom: 1px solid #222;
    padding-bottom: 2px;
}

.dbg-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.dbg-label {
    flex: 0 0 100px;
    font-size: 9px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dbg-slider {
    flex: 1;
    height: 3px;
    accent-color: #ffd700;
    cursor: pointer;
}

.dbg-val {
    flex: 0 0 36px;
    width: 36px;
    text-align: right;
    color: #ffd700;
    font-size: 9px;
    font-family: 'Courier New', monospace;
    background: transparent;
    border: none;
    border-bottom: 1px solid #444;
    padding: 0 2px;
    -moz-appearance: textfield;
}
.dbg-val::-webkit-inner-spin-button,
.dbg-val::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.dbg-val:focus {
    outline: none;
    border-bottom-color: #ffd700;
}

#dbg-export {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 8px 0;
    background: transparent;
    border: 1px solid #ffd700;
    color: #ffd700;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
}

#dbg-export:hover {
    background: #ffd700;
    color: #000;
}

/* ── Debug Focus dropdown ─────────────────────────────────────────────── */
.dbg-focus-dropdown {
    width: 100%;
    background: #111;
    color: #ffd700;
    border: 1px solid #ffd700;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    padding: 5px 4px;
    margin-bottom: 8px;
    box-sizing: border-box;
    cursor: pointer;
    letter-spacing: 1px;
}

#dbg-focus-content {
    border-bottom: 1px solid #333;
    margin-bottom: 10px;
    padding-bottom: 6px;
}

.dbg-focus-export {
    display: block;
    width: 100%;
    margin-top: 12px;
    margin-bottom: 4px;
    padding: 7px 0;
    background: transparent;
    border: 1px solid #ffd700;
    color: #ffd700;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
}

.dbg-focus-export:hover {
    background: #ffd700;
    color: #000;
}

.dbg-subsection {
    font-size: 9px;
    letter-spacing: 1px;
    color: #888;
    margin: 8px 0 2px;
    text-transform: uppercase;
}
