/* ============================================
   SOUND PULSE MAZE - CYBERPUNK DARK THEME
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;500;700&display=swap');

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

body {
    background: #050508;
    color: #e0e0e0;
    font-family: 'Rajdhani', sans-serif;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#game-container {
    position: relative;
    width: min(95vw, 95vh * 4 / 3);
    max-width: 800px;
    box-shadow: 
        0 0 20px rgba(0, 200, 255, 0.15),
        0 0 60px rgba(0, 100, 200, 0.08),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 200, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    background: #000;
}

#game-container::before {
    content: "";
    display: block;
    padding-top: 75%; /* 4:3 Aspect Ratio */
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}

/* ============================================
   HUD OVERLAY
   ============================================ */

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(180deg, rgba(5, 5, 15, 0.95) 0%, rgba(5, 5, 15, 0.7) 60%, transparent 100%);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 20px;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.5s ease;
}

#hud.hidden {
    opacity: 0;
    pointer-events: none;
}

.hud-left, .hud-right {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hud-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(0, 200, 255, 0.6);
    margin-bottom: 4px;
}

.hud-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    font-weight: 900;
    color: #00e5ff;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5), 0 0 20px rgba(0, 229, 255, 0.2);
}

#timer-display {
    color: #ff6b35;
    text-shadow: 0 0 10px rgba(255, 107, 53, 0.5);
}

.energy-container {
    min-width: 160px;
}

.energy-bar-container {
    width: 140px;
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 200, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.energy-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00e5ff 0%, #00b8d4 50%, #0097a7 100%);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
    transition: width 0.15s ease-out;
    border-radius: 1px;
}

.energy-bar.low {
    background: linear-gradient(90deg, #ff5252 0%, #d32f2f 100%);
    box-shadow: 0 0 8px rgba(255, 82, 82, 0.4);
}

.hud-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid rgba(0, 200, 255, 0.4);
    color: #00e5ff;
    cursor: pointer;
    pointer-events: all;
    border-radius: 2px;
    transition: all 0.3s ease;
    margin-top: 4px;
}

.hud-btn:hover {
    background: rgba(0, 200, 255, 0.15);
    border-color: rgba(0, 200, 255, 0.8);
    box-shadow: 0 0 15px rgba(0, 200, 255, 0.3);
}

/* ============================================
   OVERLAY SCREENS
   ============================================ */

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 2, 8, 0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    max-width: 500px;
    width: 100%;
}

.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 42px;
    font-weight: 900;
    color: #00e5ff;
    text-shadow: 
        0 0 10px rgba(0, 229, 255, 0.6),
        0 0 30px rgba(0, 229, 255, 0.3),
        0 0 60px rgba(0, 229, 255, 0.1);
    letter-spacing: 4px;
    margin-bottom: 12px;
    line-height: 1.2;
}

.game-subtitle {
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    font-weight: 300;
    color: rgba(200, 220, 255, 0.6);
    letter-spacing: 3px;
    margin-bottom: 30px;
}

.instructions {
    background: rgba(0, 200, 255, 0.03);
    border: 1px solid rgba(0, 200, 255, 0.1);
    border-radius: 4px;
    padding: 20px 30px;
    margin-bottom: 30px;
}

.instructions p {
    font-size: 14px;
    color: rgba(200, 220, 255, 0.7);
    margin: 8px 0;
    letter-spacing: 1px;
}

.key {
    display: inline-block;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #00e5ff;
    background: rgba(0, 200, 255, 0.1);
    border: 1px solid rgba(0, 200, 255, 0.3);
    padding: 2px 8px;
    border-radius: 3px;
    margin: 0 4px;
    letter-spacing: 1px;
}

.goal-text {
    color: #00e676;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(0, 230, 118, 0.4);
}

.main-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 3px;
    padding: 14px 36px;
    background: transparent;
    border: 2px solid #00e5ff;
    color: #00e5ff;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.4s ease;
    text-transform: uppercase;
}

.main-btn:hover {
    background: rgba(0, 229, 255, 0.15);
    box-shadow: 
        0 0 20px rgba(0, 229, 255, 0.3),
        0 0 40px rgba(0, 229, 255, 0.1);
    transform: translateY(-2px);
}

.screen-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 3px;
    margin-bottom: 12px;
}

.screen-title.gameover {
    color: #ff5252;
    text-shadow: 0 0 15px rgba(255, 82, 82, 0.5);
}

.screen-title.victory {
    color: #00e676;
    text-shadow: 0 0 15px rgba(0, 230, 118, 0.5);
}

