/* ========================================
   THE EDUCATION OF A WHITEBOY — Visual Novel Stylesheet
   Dark / Goth / College Apartment Aesthetic
   Queen of Spades themed — deeply personalized
   ======================================== */

:root {
    /* === Goth Purple-Black Palette === */
    --bg-darker: #06050a;
    --bg-dark: #0f0a15;
    --bg-medium: #1a1025;
    --bg-card: #110c18;
    --accent: #c77dba;
    --accent-glow: #e090d0;
    --accent-secondary: #7cacf0;
    --text: #e8e0f0;
    --text-secondary: #a8a0c0;
    --text-narrator: #c0b8d8;
    --text-dim: #8070a0;
    --danger: #ff3366;
    --danger-glow: rgba(255, 51, 102, 0.35);
    --gold: #d4a0ff;
    --gold-glow: rgba(212, 160, 255, 0.25);

    /* Legacy compat aliases */
    --neon-amber: var(--accent);
    --neon-amber-glow: rgba(199, 125, 186, 0.4);
    --neon-amber-dim: #a065a0;
    --neon-pink: var(--danger);
    --neon-pink-glow: var(--danger-glow);
    --neon-blue: var(--accent-secondary);
    --neon-purple: #9d4edd;
    --neon-purple-glow: rgba(157, 78, 221, 0.3);
    --text-primary: var(--text);

    /* Glass effects */
    --glass-bg: rgba(15, 10, 25, 0.7);
    --glass-bg-heavy: rgba(8, 6, 16, 0.92);
    --glass-border: rgba(199, 125, 186, 0.2);
    --glass-border-bright: rgba(199, 125, 186, 0.45);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-med: 0.4s ease;
    --transition-slow: 0.7s ease;
    --transition-cinematic: 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* Fonts */
    --font-ui: 'Raleway', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
    --font-handwritten: 'Caveat', 'Segoe Script', 'Comic Sans MS', cursive;

    /* Shadows */
    --shadow-heavy: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-glow-accent: 0 0 30px rgba(199, 125, 186, 0.15);
    --shadow-glow-amber: var(--shadow-glow-accent);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-darker);
    font-family: var(--font-ui);
    color: var(--text);
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== SCREEN MANAGEMENT ===== */
.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    z-index: 1;
}
.screen.active {
    display: block;
}
.hidden { display: none !important; }

/* ===== LOADING SCREEN ===== */
#loading-screen {
    background: var(--bg-darker);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
/* IMPORTANT: Only .active gets display:flex — loading screen fix */
#loading-screen.active {
    display: flex;
}

.loading-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at 50% 50%, rgba(199, 125, 186, 0.04) 0%, transparent 60%);
}

.loading-content {
    position: relative;
    text-align: center;
    z-index: 2;
}

.loading-logo {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.2em;
    margin-bottom: 40px;
    text-shadow: 0 0 30px var(--neon-amber-glow);
    animation: pulse-glow 2s ease-in-out infinite;
}
/* QoS spade motif on loading screen */
.loading-logo::after {
    content: ' \2660';
    font-size: 1.6rem;
    color: var(--gold);
    text-shadow: 0 0 18px var(--gold-glow);
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.loading-bar-outer {
    width: 300px;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto 20px;
}

.loading-bar-inner {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--danger));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ===== TITLE SCREEN ===== */
#title-screen {
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0.25;
    z-index: 0;
    filter: blur(2px) saturate(0.7);
    transition: opacity 1s ease;
}

#title-particles {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
}

.title-vignette {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at 50% 50%, transparent 30%, rgba(6, 5, 10, 0.8) 100%);
    z-index: 2;
    pointer-events: none;
}

.title-scanlines {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.04) 2px,
        rgba(0, 0, 0, 0.04) 4px
    );
    z-index: 3;
    pointer-events: none;
}

/* Title content — overflow-y: auto fix preserved */
.title-content {
    position: relative;
    z-index: 4;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    max-height: 100vh;
    padding: 24px 16px;
    overflow-y: auto;
    animation: title-fade-in 1.5s ease forwards;
}

@keyframes title-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.title-pre {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 300;
    color: var(--text-secondary);
    letter-spacing: 0.5em;
    text-transform: uppercase;
    margin-bottom: 8px;
    opacity: 0;
    animation: title-element-in 0.8s ease 0.3s forwards;
}

/* === Title Main: purple glow, dark goth aesthetic === */
.title-main {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5.5vw, 4.5rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-shadow:
        0 0 20px var(--neon-amber-glow),
        0 0 60px rgba(199, 125, 186, 0.2),
        0 0 120px rgba(199, 125, 186, 0.08),
        0 2px 0 rgba(140, 80, 130, 0.8),
        0 4px 8px rgba(0, 0, 0, 0.8);
    animation: title-glow 4s ease-in-out infinite alternate;
    line-height: 1;
}

