/* ============================================
   🎮 Game-Themed Birthday Storyboard
   Retro RPG × Modern Neon Design System
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* === Retro 8-bit Color Palette === */
    --primary: #e52521;       /* Mario Red */
    --primary-dark: #b31010;
    --primary-light: #ff5050;

    --secondary: #43b047;     /* Mario Green */
    --secondary-dark: #208020;

    --accent: #0088ff;
    --accent-dark: #0055aa;

    --gold: #fbd000;          /* Coin Yellow */
    --gold-light: #ffea70;

    --health: #e52521;        /* Heart Red */

    --wood-light: #d8a060;
    --wood-base: #b87030;
    --wood-dark: #804000;

    --bg-color: #5c94fc;      /* Mario Sky Blue */
    --bg-color-dark: #3c74dc;

    --dark: #000000;
    --dark-2: #222222;
    --dark-3: #333333;
    --dark-4: #444444;

    --light: #ffffff;
    --light-muted: #dddddd;
    --light-dim: #bbbbbb;

    /* Removed Glass/Glow */
    --glass-bg: transparent;
    --glass-bg-strong: transparent;
    --glass-border: transparent;

    /* Typography */
    --font-pixel: 'Press Start 2P', monospace;
    --font-heading: 'Press Start 2P', monospace;
    --font-body: 'Press Start 2P', monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radius - Blocky style */
    --radius: 0px;
    --radius-sm: 0px;
    --radius-lg: 0px;
    --radius-full: 0px;

    /* Transition */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--dark);
    color: var(--light);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

img {
    max-width: 100%;
    display: block;
}

/* === CRT Scanline Overlay === */
.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    mix-blend-mode: multiply;
}

/* === Starfield Background === */
.starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.star {
    position: absolute;
    border-radius: var(--radius-full);
    background: white;
    animation: star-twinkle linear infinite;
}

.star:nth-child(3n+1) { background: var(--accent); }
.star:nth-child(5n+2) { background: var(--primary-light); }
.star:nth-child(7n) { background: var(--gold); }

@keyframes star-twinkle {
    0%, 100% { opacity: 0.1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.3); }
}

/* === Custom Scrollbar === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 2px; }

/* ============================================
   GAME HUD (always visible)
   ============================================ */
.game-hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    padding: var(--space-sm) var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(10, 10, 26, 0.95) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.5s var(--ease);
}

.game-hud.visible {
    opacity: 1;
}

.hud-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.hud-level {
    font-family: var(--font-pixel);
    font-size: 0.55rem;
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
    white-space: nowrap;
}

.xp-bar-container {
    width: 100px;
    height: 8px;
    background: var(--dark-3);
    border-radius: 4px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    position: relative;
}

.xp-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--health), var(--accent));
    border-radius: 4px;
    transition: width 0.8s var(--ease-bounce);
    position: relative;
}

.xp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    background: white;
    opacity: 0.6;
    border-radius: 4px;
    filter: blur(2px);
}

.xp-text {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--gold);
    text-shadow: 0 0 6px var(--gold-glow);
    white-space: nowrap;
}

.hud-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* === Music Toggle === */
.music-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s var(--ease);
    color: var(--light);
}

