/* ==========================================================================
   RETRO CYBER JUMPER - SLEEK DARK GLASSMORPHISM THEME
   ========================================================================== */

/* --- Reset & Global Variables --- */
:root {
    --bg-dark: #0b0f19;
    --bg-surface: #0f172a;
    --glass-bg: rgba(15, 23, 42, 0.72);
    --glass-bg-dense: rgba(11, 15, 25, 0.88);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-hover: rgba(56, 189, 248, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    --glass-glow: 0 0 20px rgba(56, 189, 248, 0.2);

    --primary-cyan: #38bdf8;
    --primary-cyan-dark: #0284c7;
    --accent-blue: #818cf8;
    --accent-gold: #fbbf24;
    --accent-purple: #f0abfc;
    --accent-emerald: #4ade80;
    --accent-red: #ff4757;

    --text-bright: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    touch-action: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-bright);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    background-image: 
        radial-gradient(ellipse at 50% 20%, rgba(30, 41, 59, 0.8) 0%, rgba(11, 15, 25, 1) 80%);
}

h1, h2, h3, .title, .btn-primary, .btn-secondary, .hud-zone-pill, button, .score-digits, .game-logo-badge {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    letter-spacing: 0.5px;
}

/* --- Main Game Container --- */
#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 1280px;
    max-height: 720px;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    box-shadow: 
        0 25px 60px rgba(0, 0, 0, 0.8),
        0 0 40px rgba(56, 189, 248, 0.1);
    overflow: hidden;
    border-radius: 16px;
    touch-action: none;
}

@media (max-width: 900px), (max-height: 700px) {
    #gameContainer {
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #0f172a;
    touch-action: none;
}

/* ==========================================================================
   HUD SYSTEM (DARK GLASSMORPHISM HEADER)
   ========================================================================== */

#hud {
    position: absolute;
    top: 18px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 20;
    gap: 12px;
    transition: opacity 0.3s ease;
}

#hud.hidden {
    display: none !important;
    opacity: 0;
}

/* ==========================================================================
   BOSS HEALTH BAR OVERLAY (CYBER GIGA-MECH OMEGA-X)
   ========================================================================== */

#bossHud {
    position: absolute;
    top: clamp(60px, 12vh, 90px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    pointer-events: none;
    transition: opacity 0.3s ease;
    width: min(92%, 460px);
}

#bossHud.hidden {
    display: none !important;
    opacity: 0;
}

.boss-hud-card {
    background: rgba(15, 23, 42, 0.92);
    border: 3px solid #ef4444;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: clamp(6px, 1.5vh, 10px) clamp(12px, 3vw, 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.boss-name-label {
    font-size: clamp(10px, 3vw, 14px);
    font-weight: 900;
    color: #fca5a5;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.boss-hp-track {
    width: 100%;
    height: clamp(12px, 2vh, 16px);
    background: rgba(30, 41, 59, 0.9);
    border: 2px solid #0f172a;
    border-radius: 10px;
    overflow: hidden;
    padding: 2px;
}

.boss-hp-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #dc2626 0%, #ef4444 50%, #facc15 100%);
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
    transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    color: var(--text-bright);
    border-radius: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.hud-card:hover {
    border-color: var(--glass-border-hover);
}

/* Left Group: Hero Avatar, Lives & Zone */
.hud-hero {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.hero-mini-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary-cyan-dark), var(--primary-cyan));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.hud-lives-box {
    display: flex;
    gap: 5px;
    font-size: 20px;
    align-items: center;
}

.heart {
    display: inline-block;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.6));
    animation: heartbeat 1.4s ease-in-out infinite alternate;
}

@keyframes heartbeat {
    0% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.4)); }
    100% { transform: scale(1.18); filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.8)); }
}

.hud-zone-pill {
    font-size: 13px;
    font-weight: 800;
    color: var(--primary-cyan);
    background: rgba(56, 189, 248, 0.12);
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid rgba(56, 189, 248, 0.3);
    letter-spacing: 1px;
}

/* Center Group: Score, Coins, Gems & Keys */
.hud-score-box {
    flex-direction: column;
    gap: 2px;
    padding: 8px 24px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    align-items: center;
}

.score-title {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 2.5px;
    text-transform: uppercase;
}

.score-digits {
    font-size: 28px;
    font-weight: 900;
    color: var(--primary-cyan);
    text-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.hud-sub-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.coin-badge, .gem-badge, .key-badge {
    font-size: 12px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.3s ease;
}

.coin-badge {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(245, 158, 11, 0.35);
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
}

.gem-badge {
    background: rgba(217, 70, 239, 0.15);
    color: var(--accent-purple);
    border: 1px solid rgba(217, 70, 239, 0.35);
    text-shadow: 0 0 8px rgba(217, 70, 239, 0.3);
}

.key-badge {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(34, 197, 94, 0.35);
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
}

.key-badge.hidden {
    display: none;
}

/* Right Group: High Score Record & Quick Buttons */
.hud-meta {
    background: rgba(15, 23, 42, 0.8);
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
}

.high-score-box {
    font-size: 12px;
    font-weight: 800;
    color: var(--accent-gold);
    text-align: center;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.28);
    padding: 4px 10px;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

.hud-btn-group {
    display: flex;
    gap: 6px;
}

/* ==========================================================================
   BUTTON STYLES (GLASSMORPHISM & CTAs)
   ========================================================================== */

button {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: clamp(14px, 2.5vw, 16px);
    font-weight: 800;
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    min-height: 48px;
    min-width: 48px;
    cursor: pointer;
    pointer-events: auto;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary-cyan-dark), var(--primary-cyan));
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.35);
    text-transform: uppercase;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    touch-action: manipulation;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(56, 189, 248, 0.5);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

