/* ==========================================================================
   Shadow Escape - Game Canvas, Non-Overlapping HUD & Fixed Fit Layout
   ========================================================================== */

.game-page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: calc(100vh - 60px);
    padding: 0;
    position: relative;
    overflow: hidden;
}

body.game-active {
    overflow: hidden;
}

/* Aspect Ratio Locked Game Screen - Fits exact viewport height & width */
.game-screen-wrapper {
    position: relative;
    width: min(100vw, calc((100vh - 60px) * 16 / 9));
    height: min(calc(100vh - 60px), calc(100vw * 9 / 16));
    aspect-ratio: 16 / 9;
    background: #03050b;
    border: 1px solid var(--primary-cyan);
    box-shadow: 0 0 25px rgba(0, 243, 255, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.9);
    overflow: hidden;
    margin: 0 auto;
}

body.is-fullscreen-game .game-page-container {
    height: 100dvh;
}

body.is-fullscreen-game .game-screen-wrapper {
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border: none;
    border-radius: 0;
}

.fullscreen-toggle {
    position: relative;
    top: auto;
    right: auto;
    z-index: 12;
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--primary-gold, #fbbf24);
    border-radius: 8px;
    background: rgba(16, 20, 36, 0.88);
    color: var(--primary-gold, #fbbf24);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.35);
    user-select: none;
    touch-action: manipulation;
    transition: transform var(--transition-fast, 0.2s), background var(--transition-fast, 0.2s), box-shadow var(--transition-fast, 0.2s), color var(--transition-fast, 0.2s);
    flex-shrink: 0;
}

.fullscreen-toggle:hover, .fullscreen-toggle:active {
    background: var(--primary-gold, #fbbf24);
    color: #050608;
    box-shadow: 0 0 24px rgba(251, 191, 36, 0.75);
    transform: scale(1.08);
}

.fullscreen-toggle.exit-mode {
    border-color: rgba(255, 51, 102, 0.8);
    color: #ff3366;
    box-shadow: 0 0 14px rgba(255, 51, 102, 0.35);
}

.fullscreen-toggle.exit-mode:hover, .fullscreen-toggle.exit-mode:active {
    background: #ff3366;
    color: #ffffff;
    box-shadow: 0 0 24px rgba(255, 51, 102, 0.85);
}

/* Screen Shake Effect Target */
.shake-target {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* HTML5 Canvas */
#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: crisp-edges;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Story Mode Cinematic Intro Screen (Full Screen Black Overlay & Black Fade System) */
.level-intro-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    background: #000000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
}

.level-intro-overlay.active,
.level-intro-overlay.fade-in-black {
    opacity: 1;
    visibility: visible;
}

.level-intro-overlay.fade-out-black {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
}

.level-intro-overlay.fade-out-scene {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
}

/* Background Container & Animation Image Layers */
.intro-bg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity 1.1s cubic-bezier(0.25, 1, 0.5, 1);
}

.level-intro-overlay.scene-reveal .intro-bg-container {
    opacity: 1;
}

.level-intro-overlay.fade-out-scene .intro-bg-container,
.level-intro-overlay.fade-out .intro-bg-container {
    opacity: 0;
    transition: opacity 0.45s ease-out;
}

.intro-bg-image {
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    filter: brightness(0.85) contrast(1.1) saturate(1.1);
    transform: scale(1.06);
    transition: transform 7s ease-out;
    will-change: transform;
}

.level-intro-overlay.scene-reveal .intro-bg-image {
    animation: introKenBurns 18s cubic-bezier(0.25, 1, 0.5, 1) infinite alternate;
}

@keyframes introKenBurns {
    0% {
        transform: scale(1.04) translate(0, 0);
    }
    50% {
        transform: scale(1.11) translate(-1.5%, -1%);
    }
    100% {
        transform: scale(1.07) translate(1.5%, 1.2%);
    }
}

/* Light Dynamic Gradient & Vignette to Keep Art 100% Crisp & Visible */
.intro-bg-gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background: 
        radial-gradient(ellipse at center, rgba(6, 10, 20, 0.2) 0%, rgba(4, 7, 14, 0.5) 75%, rgba(2, 4, 8, 0.75) 100%),
        linear-gradient(180deg, rgba(2, 4, 8, 0.65) 0%, rgba(4, 7, 14, 0.1) 35%, rgba(4, 7, 14, 0.1) 65%, rgba(2, 4, 8, 0.75) 100%);
}