.music-toggle:hover {
    background: var(--glass-bg-strong);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

.music-toggle.muted { opacity: 0.4; }
.music-toggle.playing {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* === Achievement Counter === */
.achievement-counter {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 4px;
    text-shadow: 0 0 6px var(--gold-glow);
}

/* ============================================
   ACHIEVEMENT POPUP
   ============================================ */
.achievement-popup {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    z-index: 500;
    background: linear-gradient(135deg, var(--dark-3), var(--dark-4));
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    box-shadow:
        0 0 20px var(--gold-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    opacity: 0;
    pointer-events: none;
    transition: all 0.6s var(--ease-bounce);
}

.achievement-popup.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.achievement-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px var(--gold-glow));
}

.achievement-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.achievement-label {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.achievement-name {
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    color: var(--light);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

/* ============================================
   XP GAIN POPUP
   ============================================ */
.xp-popup {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    color: var(--gold);
    text-shadow:
        0 0 20px var(--gold-glow),
        0 0 40px var(--gold-glow);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}

/* ============================================
   SCENE CONTAINER
   ============================================ */
.scene {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: var(--space-lg);
    padding-top: calc(var(--space-lg) + 40px);
}

.scene.active {
    display: flex;
}

.scene-content {
    width: 100%;
    max-width: 480px;
    text-align: center;
    position: relative;
    z-index: 1;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
.section-title {
    font-family: var(--font-pixel);
    font-size: 0.85rem;
    font-weight: 400;
    margin-bottom: var(--space-lg);
    color: var(--light);
    text-shadow: 2px 2px 0 var(--dark);
    line-height: 1.6;
    letter-spacing: 1px;
}

.section-title-fancy {
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 3px 3px 0 var(--dark);
}

/* ============================================
   BUTTONS (8-Bit Block Style)
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border: 4px solid;
    border-color: #ffffff #555555 #555555 #ffffff;
    background: #aaaaaa;
    color: var(--dark);
    border-radius: 0;
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    cursor: pointer;
    transition: none; /* No transition for snappy 8-bit feel */
    outline: none;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    line-height: 1.8;
    letter-spacing: 0.5px;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}

.btn:active {
    border-color: #555555 #ffffff #ffffff #555555;
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: #ff8888 #880000 #880000 #ff8888;
}

.btn-accent {
    background: var(--accent);
    color: white;
    border-color: #88ccff #003388 #003388 #88ccff;
}

.btn-gold {
    background: var(--gold);
    color: var(--dark);
    border-color: #ffffaa #cc8800 #cc8800 #ffffaa;
}

.btn-ghost {
    background: transparent;
    color: var(--light);
    border: 4px solid var(--light);
    box-shadow: none;
}

.btn-ghost:active {
    background: rgba(255,255,255,0.2);
    border-color: var(--light);
    transform: translate(2px, 2px);
}

.btn-small {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.5rem;
    border-width: 3px;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.5);
}

.btn-glow {
    /* Removed neon glow, added simple flash */
    animation: btn-flash 1s steps(2, end) infinite;
}

@keyframes btn-flash {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

.btn-icon {
    font-size: 1.2em;
    line-height: 1;
}

.btn-hidden {
    display: none !important;
}

/* ============================================
   SCENE: INTRO CINEMATIC
   ============================================ */
.intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
}

.game-title {
    font-family: var(--font-pixel);
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    color: var(--primary-light);
    text-shadow:
        0 0 10px var(--primary-glow),
        0 0 20px var(--primary-glow),
        0 0 40px rgba(255, 45, 149, 0.3);
    letter-spacing: 2px;
    line-height: 2;
    opacity: 0;
}

.game-title-sub {
    font-family: var(--font-pixel);
    font-size: clamp(0.5rem, 2vw, 0.65rem);
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
    letter-spacing: 1px;
    line-height: 2;
    opacity: 0;
    margin-top: var(--space-sm);
}



/* Dialogue Box — 8-Bit Wooden Style */
.dialogue-box {
    background: var(--wood-base);
    border: 6px solid;
    border-color: var(--wood-light) var(--wood-dark) var(--wood-dark) var(--wood-light);
    border-radius: 0;
    padding: var(--space-md) var(--space-xl) var(--space-xl) var(--space-xl);
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 6px 6px 0 rgba(0,0,0,0.6);
    opacity: 0;
}

/* Remove the glowing triangle indicator for the dialogue box */
.dialogue-box::before {
    display: none;
}

.dialogue-continue {
    position: absolute;
    bottom: 6px;
    right: 10px;
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--light-dim);
    animation: blink-cursor 1.2s step-end infinite;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dialogue-continue .arrow {
    font-size: 0.65rem;
    animation: bounce-arrow 0.8s ease-in-out infinite;
}

@keyframes bounce-arrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(2px); }
}