/* Glossy highlight sweep on hover */
button::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 40%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transform: rotate(30deg);
    transition: left 0.6s ease;
    pointer-events: none;
}

button:hover::after {
    left: 140%;
}

.sound-toggle-btn {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: var(--primary-cyan);
    font-size: clamp(11px, 2.2vw, 12px);
    font-weight: 700;
    padding: 6px 12px;
    min-height: 44px;
    border-radius: 8px;
    box-shadow: none;
    backdrop-filter: blur(8px);
}

.sound-toggle-btn:hover {
    background: rgba(56, 189, 248, 0.25);
    border-color: rgba(56, 189, 248, 0.6);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
    transform: translateY(-1px);
}

.btn-primary, .sega-start-btn {
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    color: #ffffff;
    font-size: clamp(15px, 3.5vw, 20px);
    font-weight: 800;
    padding: 12px 28px;
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 30px rgba(56, 189, 248, 0.4);
}

.btn-primary:hover, .sega-start-btn:hover {
    background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
    box-shadow: 0 12px 35px rgba(56, 189, 248, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-bright);
    font-size: clamp(14px, 3vw, 18px);
    font-weight: 700;
    padding: 12px 24px;
    min-height: 48px;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn-gameover {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.4);
}

.btn-gameover:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    box-shadow: 0 12px 35px rgba(239, 68, 68, 0.6);
}

/* ==========================================================================
   OVERLAY & MODAL SYSTEM (DARK GLASS BACKDROP & CARDS)
   ========================================================================== */

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--glass-bg-dense);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: clamp(12px, 3vh, 24px) clamp(12px, 3vw, 24px);
    text-align: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: manipulation;
}

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

