/* ==========================================================================
   ROMANTIC 2D PLATFORMER + VISUAL NOVEL STYLES
   Pastel Pink, Purple, Soft White & Pixel-Art Aesthetic
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Nunito:wght@600;800;900&display=swap');

:root {
    --primary-pink: #ff7597;
    --primary-pink-hover: #ff527b;
    --pastel-pink: #ffd6e0;
    --soft-blush: #ffeef2;
    --lavender: #c8b6ff;
    --dark-purple: #231942;
    --deep-bg: #130e24;
    --accent-gold: #ffbe0b;
    --text-dark: #3a2e39;
    --text-light: #ffffff;
    --shadow-soft: 0 8px 24px rgba(255, 117, 151, 0.25);
    --border-cute: 3px solid #ffb3c6;
}

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

html, body {
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

body {
    background: radial-gradient(circle at 50% 20%, #2e1a47 0%, #160f29 70%, #0d091a 100%);
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow-x: hidden;
}

.game-wrapper {
    width: min(980px, 100vw - 20px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

/* --- HUD TOP BAR --- */
.hud-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    background: rgba(35, 25, 66, 0.85);
    border: 2px solid var(--primary-pink);
    border-radius: 14px;
    padding: 8px 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
}

.hud-title {
    font-family: 'Fredoka', cursive;
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 700;
    color: #ffc2d1;
    letter-spacing: 0.03em;
    text-shadow: 0 2px 8px rgba(255, 117, 151, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-counters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hud-counter-badge {
    background: rgba(255, 117, 151, 0.2);
    border: 1.5px solid var(--primary-pink);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 14px;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(255, 117, 151, 0.2);
    animation: pulseGlow 2.5s infinite ease-in-out;
}

.hud-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-btn {
    background: linear-gradient(135deg, var(--primary-pink), #e05780);
    border: none;
    border-radius: 20px;
    color: white;
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 800;
    padding: 6px 14px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(224, 87, 128, 0.4);
    transition: all 0.18s ease;
}

.hud-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #ff8fa3, #ff527b);
    box-shadow: 0 5px 14px rgba(255, 82, 123, 0.5);
}

.hud-btn:active {
    transform: translateY(1px);
}

.hud-btn-mini {
    background: rgba(200, 182, 255, 0.2);
    border: 1px solid var(--lavender);
    color: var(--lavender);
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hud-btn-mini:hover {
    background: rgba(200, 182, 255, 0.4);
    color: white;
}

/* --- CANVAS CONTAINER & FRAME --- */
.canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 540px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 3px var(--primary-pink);
    background: #000000;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* --- OVERLAY Z-INDEX HIERARCHY --- */
.interaction-prompt {
    position: absolute;
    transform: translate(-50%, -100%);
    background: linear-gradient(135deg, #ff7597, #ff4d6d);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 800;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 77, 109, 0.5);
    border: 2px solid #ffffff;
    animation: floatBob 1.2s infinite ease-in-out;
    z-index: 15;
    white-space: nowrap;
}

/* Background Scene Overlays (Sit under dialogue: z-index 25-35) */
.proposal-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 30%, #3a1c71 0%, #1d1135 60%, #0d061a 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 12px;
    z-index: 45;
    overflow-y: auto;
}

.goodbye-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, #1e1b2e 0%, #110e1c 70%, #07050d 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 30;
    animation: fadeIn 1s ease;
}

.level-complete-overlay {
    position: absolute;
    inset: 0;
    background: rgba(22, 14, 40, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 35;
}

/* Foreground UI Overlays: Dialogue (z-index 50), MCQ (z-index 60), Loading (100) */
.vn-dialogue-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 10, 25, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 12px 16px 16px 16px;
    z-index: 50;
    overflow: hidden;
    transition: opacity 0.25s ease;
}

/* Meeting Full-Body Character Illustration Stage */
.vn-pair-stage {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    width: 100%;
    flex: 1;
    min-height: 0;
    margin-bottom: -10px;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
    animation: gentlePop 0.35s ease-out;
}

.vn-pair-img {
    height: auto;
    max-height: 100%;
    max-width: 85%;
    object-fit: contain;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.65));
    user-select: none;
    -webkit-user-drag: none;
}