.dialogue-text {
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    color: var(--light);
    line-height: 2.2;
    text-align: left;
    min-height: 5em;
}

.dialogue-counter {
    position: absolute;
    top: 6px;
    right: 10px;
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--light-dim);
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}


.press-start {
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
    animation: press-start-blink 1.2s ease-in-out infinite;
    cursor: pointer;
    padding: var(--space-md) var(--space-xl);
    border: 2px solid var(--gold);
    border-radius: var(--radius-sm);
    background: transparent;
    opacity: 0;
    transition: all 0.3s ease;
}

.press-start:hover {
    background: rgba(255, 215, 0, 0.1);
    box-shadow: 0 0 20px var(--gold-glow);
}

@keyframes press-start-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============================================
   SCENE: QUEST MAP
   ============================================ */
.quest-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    padding-bottom: var(--space-lg);
    scrollbar-width: thin;
}

.quest-map {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 320px;
}

.quest-node {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--wood-base);
    border: 4px solid;
    border-color: var(--wood-light) var(--wood-dark) var(--wood-dark) var(--wood-light);
    border-radius: 0;
    cursor: default;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
    position: relative;
}

.quest-node.active {
    border-color: #ffffff var(--wood-dark) var(--wood-dark) #ffffff;
    background: var(--wood-light);
    cursor: pointer;
}

.quest-node.completed {
    border-color: #88ff88 #006600 #006600 #88ff88;
    background: var(--secondary);
}

.quest-node.locked {
    background: #666666;
    border-color: #999999 #333333 #333333 #999999;
}

.quest-node-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: 2px solid var(--dark);
    background: var(--dark-3);
    flex-shrink: 0;
}

.quest-node.completed .quest-node-icon {
    background: var(--secondary-dark);
}

.quest-node.active .quest-node-icon {
    background: var(--primary);
    animation: pulse-soft 2s steps(2, end) infinite;
}

.quest-node-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

.quest-node-name {
    font-family: var(--font-pixel);
    font-size: 0.55rem;
    color: var(--light);
    text-shadow: 1px 1px 0 var(--dark);
    line-height: 1.6;
}

.quest-node.completed .quest-node-name {
    color: var(--dark);
    text-shadow: none;
}

.quest-node-desc {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--light-dim);
    line-height: 1.4;
}

.quest-node-status {
    position: absolute;
    right: var(--space-md);
    font-size: 1rem;
    text-shadow: 2px 2px 0 var(--dark);
}

.quest-connector {
    width: 8px;
    height: 20px;
    background: #444444;
    border-left: 2px solid #666666;
    border-right: 2px solid #222222;
    position: relative;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.quest-connector.completed {
    background: var(--secondary);
    border-left: 2px solid #88ff88;
    border-right: 2px solid #006600;
}

/* ============================================
   SCENE: PUZZLE (Enhanced)
   ============================================ */
.puzzle-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.puzzle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.puzzle-header .section-title {
    margin-bottom: 0;
    font-size: 0.7rem;
}

.puzzle-badge {
    font-size: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font-pixel);
    display: inline-block;
    box-shadow: 0 0 10px var(--primary-glow);
}

.puzzle-level-badge {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--gold);
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid var(--gold);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    text-shadow: 0 0 6px var(--gold-glow);
}

.puzzle-stats {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.move-counter, .puzzle-timer {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--light-muted);
    background: var(--glass-bg);
    padding: 6px var(--space-md);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    font-variant-numeric: tabular-nums;
    line-height: 1.6;
}

.puzzle-hint {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--light-dim);
    margin-bottom: var(--space-xs);
}

.puzzle-container {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    touch-action: manipulation;
    box-shadow: 0 0 20px var(--accent-glow), inset 0 0 30px rgba(0, 240, 255, 0.03);
    width: min(85vw, 380px);
    aspect-ratio: 1;
}

