/* ==========================================================
   SAMIN & RESA: THE RESCUE MISSION
   PREMIUM ARCADE BEAT 'EM UP & RETRO AESTHETIC UI
   Mobile & Touchscreen Native Optimization
   ========================================================== */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

:root {
    --primary-red: #ff2a5f;
    --flame-gold: #ffd200;
    --electric-cyan: #00f0ff;
    --neon-pink: #ff4181;
    --hud-bg: rgba(14, 12, 22, 0.88);
    --bezel-gold: linear-gradient(135deg, #ffd700 0%, #ff8c00 50%, #b8860b 100%);
    --arcade-font: 'Impact', 'Arial Black', -apple-system, sans-serif;
    --body-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000000;
    color: #ffffff;
    font-family: var(--body-font);
    position: fixed;
}

/* Master Game Container */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #05050a;
}

/* Screen Scanline / Arcade CRT Filter (Subtle & Atmospheric) */
#game-container::after {
    content: " ";
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
                radial-gradient(circle at center, transparent 65%, rgba(0, 0, 0, 0.45) 100%);
    background-size: 100% 3px, 100% 100%;
    pointer-events: none;
    z-index: 8;
    opacity: 0.7;
}

/* Canvas Display */
#gameCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    display: block;
    z-index: 1;
}

/* Screen Transitions */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
}

.screen.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================================
   1. AUTHENTIC GAMELOFT-STYLE CINEMATIC INTRO
   ========================================================== */
#intro-screen {
    background: radial-gradient(circle at center, #111422 0%, #06070c 70%, #000000 100%);
    z-index: 100;
}

.gameloft-viewport {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Cinematic Anamorphic Letterbox Bars */
.cinema-bar {
    position: absolute;
    left: 0;
    width: 100%;
    height: 9vh;
    background: #000;
    z-index: 10;
}
.cinema-bar.top { top: 0; }
.cinema-bar.bottom { bottom: 0; }

.gameloft-logo-card {
    position: relative;
    width: 220px;
    height: 220px;
    max-width: 65vw;
    max-height: 65vw;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: gameloftScaleIn 3.4s cubic-bezier(0.12, 0.85, 0.3, 1) forwards;
}

.gameloft-logo-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 16px;
    filter: drop-shadow(0 0 25px rgba(255, 255, 255, 0.45));
}

/* Anamorphic Lens Flare Ray */
.gameloft-flare {
    position: absolute;
    top: 0;
    left: -180%;
    width: 120%;
    height: 100%;
    background: linear-gradient(
        110deg,
        transparent 20%,
        rgba(255, 255, 255, 0.85) 48%,
        rgba(0, 240, 255, 0.95) 52%,
        transparent 75%
    );
    transform: skewX(-25deg);
    pointer-events: none;
    animation: flareRaySweep 2.2s ease-in-out 0.8s forwards;
}

.gameloft-caption {
    margin-top: 26px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 6px;
    color: #e0f2fe;
    text-transform: uppercase;
    text-shadow: 0 0 14px rgba(0, 240, 255, 0.85);
    opacity: 0;
    animation: textFadeIn 1.2s ease 1.1s forwards;
}

.intro-skip-pill {
    position: absolute;
    bottom: 40px;
    right: 25px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 7px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    backdrop-filter: blur(6px);
    z-index: 15;
}

@keyframes gameloftScaleIn {
    0% { transform: scale(0.6) translateY(20px); opacity: 0; filter: blur(6px) brightness(0.2); }
    25% { opacity: 1; filter: blur(0px) brightness(1.25); }
    80% { transform: scale(1.05); filter: brightness(1.05); }
    100% { transform: scale(1); opacity: 1; filter: brightness(1); }
}

@keyframes flareRaySweep {
    0% { left: -180%; }
    100% { left: 220%; }
}

@keyframes textFadeIn {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   2. ARCADE TITLE SCREEN
   ========================================================== */
#title-screen {
    background: linear-gradient(180deg, rgba(8, 8, 20, 0.82) 0%, rgba(30, 8, 25, 0.92) 100%);
    backdrop-filter: blur(4px);
    text-align: center;
}