@keyframes title-glow {
    from {
        text-shadow:
            0 0 20px var(--neon-amber-glow),
            0 0 60px rgba(199, 125, 186, 0.15),
            0 0 120px rgba(199, 125, 186, 0.05),
            0 2px 0 rgba(140, 80, 130, 0.8),
            0 4px 8px rgba(0, 0, 0, 0.8);
        filter: brightness(1);
    }
    to {
        text-shadow:
            0 0 40px var(--neon-amber-glow),
            0 0 100px rgba(199, 125, 186, 0.25),
            0 0 160px rgba(199, 125, 186, 0.1),
            0 2px 0 rgba(140, 80, 130, 0.8),
            0 4px 8px rgba(0, 0, 0, 0.8);
        filter: brightness(1.1);
    }
}

@keyframes title-element-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.title-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    opacity: 0;
    animation: title-element-in 0.8s ease 0.6s forwards;
}
.title-divider span:first-child,
.title-divider span:last-child {
    display: block;
    width: 80px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neon-amber-dim), transparent);
}

/* === Divider: Spade symbol instead of diamond === */
.divider-diamond {
    width: auto;
    height: auto;
    background: none;
    transform: none;
    box-shadow: none;
    font-size: 1.1rem;
    color: var(--accent);
    text-shadow: 0 0 12px var(--neon-amber-glow);
    line-height: 1;
}
.divider-diamond::before {
    content: '\2660';
}

/* === Tagline: slow pulsing opacity === */
.title-tagline {
    font-family: var(--font-ui);
    font-size: clamp(0.85rem, 1.8vw, 1.1rem);
    font-weight: 300;
    font-style: italic;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    margin-top: 8px;
    opacity: 0;
    animation: title-element-in 0.8s ease 0.9s forwards;
}
/* Tagline pulse after initial fade-in */
.title-tagline.visible,
.title-content .title-tagline {
    animation: title-element-in 0.8s ease 0.9s forwards, tagline-breathe 4s ease-in-out 2s infinite;
}
@keyframes tagline-breathe {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

/* === Title Menu: goth dark glass, purple border === */
.title-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 280px;
    opacity: 0;
    animation: title-element-in 0.8s ease 1.2s forwards;
}

.menu-btn {
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 400;
    padding: 14px 32px;
    background: rgba(15, 10, 25, 0.75);
    color: var(--text);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}
.menu-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(199, 125, 186, 0.1), transparent);
    transition: left 0.5s ease;
}
.menu-btn:hover::before {
    left: 100%;
}
.menu-btn:hover:not(:disabled) {
    background: rgba(199, 125, 186, 0.14);
    border-color: var(--glass-border-bright);
    color: var(--accent);
    box-shadow: var(--shadow-glow-accent), inset 0 0 30px rgba(199, 125, 186, 0.04);
    transform: translateY(-1px);
}
.menu-btn:active:not(:disabled) {
    transform: scale(0.97) translateY(0);
}
.menu-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 0.85rem;
    opacity: 0.7;
}
.btn-text {
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.title-credit {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    opacity: 0;
    animation: title-element-in 0.8s ease 1.5s forwards;
}

.neon-flicker {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 3;
    background: radial-gradient(ellipse at 50% 100%, rgba(199, 125, 186, 0.03) 0%, transparent 60%);
    animation: flicker 6s ease-in-out infinite;
}

/* Title bottom fade to black */
#title-screen::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 30%;
    background: linear-gradient(0deg, var(--bg-darker) 0%, transparent 100%);
    z-index: 1;
    pointer-events: none;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    48% { opacity: 0.8; }
    50% { opacity: 1; }
    52% { opacity: 0.7; }
    53% { opacity: 1; }
    70% { opacity: 0.9; }
    72% { opacity: 1; }
}

/* ===== GAME SCREEN ===== */
#game-screen {
    background: var(--bg-dark);
}

/* Background Layer */
#scene-background, #scene-background-next {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--bg-dark);
    transition: opacity var(--transition-cinematic);
    z-index: 0;
}
#scene-background-next {
    opacity: 0;
    z-index: 1;
}

/* Video Background Layer */
#scene-video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 1;
    opacity: 0;
    transition: opacity var(--transition-cinematic);
    pointer-events: none;
    background: transparent;
}
#scene-video.active {
    opacity: 1;
}

/* Atmospheric Overlays */
#atmosphere-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
}

.vignette-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(6, 5, 10, 0.55) 100%);
}

.mood-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0;
    transition: opacity 1.5s ease, background 1.5s ease;
    mix-blend-mode: overlay;
}

/* Mood color grades */
.mood-overlay.mood-warm { background: rgba(199, 125, 186, 0.08); opacity: 1; }
.mood-overlay.mood-danger { background: rgba(255, 45, 45, 0.1); opacity: 1; }
.mood-overlay.mood-intimate { background: rgba(255, 100, 150, 0.1); opacity: 1; }
.mood-overlay.mood-cold { background: rgba(80, 120, 255, 0.08); opacity: 1; }
.mood-overlay.mood-neon { background: linear-gradient(135deg, rgba(199,125,186,0.06) 0%, rgba(157,78,221,0.06) 100%); opacity: 1; }
.mood-overlay.mood-ecstasy {
    background: linear-gradient(135deg, rgba(255,51,102,0.12) 0%, rgba(199,125,186,0.08) 100%);
    opacity: 1;
    animation: ecstasy-pulse 2s ease-in-out infinite;
}