.puzzle-tile {
    position: absolute;
    cursor: pointer;
    border-radius: 3px;
    border: 1px solid rgba(0, 240, 255, 0.15);
    background-color: var(--dark-2);
    background-repeat: no-repeat;
    will-change: left, top;
    transition: border 0.2s var(--ease);
}

.puzzle-tile:hover {
    border: 2px solid var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    z-index: 2;
}

.puzzle-tile:active {
    border: 2px solid var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
}

.puzzle-preview-toggle {
    margin-top: var(--space-sm);
}

/* ============================================
   SCENE: MEMORY CARD GAME
   ============================================ */
.memory-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: min(85vw, 340px);
    aspect-ratio: 1;
}

.memory-card {
    aspect-ratio: 1;
    perspective: 600px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s var(--ease);
    transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}

.memory-card-back {
    background: var(--wood-base);
    border: 4px solid;
    border-color: var(--wood-light) var(--wood-dark) var(--wood-dark) var(--wood-light);
    color: var(--dark);
    font-size: 1.2rem;
}

.memory-card-back::after {
    content: '?';
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    color: var(--light);
    text-shadow: 2px 2px 0 var(--dark);
}

.memory-card:hover .memory-card-back {
    border-color: #ffffff var(--wood-dark) var(--wood-dark) #ffffff;
}

.memory-card-front {
    background: var(--light);
    border: 4px solid var(--dark);
    transform: rotateY(180deg);
}

.memory-card.matched .memory-card-front {
    border-color: var(--secondary);
    background: #eefbee;
}

/* ============================================
   SCENE: BOSS BATTLE (2D SHOOTER)
   ============================================ */
.boss-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    max-height: 800px;
    position: relative;
}

.boss-title {
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    color: var(--primary);
    text-shadow: 2px 2px 0 var(--dark);
    line-height: 1.5;
    margin-bottom: var(--space-md);
    animation: danger-pulse 1s steps(2, end) infinite alternate;
}

@keyframes danger-pulse {
    from { color: var(--primary); }
    to { color: var(--gold); }
}

/* Shooter Arena */
.shooter-arena {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 65vh;
    min-height: 400px;
    background: #000000;
    border: 6px solid;
    border-color: #666666 #222222 #222222 #666666;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
    touch-action: none;
}

/* Star background moving downwards */
.shooter-arena::before {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 200%;
    background-image: radial-gradient(white 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    animation: grid-scroll 2s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes grid-scroll {
    from { transform: translateY(0); }
    to { transform: translateY(40px); }
}

/* UI Overlays */
.boss-hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.boss-hud-name {
    font-family: var(--font-pixel);
    font-size: 0.4rem;
    color: var(--primary-light);
    letter-spacing: 2px;
}

.boss-hp-bar {
    width: 100%;
    max-width: 250px;
    height: 12px;
    background: #000000;
    border: 2px solid #ffffff;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.boss-hp-fill {
    height: 100%;
    width: 100%;
    background: var(--primary);
    transition: width 0.2s linear;
}

.player-hud {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 10;
    display: flex;
    gap: 4px;
}

.player-hud .heart {
    font-size: 1.2rem;
    filter: grayscale(1) brightness(0.5);
    transition: all 0.3s ease;
}

.player-hud .heart.active {
    filter: grayscale(0) drop-shadow(0 0 8px rgba(255, 45, 149, 0.6));
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Entities */
#gameEntities {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 5;
    pointer-events: none; /* Let drag events pass to arena */
}

.boss-sprite {
    position: absolute;
    width: 60px;
    height: 60px;
    left: 50%;
    top: 40px;
    transform: translateX(-50%);
    font-size: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(4px 4px 0 rgba(0,0,0,0.5));
    will-change: left, top, transform;
}

.player-ship {
    position: absolute;
    width: 40px;
    height: 40px;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5));
    will-change: left, top, transform;
}

/* Projectiles */
.projectile {
    position: absolute;
    border-radius: 50%;
    will-change: left, top;
}

.player-bullet {
    width: 4px;
    height: 15px;
    background: #00f0ff;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    border-radius: 0;
}