.intro-bg-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4);
}

.intro-bg-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.08),
        rgba(0, 0, 0, 0.08) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0.25;
}

/* Widescreen Letterbox Bars */
.intro-letterbox {
    width: 100%;
    height: 38px;
    background: rgba(4, 6, 12, 0.92);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-sizing: border-box;
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.9s cubic-bezier(0.25, 1, 0.5, 1), transform 0.9s cubic-bezier(0.25, 1, 0.5, 1);
}

.intro-letterbox.top {
    border-bottom: 2px solid var(--primary-gold);
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.25);
    transform: translateY(-25px);
}

.intro-letterbox.bottom {
    border-top: 2px solid var(--primary-cyan);
    box-shadow: 0 -4px 15px rgba(0, 243, 255, 0.25);
    transform: translateY(25px);
}

.level-intro-overlay.scene-reveal .intro-letterbox {
    opacity: 1;
    transform: translateY(0);
}

.level-intro-overlay.fade-out-scene .intro-letterbox.top,
.level-intro-overlay.fade-out .intro-letterbox.top {
    opacity: 0;
    transform: translateY(-25px);
    transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}

.level-intro-overlay.fade-out-scene .intro-letterbox.bottom,
.level-intro-overlay.fade-out .intro-letterbox.bottom {
    opacity: 0;
    transform: translateY(25px);
    transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}

.letterbox-label {
    color: var(--primary-gold);
}

.letterbox-code {
    color: var(--primary-cyan);
    opacity: 0.8;
}

.intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 650px;
    width: 90%;
    padding: 1rem 0;
    z-index: 10;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition: opacity 1.1s cubic-bezier(0.25, 1, 0.5, 1), transform 1.1s cubic-bezier(0.25, 1, 0.5, 1);
}

.level-intro-overlay.scene-reveal .intro-content {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.level-intro-overlay.fade-out-scene .intro-content,
.level-intro-overlay.fade-out .intro-content {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
    transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}

/* Hero Badge */
.intro-hero-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(0, 243, 255, 0.3);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 0.4rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 12px rgba(0, 243, 255, 0.2);
}

.intro-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.intro-hero-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.intro-agent-tag {
    font-size: 0.52rem;
    color: var(--primary-cyan);
    letter-spacing: 1.5px;
    font-weight: 800;
}

.intro-agent-name {
    font-size: 0.72rem;
    color: #ffffff;
    letter-spacing: 1px;
    font-weight: 900;
}

.intro-badge {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--primary-cyan);
    background: rgba(0, 243, 255, 0.08);
    border: 1px solid rgba(0, 243, 255, 0.35);
    padding: 3px 14px;
    border-radius: 12px;
    text-shadow: 0 0 12px rgba(0, 243, 255, 0.8);
    text-transform: uppercase;
    margin-bottom: 0.4rem;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.15);
}

.intro-title {
    font-family: var(--font-heading);
    font-size: 2.7rem;
    font-weight: 900;
    letter-spacing: 4px;
    margin: 0.2rem 0;
    text-transform: uppercase;
    background: linear-gradient(180deg, #ffffff 0%, #fef08a 35%, #f59e0b 80%, #d97706 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 15px rgba(245, 158, 11, 0.6)) drop-shadow(0 0 35px rgba(251, 191, 36, 0.4));
    line-height: 1.15;
}

.intro-location {
    font-size: 0.88rem;
    color: #cbd5e1;
    letter-spacing: 1.2px;
    font-weight: 600;
    margin-top: 0.2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Story Box */
.intro-story-box {
    font-size: 0.82rem;
    line-height: 1.45;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-left: 4px solid var(--primary-gold);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin: 0.6rem 0;
    max-width: 580px;
    font-style: italic;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Tactical Directives */
.intro-directives {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 0.3rem;
}

.directive-pill {
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    padding: 3px 9px;
    border-radius: 14px;
    backdrop-filter: blur(4px);
}

.directive-pill.gold {
    color: var(--primary-gold);
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.4);
}

.directive-pill.red {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.directive-pill.cyan {
    color: var(--primary-cyan);
    background: rgba(0, 243, 255, 0.12);
    border: 1px solid rgba(0, 243, 255, 0.4);
}

.intro-divider {
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-cyan), transparent);
    margin: 0.8rem 0 0.5rem 0;
}

.intro-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--primary-cyan);
}