/* Dialogue box border glow matches mood */
#game-screen.scene-ecstasy .dialogue-inner::before {
    background: linear-gradient(90deg, transparent 5%, var(--danger) 30%, var(--accent) 50%, var(--danger) 70%, transparent 95%);
    opacity: 0.7;
    animation: ecstasy-pulse 2s ease-in-out infinite;
}
#game-screen.scene-danger .dialogue-inner::before {
    background: linear-gradient(90deg, transparent 5%, #ff4545 30%, #ff6666 50%, #ff4545 70%, transparent 95%);
    opacity: 0.6;
}
#game-screen.scene-intimate .dialogue-inner::before {
    background: linear-gradient(90deg, transparent 5%, var(--danger) 30%, rgba(255,100,150,0.8) 50%, var(--danger) 70%, transparent 95%);
    opacity: 0.5;
}

@keyframes ecstasy-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

#game-particles {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

/* Screen Flash */
#screen-flash {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 45;
    pointer-events: none;
    opacity: 0;
}
#screen-flash.flash-white {
    background: white;
    animation: flash 0.5s ease-out forwards;
}
#screen-flash.flash-amber {
    background: var(--accent);
    animation: flash 0.6s ease-out forwards;
}
#screen-flash.flash-pink {
    background: var(--danger);
    animation: flash 0.8s ease-out forwards;
}
#screen-flash.flash-purple {
    background: #6a0dad;
    animation: flash-purple 0.7s ease-out forwards;
}

@keyframes flash {
    0% { opacity: 0.7; }
    100% { opacity: 0; }
}
@keyframes flash-purple {
    0% { opacity: 0.65; }
    30% { opacity: 0.4; }
    100% { opacity: 0; }
}

/* Letterbox */
.letterbox {
    position: absolute;
    left: 0;
    width: 100%;
    height: 0;
    background: black;
    z-index: 40;
    transition: height 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
#letterbox-top { top: 0; }
#letterbox-bottom { bottom: 0; }
.letterbox.active { height: 8vh; }

/* ===== CHAPTER CARD — Lesson / Homework aesthetic ===== */
#chapter-card {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 5, 10, 0.92);
    z-index: 50;
    opacity: 0;
    transition: opacity 1s ease;
}
#chapter-card.visible {
    opacity: 1;
}

.chapter-card-inner {
    display: flex;
    align-items: center;
    gap: 30px;
    position: relative;
}

/* Spade motifs at the end of chapter lines */
.chapter-line-left, .chapter-line-right {
    width: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent));
    transition: width 1s ease 0.3s;
    position: relative;
}
.chapter-line-right {
    background: linear-gradient(90deg, var(--accent), transparent);
}
#chapter-card.visible .chapter-line-left,
#chapter-card.visible .chapter-line-right {
    width: 120px;
}
/* Spade at line ends */
.chapter-line-left::before {
    content: '\2660';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: var(--accent);
    opacity: 0.6;
    text-shadow: 0 0 6px var(--neon-amber-glow);
}
.chapter-line-right::after {
    content: '\2660';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: var(--accent);
    opacity: 0.6;
    text-shadow: 0 0 6px var(--neon-amber-glow);
}

.chapter-text-block {
    text-align: center;
}

/* Chapter number — "Lesson X" academic feel */
.chapter-number {
    display: block;
    font-family: var(--font-handwritten), var(--font-ui);
    font-size: 0.9rem;
    font-weight: 300;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 10px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.6s ease 0.5s;
}
#chapter-card.visible .chapter-number {
    opacity: 1;
    transform: translateY(0);
}

.chapter-title {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5vw, 4rem);
    font-weight: 700;
    color: var(--text);
    text-shadow: 0 0 40px rgba(199, 125, 186, 0.25);
    letter-spacing: 0.05em;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.6s ease 0.7s;
}
#chapter-card.visible .chapter-title {
    opacity: 1;
    transform: translateY(0);
}

/* Subtle spade decoration under chapter title */
.chapter-text-block::after {
    content: '\2660';
    display: block;
    margin-top: 14px;
    font-size: 1rem;
    color: var(--gold);
    opacity: 0.35;
    text-shadow: 0 0 10px var(--gold-glow);
}

/* Faint lined-paper effect on the chapter card */
#chapter-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        180deg,
        transparent 0px,
        transparent 38px,
        rgba(199, 125, 186, 0.02) 38px,
        rgba(199, 125, 186, 0.02) 40px
    );
    pointer-events: none;
    z-index: -1;
}

/* ===== CHARACTER SPRITES ===== */
#character-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 5;
    pointer-events: none;
}

.character-sprite {
    position: absolute;
    bottom: 170px;
    height: 85vh;
    max-width: 40vw;
    object-fit: contain;
    opacity: 0;
    transition: all var(--transition-med) ease, filter 0.3s ease;
    filter: drop-shadow(0 4px 25px rgba(0, 0, 0, 0.7));
}
.character-sprite.visible {
    opacity: 1;
}
.character-sprite.pos-left {
    left: 3%;
    transform: translateX(0);
}
.character-sprite.pos-left.enter {
    animation: sprite-enter-left 0.5s ease forwards;
}
.character-sprite.pos-center {
    left: 50%;
    transform: translateX(-50%);
}
.character-sprite.pos-center.enter {
    animation: sprite-enter-center 0.5s ease forwards;
}
.character-sprite.pos-right {
    right: 3%;
}
.character-sprite.pos-right.enter {
    animation: sprite-enter-right 0.5s ease forwards;
}
.character-sprite.dimmed {
    filter: brightness(0.45) saturate(0.6) drop-shadow(0 4px 25px rgba(0, 0, 0, 0.7));
}