.boss-bullet {
    width: 10px;
    height: 10px;
    background: #ff0040;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    border-radius: 0;
    animation: bullet-spin 0.5s steps(2, end) infinite;
}

@keyframes bullet-spin {
    to { transform: rotate(180deg); }
}

/* Overlays */
.shooter-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(3px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.shooter-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.shooter-overlay h3 {
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    color: white;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
    text-align: center;
}

.shooter-overlay p {
    font-family: var(--font-pixel);
    font-size: 0.4rem;
    color: var(--accent);
    letter-spacing: 1px;
}

.boss-subtitle {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--light-muted);
    margin-top: var(--space-md);
}

/* Flash effect for hits */
.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 300;
    pointer-events: none;
    opacity: 0;
}

/* ============================================
   SCENE: TREASURE / SCRAPBOOK
   ============================================ */
.treasure-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    width: 100%;
    max-width: 420px;
    height: 80vh;
    height: 80dvh;
    max-height: 700px;
}

.treasure-title {
    flex-shrink: 0;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    color: var(--gold);
    text-shadow: 0 0 15px var(--gold-glow);
    line-height: 2;
}

.mystery-box-container {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: var(--space-2xl) auto;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

.mystery-box {
    position: relative;
    width: 120px;
    height: 120px;
    transition: transform 0.3s var(--ease);
}

.mystery-box:hover {
    transform: scale(1.05);
}

.box-body {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 90px;
    background: var(--wood-base);
    border: 6px solid;
    border-color: var(--wood-light) var(--wood-dark) var(--wood-dark) var(--wood-light);
    border-radius: 0;
    box-shadow: inset 0 0 0 4px rgba(0,0,0,0.3);
}

.box-lid {
    position: absolute;
    top: 15px;
    left: -5px;
    width: 130px;
    height: 35px;
    background: var(--wood-base);
    border: 6px solid;
    border-color: var(--wood-light) var(--wood-dark) var(--wood-dark) var(--wood-light);
    border-radius: 0;
    box-shadow: 0 4px 0 rgba(0,0,0,0.5);
    z-index: 5;
    transform-origin: center center;
}

.ribbon-vertical {
    position: absolute;
    left: 50%;
    top: 15px;
    transform: translateX(-50%);
    width: 20px;
    height: 105px;
    background: #555555; /* Iron latch color for chest */
    border: 2px solid #222222;
    z-index: 6;
    box-shadow: 2px 0 0 rgba(0,0,0,0.5);
}

.ribbon-horizontal {
    position: absolute;
    top: 55px;
    left: 0;
    width: 100%;
    height: 20px;
    background: #555555; /* Iron band */
    border-top: 2px solid #888888;
    border-bottom: 2px solid #222222;
    z-index: 4;
}

.bow {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: #ffaa00; /* Gold lock */
    border: 4px solid #cc8800;
    z-index: 10;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.bow::before, .bow::after {
    display: none;
}

.mystery-box-hint {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--light);
    margin-top: var(--space-xl);
    animation: blink-cursor 1.2s infinite;
    text-shadow: 2px 2px 0 var(--dark);
}

/* Animations */
.mystery-box.shake {
    animation: box-shake 0.5s ease-in-out;
}

.mystery-box.open .box-lid {
    animation: lid-fly 0.8s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mystery-box.open .bow,
.mystery-box.open .ribbon-vertical {
    animation: bow-fly 0.8s forwards;
}

@keyframes box-shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    20% { transform: translateX(-5px) rotate(-5deg); }
    40% { transform: translateX(5px) rotate(5deg); }
    60% { transform: translateX(-5px) rotate(-3deg); }
    80% { transform: translateX(5px) rotate(3deg); }
}

@keyframes lid-fly {
    0% { transform: translateY(0) rotate(0); }
    100% { transform: translateY(-100px) rotate(-25deg) scale(1.1); opacity: 0; }
}

@keyframes bow-fly {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-120px) scale(0); opacity: 0; }
}