.title-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 520px;
    width: 92%;
    padding: 20px;
}

.arcade-badge {
    background: linear-gradient(90deg, #ff1744, #ff5252);
    color: #fff;
    font-family: var(--arcade-font);
    font-size: 12px;
    letter-spacing: 3px;
    padding: 4px 16px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 0 15px rgba(255, 23, 68, 0.7);
    margin-bottom: 12px;
}

.title-logo-text {
    font-family: var(--arcade-font);
    font-size: clamp(34px, 9vw, 62px);
    line-height: 0.98;
    text-transform: uppercase;
    background: linear-gradient(180deg, #ffffff 15%, #ff80ab 60%, #ff1744 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 18px rgba(255, 23, 68, 0.85));
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.title-subtext {
    font-family: var(--arcade-font);
    font-size: clamp(14px, 4vw, 20px);
    color: var(--flame-gold);
    letter-spacing: 4px;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(255, 210, 0, 0.75), 2px 2px 0 #000;
    margin-bottom: 24px;
}

.title-roster-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 30px;
}

.roster-card {
    position: relative;
    width: 95px;
    height: 105px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.8));
    animation: titleFloat 2.2s ease-in-out infinite alternate;
}

.roster-card.samin {
    background-image: url('sprites/frames/samin_stance.png');
}

.roster-card.resa {
    background-image: url('sprites/frames/resa_idle_0.png');
    animation-delay: 0.6s;
}

.arcade-vs-pill {
    font-family: var(--arcade-font);
    font-size: 26px;
    color: #ff2a5f;
    text-shadow: 0 0 15px rgba(255, 42, 95, 0.9), 2px 2px 0 #000;
    animation: vsPulse 1.2s infinite;
}

@keyframes titleFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

@keyframes vsPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* Insert Coin / Play Button */
.btn-arcade-start {
    background: linear-gradient(180deg, #ff3366 0%, #d80032 50%, #80001c 100%);
    border: 3px solid #ff7597;
    border-radius: 8px;
    padding: 16px 42px;
    font-family: var(--arcade-font);
    font-size: clamp(20px, 5.5vw, 26px);
    letter-spacing: 2.5px;
    color: #ffffff;
    text-transform: uppercase;
    box-shadow: 0 8px 25px rgba(255, 51, 102, 0.65), inset 0 2px 0 rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.1s ease, filter 0.1s ease;
}

.btn-arcade-start:active {
    transform: scale(0.95);
    filter: brightness(1.2);
}

.arcade-instructions-pill {
    margin-top: 20px;
    font-size: 12px;
    font-weight: 700;
    color: #cbd5e1;
    letter-spacing: 1px;
}

/* ==========================================================
   3. MANGA / COMIC STORY CUTSCENE
   ========================================================== */
#story-screen {
    background: rgba(6, 6, 14, 0.94);
    backdrop-filter: blur(10px);
    padding: 18px;
}

.manga-panel-container {
    width: 100%;
    max-width: 580px;
    margin: auto;
    display: flex;
    flex-direction: column;
}

.manga-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.manga-step-title {
    font-family: var(--arcade-font);
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--flame-gold);
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(255, 210, 0, 0.6);
}

.manga-frame {
    position: relative;
    background: #0f0a18;
    border: 3px solid #ff2a5f;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.8), 0 0 25px rgba(255, 42, 95, 0.35);
}

.manga-art-stage {
    position: relative;
    width: 100%;
    height: 190px;
    background: radial-gradient(circle at center, #231230 0%, #0c0816 100%);
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

/* Manga Speedlines */
.manga-speedlines {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.05) 0deg 8deg, transparent 8deg 16deg);
    pointer-events: none;
}