@keyframes sprite-enter-left {
    from { opacity: 0; transform: translateX(-60px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes sprite-enter-center {
    from { opacity: 0; transform: translateX(-50%) scale(0.95); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes sprite-enter-right {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== DIALOGUE BOX ===== */
#dialogue-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 20;
    padding: 0 2.5vw 1.5vh 2.5vw;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.dialogue-inner {
    background: linear-gradient(180deg, rgba(15, 10, 25, 0.85) 0%, rgba(10, 8, 18, 0.95) 100%);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border: 1px solid var(--glass-border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 20px 32px 24px;
    min-height: 150px;
    position: relative;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.dialogue-inner::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 1px;
    background: linear-gradient(90deg, transparent 5%, var(--neon-amber-dim) 30%, var(--accent) 50%, var(--neon-amber-dim) 70%, transparent 95%);
    opacity: 0.5;
}

#char-name-wrapper {
    margin-bottom: 10px;
    min-height: 2em;
}

#char-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 12px var(--gold-glow);
    letter-spacing: 0.05em;
    transition: color var(--transition-fast);
}

.name-underline {
    width: 0;
    height: 2px;
    margin-top: 4px;
    border-radius: 1px;
    background: var(--gold);
    transition: width 0.3s ease;
    opacity: 0.5;
}
.name-underline.visible {
    width: 60px;
}

/* ===== CHARACTER NAME COLORS ===== */
#char-name.char-kent { color: #7cacf0; text-shadow: 0 0 12px rgba(124, 172, 240, 0.25); }
#char-name.char-kent ~ .name-underline { background: #7cacf0; }
#char-name.char-mandy { color: #c77dba; text-shadow: 0 0 12px rgba(199, 125, 186, 0.3); }
#char-name.char-mandy ~ .name-underline { background: #c77dba; }
#char-name.char-narrator { color: var(--text-secondary); font-style: italic; font-family: var(--font-ui); font-weight: 300; opacity: 0.6; }
#char-name.char-narrator ~ .name-underline { background: var(--text-secondary); opacity: 0.3; }
#char-name.char-inner { color: #7cacf0; font-style: italic; font-family: var(--font-ui); font-weight: 300; }
#char-name.char-inner ~ .name-underline { background: #7cacf0; opacity: 0.4; }

/* ===== CHARACTER-SPECIFIC DIALOGUE BOX STYLING ===== */

/* Kent — blue left-border accent */
#dialogue-box.char-kent .dialogue-inner {
    border-left: 3px solid rgba(124, 172, 240, 0.35);
}

/* Mandy — purple left-border, slightly more opaque (she dominates) */
#dialogue-box.char-mandy .dialogue-inner {
    border-left: 3px solid rgba(199, 125, 186, 0.45);
    background: linear-gradient(180deg, rgba(20, 12, 28, 0.9) 0%, rgba(14, 10, 22, 0.96) 100%);
}

/* Narrator — very subtle, no border accent, transparent */
#dialogue-box.char-narrator .dialogue-inner {
    border-left: none;
    background: linear-gradient(180deg, rgba(15, 10, 25, 0.72) 0%, rgba(10, 8, 18, 0.82) 100%);
}

/* Inner thoughts (Kent's mind) — thought-bubble look */
#dialogue-box.char-inner .dialogue-inner {
    background: rgba(15, 12, 28, 0.55);
    border: 1.5px dashed rgba(124, 172, 240, 0.25);
    border-bottom: 1.5px dashed rgba(124, 172, 240, 0.25);
    border-radius: 18px 18px 8px 8px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}
#dialogue-box.char-inner .dialogue-inner::before {
    opacity: 0.2;
}

/* ===== INNER THOUGHTS EFFECT ===== */
#dialogue-box.inner-thoughts .dialogue-inner {
    background: rgba(12, 10, 24, 0.45);
    border: 1.5px dashed rgba(124, 172, 240, 0.2);
    border-radius: 18px 18px 8px 8px;
    animation: thoughts-breathe 3s ease-in-out infinite;
}
#dialogue-box.inner-thoughts #dialogue-text {
    font-style: italic;
    color: rgba(200, 190, 220, 0.8);
}
#dialogue-box.inner-thoughts .advance-arrow {
    opacity: 0.35;
}
#dialogue-box.inner-thoughts .dialogue-inner::before {
    opacity: 0.15;
}

@keyframes thoughts-breathe {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

#dialogue-text {
    font-family: var(--font-ui);
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    font-weight: 400;
    line-height: 1.85;
    color: var(--text);
    min-height: 3.6em;
    letter-spacing: 0.01em;
}

#dialogue-text.narrator-text {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    color: var(--text-narrator);
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
}

#dialogue-text.inner-text {
    font-style: italic;
    font-weight: 300;
    color: #7cacf0;
    opacity: 0.85;
    text-shadow: 0 0 20px rgba(124, 172, 240, 0.2);
}