/* Button style for Claim Reward */
.btn-claim-reward {
    background: linear-gradient(135deg, var(--gold), #ff8c00) !important;
    color: var(--dark) !important;
    border-color: #fff !important;
    box-shadow: 0 0 20px var(--gold-glow), inset 0 0 10px rgba(255,255,255,0.5) !important;
    animation: pulse-gold 1.5s infinite !important;
}

@keyframes pulse-gold {
    0% { box-shadow: 0 0 10px var(--gold-glow); }
    50% { box-shadow: 0 0 30px var(--gold-glow); transform: scale(1.05); }
    100% { box-shadow: 0 0 10px var(--gold-glow); }
}

/* ============================================
   RPG INVENTORY (Option 2)
   ============================================ */
.inventory-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    background: #000;
    border: 4px solid #fff;
    padding: var(--space-xl);
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.8), inset 0 0 0 4px #000;
}

.inventory-title {
    font-family: var(--font-pixel);
    color: var(--gold);
    font-size: 0.8rem;
    margin-bottom: var(--space-xl);
    text-shadow: 2px 2px 0 #000;
    text-align: center;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    width: 100%;
}

.inventory-slot {
    aspect-ratio: 1;
    background: #222;
    border: 2px solid #555;
    border-bottom-color: #111;
    border-right-color: #111;
    border-top-color: #888;
    border-left-color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s;
    position: relative;
}

.inventory-slot:hover {
    background: #333;
    border-color: #fff;
}

.inventory-slot:active {
    transform: scale(0.95);
    border-top-color: #111;
    border-left-color: #111;
    border-bottom-color: #888;
    border-right-color: #888;
}

.inventory-slot.viewed::after {
    content: '✓';
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.6rem;
    color: #0f0;
    font-family: var(--font-pixel);
    text-shadow: 1px 1px 0 #000;
}

.item-icon {
    font-size: 1.8rem;
    filter: drop-shadow(2px 2px 0 #000);
}

/* Item Modal */
.item-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.item-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.item-modal-content {
    background: #000;
    border: 4px solid #fff;
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90%;
    max-width: 400px;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 1), inset 0 0 0 4px #000;
}

.item-image-wrapper {
    width: 100%;
    aspect-ratio: 1;
    background: #111;
    border: 4px solid #555;
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

.item-text {
    font-family: var(--font-pixel);
    color: #fff;
    font-size: 0.6rem;
    line-height: 1.5;
    text-align: center;
    min-height: 3em;
}

/* ============================================
   SCENE: FINAL CUTSCENE
   ============================================ */
.final-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding-bottom: var(--space-2xl);
    background: #000;
    overflow: hidden;
    position: relative;
}

.rolling-credits {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2xl);
    position: absolute;
    width: 100%;
    max-width: 500px;
    padding: 0 var(--space-xl);
    bottom: -100%; /* GSAP will animate this */
    text-align: center;
}

.final-message {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: var(--space-2xl) 0;
    box-shadow: none;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.final-badge {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: var(--gold);
    background: transparent;
    border: 2px solid var(--gold);
    padding: 4px 12px;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 #000;
    display: inline-block;
    margin-bottom: var(--space-lg);
}

.final-title {
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    margin-bottom: var(--space-xl);
    color: var(--primary-light);
    text-shadow: 2px 2px 0 #000;
}

.final-text {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.final-text p {
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    line-height: 2;
    color: #fff;
    text-align: center;
}

.final-text p:first-child {
    font-size: 0.7rem;
    color: var(--gold);
}

.final-signature {
    text-align: center;
    border-top: 2px solid #fff;
    padding-top: var(--space-lg);
}

.final-signature p {
    font-family: var(--font-pixel);
    color: #aaa;
    font-size: 0.5rem;
}

.signature-name {
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    color: var(--gold) !important;
    font-style: normal;
    margin-top: var(--space-xs);
    text-shadow: 2px 2px 0 #000;
}

/* Game stats in final scene */
.game-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    gap: var(--space-sm);
}

.stat-box {
    background: #000;
    border: 2px solid #fff;
    border-radius: 0;
    padding: var(--space-sm);
    text-align: center;
    flex: 1;
}

.stat-value {
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    color: var(--accent);
    text-shadow: 2px 2px 0 #000;
}

.stat-label {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    color: #fff;
    margin-top: 8px;
}

/* ============================================
   PREVIEW MODAL
   ============================================ */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-xl);
}