.manga-char {
    position: absolute;
    bottom: 5px;
    width: 130px;
    height: 130px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    transition: all 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.manga-dialogue-card {
    padding: 16px 20px;
    background: #140d20;
    border-top: 2px solid rgba(255, 42, 95, 0.4);
    text-align: left;
}

.manga-speaker-name {
    font-family: var(--arcade-font);
    font-size: 16px;
    letter-spacing: 1.5px;
    color: #ff4181;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.manga-dialogue-body {
    font-size: 15px;
    line-height: 1.45;
    color: #f1f5f9;
    min-height: 48px;
}

.manga-footer-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

.btn-manga-skip {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #e2e8f0;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
}

.btn-manga-next {
    background: linear-gradient(180deg, #ff2a5f 0%, #c20038 100%);
    border: 2px solid #ff7b9b;
    border-radius: 6px;
    color: #fff;
    padding: 10px 28px;
    font-family: var(--arcade-font);
    font-size: 16px;
    letter-spacing: 1.5px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(255, 42, 95, 0.5);
}

/* ==========================================================
   4. AUTHENTIC FIGHTING GAME HUD
   ========================================================== */
#hud-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
    display: none;
}

#hud-overlay.active {
    display: block;
}

.hud-top-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Player Gauge (Street Fighter Style) */
.fighter-gauge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fighter-portrait-bezel {
    width: 48px;
    height: 48px;
    border: 3px solid #ff2a5f;
    border-radius: 6px;
    background: #110d18;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(255, 42, 95, 0.75);
    position: relative;
}

.fighter-portrait {
    width: 100%;
    height: 100%;
    background: url('sprites/frames/samin_idle_0.png') no-repeat center top;
    background-size: 175%;
}

.fighter-bars-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fighter-name-tag {
    font-family: var(--arcade-font);
    font-size: 13px;
    letter-spacing: 1.5px;
    color: #ffffff;
    text-shadow: 1px 1px 0 #000, 0 0 8px rgba(255, 42, 95, 0.8);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Angular Slanted Life Gauge */
.hp-gauge-frame {
    position: relative;
    width: 135px;
    height: 15px;
    background: #181520;
    border: 2px solid #ffffff;
    transform: skewX(-16deg);
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
}

/* Chip Damage Red Drain Lag Bar */
.hp-lag-fill {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #ff0033;
    transition: width 0.75s ease-out;
}

/* Main Active Yellow-Green Health Bar */
.hp-active-fill {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, #ffd700 0%, #00e676 100%);
    transition: width 0.15s ease-out;
}

/* Super Energy Gauge */
.super-gauge-frame {
    position: relative;
    width: 120px;
    height: 9px;
    background: #151022;
    border: 1px solid #00f0ff;
    transform: skewX(-16deg);
    overflow: hidden;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

.super-active-fill {
    position: absolute;
    top: 0; left: 0;
    width: 0%; height: 100%;
    background: linear-gradient(90deg, #00f0ff, #ff007f);
    transition: width 0.2s ease;
}

/* Boss Life Gauge */
.boss-gauge-bezel {
    display: none;
    align-items: center;
    gap: 8px;
    flex-direction: row-reverse;
}

.boss-gauge-bezel.visible {
    display: flex;
}

.boss-hp-frame {
    width: 130px;
    height: 15px;
    background: #1a0808;
    border: 2px solid #ff4500;
    transform: skewX(16deg);
    overflow: hidden;
    position: relative;
}

.boss-hp-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff1744 0%, #ff6d00 100%);
    transition: width 0.2s ease-out;
}

/* Arcade Combo Counter */
.arcade-combo-card {
    position: absolute;
    top: 80px;
    left: 18px;
    text-align: left;
    opacity: 0;
    transform: scale(0.7) skewX(-12deg);
    transition: all 0.15s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    pointer-events: none;
}

.arcade-combo-card.active {
    opacity: 1;
    transform: scale(1.1) skewX(-12deg);
}

.combo-hits-number {
    font-family: var(--arcade-font);
    font-size: 36px;
    line-height: 0.9;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.9), 3px 3px 0 #000;
}

.combo-rating-label {
    font-family: var(--arcade-font);
    font-size: 14px;
    letter-spacing: 2px;
    color: #ff2a5f;
    text-shadow: 0 0 10px rgba(255, 42, 95, 0.8), 1px 1px 0 #000;
    text-transform: uppercase;
}

/* ==========================================================
   5. SANWA-STYLE ARCADE TOUCH CONTROLS
   ========================================================== */
#touch-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    pointer-events: none;
    z-index: 15;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 15px 18px 24px 18px;
}