/* Typewriter cursor */
.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.15em;
    background: var(--accent);
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: cursor-blink 0.7s step-end infinite;
    box-shadow: 0 0 6px var(--neon-amber-glow);
}

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

#advance-indicator {
    position: absolute;
    bottom: 10px;
    right: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}
#advance-indicator.visible {
    opacity: 1;
}
#advance-indicator.auto-mode .advance-arrow {
    color: var(--danger);
    animation: auto-pulse 1.5s ease-in-out infinite;
}
@keyframes auto-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; transform: translateY(3px); }
}
.advance-arrow {
    font-size: 0.8rem;
    color: var(--accent);
    opacity: 0.7;
    animation: bounce-arrow 1.2s ease-in-out infinite;
}

@keyframes bounce-arrow {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(5px); opacity: 1; }
}

/* ===== CHOICE CONTAINER ===== */
#choice-container {
    position: absolute;
    bottom: 190px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 420px;
    max-width: 620px;
    width: 50vw;
}

/* === Choice Buttons: dark glass morphism, purple accent, spade hover === */
.choice-btn {
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 400;
    padding: 18px 28px;
    background: linear-gradient(135deg, rgba(10, 8, 18, 0.92) 0%, rgba(20, 14, 32, 0.92) 100%);
    color: var(--text);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    text-align: left;
    opacity: 0;
    transform: translateX(-20px);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}