.preview-modal.active { display: flex; }

.preview-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.preview-modal-content img {
    max-width: min(90vw, 400px);
    max-height: 60vh;
    border-radius: var(--radius);
    box-shadow: 0 0 20px var(--accent-glow);
    border: 2px solid var(--accent);
    object-fit: contain;
}

/* ============================================
   PUZZLE COMPLETE OVERLAY
   ============================================ */
.puzzle-complete-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 150;
    display: none;
    align-items: center;
    justify-content: center;
}

.puzzle-complete-overlay.active { display: flex; }

.puzzle-complete-content {
    text-align: center;
    padding: var(--space-2xl);
}

.puzzle-complete-content h2 {
    font-family: var(--font-pixel);
    font-size: clamp(0.7rem, 4vw, 1rem);
    margin-bottom: var(--space-md);
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold-glow);
    line-height: 2;
}

.puzzle-complete-content p {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--light-muted);
}

.puzzle-complete-xp {
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    color: var(--gold);
    text-shadow: 0 0 15px var(--gold-glow);
    margin-top: var(--space-md);
}

/* ============================================
   KEYFRAME ANIMATIONS
   ============================================ */
@keyframes pulse-soft {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

@keyframes neon-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
    20%, 24%, 55% { opacity: 0.5; }
}

@keyframes float-up-fade {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -150%) scale(1.5); }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Small phones */
@media (max-width: 380px) {
    :root {
        --space-lg: 20px;
        --space-xl: 28px;
    }

    .scene {
        padding: var(--space-md);
        padding-top: calc(var(--space-md) + 40px);
    }

    .game-title {
        font-size: 0.7rem;
    }

    .section-title {
        font-size: 0.7rem;
    }

    .btn {
        padding: var(--space-sm) var(--space-lg);
        font-size: 0.5rem;
    }

    .memory-grid {
        gap: 5px;
    }

    .memory-card-face {
        font-size: 1.3rem;
    }

    .loot-card {
        padding: 8px;
    }

    .scrapbook-swiper .swiper-slide {
        width: 220px;
    }

    .final-message {
        padding: var(--space-xl) var(--space-md);
    }

    .final-title {
        font-size: 1.5rem;
    }

    .game-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .stat-value { font-size: 0.55rem; }
    .stat-label { font-size: 0.6rem; }

    .quest-node {
        padding: var(--space-sm) var(--space-md);
    }

    .quest-node-name {
        font-size: 0.45rem;
    }

    .xp-bar-container {
        width: 70px;
    }
}

/* Taller phones */
@media (min-height: 700px) {
    .intro-content {
        gap: var(--space-2xl);
    }
}

/* Tablets / Desktop */
@media (min-width: 768px) {
    .scene-content {
        max-width: 500px;
    }

    .puzzle-container {
        width: min(55vw, 420px);
    }

    .treasure-content {
        max-width: 460px;
    }

    .memory-grid {
        width: min(55vw, 380px);
    }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    .game-title {
        font-size: 0.7rem;
    }

    .puzzle-container {
        width: min(45vh, 300px);
    }

    .memory-grid {
        width: min(45vh, 280px);
    }

    .treasure-content {
        height: 85vh;
    }
}

/* ============================================
   UTILITY
   ============================================ */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-glow-primary {
    text-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--primary-glow);
}

.text-glow-accent {
    text-shadow: 0 0 10px var(--accent-glow), 0 0 20px var(--accent-glow);
}

.text-glow-gold {
    text-shadow: 0 0 10px var(--gold-glow), 0 0 20px var(--gold-glow);
}