/* Left Virtual D-Pad Cluster (4-Way Arcade Layout) */
.arcade-dpad {
    position: relative;
    width: 150px;
    height: 150px;
    pointer-events: auto;
}

.dpad-key {
    position: absolute;
    width: 48px;
    height: 48px;
    background: linear-gradient(180deg, #2a2c38 0%, #171822 100%);
    border: 2px solid #4a4d62;
    border-radius: 10px;
    color: #cbd5e1;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 12px rgba(0,0,0,0.6), inset 0 2px 2px rgba(255,255,255,0.25);
    cursor: pointer;
    transition: transform 0.08s ease, background 0.08s ease;
}

.dpad-key:active, .dpad-key.pressed {
    transform: scale(0.92);
    background: #ff2a5f;
    border-color: #ff80a0;
    color: #fff;
    box-shadow: 0 0 14px rgba(255, 42, 95, 0.7);
}

.dpad-key.up { top: 0; left: 51px; }
.dpad-key.down { bottom: 0; left: 51px; }
.dpad-key.left { top: 51px; left: 0; }
.dpad-key.right { top: 51px; right: 0; }
.dpad-center {
    position: absolute;
    top: 53px; left: 53px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: #1b1c26;
    border: 1px solid #333647;
    pointer-events: none;
}

/* Right Sanwa Arcade Action Buttons */
.arcade-buttons-grid {
    position: relative;
    width: 170px;
    height: 150px;
    pointer-events: auto;
}

.sanwa-btn {
    position: absolute;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--arcade-font);
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0,0,0,0.65), inset 0 3px 5px rgba(255,255,255,0.45);
    transition: transform 0.08s ease, filter 0.08s ease;
}

.sanwa-btn:active, .sanwa-btn.pressed {
    transform: scale(0.90) translateY(4px);
    filter: brightness(1.3);
}