/* Purple left-accent bar on hover */
.choice-btn::before {
    content: '';
    position: absolute;
    left: 0; top: 0;
    width: 3px; height: 100%;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.choice-btn:hover::before {
    opacity: 1;
}
/* Spade watermark on hover */
.choice-btn::after {
    content: '\2660';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.choice-btn:hover::after {
    opacity: 0.06;
}
.choice-btn.appear {
    animation: choice-slide-in 0.4s ease forwards;
}
.choice-btn:nth-child(1).appear { animation-delay: 0.05s; }
.choice-btn:nth-child(2).appear { animation-delay: 0.15s; }
.choice-btn:nth-child(3).appear { animation-delay: 0.25s; }

@keyframes choice-slide-in {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.choice-btn:hover {
    background: linear-gradient(135deg, rgba(199, 125, 186, 0.15) 0%, rgba(199, 125, 186, 0.06) 100%);
    border-color: var(--glass-border-bright);
    color: var(--accent-glow);
    box-shadow: 0 0 30px rgba(199, 125, 186, 0.1), inset 0 0 30px rgba(199, 125, 186, 0.03);
    transform: translateX(4px);
}
.choice-btn:active {
    transform: scale(0.98);
    transition-duration: 0.05s;
    background: rgba(199, 125, 186, 0.25);
    box-shadow: 0 0 40px rgba(199, 125, 186, 0.2);
}

.choice-label {
    display: block;
    line-height: 1.5;
}
/* Hint text in Mandy-purple */
.choice-hint {
    display: block;
    font-size: 0.78rem;
    font-weight: 300;
    font-style: italic;
    color: var(--accent);
    margin-top: 5px;
    opacity: 0.5;
}

/* ===== STATS PANEL ===== */
#stats-panel {
    position: absolute;
    top: 60px;
    left: 16px;
    z-index: 15;
    background: var(--glass-bg-heavy);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 16px 20px 14px;
    min-width: 200px;
    transition: all var(--transition-med);
    box-shadow: var(--shadow-heavy);
    animation: panel-slide-in 0.3s ease;
}

@keyframes panel-slide-in {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Stats header — "Kent's State" */
.stats-header {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(199, 125, 186, 0.15);
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.stat-row:last-child { margin-bottom: 0; }

.stat-icon {
    font-size: 0.7rem;
    width: 16px;
    text-align: center;
    opacity: 0.7;
    transition: all 0.3s ease;
}
/* Spade icon for Pride — larger and purple */
.stat-icon.icon-pride {
    font-size: 0.85rem;
    color: var(--accent);
    opacity: 0.9;
}
/* Diamond icon for Acceptance — glows when high */
.stat-icon.icon-acceptance {
    transition: text-shadow 0.5s ease, color 0.5s ease;
}
.stat-icon.icon-acceptance.high-value {
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
    opacity: 1;
}
/* Heart icon for Arousal — pulses when active */
.stat-icon.icon-arousal {
    transition: all 0.3s ease;
}
.stat-icon.icon-arousal.arousal-active {
    color: var(--danger);
    animation: heart-pulse 1s ease-in-out infinite;
}
@keyframes heart-pulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.25); opacity: 1; }
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    width: 70px;
    flex-shrink: 0;
}

.stat-bar-outer {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.stat-bar-inner {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}
.stat-bar-inner::after {
    content: '';
    position: absolute;
    right: 0; top: 0;
    width: 6px; height: 100%;
    background: white;
    opacity: 0.5;
    border-radius: 0 2px 2px 0;
    filter: blur(2px);
}

.bar-confidence { background: linear-gradient(90deg, #0077cc, var(--accent-secondary)); width: 50%; }
.bar-submission { background: linear-gradient(90deg, #6b21a8, var(--neon-purple)); width: 0%; }
.bar-arousal { background: linear-gradient(90deg, #cc1155, var(--danger)); width: 0%; }

/* === Arousal Bar Animations === */
.bar-arousal.arousal-high {
    animation: arousal-throb 1.2s ease-in-out infinite;
}
.bar-arousal.arousal-critical {
    background: linear-gradient(90deg, #ff1155, #ff3366, #ff6699);
    animation: arousal-critical-throb 0.6s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.5), 0 0 20px rgba(255, 51, 102, 0.2);
}
@keyframes arousal-throb {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.4); }
}
@keyframes arousal-critical-throb {
    0%, 100% { filter: brightness(1); box-shadow: 0 0 8px rgba(255, 51, 102, 0.4); }
    50% { filter: brightness(1.6); box-shadow: 0 0 16px rgba(255, 51, 102, 0.7), 0 0 30px rgba(255, 51, 102, 0.3); }
}

/* === Confidence/Pride Bar — flicker when low === */
.bar-confidence.pride-low {
    animation: pride-flicker 0.8s ease-in-out infinite;
}
@keyframes pride-flicker {
    0% { opacity: 1; }
    15% { opacity: 0.5; }
    30% { opacity: 0.9; }
    45% { opacity: 0.4; }
    60% { opacity: 1; }
    80% { opacity: 0.6; }
    100% { opacity: 1; }
}

.stat-value {
    font-size: 0.65rem;
    color: var(--text-dim);
    width: 24px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}
.stat-value.changed {
    color: var(--accent);
}

/* Stat change flash */
.stat-flash {
    animation: stat-pulse 0.5s ease;
}
@keyframes stat-pulse {
    0% { filter: brightness(1); }
    50% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

/* ===== SCENE PROGRESS ===== */
#scene-progress {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 2px;
    z-index: 15;
    background: rgba(255, 255, 255, 0.03);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--danger));
    transition: width 0.8s ease;
    box-shadow: 0 0 8px var(--neon-amber-glow);
}

/* ===== QUICK MENU ===== */
#quick-menu {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 15;
    display: flex;
    gap: 6px;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}
#quick-menu:hover {
    opacity: 1;
}

.qm-btn {
    width: 34px;
    height: 34px;
    background: var(--glass-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.qm-btn svg {
    width: 15px;
    height: 15px;
}
.qm-btn:hover {
    background: rgba(199, 125, 186, 0.12);
    border-color: var(--glass-border-bright);
    color: var(--accent);
    box-shadow: 0 0 15px rgba(199, 125, 186, 0.1);
}
.qm-btn.active {
    background: rgba(199, 125, 186, 0.18);
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== OVERLAYS ===== */
.overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(6, 5, 10, 0.88);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlay-in 0.3s ease;
}

@keyframes overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-panel {
    background: linear-gradient(180deg, rgba(17, 12, 24, 0.97) 0%, rgba(10, 8, 16, 0.97) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 40px 48px;
    min-width: 340px;
    text-align: center;
    box-shadow: var(--shadow-heavy), 0 0 60px rgba(0, 0, 0, 0.5);
    animation: panel-pop 0.3s ease;
}
.overlay-wide {
    min-width: 500px;
    max-width: 700px;
    width: 50vw;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

@keyframes panel-pop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.overlay-panel h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 28px;
    text-shadow: 0 0 20px rgba(199, 125, 186, 0.2);
    letter-spacing: 0.08em;
}

.overlay-panel .menu-btn {
    display: flex;
    width: 100%;
    margin-bottom: 8px;
    font-size: 0.95rem;
}
.overlay-panel .menu-btn:last-child { margin-bottom: 0; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 16px;
}
.setting-row label {
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: left;
}
.setting-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    height: 4px;
}
.setting-val {
    font-size: 0.8rem;
    color: var(--accent);
    min-width: 30px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.shortcuts-info {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
}
.shortcuts-title {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.shortcut-key {
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 2px 8px;
    color: var(--accent);
}

.button-row {
    margin-top: 24px;
}

/* ===== HISTORY LOG ===== */
.history-log {
    flex: 1;
    overflow-y: auto;
    text-align: left;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 16px;
    max-height: 50vh;
}
.history-log::-webkit-scrollbar {
    width: 4px;
}
.history-log::-webkit-scrollbar-track {
    background: transparent;
}
.history-log::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 2px;
}
.history-entry {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.history-entry:last-child {
    margin-bottom: 0;
    border-bottom: none;
}
.history-name {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 3px;
}
.history-text {
    font-size: 0.85rem;
    font-weight: 300;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* === History character color-coding === */
.history-entry.history-kent .history-name {
    color: #7cacf0;
}
.history-entry.history-kent .history-text {
    color: var(--text-secondary);
}
.history-entry.history-mandy .history-name {
    color: #c77dba;
}
.history-entry.history-mandy .history-text {
    color: var(--text-secondary);
}
.history-entry.history-narrator .history-name {
    color: var(--text-dim);
    font-weight: 300;
    font-style: italic;
}
.history-entry.history-narrator .history-text {
    color: var(--text-dim);
}
.history-entry.history-inner .history-name {
    color: #7cacf0;
    font-style: italic;
    font-weight: 400;
}
.history-entry.history-inner .history-text {
    color: rgba(124, 172, 240, 0.7);
    font-style: italic;
}

/* ===== NOTIFICATION ===== */
#notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    z-index: 200;
    background: var(--glass-bg-heavy);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border-bright);
    border-radius: 10px;
    padding: 10px 28px;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: var(--shadow-glow-accent);
}
#notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    display: block !important;
}

/* ===== SCENE TRANSITION ===== */
#scene-transition {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: black;
    z-index: 35;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}
#scene-transition.active {
    opacity: 1;
    transition: opacity 0.4s ease;
}

/* CRT Scanlines on game screen */
#game-scanlines {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.015) 2px,
        rgba(0, 0, 0, 0.015) 4px
    );
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}
#game-scanlines.active { opacity: 1; }