.screen-message {
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    color: rgba(200, 220, 255, 0.6);
    margin-bottom: 30px;
    letter-spacing: 1px;
}

/* Scanline effect */
#game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 200, 255, 0.015) 2px,
        rgba(0, 200, 255, 0.015) 4px
    );
    pointer-events: none;
    z-index: 5;
}

/* ============================================
   RESPONSIVE DESIGN & MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 600px) {
    #hud {
        height: 50px;
        padding: 8px 15px;
    }
    .hud-left, .hud-right {
        gap: 12px;
    }
    .hud-value {
        font-size: 16px;
    }
    .hud-label {
        font-size: 8px;
        margin-bottom: 2px;
    }
    .energy-container {
        min-width: 100px;
    }
    .energy-bar-container {
        width: 90px;
        height: 8px;
    }
    .hud-btn {
        font-size: 8px;
        padding: 4px 10px;
        margin-top: 2px;
    }
    .overlay-content {
        padding: 20px;
    }
    .game-title {
        font-size: 24px;
        letter-spacing: 2px;
        margin-bottom: 8px;
    }
    .game-subtitle {
        font-size: 11px;
        letter-spacing: 1.5px;
        margin-bottom: 15px;
    }
    .instructions {
        padding: 10px 15px;
        margin-bottom: 15px;
    }
    .instructions p {
        font-size: 11px;
        margin: 4px 0;
    }
    .key {
        font-size: 9px;
        padding: 1px 4px;
    }
    .main-btn {
        font-size: 11px;
        padding: 10px 24px;
        letter-spacing: 2px;
    }
    .screen-title {
        font-size: 20px;
        letter-spacing: 2px;
        margin-bottom: 8px;
    }
    .screen-message {
        font-size: 12px;
        margin-bottom: 15px;
    }
}

/* Landscape Mobile adjustments to prevent HUD blocking */
@media (max-height: 480px) and (orientation: landscape) {
    #hud {
        height: 45px;
        padding: 4px 12px;
    }
    .hud-value {
        font-size: 14px;
    }
    .hud-label {
        font-size: 7px;
        margin-bottom: 0px;
    }
    .energy-container {
        min-width: 80px;
    }
    .energy-bar-container {
        width: 70px;
        height: 6px;
    }
    .hud-btn {
        font-size: 7px;
        padding: 2px 6px;
        margin-top: 0px;
    }
}

/* ============================================
   TOUCH CONTROLS (MOBILE HUD)
   ============================================ */

.touch-controls {
    display: none;
    position: fixed;
    bottom: 25px;
    left: 20px;
    right: 20px;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 100;
}

.touch-btn {
    pointer-events: auto;
    background: rgba(5, 5, 15, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 2px solid rgba(0, 200, 255, 0.4);
    color: #00e5ff;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
    box-shadow: 0 0 15px rgba(0, 200, 255, 0.1), inset 0 0 10px rgba(0, 200, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    transition: all 0.1s ease;
}

.dpad {
    display: grid;
    grid-template-areas: 
        ".    up    ."
        "left .     right"
        ".    down  .";
    grid-template-columns: 50px 50px 50px;
    grid-template-rows: 50px 50px 50px;
    gap: 6px;
    pointer-events: none;
}

#btn-up { grid-area: up; }
#btn-left { grid-area: left; }
#btn-right { grid-area: right; }
#btn-down { grid-area: down; }

.dpad-btn {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    font-size: 18px;
}

.dpad-btn:active {
    background: rgba(0, 200, 255, 0.25);
    border-color: #00e5ff;
    box-shadow: 0 0 20px rgba(0, 200, 255, 0.4), inset 0 0 10px rgba(0, 200, 255, 0.2);
    transform: scale(0.95);
}

.action-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border-color: rgba(255, 82, 82, 0.4);
    color: #ff5252;
    text-shadow: 0 0 8px rgba(255, 82, 82, 0.6);
    box-shadow: 0 0 15px rgba(255, 82, 82, 0.1), inset 0 0 10px rgba(255, 82, 82, 0.1);
    font-size: 14px;
    letter-spacing: 1px;
}

.action-btn:active {
    background: rgba(255, 82, 82, 0.25);
    border-color: #ff5252;
    box-shadow: 0 0 20px rgba(255, 82, 82, 0.4), inset 0 0 10px rgba(255, 82, 82, 0.2);
    transform: scale(0.95);
}

/* Show touch controls on coarse pointer screens */
@media (pointer: coarse) {
    .touch-controls {
        display: flex;
    }
}