.status-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-cyan);
    box-shadow: 0 0 10px var(--primary-cyan);
    animation: statusPulse 0.9s infinite alternate ease-in-out;
}

.intro-skip-hint {
    font-size: 0.64rem;
    color: #64748b;
    letter-spacing: 1.5px;
    margin-top: 0.6rem;
    text-transform: uppercase;
    animation: fadeInBlink 1.8s infinite ease-in-out;
}

@keyframes introPopIn {
    0% { opacity: 0; transform: scale(0.92) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes statusPulse {
    0% { opacity: 0.3; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1.2); }
}

@keyframes fadeInBlink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.85; }
}

/* Mobile & Tablet Responsive Optimization for Level Intro & Story Briefing Overlay */
@media (max-width: 900px) {
    .intro-letterbox {
        height: 30px;
        padding: 0 0.8rem;
        font-size: 0.58rem;
    }
    .intro-content {
        max-width: 92%;
        padding: 0.4rem 0;
    }
    .intro-title {
        font-size: clamp(1.6rem, 6.5vw, 2.3rem);
        letter-spacing: 2px;
    }
    .intro-location {
        font-size: 0.78rem;
    }
    .intro-story-box {
        font-size: 0.76rem;
        padding: 0.45rem 0.75rem;
        margin: 0.4rem 0;
        max-width: 100%;
        line-height: 1.4;
    }
    .directive-pill {
        font-size: 0.58rem;
        padding: 2px 7px;
    }
    .intro-skip-hint {
        font-size: 0.58rem;
        margin-top: 0.4rem;
    }
}

/* In-Game HUD Overlay - Clean Non-Overlapping Layout */
.game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 10;
    font-family: var(--font-heading);
    box-sizing: border-box;
}

.hud-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.hud-group.left {
    justify-content: flex-start;
}

.hud-group.right {
    justify-content: flex-end;
}

/* Vitals Pod (HP & Flight Fuel) */
.hud-vitals-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(6, 7, 12, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 5px 9px;
    border-radius: 8px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.hud-health-box, .hud-fuel-box {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-badge {
    font-size: 0.6rem;
    font-weight: 900;
    letter-spacing: 0.8px;
    padding: 1px 5px;
    border-radius: 4px;
    line-height: 1.2;
}

.hp-badge {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.3);
}

.fuel-badge {
    color: #00f3ff;
    background: rgba(0, 243, 255, 0.2);
    border: 1px solid rgba(0, 243, 255, 0.5);
    box-shadow: 0 0 6px rgba(0, 243, 255, 0.3);
}

.health-bar-container {
    width: 110px;
    height: 10px;
    background: rgba(4, 5, 8, 0.9);
    border: 1px solid rgba(239, 68, 68, 0.6);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.health-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #dc2626, #ef4444, #f59e0b);
    transition: width 0.2s ease;
}

.fuel-bar-container {
    width: 110px;
    height: 8px;
    background: rgba(4, 5, 8, 0.9);
    border: 1px solid rgba(0, 243, 255, 0.6);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.3);
}

.fuel-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #0284c7, #00f3ff);
    transition: width 0.15s ease;
}

/* Energy Crystals Counter */
.hud-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(6, 7, 12, 0.85);
    border: 1px solid rgba(251, 191, 36, 0.4);
    padding: 4px 10px;
    border-radius: 14px;
    backdrop-filter: blur(8px);
    font-size: 0.8rem;
    white-space: nowrap;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.hud-value {
    font-size: 0.8rem;
    font-weight: 800;
    color: #ffffff;
}

/* Key Indicator */
.key-indicator {
    opacity: 0.35;
    transition: opacity 0.3s ease;
}

.key-indicator.acquired {
    opacity: 1;
    filter: drop-shadow(0 0 12px var(--primary-gold));
}

/* Compact In-Game Level Tag */
.hud-level-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(6, 7, 12, 0.88);
    border: 1px solid rgba(251, 191, 36, 0.5);
    padding: 3px 12px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.3), inset 0 0 8px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    user-select: none;
    pointer-events: none;
}