/* Dialogue fade effect */
#dialogue-text.text-fade-in {
    animation: textFadeIn 0.2s ease;
}
@keyframes textFadeIn {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

/* Quick menu auto-hide */
#quick-menu.dim {
    opacity: 0.1;
}

/* ===== CLICK HINT ===== */
#click-hint {
    position: fixed;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    background: var(--glass-bg);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 8px 24px;
    font-size: 0.75rem;
    font-weight: 300;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}
#click-hint.visible {
    display: block !important;
    animation: hintPulse 4s ease-in-out forwards;
}
@keyframes hintPulse {
    0% { opacity: 0; }
    15% { opacity: 0.7; }
    70% { opacity: 0.7; }
    100% { opacity: 0; display: none; }
}

/* ===== SCREEN EFFECTS ===== */
.screen-shake {
    animation: shake 0.4s ease-in-out;
}
@keyframes shake {
    0%, 100% { transform: translate(0); }
    15% { transform: translate(-5px, 3px); }
    30% { transform: translate(5px, -2px); }
    45% { transform: translate(-3px, 5px); }
    60% { transform: translate(3px, -3px); }
    75% { transform: translate(-2px, 2px); }
}

.screen-pulse {
    animation: screen-pulse 0.6s ease;
}
@keyframes screen-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

/* ===================================================
   TV STATIC / CRT EFFECT
   =================================================== */
#game-screen.tv-static::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 44;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(199, 125, 186, 0.015) 1px,
        rgba(199, 125, 186, 0.015) 2px
    );
    animation: tv-scanlines 0.1s linear infinite, tv-static-burst 0.15s steps(3) infinite;
    opacity: 0.7;
}

@keyframes tv-scanlines {
    0% { background-position: 0 0; }
    100% { background-position: 0 4px; }
}

@keyframes tv-static-burst {
    0% { opacity: 0.5; }
    25% { opacity: 0.8; }
    50% { opacity: 0.3; }
    75% { opacity: 0.9; }
    100% { opacity: 0.5; }
}

/* ===================================================
   TV GLOW EFFECT
   =================================================== */
#game-screen.tv-glow-active {
    box-shadow:
        inset 0 0 60px rgba(199, 125, 186, 0.08),
        inset 0 0 120px rgba(124, 172, 240, 0.04),
        0 0 40px rgba(199, 125, 186, 0.1),
        0 0 80px rgba(124, 172, 240, 0.05);
    animation: tv-screen-flicker 4s ease-in-out infinite;
}

#game-screen.tv-glow-active .vignette-overlay {
    background: radial-gradient(ellipse at 50% 50%, transparent 35%, rgba(6, 5, 10, 0.7) 100%);
}

@keyframes tv-screen-flicker {
    0%, 100% { filter: brightness(1); }
    48% { filter: brightness(0.97); }
    50% { filter: brightness(1.02); }
    52% { filter: brightness(0.98); }
    80% { filter: brightness(1); }
}

/* ===================================================
   HEARTBEAT EFFECT
   =================================================== */
#game-screen.heartbeat {
    animation: heartbeat-screen 0.833s ease-in-out infinite; /* ~72bpm */
}

#game-screen.heartbeat .vignette-overlay {
    animation: heartbeat-vignette 0.833s ease-in-out infinite;
}

@keyframes heartbeat-screen {
    0% { transform: scale(1); }
    15% { transform: scale(1.005); }
    30% { transform: scale(1); }
    45% { transform: scale(1.003); }
    60% { transform: scale(1); }
    100% { transform: scale(1); }
}

@keyframes heartbeat-vignette {
    0% {
        background: radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(6, 5, 10, 0.55) 100%);
        box-shadow: inset 0 0 80px transparent;
    }
    15% {
        background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(60, 10, 20, 0.35) 100%);
        box-shadow: inset 0 0 80px rgba(255, 51, 102, 0.06);
    }
    30% {
        background: radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(6, 5, 10, 0.55) 100%);
        box-shadow: inset 0 0 80px transparent;
    }
    45% {
        background: radial-gradient(ellipse at 50% 50%, transparent 42%, rgba(50, 8, 18, 0.28) 100%);
        box-shadow: inset 0 0 60px rgba(255, 51, 102, 0.04);
    }
    60%, 100% {
        background: radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(6, 5, 10, 0.55) 100%);
        box-shadow: inset 0 0 80px transparent;
    }
}

/* ===================================================
   PRIDE CRACK EFFECT
   =================================================== */