.overlay.sega-overlay {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.sega-secret-btn {
    position: absolute;
    top: clamp(12px, 3vh, 24px);
    left: clamp(12px, 3vw, 24px);
    background: rgba(15, 23, 42, 0.85);
    border: 2px solid #facc15;
    color: #facc15;
    font-size: clamp(11px, 2.8vw, 13px);
    font-weight: 800;
    padding: 8px 18px;
    min-height: 48px;
    border-radius: 20px;
    cursor: pointer;
    z-index: 30;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
    transition: transform 0.2s, background 0.2s;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sega-secret-btn:hover {
    background: #facc15;
    color: #0f172a;
    transform: scale(1.05);
}

.modal-stage-select {
    max-width: 640px;
    width: min(94%, 640px);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
}

.stage-select-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.stage-icon {
    font-size: 32px;
}

.secret-code-row {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-bottom: 18px;
}

.secret-input {
    flex: 1;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 10px;
    padding: 10px 16px;
    color: #ffffff;
    font-size: 16px; /* Prevents auto zoom on iOS Safari */
    min-height: 48px;
    font-weight: 700;
    outline: none;
}

.stage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: clamp(8px, 2vw, 14px);
    width: 100%;
}

.stage-card {
    background: rgba(30, 41, 59, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 12px 16px;
    min-height: 56px;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.stage-card:hover {
    border-color: var(--primary-cyan);
    background: rgba(56, 189, 248, 0.15);
    transform: translateY(-2px);
}

.stage-card.stage-4 {
    border-color: rgba(239, 68, 68, 0.6);
    background: rgba(239, 68, 68, 0.1);
}

.stage-card.stage-4:hover {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.25);
}

.stage-num {
    font-size: 11px;
    font-weight: 800;
    color: var(--primary-cyan);
    letter-spacing: 1px;
}

.stage-card.stage-4 .stage-num {
    color: #fca5a5;
}

.stage-name {
    font-size: 15px;
    font-weight: 900;
    color: #ffffff;
    margin-top: 4px;
}

/* ==========================================================================
   PROGRESSION-BASED LEVEL SELECT OVERLAY (FULL SCREEN AAA ARCADE MODE)
   ========================================================================== */

#levelSelectOverlay {
    background: radial-gradient(circle at center, #1e1b4b 0%, #0f172a 60%, #090d16 100%);
    padding: 0;
    margin: 0;
    align-items: stretch;
    justify-content: stretch;
}

.modal-level-select {
    width: 100%;
    height: 100%;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 40px 60px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

.level-select-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    text-align: center;
}

.header-title-box {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-icon {
    font-size: 42px;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.6));
}

.title-level-select {
    font-size: 38px;
    font-weight: 900;
    letter-spacing: 3px;
    background: linear-gradient(180deg, #ffffff 0%, #38bdf8 50%, #0284c7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(56, 189, 248, 0.5);
    margin: 0;
}

.level-select-subtitle {
    font-size: 15px;
    color: #94a3b8;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.level-select-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    width: 100%;
    max-width: 1200px;
    flex: 1;
    margin: 20px 0;
}

.zone-card {
    position: relative;
    background: rgba(15, 23, 42, 0.85);
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s, box-shadow 0.3s;
}

.zone-img-box {
    position: relative;
    width: 100%;
    height: 155px;
    overflow: hidden;
    background: #0f172a;
}

.zone-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.zone-card.unlocked:hover .zone-preview-img {
    transform: scale(1.1);
}

.zone-badge-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.zone-card-content {
    padding: 16px 18px 18px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
}

/* Zone Specific Graphical Themes */
.zone-card.zone-1-theme {
    background: linear-gradient(160deg, rgba(6, 78, 59, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
}
.zone-card.zone-2-theme {
    background: linear-gradient(160deg, rgba(88, 28, 135, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
}
.zone-card.zone-3-theme {
    background: linear-gradient(160deg, rgba(30, 27, 75, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
}
.zone-card.zone-4-theme {
    background: linear-gradient(160deg, rgba(127, 29, 29, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
}

.zone-card.unlocked:hover {
    transform: translateY(-8px) scale(1.04);
    border-color: #facc15;
    box-shadow: 0 15px 35px rgba(250, 204, 21, 0.4);
}

.zone-card.locked {
    opacity: 0.5;
    filter: grayscale(0.6);
    cursor: not-allowed;
    border-color: rgba(148, 163, 184, 0.2);
}

.zone-badge-pill {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #facc15;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 20px;
    width: fit-content;
    border: 1px solid rgba(250, 204, 21, 0.3);
}

.zone-card.zone-boss .zone-badge-pill {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
}

.zone-card-title {
    font-size: 22px;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.25;
    margin-top: 16px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.zone-status-tag {
    font-size: 14px;
    font-weight: 900;
    margin-top: auto;
    padding-top: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zone-card.unlocked .zone-status-tag {
    color: #4ade80;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.6);
}

.zone-card.locked .zone-status-tag {
    color: #cbd5e1;
}

.level-select-back-btn {
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
    border: 2px solid #64748b;
    color: #ffffff;
    font-size: clamp(13px, 3vw, 16px);
    font-weight: 900;
    padding: 12px 32px;
    min-height: 48px;
    border-radius: 30px;
    cursor: pointer;
    letter-spacing: 1px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s, border-color 0.2s, background 0.2s;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.level-select-back-btn:hover {
    background: #facc15;
    color: #0f172a;
    border-color: #fef08a;
    transform: scale(1.05);
}

.sega-start-banner-btn {
    position: absolute;
    bottom: clamp(20px, 6vh, 50px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    color: #ffffff;
    font-size: clamp(13px, 3.5vw, 22px);
    font-weight: 900;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: clamp(10px, 2vh, 16px) clamp(20px, 4vw, 40px);
    min-height: 52px;
    border-radius: 50px;
    border: 3px solid #ffffff;
    box-shadow: 0 10px 35px rgba(56, 189, 248, 0.6), 0 0 20px rgba(255, 255, 255, 0.4);
    cursor: pointer;
    letter-spacing: 1.5px;
    z-index: 20;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: startBannerPulse 1.5s infinite alternate;
    touch-action: manipulation;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sega-start-banner-btn:hover {
    background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 45px rgba(56, 189, 248, 0.8), 0 0 30px rgba(255, 255, 255, 0.8);
}

@keyframes startBannerPulse {
    0% { transform: scale(1); box-shadow: 0 10px 35px rgba(56, 189, 248, 0.5); }
    100% { transform: scale(1.05); box-shadow: 0 14px 45px rgba(56, 189, 248, 0.8), 0 0 30px rgba(255, 255, 255, 0.8); }
}

.modal-card {
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(56, 189, 248, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: clamp(20px, 4vw, 36px) clamp(20px, 5vw, 48px);
    border-radius: 24px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.8),
        0 0 40px rgba(56, 189, 248, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 580px;
    width: 94%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: modalAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-btn-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 18px;
}

.btn-pause-action {
    width: 100%;
    text-align: center;
    justify-content: center;
}

.btn-danger {
    background: linear-gradient(135deg, rgba(225, 29, 72, 0.2) 0%, rgba(190, 18, 60, 0.4) 100%);
    border: 1px solid rgba(244, 63, 94, 0.4);
    color: #f43f5e;
}

.btn-danger:hover {
    background: linear-gradient(135deg, rgba(225, 29, 72, 0.4) 0%, rgba(190, 18, 60, 0.6) 100%);
    border-color: rgba(244, 63, 94, 0.7);
    color: #ffffff;
    box-shadow: 0 8px 25px rgba(244, 63, 94, 0.4);
}

/* Pause Modal Custom Styling */
.pause-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.pause-icon {
    font-size: 36px;
}

.pause-stats-row {
    display: flex;
    gap: clamp(8px, 2vw, 20px);
    width: 100%;
    margin-bottom: 20px;
}

.pause-stat {
    flex: 1;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pause-stat .stat-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 1.5px;
}

.pause-stat .stat-val {
    font-size: clamp(16px, 4vw, 20px);
    font-weight: 900;
    color: var(--primary-cyan);
}

/* Game Over Modal Custom Styling */
.modal-gameover {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(239, 68, 68, 0.2);
}

.gameover-skull {
    font-size: clamp(34px, 8vh, 52px);
    animation: skullPulse 1.5s ease-in-out infinite alternate;
    margin-bottom: 8px;
}

@keyframes skullPulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.4)); }
    100% { transform: scale(1.15); filter: drop-shadow(0 0 25px rgba(239, 68, 68, 0.8)); }
}

.gameover-score-card {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 14px;
    padding: 12px 28px;
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
}

.gameover-score-label {
    font-size: 12px;
    font-weight: 800;
    color: #fca5a5;
    letter-spacing: 2px;
}

.gameover-score-val {
    font-size: clamp(22px, 6vw, 32px);
    font-weight: 900;
    color: #ffffff;
}

@keyframes modalAppear {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.game-logo-badge {
    font-size: 12px;
    font-weight: 800;
    color: var(--primary-cyan);
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.overlay-main-title {
    font-size: clamp(24px, 6vw, 42px);
    font-weight: 900;
    background: linear-gradient(135deg, #e0f2fe 0%, #38bdf8 50%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.overlay-tagline {
    font-size: clamp(12px, 3vw, 14px);
    color: var(--text-muted);
    margin-bottom: 24px;
}

.title {
    font-size: clamp(22px, 6vw, 38px);
    font-weight: 900;
    background: linear-gradient(135deg, #e0f2fe 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.title-gameover {
    background: linear-gradient(135deg, #fecdd3 0%, #ff4757 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.title-win {
    background: linear-gradient(135deg, #dcfce7 0%, #2ed573 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-bright);
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 8px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.overlay-btn-row {
    display: flex;
    gap: clamp(8px, 2vw, 14px);
    flex-wrap: wrap;
    justify-content: center;
    width: min(94%, 740px);
}

.overlay-btn-row button {
    min-height: 48px;
    font-size: clamp(12px, 3vw, 16px);
    padding: 10px 18px;
    flex: 1 1 auto;
    min-width: 130px;
}

/* Controls Overview Card */
.controls-card.compact {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 18px 24px;
    width: 100%;
    margin-bottom: 24px;
    text-align: left;
}

.controls-title {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.controls-card.compact ul {
    list-style: none;
    color: var(--text-bright);
    font-size: 14px;
    line-height: 2.1;
}

.key-cap {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    color: var(--primary-cyan);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* ==========================================================================
   Cyber Kael Arcade ARCADE OFFICIAL LOADING OVERLAY
   ========================================================================== */

.overlay.mania-loading-overlay {
    background: #facc15;
    z-index: 100;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
}

.mania-anim-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 2;
    opacity: 1;
}

.mania-logo-corner {
    position: absolute;
    top: 24px; right: 32px;
    font-size: 24px;
    font-weight: 900;
    font-style: italic;
    color: #ffffff;
    background: #0f172a;
    padding: 6px 20px;
    border: 3px solid #ffffff;
    box-shadow: 5px 5px 0 #0f172a;
    letter-spacing: 2px;
    transform: rotate(2deg);
    z-index: 10;
}

/* Diagonal Graphic Stripes */
.mania-stripe {
    position: absolute;
    transform: rotate(-35deg);
    transform-origin: center;
    pointer-events: none;
    display: block;
    animation: maniaStripeSlide 8s ease-in-out infinite alternate;
    z-index: 1;
}

@keyframes maniaStripeSlide {
    0% { transform: rotate(-35deg) translateY(-25px); }
    100% { transform: rotate(-35deg) translateY(25px); }
}

.mania-stripe.blue {
    width: 250%; height: 140px;
    background: #2563eb;
    top: 26%;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
}

.mania-stripe.orange {
    width: 250%; height: 70px;
    background: #f97316;
    top: 18%;
    animation-delay: -2s;
}

.mania-stripe.teal {
    width: 250%; height: 50px;
    background: #14b8a6;
    top: 46%;
    animation-delay: -4s;
}

.mania-stripe.pink {
    width: 250%; height: 65px;
    background: #ff007f;
    top: 58%;
    animation-delay: -1s;
}

.mania-stripe.yellow {
    width: 250%; height: 45px;
    background: #fde047;
    top: 72%;
    animation-delay: -3s;
}

/* Zone Title & Act Circle Card */
.mania-card {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 30px;
    transform: skewX(-12deg);
    background: #ff007f;
    padding: 32px 48px;
    border: 6px solid #0f172a;
    box-shadow: 10px 10px 0 #0f172a, 0 20px 40px rgba(0, 0, 0, 0.4);
    margin-bottom: 28px;
}

.mania-text-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.mania-zone-name {
    font-size: 50px;
    font-weight: 900;
    font-style: italic;
    color: #ffffff;
    text-transform: uppercase;
    margin: 0;
    line-height: 1;
    -webkit-text-stroke: 3px #0f172a;
    text-shadow: 6px 6px 0 #0f172a, 0 10px 20px rgba(0, 0, 0, 0.4);
    letter-spacing: 2px;
}

.mania-zone-sub {
    background: #0f172a;
    color: #ffffff;
    font-size: 24px;
    font-weight: 900;
    font-style: italic;
    padding: 2px 24px;
    margin-top: 6px;
    letter-spacing: 4px;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
    border: 3px solid #ffffff;
}

/* Orange Act Circle Badge */
.mania-act-badge {
    width: 110px; height: 110px;
    background: #f97316;
    border: 5px solid #0f172a;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 6px 6px 0 #0f172a, 0 10px 25px rgba(0, 0, 0, 0.3);
    transform: skewX(12deg);
    flex-shrink: 0;
}

.act-label {
    font-size: 14px;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: 1px;
    margin-bottom: -4px;
}

.act-number {
    font-size: 54px;
    font-weight: 900;
    color: #0f172a;
    line-height: 1;
}

/* 7-Second Progress Bar Box */
.mania-loader-box {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 520px;
    max-width: 90%;
    background: rgba(15, 23, 42, 0.92);
    border: 4px solid #0f172a;
    box-shadow: 8px 8px 0 #0f172a;
    border-radius: 18px;
    padding: 18px 28px;
}

.mania-tip-text {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    background: #facc15;
    padding: 6px 22px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 2px solid #0f172a;
    margin-bottom: 0;
    text-align: center;
}

.mania-loader-text {
    font-size: 16px;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 1px;
    margin-bottom: 0;
    text-shadow: 1px 1px 0 #0f172a;
}

.mania-progress-track {
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid #0f172a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

.mania-progress-fill {
    width: 0%; height: 100%;
    background: linear-gradient(90deg, #ff007f, #f97316, #2563eb, #14b8a6);
    border-radius: 8px;
    border-right: 2px solid #ffffff;
    transition: width 0.05s linear;
    box-shadow: 0 0 12px rgba(255, 0, 127, 0.8);
}

/* ==========================================================================
   UNLEASHED / END-OF-LEVEL RESULTS CARD (DARK GLASS)
   ========================================================================== */

.unleashed-results-card {
    display: flex;
    align-items: center;
    gap: clamp(14px, 2.5vw, 28px);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(16px);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.1);
    padding: clamp(14px, 3vw, 28px);
    max-width: 740px;
    width: min(94%, 740px);
    max-height: 80vh;
    max-height: 80dvh;
    overflow-y: auto;
    margin-bottom: 16px;
    border-radius: 20px;
}

.results-dance-box {
    width: clamp(90px, 25vw, 120px);
    height: clamp(110px, 28vw, 140px);
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.results-tally-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.5vh, 10px);
    text-align: left;
    color: var(--text-bright);
    min-width: 0;
}

.results-main-title {
    font-size: clamp(18px, 4.5vw, 26px);
    margin-bottom: 4px;
}

.tally-row {
    display: flex;
    justify-content: space-between;
    font-size: clamp(11px, 2.8vw, 14px);
    font-weight: 700;
    background: rgba(30, 41, 59, 0.5);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tally-row.total {
    font-size: clamp(15px, 4vw, 20px);
    font-weight: 900;
    color: var(--primary-cyan);
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.tally-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
}

.tally-rank-detail {
    font-size: clamp(11px, 2.6vw, 13px);
    color: #facc15;
    font-weight: 800;
    text-align: center;
    background: rgba(250, 204, 21, 0.12);
    border: 1px solid rgba(250, 204, 21, 0.35);
    border-radius: 8px;
    padding: 6px 10px;
    margin-top: 4px;
    letter-spacing: 0.5px;
}

.results-badges-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.results-badge {
    font-size: clamp(10px, 2.5vw, 12px);
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 6px;
}

.results-badge.gold { background: rgba(245, 158, 11, 0.18); color: var(--accent-gold); border: 1px solid rgba(245, 158, 11, 0.4); }
.results-badge.purple { background: rgba(217, 70, 239, 0.18); color: var(--accent-purple); border: 1px solid rgba(217, 70, 239, 0.4); }
.results-badge.cyan { background: rgba(56, 189, 248, 0.18); color: var(--primary-cyan); border: 1px solid rgba(56, 189, 248, 0.4); }
.results-badge.hidden { display: none; }

.results-rank-box {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.rank-title {
    font-size: clamp(11px, 2.8vw, 13px);
    font-weight: 900;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.rank-badge {
    position: relative;
    width: clamp(85px, 22vw, 120px);
    height: clamp(85px, 22vw, 120px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 24px;
    transform: rotate(-3deg);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    perspective: 500px;
}

.rank-badge:hover {
    transform: rotate(0deg) scale(1.08);
}

.rank-letter {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 64px;
    font-weight: 900;
    font-style: italic;
    line-height: 1;
    color: #ffffff;
    text-shadow: 
        4px 4px 0 #0f172a,
        -2px -2px 0 #0f172a,
        2px -2px 0 #0f172a,
        -2px 2px 0 #0f172a,
        0 6px 12px rgba(0, 0, 0, 0.6);
    z-index: 2;
}

.rank-sub-title {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2px;
    background: #0f172a;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: -6px;
    z-index: 3;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.rank-badge-stars {
    position: absolute;
    top: -12px;
    font-size: 16px;
    letter-spacing: 2px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    z-index: 4;
}

/* RANK S - GOLDEN NEON MAGENTA LEGEND CREST */
.rank-badge.rank-s {
    background: linear-gradient(135deg, #ff007f 0%, #d946ef 50%, #facc15 100%);
    border: 4px solid #fef08a;
    box-shadow: 
        0 0 35px rgba(255, 0, 127, 0.7),
        0 0 15px rgba(250, 204, 21, 0.8),
        inset 0 2px 4px rgba(255, 255, 255, 0.8),
        8px 8px 0 #0f172a;
    animation: rankSPulse 2s ease-in-out infinite alternate;
}

@keyframes rankSPulse {
    0% { filter: drop-shadow(0 0 12px rgba(255, 0, 127, 0.6)); transform: rotate(-3deg) scale(1); }
    100% { filter: drop-shadow(0 0 25px rgba(250, 204, 21, 0.9)); transform: rotate(-1deg) scale(1.05); }
}

.rank-badge.rank-s .rank-letter {
    background: linear-gradient(180deg, #ffffff 0%, #fef08a 60%, #eab308 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 2px #0f172a;
}

/* RANK A - ROYAL GOLDEN CROWN CREST */
.rank-badge.rank-a {
    background: linear-gradient(135deg, #f97316 0%, #eab308 100%);
    border: 4px solid #fef08a;
    box-shadow: 
        0 0 30px rgba(249, 115, 22, 0.7),
        inset 0 2px 4px rgba(255, 255, 255, 0.7),
        8px 8px 0 #0f172a;
}

.rank-badge.rank-a .rank-letter {
    color: #ffffff;
    text-shadow: 4px 4px 0 #0f172a;
}

/* RANK B - ELECTRIC CYAN SHIELD */
.rank-badge.rank-b {
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    border: 4px solid #bae6fd;
    box-shadow: 
        0 0 25px rgba(56, 189, 248, 0.7),
        inset 0 2px 4px rgba(255, 255, 255, 0.7),
        8px 8px 0 #0f172a;
}

/* RANK C - EMERALD CRYSTAL OCTAGON */
.rank-badge.rank-c {
    background: linear-gradient(135deg, #15803d 0%, #22c55e 100%);
    border: 4px solid #bbf7d0;
    box-shadow: 
        0 0 20px rgba(34, 197, 94, 0.6),
        8px 8px 0 #0f172a;
}

/* RANK D - INDUSTRIAL STEEL SHIELD */
.rank-badge.rank-d {
    background: linear-gradient(135deg, #334155 0%, #64748b 100%);
    border: 4px solid #cbd5e1;
    box-shadow: 
        0 0 15px rgba(100, 116, 139, 0.5),
        8px 8px 0 #0f172a;
}

/* RANK E - RUST BRONZE */
.rank-badge.rank-e {
    background: linear-gradient(135deg, #78350f 0%, #9a3412 100%);
    border: 4px solid #fed7aa;
    box-shadow: 
        0 0 15px rgba(154, 52, 18, 0.5),
        8px 8px 0 #0f172a;
}

/* ==========================================================================
   MOBILE TOUCH CONTROLS (ARCADE VIRTUAL D-PAD & ACTION BUTTONS)
   ========================================================================== */

#touchControls {
    position: absolute;
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    left: max(16px, env(safe-area-inset-left, 16px));
    right: max(16px, env(safe-area-inset-right, 16px));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 40;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}

/* Visibility: Display on touch screens, mobile/tablet screen sizes, or when touch is active */
@media (hover: hover) and (pointer: fine) and (min-width: 1025px) {
    #touchControls:not(.touch-active) {
        display: none !important;
    }
}

/* --- Virtual Arcade D-Pad Grid Layout --- */
.dpad-container {
    display: grid;
    grid-template-columns: repeat(3, clamp(42px, 11vw, 56px));
    grid-template-rows: repeat(3, clamp(42px, 11vw, 56px));
    gap: 3px;
    align-items: center;
    justify-items: center;
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.45);
    padding: 6px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

.touch-btn {
    position: relative;
    background: rgba(15, 23, 42, 0.85);
    border: 1.5px solid rgba(56, 189, 248, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--primary-cyan);
    font-weight: 800;
    pointer-events: auto;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    transition: transform 0.08s ease, background 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    outline: none;
}

.touch-btn:active, .touch-btn.active {
    background: rgba(56, 189, 248, 0.4) !important;
    color: #ffffff !important;
    border-color: #38bdf8 !important;
    transform: scale(0.92) !important;
    box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.5), 0 0 15px rgba(56, 189, 248, 0.6) !important;
}

.dpad-btn {
    width: 100%;
    height: 100%;
    font-size: clamp(18px, 4.5vw, 24px);
}

.dpad-up {
    grid-column: 2;
    grid-row: 1;
    border-radius: 14px 14px 4px 4px;
}

.dpad-left {
    grid-column: 1;
    grid-row: 2;
    border-radius: 14px 4px 4px 14px;
}

.dpad-center-core {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 4px;
}

.dpad-right {
    grid-column: 3;
    grid-row: 2;
    border-radius: 4px 14px 14px 4px;
}

.dpad-down {
    grid-column: 2;
    grid-row: 3;
    border-radius: 4px 4px 14px 14px;
}

/* --- Action Buttons Cluster --- */
.action-buttons-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: auto;
    touch-action: none;
}

.action-top-row {
    display: flex;
    gap: 10px;
}

.action-btn {
    border-radius: 50% !important;
    gap: 2px;
}

.action-jump {
    width: clamp(66px, 17vw, 82px);
    height: clamp(66px, 17vw, 82px);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.88) 0%, rgba(3, 105, 161, 0.88) 100%) !important;
    border: 2px solid #38bdf8 !important;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.5), 0 6px 20px rgba(0, 0, 0, 0.4) !important;
}

.action-jump:active, .action-jump.active {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
    border-color: #e0f2fe !important;
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.9), inset 0 2px 6px rgba(255, 255, 255, 0.6) !important;
}

.action-spin {
    width: clamp(50px, 13vw, 62px);
    height: clamp(50px, 13vw, 62px);
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.88) 0%, rgba(161, 98, 7, 0.88) 100%) !important;
    border: 2px solid #facc15 !important;
    box-shadow: 0 0 14px rgba(250, 204, 21, 0.4), 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

.action-spin:active, .action-spin.active {
    background: linear-gradient(135deg, #ca8a04 0%, #854d0e 100%) !important;
    border-color: #fef08a !important;
    box-shadow: 0 0 22px rgba(250, 204, 21, 0.9), inset 0 2px 6px rgba(255, 255, 255, 0.6) !important;
}

.action-bounce {
    width: clamp(50px, 13vw, 62px);
    height: clamp(50px, 13vw, 62px);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.88) 0%, rgba(185, 28, 28, 0.88) 100%) !important;
    border: 2px solid #f87171 !important;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.4), 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

.action-bounce:active, .action-bounce.active {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%) !important;
    border-color: #fecaca !important;
    box-shadow: 0 0 22px rgba(239, 68, 68, 0.9), inset 0 2px 6px rgba(255, 255, 255, 0.6) !important;
}

.btn-icon {
    font-size: clamp(16px, 4vw, 22px);
    line-height: 1;
}

.btn-label {
    font-size: clamp(8px, 2vw, 10px);
    letter-spacing: 0.5px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

@media (max-width: 600px) {
    #touchControls {
        bottom: max(10px, env(safe-area-inset-bottom, 10px));
        left: max(10px, env(safe-area-inset-left, 10px));
        right: max(10px, env(safe-area-inset-right, 10px));
    }
}

/* ==========================================================================
   RESPONSIVE LAYOUT ADJUSTMENTS (MOBILE & TABLETS - PORTRAIT & LANDSCAPE)
   ========================================================================== */

@media (max-width: 900px) {
    .level-select-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px !important;
    }
}

@media (max-width: 820px) {
    #hud {
        top: max(8px, env(safe-area-inset-top, 8px));
        left: max(8px, env(safe-area-inset-left, 8px));
        right: max(8px, env(safe-area-inset-right, 8px));
        gap: 6px;
    }

    .hud-card {
        padding: 5px 10px;
        gap: 6px;
        border-radius: 10px;
    }

    .hero-mini-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .hud-lives-box {
        font-size: 15px;
        gap: 2px;
    }

    .hud-zone-pill {
        font-size: 10px;
        padding: 3px 6px;
    }

    .score-digits {
        font-size: clamp(16px, 4vw, 22px);
    }

    .score-title {
        font-size: 9px;
    }

    .coin-badge, .gem-badge, .key-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .high-score-box {
        font-size: 10px;
        padding: 3px 6px;
    }

    .sound-toggle-btn {
        font-size: 10px;
        padding: 4px 8px;
        min-height: 44px;
    }

    .modal-card {
        padding: 20px 24px;
    }
}

@media (max-width: 680px) {
    .unleashed-results-card {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .results-dance-box {
        order: 1;
    }
    
    .results-rank-box {
        order: 2;
    }
    
    .results-tally-box {
        order: 3;
        width: 100%;
    }
}

@media (max-width: 540px) {
    #hud {
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .hud-score-box {
        order: -1;
        width: 100%;
        margin-bottom: 2px;
        padding: 4px 12px;
    }
    
    .hud-hero {
        order: 1;
    }
    
    .hud-meta {
        order: 2;
    }

    .level-select-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
}

/* Landscape Mobile Viewports (Short Height <= 520px) */
@media (max-height: 520px) and (orientation: landscape) {
    #hud {
        top: max(4px, env(safe-area-inset-top, 4px));
        left: max(8px, env(safe-area-inset-left, 8px));
        right: max(8px, env(safe-area-inset-right, 8px));
    }

    .hud-card {
        padding: 4px 8px;
    }

    .score-digits {
        font-size: 16px;
    }

    .modal-card {
        padding: 14px 20px;
        max-height: 94vh;
        max-height: 94dvh;
    }

    .title {
        font-size: 20px;
        margin-bottom: 6px;
    }

    .gameover-skull {
        font-size: 32px;
        margin-bottom: 2px;
    }

    .gameover-score-card {
        padding: 6px 14px;
        margin-bottom: 10px;
    }

    .gameover-score-val {
        font-size: 20px;
    }

    .pause-stats-row {
        margin-bottom: 10px;
        gap: 10px;
    }

    .pause-stat {
        padding: 4px 8px;
    }

    .unleashed-results-card {
        padding: 12px 16px;
        gap: 12px;
        margin-bottom: 8px;
    }

    .results-dance-box {
        width: 80px;
        height: 95px;
    }

    .rank-badge {
        width: 75px;
        height: 75px;
        border-radius: 18px;
    }

    .rank-letter {
        font-size: 40px;
    }

    .mania-card {
        padding: 16px 24px;
        margin-bottom: 14px;
    }

    .mania-zone-name {
        font-size: 28px;
    }

    .mania-act-badge {
        width: 70px;
        height: 70px;
    }

    .act-number {
        font-size: 32px;
    }
}

/* ==========================================================================
   INTRO CINEMATIC CUTSCENE OVERLAY
   ========================================================================== */

.overlay.cinematic-overlay {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    touch-action: none;
    z-index: 60;
    pointer-events: auto;
    cursor: pointer;
}

.cinematic-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.cinematic-dialogue-box {
    position: absolute;
    bottom: max(55px, calc(env(safe-area-inset-bottom, 30px) + 55px));
    left: 50%;
    transform: translateX(-50%);
    width: min(92%, 900px);
    background: rgba(8, 12, 28, 0.94);
    border: 2px solid rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 18px 24px 14px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    pointer-events: auto;
}

.cinematic-speaker-name {
    font-size: 14px;
    font-weight: 900;
    color: #38bdf8;
    letter-spacing: 3px;
    text-transform: uppercase;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(56, 189, 248, 0.3);
}

.cinematic-text {
    font-size: clamp(15px, 2.5vw, 18px);
    font-weight: 600;
    color: #e2e8f0;
    line-height: 1.65;
    min-height: 54px;
    white-space: pre-wrap;
}

.cinematic-advance {
    font-size: 12px;
    font-weight: 700;
    color: #fbbf24;
    text-align: right;
    letter-spacing: 1px;
    animation: blinkAdvance 1s ease-in-out infinite;
}

@keyframes blinkAdvance {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.skip-btn {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 20px));
    right: 20px;
    background: rgba(15, 23, 42, 0.8);
    border: 1.5px solid rgba(251, 191, 36, 0.5);
    color: #fbbf24;
    font-size: 13px;
    font-weight: 800;
    padding: 8px 18px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s, background 0.2s;
    min-height: 44px;
    z-index: 20;
    pointer-events: auto;
}

.skip-btn:hover {
    transform: scale(1.05);
    background: #facc15;
}

/* ==========================================================================
   MOBILE ORIENTATION WARNING OVERLAY (LANDSCAPE MODE PROMPT)
   ========================================================================== */
.orientation-overlay {
    z-index: 200;
    background: rgba(11, 15, 25, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.modal-orientation-card {
    border-color: rgba(251, 191, 36, 0.5);
    box-shadow: 0 0 40px rgba(251, 191, 36, 0.25);
    text-align: center;
    max-width: 420px;
    padding: 32px 24px;
}

.phone-rotate-icon {
    font-size: 56px;
    margin-bottom: 12px;
    animation: rotatePhone 2s ease-in-out infinite;
}

@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.title-orientation {
    background: linear-gradient(135deg, #fef08a 0%, #facc15 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 24px;
    margin-bottom: 8px;
}

.orientation-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ==========================================================================
   3-PAGE STORYBOOK OVERLAY ("CHRONIQUES DE NÉORA")
   ========================================================================== */
.storybook-overlay {
    z-index: 150;
    background: radial-gradient(circle at 50% 40%, rgba(14, 23, 42, 0.96) 0%, rgba(3, 7, 18, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 24px);
}

.storybook-card {
    position: relative;
    width: min(94%, 780px);
    max-height: min(92vh, 680px);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.95) 0%, rgba(10, 16, 30, 0.98) 100%);
    border: 2px solid rgba(251, 191, 36, 0.6);
    border-radius: 24px;
    box-shadow: 0 0 50px rgba(251, 191, 36, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 20px 40px rgba(0, 0, 0, 0.6);
    padding: clamp(20px, 3.5vw, 36px);
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2.5vw, 22px);
    overflow: hidden;
    animation: bookPopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bookPopIn {
    0% { transform: scale(0.9) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.storybook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(251, 191, 36, 0.25);
    padding-bottom: 14px;
}

.storybook-tag {
    font-size: clamp(12px, 2vw, 14px);
    font-weight: 900;
    color: #facc15;
    letter-spacing: 2px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

.book-skip-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 800;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.book-skip-btn:hover {
    background: rgba(234, 179, 8, 0.2);
    border-color: #facc15;
    color: #fef08a;
    transform: translateY(-1px);
}

.storybook-body {
    flex: 1;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
}

.storybook-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: pageFadeIn 0.3s ease-out;
}

.storybook-page.hidden {
    display: none;
}

@keyframes pageFadeIn {
    0% { opacity: 0; transform: translateX(16px); }
    100% { opacity: 1; transform: translateX(0); }
}

.page-badge {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.25) 0%, rgba(202, 138, 4, 0.15) 100%);
    border: 1px solid rgba(250, 204, 21, 0.6);
    color: #fef08a;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 2.5px;
    padding: 4px 14px;
    border-radius: 12px;
    text-transform: uppercase;
}

.page-illustration {
    font-size: clamp(36px, 6vw, 48px);
    margin-bottom: 2px;
}

.page-title {
    font-size: clamp(20px, 4vw, 28px);
    font-weight: 900;
    color: #ffffff;
    letter-spacing: -0.5px;
    margin: 0;
    background: linear-gradient(135deg, #ffffff 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-text {
    font-size: clamp(14px, 2.2vw, 16px);
    color: #cbd5e1;
    line-height: 1.65;
    margin: 0;
}

.page-text strong {
    color: #facc15;
    font-weight: 800;
}

.page-text em {
    color: #38bdf8;
    font-style: normal;
    font-weight: 700;
}

.page-callout {
    margin-top: 6px;
    background: rgba(56, 189, 248, 0.12);
    border-left: 3px solid #38bdf8;
    padding: 10px 14px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: #7dd3fc;
    font-weight: 700;
}

.storybook-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(251, 191, 36, 0.25);
    padding-top: 14px;
    margin-top: auto;
}

.book-nav-btn {
    min-height: 44px;
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s;
}

.book-prev-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1.5px solid rgba(148, 163, 184, 0.5);
    color: #e2e8f0;
}

.book-prev-btn:not(:disabled):hover {
    background: rgba(51, 65, 85, 1);
    border-color: #cbd5e1;
    transform: translateX(-2px);
}

.book-prev-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.book-next-btn {
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
    border: 1.5px solid #fef08a;
    color: #0f172a;
    box-shadow: 0 4px 15px rgba(234, 179, 8, 0.35);
}

.book-next-btn:hover {
    background: #facc15;
    transform: translateX(2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(234, 179, 8, 0.5);
}

.book-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.4);
    transition: all 0.25s;
}

.page-dot.active {
    width: 22px;
    border-radius: 10px;
    background: #facc15;
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.6);
}

.page-indicator-text {
    font-size: 12px;
    font-weight: 800;
    color: #94a3b8;
    margin-left: 6px;
}