.hud-level-tag .lvl-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--primary-cyan);
    text-shadow: 0 0 6px rgba(0, 243, 255, 0.6);
}

.hud-level-tag .lvl-num {
    font-size: 0.9rem;
    font-weight: 900;
    color: var(--primary-gold);
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.9);
}

/* Combat Controls Quick Hint Banner Popup */
.combat-controls-hint {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(6, 9, 20, 0.92);
    border: 1px solid rgba(0, 243, 255, 0.6);
    border-radius: 20px;
    padding: 5px 16px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    color: var(--primary-cyan);
    z-index: 25;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.35);
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
}

.combat-controls-hint.show-popup {
    animation: combatHintPopup 4.5s ease-in-out forwards;
}

@keyframes combatHintPopup {
    0% {
        opacity: 0;
        transform: translate(-50%, -15px) scale(0.9);
        visibility: visible;
    }
    12% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
        visibility: visible;
    }
    82% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
        visibility: visible;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -10px) scale(0.95);
        visibility: hidden;
    }
}

.combat-controls-hint b {
    color: var(--primary-gold);
    background: rgba(251, 191, 36, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
}

/* 3-Lines Escape / Pause Menu Button */
.hud-pause-btn {
    background: rgba(16, 20, 36, 0.88);
    border: 1.5px solid var(--primary-gold);
    color: var(--primary-gold);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.15rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.35);
    user-select: none;
    touch-action: manipulation;
    transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}

.hud-pause-btn:hover, .hud-pause-btn:active {
    background: var(--primary-gold);
    color: #050608;
    box-shadow: 0 0 24px rgba(251, 191, 36, 0.75);
    transform: scale(1.08);
}