#game-screen.pride-crack::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 46;
    pointer-events: none;
    background:
        /* Crack fracture lines */
        linear-gradient(135deg,
            transparent 42%,
            rgba(199, 125, 186, 0.4) 42.5%,
            rgba(255, 255, 255, 0.6) 43%,
            rgba(199, 125, 186, 0.3) 43.5%,
            transparent 44%
        ),
        linear-gradient(160deg,
            transparent 48%,
            rgba(199, 125, 186, 0.3) 48.3%,
            rgba(255, 255, 255, 0.4) 48.6%,
            rgba(199, 125, 186, 0.2) 48.9%,
            transparent 49.2%
        ),
        linear-gradient(115deg,
            transparent 51%,
            rgba(199, 125, 186, 0.25) 51.2%,
            rgba(255, 255, 255, 0.35) 51.5%,
            transparent 51.8%
        );
    animation: pride-crack-appear 1.2s ease-out forwards;
}

@keyframes pride-crack-appear {
    0% {
        opacity: 0;
        filter: brightness(5);
    }
    8% {
        opacity: 1;
        filter: brightness(3);
    }
    20% {
        opacity: 1;
        filter: brightness(1);
    }
    100% {
        opacity: 0;
        filter: brightness(1);
    }
}

/* ===== ENDING SCREEN ===== */
.ending-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    text-shadow:
        0 0 40px var(--neon-amber-glow),
        0 0 80px rgba(199, 125, 186, 0.15),
        0 0 120px rgba(199, 125, 186, 0.08);
    margin-bottom: 16px;
    opacity: 0;
    animation: title-element-in 1s ease 0.3s forwards;
}
/* "CLASS DISMISSED" — dramatic purple glow */
.ending-title.class-dismissed,
.ending-title {
    letter-spacing: 0.1em;
}

.ending-tagline {
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 300;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 32px;
    opacity: 0;
    animation: title-element-in 0.8s ease 0.8s forwards;
}
.ending-stats {
    display: flex;
    gap: 40px;
    justify-content: center;
    margin-bottom: 32px;
    opacity: 0;
    animation: title-element-in 0.8s ease 1.2s forwards;
}
.ending-stat {
    text-align: center;
}
.ending-stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}
.ending-stat-value.stat-confidence { color: var(--accent-secondary); }
.ending-stat-value.stat-submission { color: var(--neon-purple); }
.ending-stat-value.stat-arousal { color: var(--danger); }
.ending-stat-label {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.ending-credit {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    margin-bottom: 32px;
    opacity: 0;
    animation: title-element-in 0.8s ease 1.6s forwards;
}
.ending-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    opacity: 0;
    animation: title-element-in 0.8s ease 2s forwards;
}
.ending-buttons .menu-btn {
    min-width: 160px;
}

/* Ending screen background — purple vignette */
#ending-screen,
.screen.ending-screen {
    background: var(--bg-darker);
}
#ending-screen::before,
.screen.ending-screen::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at 50% 50%, transparent 20%, rgba(100, 40, 120, 0.08) 60%, rgba(6, 5, 10, 0.9) 100%);
    pointer-events: none;
}

/* ===== FADE TRANSITIONS ===== */
.fade-in { animation: fadeIn 0.6s ease forwards; }
.fade-out { animation: fadeOut 0.6s ease forwards; }
.fade-in-slow { animation: fadeIn 1.2s ease forwards; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ===== DIALOGUE BOX BREATHING ===== */
#dialogue-box .dialogue-inner::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(180deg, transparent 70%, rgba(199, 125, 186, 0.02) 100%);
    pointer-events: none;
    border-radius: inherit;
}

/* ===== AMBIENT GLOW ===== */
.character-sprite.visible {
    animation: sprite-breathe 4s ease-in-out infinite;
}
@keyframes sprite-breathe {
    0%, 100% { filter: drop-shadow(0 4px 25px rgba(0, 0, 0, 0.7)); }
    50% { filter: drop-shadow(0 4px 30px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 5px rgba(199, 125, 186, 0.05)); }
}
.character-sprite.dimmed {
    animation: none;
    filter: brightness(0.45) saturate(0.6) drop-shadow(0 4px 25px rgba(0, 0, 0, 0.7));
}

/* ===== CHOICE COUNTDOWN HINT ===== */
/* Note: ::after is now used for spade watermark, bottom-line on a separate element if needed */

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .dialogue-inner {
        padding: 14px 18px 18px;
        min-height: 120px;
    }
    #char-name { font-size: 1rem; }
    #dialogue-text { font-size: 0.9rem; }
    #choice-container {
        min-width: unset;
        width: 92vw;
        bottom: 160px;
    }
    .choice-btn { font-size: 0.9rem; padding: 14px 20px; }
    .character-sprite { height: 70vh; max-width: 50vw; bottom: 140px; }
    #stats-panel { top: 50px; left: 8px; padding: 10px 14px; min-width: 160px; }
    .overlay-panel { padding: 28px 24px; min-width: 280px; }
    .overlay-wide { min-width: unset; width: 92vw; }
    .title-main { letter-spacing: 0.06em; }

    /* Smaller spade watermark on mobile */
    .choice-btn::after {
        font-size: 1.8rem;
        right: 10px;
    }

    /* Simplify heartbeat on mobile for perf */
    #game-screen.heartbeat {
        animation: heartbeat-screen 0.833s ease-in-out infinite;
    }
}