/* Button 1: JUMP (Blue) */
.btn-act-jump {
    width: 60px; height: 60px;
    bottom: 74px; left: 10px;
    background: radial-gradient(circle at 35% 35%, #00e5ff 0%, #0088cc 70%, #004477 100%);
    border: 3px solid #66f0ff;
    color: #fff;
}

/* Button 2: PUNCH (Red) */
.btn-act-punch {
    width: 68px; height: 68px;
    bottom: 6px; left: 24px;
    background: radial-gradient(circle at 35% 35%, #ff3b68 0%, #d80032 70%, #680017 100%);
    border: 3px solid #ff88a3;
    color: #fff;
}

/* Button 3: KICK (Orange-Amber) */
.btn-act-kick {
    width: 68px; height: 68px;
    bottom: 66px; right: 6px;
    background: radial-gradient(circle at 35% 35%, #ff9900 0%, #cc5500 70%, #662b00 100%);
    border: 3px solid #ffbe66;
    color: #fff;
}

/* Button 4: SUPER LOVE DASH (Gold Star) */
.btn-act-super {
    width: 58px; height: 58px;
    bottom: 2px; right: 14px;
    background: radial-gradient(circle at 35% 35%, #ffd700 0%, #ff8c00 70%, #804600 100%);
    border: 2px dashed #ffe680;
    color: #fff;
    opacity: 0.65;
}

.btn-act-super.ready {
    opacity: 1;
    border-style: solid;
    animation: superGlowPulse 0.85s infinite alternate;
}

@keyframes superGlowPulse {
    0% { transform: scale(1); box-shadow: 0 0 15px rgba(255, 215, 0, 0.7); }
    100% { transform: scale(1.12); box-shadow: 0 0 28px rgba(255, 215, 0, 1), 0 0 45px rgba(255, 42, 95, 0.8); }
}

.sanwa-icon { font-size: 22px; line-height: 1; }
.sanwa-label { font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; margin-top: 2px; }

/* ==========================================================
   6. PREMIUM ROMANTIC VICTORY / MISSION ACCOMPLISHED SCREEN
   ========================================================== */
#ending-screen {
    background: radial-gradient(circle at center, rgba(38, 14, 42, 0.96) 0%, rgba(10, 4, 15, 0.98) 100%);
    backdrop-filter: blur(14px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 12px 60px 12px;
    justify-content: flex-start;
}

.victory-scroll-card {
    width: 100%;
    max-width: 620px;
    margin: 8px auto;
    background: rgba(24, 11, 28, 0.88);
    border: 3px solid #ff3366;
    border-radius: 24px;
    padding: 24px 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9), 0 0 40px rgba(255, 51, 102, 0.4);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Animated Gilded Border Aura */
.victory-scroll-card::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: conic-gradient(
        transparent,
        rgba(255, 42, 95, 0.35),
        rgba(255, 215, 0, 0.5),
        rgba(255, 105, 180, 0.35),
        transparent 55%
    );
    animation: rotateAura 10s linear infinite;
    z-index: -1;
}

@keyframes rotateAura {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Cinematic View Toggle Tabs */
.ending-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #cbd5e1;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: linear-gradient(135deg, #ff2a5f, #ff758c);
    border-color: #ff80a0;
    color: #fff;
    box-shadow: 0 0 12px rgba(255, 42, 95, 0.6);
}

.victory-sprites-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.victory-char-sprite {
    width: 95px; height: 95px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    filter: drop-shadow(0 8px 18px rgba(255, 42, 95, 0.5));
}

.victory-char-sprite.samin {
    background-image: url('sprites/frames/samin_cheer.png');
    animation: bounceDuo 1.4s ease-in-out infinite alternate;
}

.victory-char-sprite.resa {
    background-image: url('sprites/frames/resa_idle_2.png');
    animation: bounceDuo 1.4s ease-in-out infinite alternate 0.35s;
}

@keyframes bounceDuo {
    0% { transform: translateY(0); }
    100% { transform: translateY(-12px); }
}

.victory-big-title {
    font-family: var(--arcade-font);
    font-size: clamp(24px, 6.8vw, 36px);
    letter-spacing: 2px;
    color: #ff2a5f;
    text-shadow: 0 0 16px rgba(255, 42, 95, 0.85);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.victory-sub-title {
    font-size: clamp(16px, 4.2vw, 20px);
    font-weight: 800;
    color: var(--flame-gold);
    letter-spacing: 1.5px;
    text-shadow: 0 0 12px rgba(255, 210, 0, 0.65);
    margin-bottom: 14px;
}

/* Audio Waveform Indicator */
.bgm-wave-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #ff80ab;
    font-weight: 700;
}

.wave-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 16px;
}

.wave-bar {
    width: 3px;
    background: #ff2a5f;
    border-radius: 2px;
    animation: waveJump 0.75s ease-in-out infinite alternate;
}
.wave-bar:nth-child(2) { animation-delay: 0.15s; height: 12px; }
.wave-bar:nth-child(3) { animation-delay: 0.35s; height: 16px; }
.wave-bar:nth-child(4) { animation-delay: 0.2s; height: 9px; }

@keyframes waveJump {
    0% { height: 3px; }
    100% { height: 16px; }
}

/* --- Storybook Slide Mode --- */
.storybook-container {
    width: 100%;
    min-height: 240px;
    margin-bottom: 18px;
    position: relative;
}

.story-slide {
    display: none;
    flex-direction: column;
    align-items: center;
    background: rgba(14, 7, 18, 0.82);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 18px;
    padding: 24px 18px;
    text-align: center;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
    animation: slideFadeIn 0.4s ease;
}

.story-slide.active {
    display: flex;
}

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

.slide-chapter-tag {
    font-size: 12px;
    font-weight: 800;
    color: var(--flame-gold);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.slide-content-text {
    font-size: clamp(15px, 4vw, 17px);
    line-height: 1.65;
    color: #f8fafc;
    margin-bottom: 14px;
}

.slide-highlight-gold {
    font-size: clamp(17px, 4.5vw, 20px);
    font-weight: 800;
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
    margin: 12px 0;
    line-height: 1.4;
}

.slide-decree-box {
    margin-top: 10px;
    padding: 14px;
    background: rgba(255, 42, 95, 0.18);
    border: 1px dashed #ff2a5f;
    border-radius: 12px;
    color: #fecdd3;
    font-weight: 700;
    line-height: 1.5;
}

.storybook-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 14px;
}

.btn-slide-nav {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

.slide-dots {
    display: flex;
    gap: 6px;
}

.slide-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.slide-dot.active {
    background: #ff2a5f;
    width: 20px;
    border-radius: 10px;
}

/* --- Full Love Letter View --- */
.love-scroll-parchment {
    display: none;
    background: rgba(14, 7, 18, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 18px;
    padding: 22px 18px;
    text-align: left;
    margin-bottom: 24px;
}

.love-scroll-parchment.active {
    display: block;
}

.reward-heading {
    font-size: 16px;
    font-weight: 800;
    color: #ff80ab;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reward-items {
    list-style: none;
    margin-bottom: 18px;
    padding-left: 4px;
}

.reward-items li {
    font-size: 15px;
    line-height: 1.8;
    color: #fde8ee;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.love-prose {
    font-size: 15px;
    line-height: 1.6;
    color: #f1f5f9;
    margin-bottom: 14px;
}

.love-highlight {
    font-size: 17px;
    font-weight: 800;
    color: var(--flame-gold);
    text-align: center;
    margin: 18px 0;
    line-height: 1.4;
    text-shadow: 0 0 10px rgba(255, 210, 0, 0.5);
}

.love-ps-box {
    margin-top: 14px;
    padding: 14px;
    background: rgba(255, 42, 95, 0.16);
    border-left: 4px solid #ff2a5f;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #fecdd3;
    line-height: 1.5;
}

/* Interactive Affection Toolbar */
.affection-toolbar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
    width: 100%;
}

.btn-affection {
    background: rgba(255, 42, 95, 0.2);
    border: 1.5px solid #ff3366;
    border-radius: 12px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.1s ease, background 0.1s ease;
}

.btn-affection:active {
    transform: scale(0.95);
    background: #ff2a5f;
}

/* Interactive Action Buttons */
.victory-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-arcade-replay {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #e2e8f0;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1.5px;
    padding: 12px 24px;
    cursor: pointer;
    text-transform: uppercase;
}

/* Confetti Container */
#fx-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 999;
}

.floating-heart {
    position: absolute;
    pointer-events: none;
    font-size: 26px;
    animation: loveFloat 2.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes loveFloat {
    0% { opacity: 1; transform: translateY(0) scale(0.6) rotate(0deg); }
    100% { opacity: 0; transform: translateY(-280px) scale(1.6) rotate(35deg); }
}

/* Utility Bar (Sound & Fullscreen) */
.hud-util-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.btn-hud-util {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(20, 20, 35, 0.7);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: transform 0.1s ease, background 0.1s ease;
}

.btn-hud-util:active {
    transform: scale(0.9);
    background: #ff2a5f;
}

/* Portrait Orientation Helper Banner */
.rotate-hint-banner {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(14, 10, 24, 0.92);
    border: 1px solid #ffd700;
    border-radius: 25px;
    padding: 8px 16px;
    color: #ffd700;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7), 0 0 10px rgba(255, 215, 0, 0.4);
    animation: bannerPulse 2s infinite alternate;
}

.btn-dismiss-rotate {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
}

@keyframes bannerPulse {
    0% { transform: translateX(-50%) scale(1); }
    100% { transform: translateX(-50%) scale(1.03); }
}

/* Mobile Screen & Safe Area Optimizations */
@media (max-width: 900px) {
    #touch-controls {
        height: 180px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .hud-top-bar {
        padding-top: max(8px, env(safe-area-inset-top));
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }
}

/* Portrait Mobile Handling */
@media (orientation: portrait) and (max-width: 768px) {
    .rotate-hint-banner {
        display: flex;
    }

    .arcade-dpad {
        transform: scale(0.9);
        transform-origin: bottom left;
    }

    .arcade-buttons-grid {
        transform: scale(0.9);
        transform-origin: bottom right;
    }
}