/* Custom Game Play Music Toggle Button - Side Positioned for 100% Unobstructed Player View */
.hud-music-btn {
    background: rgba(10, 12, 24, 0.72);
    border: 1px solid rgba(0, 243, 255, 0.45);
    color: var(--primary-cyan, #00f3ff);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
    user-select: none;
    touch-action: manipulation;
    transition: transform var(--transition-fast, 0.2s), background var(--transition-fast, 0.2s), box-shadow var(--transition-fast, 0.2s), color var(--transition-fast, 0.2s), opacity 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    opacity: 0.82;
    margin-left: 2px;
}

.hud-music-btn:hover, .hud-music-btn:active {
    background: rgba(0, 243, 255, 0.2);
    border-color: #00f3ff;
    color: #ffffff;
    box-shadow: 0 0 24px rgba(0, 243, 255, 0.75);
    transform: scale(1.08);
}

.hud-music-btn.playing {
    border-color: var(--accent-gold, #fbbf24);
    color: var(--accent-gold, #fbbf24);
    background: rgba(251, 191, 36, 0.15);
    box-shadow: 0 0 18px rgba(251, 191, 36, 0.6);
    animation: hudMusicPulse 1.6s infinite ease-in-out;
}

.hud-music-btn.playing:hover, .hud-music-btn.playing:active {
    background: var(--accent-gold, #fbbf24);
    color: #050608;
    box-shadow: 0 0 26px rgba(251, 191, 36, 0.85);
}

@keyframes hudMusicPulse {
    0%, 100% {
        box-shadow: 0 0 14px rgba(251, 191, 36, 0.4), 0 0 6px rgba(0, 243, 255, 0.25);
    }
    50% {
        box-shadow: 0 0 22px rgba(251, 191, 36, 0.85), 0 0 12px rgba(0, 243, 255, 0.5);
        transform: scale(1.05);
    }
}

.hud-music-btn .music-note-icon {
    font-size: 0.95rem;
    display: inline-block;
    transition: transform 0.2s ease;
}

.hud-music-btn.playing .music-note-icon {
    animation: musicNoteSpin 3s infinite linear;
}

@keyframes musicNoteSpin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(15deg) scale(1.12); }
    100% { transform: rotate(0deg) scale(1); }
}

.hud-music-waves {
    display: none;
    align-items: flex-end;
    gap: 1.5px;
    height: 10px;
    margin-left: 2px;
}

.hud-music-btn.playing .hud-music-waves {
    display: inline-flex;
}

.hud-music-waves span {
    width: 2px;
    background: var(--accent-gold, #fbbf24);
    border-radius: 1px;
}

.hud-music-btn.playing:hover .hud-music-waves span {
    background: #050608;
}

.hud-music-waves .w1 { animation: eqAnim 0.5s infinite ease-in-out alternate; }
.hud-music-waves .w2 { animation: eqAnim 0.7s infinite ease-in-out alternate 0.15s; }
.hud-music-waves .w3 { animation: eqAnim 0.45s infinite ease-in-out alternate 0.3s; }

@keyframes eqAnim {
    0% { height: 2px; }
    100% { height: 10px; }
}

/* Mobile Virtual Touch Controls Overlay - AAA Professional Arcade Layout */
.touch-controls {
    display: none;
    position: absolute;
    bottom: max(36px, env(safe-area-inset-bottom, 36px));
    left: 0;
    width: 100%;
    padding-left: max(36px, env(safe-area-inset-left, 36px));
    padding-right: max(36px, env(safe-area-inset-right, 36px));
    box-sizing: border-box;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 20;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.touch-cluster {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    pointer-events: auto;
    touch-action: none;
}

.vertical-action-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    pointer-events: auto;
    touch-action: none;
}

.touch-btn {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(32, 40, 64, 0.96) 0%, rgba(10, 14, 26, 0.98) 100%);
    border: 2.5px solid var(--primary-gold, #fbbf24);
    color: var(--primary-gold, #fbbf24);
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 
                0 0 24px rgba(251, 191, 36, 0.5), 
                inset 0 1.5px 2px rgba(255, 255, 255, 0.4),
                inset 0 0 18px rgba(251, 191, 36, 0.2);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    will-change: transform, box-shadow;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.1s ease, background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
    backdrop-filter: blur(12px);
    cursor: pointer;
    overflow: hidden;
}

/* Glassmorphic Top Gloss Flare */
.touch-btn::after {
    content: '';
    position: absolute;
    top: 2px; left: 10%; right: 10%;
    height: 40%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 50% 50% 0 0;
    pointer-events: none;
}

.touch-btn:active, .touch-btn.active {
    transform: scale(0.90) translateY(3px);
    background: radial-gradient(circle at 50% 50%, var(--primary-gold, #fbbf24) 0%, #d97706 100%);
    color: #050608;
    box-shadow: 0 0 40px rgba(251, 191, 36, 1), inset 0 0 14px rgba(0, 0, 0, 0.6);
    border-color: #ffffff;
}

/* Directional Buttons (Left ◄ / Right ►) */
.touch-btn.directional-btn {
    border-color: rgba(251, 191, 36, 0.95);
    color: #fbbf24;
    background: radial-gradient(circle at 35% 35%, rgba(45, 36, 18, 0.96) 0%, rgba(12, 10, 5, 0.98) 100%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 
                0 0 25px rgba(251, 191, 36, 0.55), 
                inset 0 1.5px 2px rgba(255, 255, 255, 0.35),
                inset 0 0 18px rgba(251, 191, 36, 0.2);
    text-shadow: 0 0 14px rgba(251, 191, 36, 0.9);
}

.touch-btn.directional-btn:active, .touch-btn.directional-btn.active {
    background: radial-gradient(circle at 50% 50%, #fbbf24 0%, #d97706 100%);
    color: #050608;
    box-shadow: 0 0 40px rgba(251, 191, 36, 1), inset 0 0 14px rgba(0, 0, 0, 0.6);
    border-color: #ffffff;
}

/* Power / Speed Dash Button (⚡) */
.touch-btn.dash-btn, .touch-btn.power-btn {
    border-color: #f59e0b;
    color: #fbbf24;
    background: radial-gradient(circle at 35% 35%, rgba(55, 32, 12, 0.96) 0%, rgba(18, 10, 3, 0.98) 100%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 
                0 0 26px rgba(245, 158, 11, 0.65), 
                inset 0 1.5px 2px rgba(255, 255, 255, 0.35),
                inset 0 0 18px rgba(245, 158, 11, 0.25);
    text-shadow: 0 0 14px rgba(245, 158, 11, 0.9);
}

.touch-btn.dash-btn:active, .touch-btn.dash-btn.active,
.touch-btn.power-btn:active, .touch-btn.power-btn.active {
    background: radial-gradient(circle at 50% 50%, #fbbf24 0%, #d97706 100%);
    color: #000000;
    box-shadow: 0 0 42px rgba(245, 158, 11, 1), inset 0 0 14px rgba(0, 0, 0, 0.6);
    border-color: #ffffff;
}

/* Fight / Attack Button (⚔️) */
.touch-btn.attack-btn, .touch-btn.flight-btn {
    border-color: #00f3ff;
    color: #00f3ff;
    background: radial-gradient(circle at 35% 35%, rgba(12, 42, 58, 0.96) 0%, rgba(4, 16, 24, 0.98) 100%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 
                0 0 26px rgba(0, 243, 255, 0.6), 
                inset 0 1.5px 2px rgba(255, 255, 255, 0.35),
                inset 0 0 18px rgba(0, 243, 255, 0.25);
    text-shadow: 0 0 14px rgba(0, 243, 255, 0.9);
}

.touch-btn.attack-btn:active, .touch-btn.attack-btn.active,
.touch-btn.flight-btn:active, .touch-btn.flight-btn.active {
    background: radial-gradient(circle at 50% 50%, #00f3ff 0%, #0284c7 100%);
    color: #000000;
    box-shadow: 0 0 42px rgba(0, 243, 255, 1), inset 0 0 14px rgba(0, 0, 0, 0.6);
    border-color: #ffffff;
}

/* Jump Button (▲) */
.touch-btn.jump-btn {
    border-color: #10b981;
    color: #34d399;
    background: radial-gradient(circle at 35% 35%, rgba(12, 48, 32, 0.96) 0%, rgba(4, 20, 12, 0.98) 100%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 
                0 0 26px rgba(16, 185, 129, 0.6), 
                inset 0 1.5px 2px rgba(255, 255, 255, 0.35),
                inset 0 0 18px rgba(16, 185, 129, 0.25);
    text-shadow: 0 0 14px rgba(52, 211, 153, 0.9);
}

.touch-btn.jump-btn:active, .touch-btn.jump-btn.active {
    background: radial-gradient(circle at 50% 50%, #34d399 0%, #059669 100%);
    color: #000000;
    box-shadow: 0 0 42px rgba(16, 185, 129, 1), inset 0 0 14px rgba(0, 0, 0, 0.6);
    border-color: #ffffff;
}

/* Mobile Rotation Overlay */
.rotate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 7, 18, 0.96);
    backdrop-filter: blur(16px);
    z-index: 9999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    color: var(--primary-cyan);
}

/* Small Home Button at top-right of overlay */
.rotate-home-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: #f1f5f9;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.rotate-home-btn:hover,
.rotate-home-btn:focus-visible {
    background: rgba(251, 191, 36, 0.2);
    border-color: var(--primary-gold);
    color: var(--primary-gold);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

.rotate-home-btn:active {
    transform: scale(0.95);
}

/* Rotate & Play Buttons Wrapper */
.rotate-icon-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.rotate-device-badge {
    font-size: 2.8rem;
    padding: 0.5rem 1rem;
    background: rgba(124, 58, 237, 0.2);
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 18px;
    box-shadow: 0 0 25px rgba(124, 58, 237, 0.35);
}

/* Vibrant 3D Glowing Blue Rotate Button for Play */
.rotate-play-btn {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border: 2px solid #93c5fd;
    border-radius: 20px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.7), inset 0 2px 4px rgba(255, 255, 255, 0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: pulseRotateBtn 3s infinite ease-in-out;
}

.rotate-play-btn:hover {
    transform: scale(1.12) rotate(180deg);
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
    box-shadow: 0 0 40px rgba(96, 165, 250, 0.9), inset 0 2px 4px rgba(255, 255, 255, 0.7);
}

.rotate-play-btn:active {
    transform: scale(0.95) rotate(180deg);
}

@keyframes pulseRotateBtn {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.06) rotate(180deg);
    }
}

.rotate-title {
    font-family: var(--font-heading);
    color: var(--primary-gold);
    margin-bottom: 0.5rem;
    font-size: 1.6rem;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
}

.rotate-desc {
    color: var(--text-muted);
    max-width: 340px;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

/* Action Button: Rotate & Play */
.rotate-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.8rem;
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--primary-amber) 100%);
    border: none;
    border-radius: var(--border-radius-sm, 8px);
    color: #050608;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    cursor: pointer;
    box-shadow: 0 0 22px rgba(251, 191, 36, 0.45);
    transition: all 0.25s ease;
}

.rotate-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 32px rgba(251, 191, 36, 0.75);
    filter: brightness(1.1);
}

.rotate-action-btn:active {
    transform: translateY(0) scale(0.98);
}


/* Responsive Touch Viewports */
@media (max-width: 1024px), (pointer: coarse) {
    .touch-controls {
        display: flex;
    }
}

/* Show Rotate Prompt when phone is held in Portrait mode during gameplay */
@media (max-width: 900px) and (orientation: portrait) {
    .rotate-overlay.active {
        display: flex;
    }
}

/* Full Landscape Mobile Optimization */
@media (max-width: 950px) and (orientation: landscape) {
    .game-page-container {
        height: calc(100dvh - 50px);
    }
    .game-screen-wrapper {
        border-radius: 0;
        border-left: none;
        border-right: none;
        width: min(100vw, calc((100dvh - 50px) * 16 / 9));
        height: min(calc(100dvh - 50px), calc(100vw * 9 / 16));
    }
    .hud-level-tag {
        padding: 2px 8px;
        gap: 4px;
    }
    .hud-level-tag .lvl-label {
        font-size: 0.58rem;
        letter-spacing: 1px;
    }
    .hud-level-tag .lvl-num {
        font-size: 0.78rem;
    }
    .intro-title {
        font-size: 2.0rem;
    }
    .hud-item {
        font-size: 0.72rem;
        padding: 2px 6px;
    }
    .health-bar-container {
        width: 80px;
        height: 10px;
    }
    .touch-btn {
        width: 66px;
        height: 66px;
        font-size: 1.4rem;
    }
    .touch-controls {
        bottom: max(32px, env(safe-area-inset-bottom, 32px));
        padding-left: max(32px, env(safe-area-inset-left, 32px));
        padding-right: max(32px, env(safe-area-inset-right, 32px));
    }
}

@media (max-width: 950px) and (orientation: portrait) {
    .game-page-container {
        height: calc(100dvh - 60px);
        justify-content: flex-start;
        padding-top: 0;
    }

    .game-screen-wrapper {
        width: min(100vw, calc((100dvh - 60px) * 16 / 9));
        height: min(calc(100dvh - 60px), calc(100vw * 9 / 16));
        max-width: 100vw;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    .game-hud {
        padding: 0.35rem 0.6rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
    }

    .hud-group {
        gap: 0.35rem;
        flex-wrap: nowrap;
    }

    .hud-group.left,
    .hud-group.right {
        justify-content: flex-start;
    }

    .hud-vitals-card {
        padding: 3px 6px;
        gap: 3px;
    }

    .hud-badge {
        font-size: 0.55rem;
        padding: 1px 3px;
    }

    .health-bar-container {
        width: 75px;
        height: 8px;
    }

    .fuel-bar-container {
        width: 75px;
        height: 7px;
    }

    .hud-item {
        font-size: 0.68rem;
        padding: 2px 6px;
    }

    .hud-value {
        font-size: 0.72rem;
    }

    .hud-music-btn {
        width: 25px;
        height: 25px;
        font-size: 0.75rem;
        border-radius: 5px;
        margin-left: 1px;
    }

    .hud-music-btn .music-note-icon {
        font-size: 0.75rem;
    }

    .hud-music-waves {
        height: 7px;
        gap: 1px;
    }

    .touch-controls {
        bottom: max(30px, env(safe-area-inset-bottom, 30px));
        padding-left: max(24px, env(safe-area-inset-left, 24px));
        padding-right: max(24px, env(safe-area-inset-right, 24px));
    }

    .touch-cluster {
        gap: 12px;
    }

    .vertical-action-stack {
        gap: 10px;
    }

    .touch-btn {
        width: 58px;
        height: 58px;
        font-size: 1.25rem;
    }
}

/* Hide Header & Fit Full Mobile Screen during In-Game Gameplay */
@media (max-width: 950px) {
    body.in-game-view .navbar {
        display: none !important;
    }
    body.in-game-view .game-page-container {
        height: 100dvh !important;
        width: 100vw !important;
        padding: 0 !important;
        margin: 0 !important;
        justify-content: center !important;
    }
    body.in-game-view .game-screen-wrapper {
        width: 100vw !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
}