.vn-dialogue-box {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.vn-portrait-wrap {
    width: 130px;
    height: 130px;
    min-width: 130px;
    background: radial-gradient(circle, #fff0f5 0%, #ffd6e0 80%);
    border: 3px solid #ff7597;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 16px rgba(255, 117, 151, 0.4);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#vn-portrait-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

.vn-content-wrap {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #ff7597;
    border-radius: 18px;
    padding: 16px 22px;
    position: relative;
    min-height: 110px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(255, 117, 151, 0.25);
    cursor: pointer;
}

.vn-speaker-tag {
    position: absolute;
    top: -14px;
    left: 20px;
    background: linear-gradient(135deg, #ff7597, #ff4d6d);
    color: white;
    font-family: 'Fredoka', cursive;
    font-size: 15px;
    font-weight: 700;
    padding: 3px 18px;
    border-radius: 12px;
    border: 2px solid #ffffff;
    box-shadow: 0 3px 10px rgba(255, 77, 109, 0.4);
    letter-spacing: 0.05em;
}

.vn-speaker-tag[data-speaker="girl"] {
    background: linear-gradient(135deg, #c77dff, #9d4edd);
}

.vn-speaker-tag[data-speaker="boy"] {
    background: linear-gradient(135deg, #ff7597, #e05780);
}

.vn-text {
    color: var(--text-dark);
    font-size: clamp(16px, 2.1vw, 20px);
    font-weight: 700;
    line-height: 1.45;
    margin-top: 4px;
    min-height: 48px;
    word-break: break-word;
}

.vn-next-indicator {
    position: absolute;
    bottom: 12px;
    right: 18px;
    color: var(--primary-pink);
    font-size: 16px;
    animation: bounceDown 0.8s infinite alternate ease-in-out;
}

/* SKIP DIALOGUE BUTTON */
.vn-skip-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 700;
    background: linear-gradient(135deg, rgba(255, 117, 151, 0.45), rgba(255, 42, 85, 0.45));
    border: 1.5px solid #ff7597;
    color: #ffffff;
    border-radius: 16px;
    padding: 6px 14px;
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.vn-skip-btn:hover,
.vn-skip-btn:active {
    background: linear-gradient(135deg, #ff7597, #ff2a55);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(255, 77, 109, 0.6);
}

/* --- MCQ MODAL OVERLAY --- */
.mcq-overlay {
    position: absolute;
    inset: 0;
    background: rgba(18, 12, 32, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 60;
}

.mcq-card {
    background: linear-gradient(160deg, #fff5f8 0%, #ffe8ee 100%);
    border: 3px solid #ff7597;
    border-radius: 24px;
    padding: 24px 28px;
    width: min(540px, 92vw);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 117, 151, 0.35);
    text-align: center;
    animation: popIn 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mcq-badge {
    display: inline-block;
    background: linear-gradient(135deg, #ff7597, #ff4d6d);
    color: white;
    font-family: 'Fredoka', cursive;
    font-size: 14px;
    font-weight: 700;
    padding: 4px 18px;
    border-radius: 14px;
    margin-bottom: 14px;
    box-shadow: 0 3px 10px rgba(255, 77, 109, 0.3);
}

.mcq-question-text {
    color: var(--text-dark);
    font-size: clamp(17px, 2.2vw, 21px);
    font-weight: 800;
    line-height: 1.4;
    margin-bottom: 20px;
}

.mcq-options-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.mcq-choice-btn {
    background: #ffffff;
    border: 2px solid #ffccd5;
    border-radius: 14px;
    color: var(--text-dark);
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 800;
    padding: 12px 18px;
    cursor: pointer;
    transition: all 0.16s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
    text-align: left;
}

.mcq-choice-btn:hover {
    border-color: #ff7597;
    background: #fff0f3;
    transform: translateX(4px);
}

.mcq-choice-btn.correct {
    background: #d8f3dc;
    border-color: #52b788;
    color: #1b4332;
    transform: scale(1.02);
}

.mcq-choice-btn.wrong {
    background: #ffe5d9;
    border-color: #e63946;
    color: #9d0208;
    animation: shake 0.4s ease-in-out;
}

.mcq-feedback {
    min-height: 24px;
    font-size: 15px;
    font-weight: 800;
    transition: all 0.2s ease;
}

.correct-toast {
    color: #2d6a4f;
}

.wrong-toast {
    color: #d90429;
}

/* --- LEVEL COMPLETE OVERLAY --- */
.complete-card {
    background: linear-gradient(145deg, #ffffff, #fff0f3);
    border: 4px solid var(--primary-pink);
    border-radius: 28px;
    padding: 32px 36px;
    text-align: center;
    width: min(480px, 90vw);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 117, 151, 0.4);
    animation: popIn 0.3s ease;
}

.complete-title {
    font-family: 'Fredoka', cursive;
    font-size: 26px;
    color: #ff4d6d;
    margin-bottom: 10px;
}

.complete-msg {
    color: var(--text-dark);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 24px;
}

.btn-romantic-action {
    background: linear-gradient(135deg, #ff7597, #ff4d6d);
    color: white;
    border: none;
    border-radius: 24px;
    padding: 12px 30px;
    font-family: 'Nunito', sans-serif;
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 77, 109, 0.4);
    transition: all 0.18s ease;
}

.btn-romantic-action:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 25px rgba(255, 77, 109, 0.6);
}

/* --- SECTION 7 & 8: PROPOSAL & HAPPY ENDING SCENE --- */
.proposal-portraits-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 650px;
    margin: 0 auto 12px;
}

.proposal-portrait-box {
    width: 100px;
    height: 100px;
    border-radius: 18px;
    background: radial-gradient(circle, #fff0f5 0%, #ffd6e0 90%);
    border: 3px solid #ff7597;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 16px rgba(255, 117, 151, 0.4);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.proposal-portrait-box canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.proposal-heart-center {
    font-size: 38px;
    color: #ff4d6d;
    animation: heartPulse 1.2s infinite ease-in-out;
    flex-shrink: 0;
}

.proposal-choices-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    z-index: 55;
    animation: popIn 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.proposal-decision-title {
    font-family: 'Fredoka', cursive;
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.5px;
}

.proposal-buttons-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.btn-proposal-choice {
    color: white;
    border: 3px solid #ffffff;
    border-radius: 28px;
    padding: 12px 32px;
    font-family: 'Fredoka', cursive;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.btn-choice-yes {
    background: linear-gradient(135deg, #ff7597, #ff2a55);
    box-shadow: 0 8px 24px rgba(255, 42, 85, 0.6);
}

.btn-choice-yes:hover {
    transform: translateY(-4px) scale(1.06);
    background: linear-gradient(135deg, #ff8fa3, #ff2a55);
    box-shadow: 0 12px 30px rgba(255, 42, 85, 0.7);
}

.btn-choice-no {
    background: linear-gradient(135deg, #6c757d, #495057);
    border-color: #adb5bd;
    box-shadow: 0 8px 24px rgba(108, 117, 125, 0.4);
}

.btn-choice-no:hover {
    transform: translateY(-4px) scale(1.06);
    background: linear-gradient(135deg, #868e96, #343a40);
    box-shadow: 0 12px 30px rgba(52, 58, 64, 0.6);
}

.happy-ending-banner {
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #ff7597;
    border-radius: 24px;
    padding: 14px 28px;
    font-family: 'Fredoka', cursive;
    font-size: 22px;
    color: #ff4d6d;
    box-shadow: 0 12px 35px rgba(255, 77, 109, 0.5);
    animation: floatBob 2s infinite ease-in-out;
    white-space: nowrap;
    margin: 30px auto;
    z-index: 55;
}

.sad-ending-banner {
    background: rgba(25, 20, 35, 0.95);
    border: 3px solid #6c757d;
    border-radius: 24px;
    padding: 14px 28px;
    font-family: 'Fredoka', cursive;
    font-size: 22px;
    color: #ced4da;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7);
    animation: floatBob 2s infinite ease-in-out;
    white-space: nowrap;
    margin: 30px auto;
    z-index: 55;
}

.sad-ending-actions-container {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: auto;
    margin-bottom: 24px;
    z-index: 60;
}

/* --- SECTION 9: GOODBYE SCREEN --- */
.goodbye-portraits-stage {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
}

.goodbye-banner {
    text-align: center;
    margin-bottom: 24px;
}

.goodbye-title {
    font-family: 'Fredoka', cursive;
    font-size: 38px;
    color: #ffccd5;
    margin-bottom: 8px;
    text-shadow: 0 4px 15px rgba(255, 204, 213, 0.3);
}

.goodbye-subtitle {
    font-size: 18px;
    color: #c8b6ff;
    font-weight: 700;
}

/* --- LOADING SCREEN --- */
.loading-screen {
    position: absolute;
    inset: 0;
    background: #1d1430;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 100;
}

.loading-heart {
    font-size: 48px;
    animation: heartPulse 0.9s infinite ease-in-out;
}

.loading-text {
    font-size: 16px;
    font-weight: 700;
    color: #ffb3c6;
}

/* --- UTILITIES & ANIMATIONS --- */
.hidden {
    display: none !important;
}

@keyframes popIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes floatBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes bounceDown {
    0% { transform: translateY(0); }
    100% { transform: translateY(5px); }
}

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

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 2px 8px rgba(255, 117, 151, 0.2); }
    50% { box-shadow: 0 2px 14px rgba(255, 117, 151, 0.5); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* ==========================================================================
   CINEMATIC STUDIO INTRO (GAMELOFT STYLE)
   ========================================================================== */
.studio-intro-overlay {
    position: fixed;
    inset: 0;
    background: #000000;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    touch-action: none;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s ease;
}

.studio-intro-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.studio-intro-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(45, 25, 75, 0.45) 0%, rgba(10, 5, 20, 0.8) 60%, #000000 100%);
    pointer-events: none;
}

.studio-intro-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    animation: studioDramaticZoom 3.2s cubic-bezier(0.12, 0.8, 0.22, 1) forwards;
}

.studio-logo-frame {
    position: relative;
    width: clamp(160px, 46vw, 240px);
    height: clamp(160px, 46vw, 240px);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 0 60px rgba(255, 255, 255, 0.2), 0 20px 50px rgba(0, 0, 0, 0.9);
    background: #000;
    opacity: 0;
    animation: studioLogoReveal 1.3s 0.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.studio-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Light beam / specular shine sweep across logo */
.studio-logo-shine {
    position: absolute;
    top: 0;
    left: -150%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        105deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.15) 40%,
        rgba(255, 255, 255, 0.9) 50%,
        rgba(255, 255, 255, 0.15) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: studioShineSweep 1.6s 0.8s ease-in-out infinite;
    pointer-events: none;
}

.studio-presents-text {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: clamp(13px, 3.5vw, 18px);
    font-weight: 700;
    letter-spacing: 0.6em;
    color: #e2d9f3;
    text-shadow: 0 0 20px rgba(200, 182, 255, 0.85), 0 0 40px rgba(255, 117, 151, 0.6);
    opacity: 0;
    transform: translateY(12px);
    animation: studioPresentsFade 1.4s 0.9s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.studio-skip-hint {
    position: absolute;
    bottom: max(24px, env(safe-area-inset-bottom));
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 7px 18px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    animation: pulseSkip 1.6s infinite ease-in-out;
}

@keyframes studioDramaticZoom {
    0% { transform: scale(0.88); }
    100% { transform: scale(1.04); }
}

@keyframes studioLogoReveal {
    0% { opacity: 0; transform: scale(0.82) translateY(18px); filter: blur(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

@keyframes studioShineSweep {
    0% { left: -150%; }
    100% { left: 180%; }
}

@keyframes studioPresentsFade {
    0% { opacity: 0; transform: translateY(12px); letter-spacing: 0.35em; }
    100% { opacity: 1; transform: translateY(0); letter-spacing: 0.6em; }
}

@keyframes pulseSkip {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.05); }
}

/* ==========================================================================
   PREMIUM MOBILE TOUCH CONTROLS
   ========================================================================== */
.touch-controls-container {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 140px;
    pointer-events: none;
    z-index: 100;
    padding: 0 max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    justify-content: space-between;
    align-items: flex-end;
    box-sizing: border-box;
}

/* Activate on touch devices or screens <= 920px */
@media (hover: none) and (pointer: coarse), (max-width: 920px) {
    .touch-controls-container {
        display: flex;
    }
}

.touch-dpad {
    display: flex;
    gap: 14px;
    pointer-events: auto;
    margin-bottom: 6px;
}

.touch-actions {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    pointer-events: auto;
    margin-bottom: 6px;
}

.touch-btn {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: rgba(35, 25, 66, 0.72);
    border: 2px solid rgba(255, 117, 151, 0.65);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), inset 0 2px 4px rgba(255, 255, 255, 0.25), 0 0 16px rgba(255, 117, 151, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease;
}

.touch-btn:active, .touch-btn.active {
    transform: scale(0.91);
    background: linear-gradient(135deg, rgba(255, 117, 151, 0.9), rgba(224, 87, 128, 0.95));
    border-color: #ffffff;
    box-shadow: 0 4px 18px rgba(255, 117, 151, 0.8), inset 0 1px 2px rgba(255, 255, 255, 0.6);
}

.touch-btn-dir {
    width: 62px;
    height: 62px;
}

.touch-icon {
    width: 30px;
    height: 30px;
    fill: currentColor;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.45));
}

.touch-btn-jump {
    width: 74px;
    height: 74px;
    background: linear-gradient(135deg, rgba(255, 117, 151, 0.8), rgba(186, 75, 140, 0.8));
    border: 2.5px solid #ffccd5;
    box-shadow: 0 8px 25px rgba(255, 117, 151, 0.55), inset 0 2px 5px rgba(255, 255, 255, 0.45);
}

.touch-action-sub {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.08em;
    margin-top: -3px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.touch-btn-interact {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, rgba(255, 190, 11, 0.85), rgba(251, 86, 7, 0.85));
    border: 2px solid #fff3b0;
    box-shadow: 0 6px 22px rgba(255, 190, 11, 0.55);
    animation: interactPulse 1.2s infinite ease-in-out;
}

.touch-action-label {
    font-family: 'Fredoka', cursive;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

@keyframes interactPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 6px 20px rgba(255, 190, 11, 0.55); }
    50% { transform: scale(1.08); box-shadow: 0 8px 28px rgba(255, 190, 11, 0.85); }
}

/* ==========================================================================
   PHONE-OPTIMIZED RESPONSIVE DESIGN (ALL SMARTPHONES)
   ========================================================================== */
/* ==========================================================================
   PHONE-OPTIMIZED RESPONSIVE DESIGN (PREMIUM MOBILE CONSOLE EXPERIENCE)
   ========================================================================== */

/* Universal mobile adjustments */
@media (max-width: 820px) {
    .sound-text {
        display: none !important;
    }

    .hud-btn-mini {
        display: none !important;
    }

    /* Keep the Proposal shortcut visible and styled like a luxury romantic pill in mobile HUD */
    #btn-jump-proposal.hud-btn-mini {
        display: inline-flex !important;
        align-items: center;
        gap: 3px;
        font-size: 11px !important;
        font-weight: 700 !important;
        padding: 4px 10px !important;
        border-radius: 14px !important;
        background: linear-gradient(135deg, rgba(255, 117, 151, 0.4), rgba(255, 42, 85, 0.4)) !important;
        border: 1.5px solid #ff7597 !important;
        color: #ffffff !important;
        white-space: nowrap !important;
        cursor: pointer !important;
    }

    /* FULLSCREEN PROPOSAL & GOODBYE ON ALL MOBILE DEVICES */
    .proposal-overlay:not(.hidden),
    .goodbye-overlay:not(.hidden) {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 500 !important;
        background: radial-gradient(circle at 50% 30%, #3a1c71 0%, #1d1135 60%, #0d061a 100%) !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)) 20px !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .goodbye-overlay:not(.hidden) {
        background: radial-gradient(circle at 50% 40%, #1e1b2e 0%, #110e1c 70%, #07050d 100%) !important;
    }

    .proposal-portraits-stage,
    .goodbye-portraits-stage {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 16px !important;
        width: 100% !important;
        max-width: 360px !important;
        margin: 0 auto 16px auto !important;
        flex-shrink: 0 !important;
    }

    .proposal-portrait-box {
        width: 86px !important;
        height: 86px !important;
        border-radius: 18px !important;
        border: 3px solid #ff7597 !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 16px rgba(255, 117, 151, 0.4) !important;
        overflow: hidden !important;
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .proposal-portrait-box canvas {
        width: 86px !important;
        height: 86px !important;
        display: block !important;
    }

    .proposal-heart-center {
        font-size: 32px !important;
        animation: heartPulse 1.2s infinite ease-in-out !important;
        flex-shrink: 0 !important;
    }

    /* CHOICE CONTAINER & YES/NO BUTTONS (PROMINENT, IMPOSSIBLE TO MISS) */
    .proposal-choices-container:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 16px !important;
        margin-top: 14px !important;
        width: 100% !important;
        max-width: 400px !important;
        z-index: 550 !important;
        animation: popIn 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards !important;
    }

    .proposal-decision-title {
        font-family: 'Fredoka', cursive !important;
        font-size: 21px !important;
        font-weight: 700 !important;
        color: #ffffff !important;
        text-shadow: 0 3px 12px rgba(0, 0, 0, 0.8), 0 0 12px rgba(255, 117, 151, 0.5) !important;
        letter-spacing: 0.5px !important;
        text-align: center !important;
    }

    .proposal-buttons-row {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 20px !important;
        width: 100% !important;
    }

    .btn-proposal-choice {
        min-width: 130px !important;
        min-height: 52px !important;
        padding: 14px 28px !important;
        font-family: 'Fredoka', cursive !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        border-radius: 30px !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .btn-choice-yes {
        background: linear-gradient(135deg, #ff7597, #ff2a55) !important;
        border: 3px solid #ffffff !important;
        color: #ffffff !important;
        box-shadow: 0 8px 25px rgba(255, 42, 85, 0.7), 0 0 15px rgba(255, 117, 151, 0.5) !important;
        animation: heartPulse 2s infinite ease-in-out !important;
    }

    .btn-choice-no {
        background: linear-gradient(135deg, #6c757d, #343a40) !important;
        border: 3px solid rgba(255, 255, 255, 0.7) !important;
        color: #ffffff !important;
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5) !important;
    }

    .btn-proposal-choice:active {
        transform: scale(0.96) !important;
    }

    /* Ending banners & sad actions on mobile */
    .happy-ending-banner:not(.hidden),
    .sad-ending-banner:not(.hidden) {
        font-family: 'Fredoka', cursive !important;
        font-size: 19px !important;
        padding: 12px 20px !important;
        margin: 14px auto !important;
        text-align: center !important;
        border-radius: 20px !important;
        max-width: 90% !important;
        white-space: normal !important;
    }

    .sad-ending-actions-container:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 12px !important;
        margin-top: 14px !important;
        width: 100% !important;
        max-width: 320px !important;
    }

    /* Dialogue container on mobile has higher z-index so confession sits in front of proposal */
    .vn-dialogue-overlay:not(.hidden) {
        z-index: 600 !important;
    }
}

/* --- PORTRAIT MOBILE (NINTENDO DS / LUXURY HANDHELD DUAL-DECK LAYOUT) --- */
@media (max-width: 820px) and (orientation: portrait) {
    body {
        padding: 0;
        margin: 0;
        height: 100vh;
        height: 100dvh;
        width: 100vw;
        background: #0d081a;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
    }

    .game-wrapper {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 0;
        margin: 0;
        padding: 0;
    }

    /* Single-line streamlined Top HUD */
    .hud-bar {
        height: 42px;
        min-height: 42px;
        width: 100vw;
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: space-between;
        align-items: center;
        padding: max(4px, env(safe-area-inset-top)) 10px 4px 10px;
        border-radius: 0;
        border: none;
        border-bottom: 1.5px solid rgba(255, 117, 151, 0.4);
        background: rgba(22, 14, 40, 0.95);
        backdrop-filter: blur(8px);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
        flex-shrink: 0;
        z-index: 40;
    }

    .hud-title {
        font-size: 12px;
        font-weight: 700;
        max-width: 140px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 1;
        gap: 4px;
    }

    .hud-counters {
        flex: 1;
        justify-content: center;
        gap: 6px;
    }

    .hud-counter-badge {
        font-size: 11px;
        padding: 2px 7px;
        border-radius: 12px;
        white-space: nowrap;
    }

    .hud-controls {
        flex-shrink: 0;
        gap: 4px;
    }

    .hud-btn {
        padding: 4px 8px;
        font-size: 13px;
        border-radius: 12px;
        min-width: 32px;
        text-align: center;
    }

    /* Floating Rotate Hint Pill (Dismissible) */
    .rotate-hint-pill {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        background: rgba(40, 20, 65, 0.88);
        border: 1px solid rgba(255, 117, 151, 0.5);
        color: #ffccd5;
        font-size: 10.5px;
        font-weight: 700;
        padding: 4px 12px;
        border-radius: 20px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        margin: 4px auto;
        width: fit-content;
        max-width: 92vw;
        z-index: 30;
        animation: pulseGlow 2.5s infinite ease-in-out;
    }

    .rotate-hint-close {
        background: none;
        border: none;
        color: rgba(255, 255, 255, 0.7);
        font-size: 13px;
        cursor: pointer;
        padding: 0 2px;
    }

    /* Clean 16:9 Screen at the top of the handheld */
    .canvas-container {
        width: 100vw;
        aspect-ratio: 16 / 9;
        max-height: unset;
        height: auto;
        border-radius: 0;
        border: none;
        border-bottom: 2px solid var(--primary-pink);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65);
        margin: 0;
        flex-shrink: 0;
        overflow: hidden;
    }

    /* Dialogue Overlay in Portrait: Head & Face ALWAYS fully visible! */
    .vn-dialogue-overlay {
        padding: 6px 8px 8px 8px;
        overflow: hidden;
        justify-content: flex-end;
    }

    .vn-pair-stage {
        flex: 1;
        min-height: 0;
        max-height: calc(100% - 75px);
        margin-bottom: -6px;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: flex-end;
    }

    .vn-pair-img {
        max-height: 100%;
        height: auto;
        max-width: 82%;
        object-fit: contain;
    }

    .vn-dialogue-box {
        gap: 8px;
        width: 100%;
    }

    .vn-portrait-wrap {
        width: 56px;
        height: 56px;
        min-width: 56px;
        border-radius: 12px;
        border-width: 2px;
    }

    .vn-portrait-wrap canvas {
        width: 56px;
        height: 56px;
    }

    .vn-content-wrap {
        padding: 8px 12px 8px 12px;
        min-height: 56px;
        border-radius: 12px;
        border-width: 2px;
        flex: 1;
    }

    .vn-speaker-tag {
        top: -9px;
        left: 10px;
        font-size: 10px;
        padding: 1px 8px;
        border-radius: 6px;
    }

    .vn-text {
        font-size: 12px;
        line-height: 1.35;
        max-height: 48px;
        overflow-y: auto;
    }

    .vn-next-indicator {
        bottom: 4px;
        right: 8px;
        font-size: 11px;
    }

    /* Handheld Controller Deck below the screen (Thumbs NEVER block the game!) */
    .touch-controls-container {
        position: relative !important;
        flex: 1;
        width: 100vw;
        height: auto;
        min-height: 180px;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 18px 24px max(28px, env(safe-area-inset-bottom)) 24px;
        background: radial-gradient(circle at 50% 25%, #22143d 0%, #0c0717 100%);
        pointer-events: auto !important;
        border-top: 1.5px solid rgba(255, 117, 151, 0.35);
        box-shadow: inset 0 10px 24px rgba(0, 0, 0, 0.6);
        box-sizing: border-box;
    }

    .touch-dpad {
        display: flex;
        gap: 16px;
        pointer-events: auto;
    }

    .touch-actions {
        display: flex;
        align-items: center;
        gap: 16px;
        pointer-events: auto;
    }

    .touch-btn {
        width: 68px;
        height: 68px;
    }

    .touch-btn-jump {
        width: 78px;
        height: 78px;
    }

    .touch-btn-interact {
        width: 66px;
        height: 66px;
    }

    /* MCQ Overlay in Portrait */
    .mcq-card {
        padding: 14px 12px;
        width: 94%;
        gap: 10px;
        border-radius: 16px;
    }

    .mcq-badge {
        font-size: 11px;
        padding: 2px 10px;
    }

    .mcq-question-text {
        font-size: 13px;
        line-height: 1.3;
    }

    .mcq-choice-btn {
        padding: 9px 10px;
        font-size: 12.5px;
    }

}

/* --- LANDSCAPE MOBILE (FULLSCREEN CINEMATIC EXPERIENCE) --- */
@media (max-width: 950px) and (orientation: landscape) {
    body {
        padding: 0;
        margin: 0;
        height: 100vh;
        height: 100dvh;
        width: 100vw;
        background: #000000;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .game-wrapper {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        margin: 0;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .rotate-hint-pill {
        display: none !important;
    }

    /* Floating Sleek HUD Pill in Landscape */
    .hud-bar {
        position: absolute;
        top: max(4px, env(safe-area-inset-top));
        left: 50%;
        transform: translateX(-50%);
        z-index: 45;
        border-radius: 20px;
        padding: 4px 14px;
        background: rgba(22, 14, 40, 0.85);
        border: 1.5px solid rgba(255, 117, 151, 0.45);
        backdrop-filter: blur(8px);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
        gap: 8px;
    }

    .hud-title {
        font-size: 12px;
    }

    .hud-counter-badge {
        font-size: 11px;
        padding: 2px 8px;
    }

    .hud-btn {
        padding: 3px 8px;
        font-size: 12px;
    }

    /* Edge-to-Edge Screen in Landscape */
    .canvas-container {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        aspect-ratio: 16 / 9;
        width: auto;
        border: none;
        border-radius: 0;
        margin: 0 auto;
        box-shadow: none;
    }

    /* Floating Touch Controls on Left & Right Edges */
    .touch-controls-container {
        position: fixed;
        inset: 0;
        height: 100vh;
        height: 100dvh;
        pointer-events: none;
        z-index: 100;
        display: flex !important;
        justify-content: space-between;
        align-items: flex-end;
        padding: 0 max(20px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
        box-sizing: border-box;
    }

    .touch-btn {
        width: 62px;
        height: 62px;
        background: rgba(35, 25, 66, 0.6);
    }

    .touch-btn-jump {
        width: 70px;
        height: 70px;
    }

    .touch-btn-interact {
        width: 58px;
        height: 58px;
    }

    /* Full-body characters scaled gracefully in Landscape */
    .vn-dialogue-overlay {
        padding: 8px 24px 12px 24px;
    }

    .vn-pair-stage {
        flex: 1;
        min-height: 0;
        margin-bottom: -10px;
    }

    .vn-pair-img {
        max-height: 100%;
        height: auto;
        max-width: 60%;
        object-fit: contain;
    }

    /* Fullscreen Proposal in Landscape */
    .proposal-overlay:not(.hidden),
    .goodbye-overlay:not(.hidden) {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 500 !important;
        background: radial-gradient(circle at 50% 30%, #3a1c71 0%, #1d1135 60%, #0d061a 100%) !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: max(10px, env(safe-area-inset-top)) 20px max(10px, env(safe-area-inset-bottom)) 20px !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
    }

    .proposal-portraits-stage,
    .goodbye-portraits-stage {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 12px !important;
        margin-bottom: 8px !important;
    }

    .proposal-portrait-box {
        width: 72px !important;
        height: 72px !important;
        border-radius: 14px !important;
    }

    .proposal-portrait-box canvas {
        width: 72px !important;
        height: 72px !important;
    }

    .proposal-heart-center {
        font-size: 26px !important;
    }

    .proposal-choices-container:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
        margin-top: 8px !important;
        z-index: 550 !important;
    }

    .proposal-decision-title {
        font-size: 18px !important;
    }

    .proposal-buttons-row {
        display: flex !important;
        gap: 20px !important;
    }

    .btn-proposal-choice {
        min-width: 110px !important;
        min-height: 44px !important;
        padding: 10px 24px !important;
        font-size: 16px !important;
    }
}
