/* Lode Runner - VGA Style (Responsive) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --game-width: 672px;
    --game-height: 384px;
    --scale: 1;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: linear-gradient(135deg, #000055 0%, #000022 50%, #000055 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Courier New', monospace;
    margin: 0;
    padding: 0;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #000044 0%, #000022 100%);
    padding: calc(6px * var(--scale));
    border: calc(2px * var(--scale)) solid #5555FF;
    border-radius: calc(4px * var(--scale));
    box-shadow:
        0 0 calc(15px * var(--scale)) rgba(85, 85, 255, 0.5),
        0 0 calc(30px * var(--scale)) rgba(85, 85, 255, 0.3),
        inset 0 0 calc(10px * var(--scale)) rgba(0, 0, 0, 0.5);
    transform-origin: center center;
    flex-shrink: 0;
}

#header {
    width: var(--game-width);
    background: linear-gradient(180deg, #000088 0%, #000044 100%);
    color: #55FFFF;
    font-size: calc(12px * var(--scale));
    font-weight: bold;
    padding: calc(5px * var(--scale)) calc(10px * var(--scale));
    display: flex;
    justify-content: space-between;
    font-family: 'Courier New', monospace;
    letter-spacing: calc(1px * var(--scale));
    border: calc(2px * var(--scale)) solid #5555FF;
    border-bottom: none;
    border-radius: calc(3px * var(--scale)) calc(3px * var(--scale)) 0 0;
}

#header .label {
    color: #FFFF55;
    text-shadow: calc(1px * var(--scale)) calc(1px * var(--scale)) 0 #000000;
}

#header .value {
    color: #FFFFFF;
    margin-left: calc(8px * var(--scale));
    text-shadow: calc(1px * var(--scale)) calc(1px * var(--scale)) 0 #000000;
}

#sound-toggle {
    cursor: pointer;
    font-size: calc(20px * var(--scale));
    transition: transform 0.1s ease;
    user-select: none;
}

#sound-toggle:hover {
    transform: scale(1.2);
}

#sound-toggle:active {
    transform: scale(0.9);
}

#sound-toggle.muted #sound-icon::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: #FF5555;
    transform: rotate(-45deg);
    top: 50%;
}

#header .version {
    color: #55FF55;
    font-size: calc(12px * var(--scale));
    text-shadow: calc(1px * var(--scale)) calc(1px * var(--scale)) 0 #000000;
}

#game-canvas {
    display: block;
    background-color: #0000AA;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: calc(2px * var(--scale)) solid #5555FF;
}

#message {
    width: var(--game-width);
    background: linear-gradient(180deg, #000044 0%, #000088 100%);
    color: #FFFF55;
    font-size: calc(12px * var(--scale));
    font-weight: bold;
    text-align: center;
    padding: calc(5px * var(--scale));
    min-height: calc(24px * var(--scale));
    font-family: 'Courier New', monospace;
    letter-spacing: calc(2px * var(--scale));
    border: calc(2px * var(--scale)) solid #5555FF;
    border-top: none;
    text-shadow: calc(1px * var(--scale)) calc(1px * var(--scale)) 0 #000000;
    border-radius: 0 0 calc(3px * var(--scale)) calc(3px * var(--scale));
}

#instructions {
    color: #55FFFF;
    font-size: calc(9px * var(--scale));
    text-align: center;
    padding: calc(3px * var(--scale)) calc(6px * var(--scale));
    font-family: 'Courier New', monospace;
    max-width: var(--game-width);
    line-height: 1.3;
    text-shadow: calc(1px * var(--scale)) calc(1px * var(--scale)) 0 #000000;
}

#instructions p {
    margin: calc(1px * var(--scale)) 0;
}

#key-display {
    display: flex;
    justify-content: center;
    gap: calc(4px * var(--scale));
    margin-top: calc(4px * var(--scale));
}

#key-display .key-item {
    display: inline-block;
    min-width: calc(24px * var(--scale));
    padding: calc(3px * var(--scale)) calc(6px * var(--scale));
    background: linear-gradient(180deg, #333355 0%, #222244 100%);
    border: calc(1px * var(--scale)) solid #444466;
    border-radius: calc(3px * var(--scale));
    color: #666688;
    font-size: calc(10px * var(--scale));
    font-weight: bold;
    text-align: center;
    transition: all 0.1s ease;
    box-shadow: 0 calc(2px * var(--scale)) 0 #111122;
}

#key-display .key-item.active {
    background: linear-gradient(180deg, #FFFF55 0%, #FFAA00 100%);
    border-color: #FFFF88;
    color: #000000;
    box-shadow: 0 0 calc(10px * var(--scale)) rgba(255, 255, 0, 0.5);
    transform: translateY(calc(2px * var(--scale)));
}

/* Death reason overlay */
#death-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: calc(4px * var(--scale));
}

#death-overlay.visible {
    display: flex;
}

#death-overlay h2 {
    color: #FF5555;
    font-size: calc(28px * var(--scale));
    font-family: 'Courier New', monospace;
    margin-bottom: calc(20px * var(--scale));
    text-shadow: calc(3px * var(--scale)) calc(3px * var(--scale)) 0 #000000;
    animation: pulse 1s ease-in-out infinite;
}

#death-overlay .reason {
    color: #FFFF55;
    font-size: calc(16px * var(--scale));
    font-family: 'Courier New', monospace;
    text-align: center;
    max-width: 80%;
    line-height: 1.8;
    margin-bottom: calc(20px * var(--scale));
    text-shadow: calc(2px * var(--scale)) calc(2px * var(--scale)) 0 #000000;
}

#death-overlay .hint {
    color: #55FFFF;
    font-size: calc(14px * var(--scale));
    font-family: 'Courier New', monospace;
    text-shadow: calc(1px * var(--scale)) calc(1px * var(--scale)) 0 #000000;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* Canvas wrapper for overlay positioning */
#canvas-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Copyright notice */
#copyright {
    width: var(--game-width);
    display: flex;
    justify-content: flex-end;
    gap: calc(6px * var(--scale));
    padding: calc(2px * var(--scale)) calc(6px * var(--scale));
    font-family: 'Courier New', monospace;
    font-size: calc(8px * var(--scale));
    color: #888888;
    text-shadow: calc(1px * var(--scale)) calc(1px * var(--scale)) 0 #000000;
}

#copyright span:first-child {
    color: #666666;
}

#copyright .refactor {
    color: #55FFFF;
    font-size: calc(7px * var(--scale));
    opacity: 0.8;
}
