/* ============================================================================
   ORDKONGEN HYBRIDMOTOR: VISUELL ROMAN & ESCAPE ROOM (Felles Motorkjerne)
   Fil: engine/css/engine.css
   ============================================================================ */

:root {
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --primary-glow: rgba(245, 158, 11, 0.4);
    --bg-dark: #09090b;
    --bg-card: rgba(18, 18, 24, 0.94);
    --border-color: rgba(255, 255, 255, 0.12);
    --border-gold: rgba(245, 158, 11, 0.5);
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --accent-blue: #3b82f6;
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Roboto Mono', monospace;
    --font-serif: 'Playfair Display', Georgia, serif;
    --font-courier: 'Courier Prime', Courier, monospace;
    --game-zoom: 1;
}

/* Grunnleggende oppsett */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
    -webkit-user-select: none;
    zoom: var(--game-zoom, 1);
}

/* Subtilt filmisk støy/teksturoverlay */
body::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100" height="100" filter="url(%23noise)" opacity="0.035"/></svg>');
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: overlay;
}

/* ----------------------------------------------------------------------------
   Skjermeffekter & Risting
   ---------------------------------------------------------------------------- */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-8px, -6px) rotate(-0.4deg); }
    30% { transform: translate(7px, 5px) rotate(0.4deg); }
    45% { transform: translate(-6px, 4px); }
    60% { transform: translate(5px, -4px); }
    75% { transform: translate(-3px, 2px); }
    90% { transform: translate(2px, -1px); }
}

body.effect-shake #parallax-container,
body.effect-shake {
    animation: screenShake 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes screenFlash {
    0% { filter: brightness(2.8) contrast(1.4); }
    30% { filter: brightness(1.8) hue-rotate(40deg); }
    100% { filter: none; }
}

body.effect-flash {
    animation: screenFlash 0.85s ease-out both;
}

/* ----------------------------------------------------------------------------
   Parallax Bakgrunn & Point & Click Hotspots
   ---------------------------------------------------------------------------- */
#parallax-container {
    perspective: 1000px;
    background-color: #060608;
}

.parallax-layer {
    transition: transform 0.12s ease-out;
    width: 108%;
    height: 108%;
    left: -4%;
    top: -4%;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

/* Klikkbare soner på bakgrunnsbildet (Hotspots / Point & Click) */
.bg-hotspot {
    position: absolute;
    cursor: pointer;
    border: none;
    background: transparent;
    border-radius: 16px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.bg-hotspot:hover {
    background: radial-gradient(ellipse at center, rgba(251, 191, 36, 0.18) 0%, rgba(251, 191, 36, 0.04) 60%, transparent 80%);
}

/* Pulserende Point & Click-merke */
.hotspot-beacon {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bg-hotspot:hover .hotspot-beacon {
    transform: scale(1.18);
}

.beacon-pulse-ring {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(251, 191, 36, 0.75);
    animation: beaconPulse 2.2s cubic-bezier(0.15, 0.85, 0.35, 1) infinite;
    pointer-events: none;
}

.beacon-core {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #92400e 0%, #78350f 45%, #291205 100%);
    border: 2px solid #fbbf24;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.85), 0 0 16px rgba(251, 191, 36, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fef08a;
    font-size: 16px;
}

@keyframes beaconPulse {
    0% { transform: scale(0.65); opacity: 0.95; }
    100% { transform: scale(1.65); opacity: 0; }
}

.bg-hotspot-label {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(28, 20, 8, 0.96), rgba(15, 10, 4, 0.98));
    border: 1.5px solid #fbbf24;
    color: #fef08a;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 9999px;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
    max-width: min(220px, 45vw);
    width: max-content;
    pointer-events: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.85), 0 0 15px rgba(251, 191, 36, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    letter-spacing: 0.02em;
    word-break: break-word;
    z-index: 40;
}

.bg-hotspot:hover .bg-hotspot-label {
    transform: translateX(-50%) translateY(2px) scale(1.05);
    border-color: #ffffff;
    color: #ffffff;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.95), 0 0 25px rgba(251, 191, 36, 0.85);
}

/* Smarte kantopprettinger for etiketter nær skjermkanten */
.bg-hotspot.label-align-right .bg-hotspot-label {
    left: auto;
    right: 0;
    transform: none;
}
.bg-hotspot:hover.label-align-right .bg-hotspot-label {
    transform: translateY(2px) scale(1.05);
}

.bg-hotspot.label-align-left .bg-hotspot-label {
    left: 0;
    right: auto;
    transform: none;
}
.bg-hotspot:hover.label-align-left .bg-hotspot-label {
    transform: translateY(2px) scale(1.05);
}

.bg-hotspot.label-pos-top .bg-hotspot-label {
    bottom: auto;
    top: -34px;
}
.bg-hotspot:hover.label-pos-top:not(.label-align-right):not(.label-align-left) .bg-hotspot-label {
    transform: translateX(-50%) translateY(-2px) scale(1.05);
}
.bg-hotspot:hover.label-pos-top.label-align-right .bg-hotspot-label {
    transform: translateY(-2px) scale(1.05);
}
.bg-hotspot:hover.label-pos-top.label-align-left .bg-hotspot-label {
    transform: translateY(-2px) scale(1.05);
}


/* ----------------------------------------------------------------------------
   Karakter-sprites & Animasjoner (Visuell Roman)
   ---------------------------------------------------------------------------- */
.char-enter-left {
    transform: translateX(-140%);
    opacity: 0;
}

.char-enter-right {
    transform: translateX(140%);
    opacity: 0;
}

.char-active {
    transform: translateX(0);
    opacity: 1;
}

.char-exit-left {
    transform: translateX(-140%) !important;
    opacity: 0 !important;
}

.char-exit-right {
    transform: translateX(140%) !important;
    opacity: 0 !important;
}

/* Dimming av passiv taler når to karakterer samtaler */
.char-dimmed {
    opacity: 0.45 !important;
    filter: brightness(0.65) saturate(0.8) !important;
    transform: scale(0.96) !important;
    transition: all 0.4s ease;
}

.char-focused {
    opacity: 1 !important;
    filter: brightness(1.05) drop-shadow(0 0 15px rgba(245, 158, 11, 0.3)) !important;
    transform: scale(1) !important;
    transition: all 0.4s ease;
}

/* Duel / Konfrontasjon: Begge karakterer er fullt opplyste og aktive i overgangsscener */
.char-duel {
    opacity: 1 !important;
    filter: brightness(1.05) !important;
    transform: scale(1) !important;
}

/* Karakter-omriss (Tegneserie / Cutout-effekt for overgangsscener) */
.char-outline-white {
    filter: drop-shadow(-2px -2px 0 #ffffff)
            drop-shadow(2px -2px 0 #ffffff)
            drop-shadow(-2px 2px 0 #ffffff)
            drop-shadow(2px 2px 0 #ffffff)
            drop-shadow(0 0 10px rgba(255, 255, 255, 0.85)) !important;
}

.char-outline-gold {
    filter: drop-shadow(-2px -2px 0 #f59e0b)
            drop-shadow(2px -2px 0 #f59e0b)
            drop-shadow(-2px 2px 0 #f59e0b)
            drop-shadow(2px 2px 0 #f59e0b)
            drop-shadow(0 0 10px rgba(245, 158, 11, 0.85)) !important;
}

.char-outline-red {
    filter: drop-shadow(-2px -2px 0 #ef4444)
            drop-shadow(2px -2px 0 #ef4444)
            drop-shadow(-2px 2px 0 #ef4444)
            drop-shadow(2px 2px 0 #ef4444)
            drop-shadow(0 0 10px rgba(239, 68, 68, 0.85)) !important;
}

.char-outline-cyan {
    filter: drop-shadow(-2px -2px 0 #06b6d4)
            drop-shadow(2px -2px 0 #06b6d4)
            drop-shadow(-2px 2px 0 #06b6d4)
            drop-shadow(2px 2px 0 #06b6d4)
            drop-shadow(0 0 10px rgba(6, 182, 212, 0.85)) !important;
}

/* Idle og uttrykks-animasjoner */
@keyframes breathing {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.006); }
}
.char-breathing {
    animation: breathing 3.8s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes charFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-7px) rotate(0.4deg); }
    66% { transform: translateY(-3px) rotate(-0.4deg); }
}
.char-float {
    animation: charFloat 4.2s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes sway {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(0.6deg) translateY(-2px); }
}
.char-sway {
    animation: sway 4.5s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-12px); }
    60% { transform: translateY(0); }
}
.char-bounce {
    animation: bounce 0.6s ease-out;
    transform-origin: bottom center;
}

@keyframes angrySnap {
    0% { transform: scale(1) translateY(0); }
    15% { transform: scale(1.06) translateY(-16px) rotate(-2deg); filter: brightness(1.15); }
    30% { transform: scale(1.08) translateY(6px) rotate(2deg); }
    45% { transform: scale(1.04) translateY(-6px); }
    100% { transform: scale(1) translateY(0); }
}
.char-angry {
    animation: angrySnap 0.8s cubic-bezier(0.25, 1, 0.5, 1) both;
    transform-origin: bottom center;
}

@keyframes shockReaction {
    0% { transform: scale(1); }
    20% { transform: scale(1.12) translateY(-14px); }
    40% { transform: scale(0.96) translateY(2px); }
    100% { transform: scale(1) translateY(0); }
}
.char-shocked {
    animation: shockReaction 0.6s ease-out both;
    transform-origin: bottom center;
}

/* ----------------------------------------------------------------------------
   Dialog- og Valgboks (Visuell Roman UI)
   ---------------------------------------------------------------------------- */
#dialog-text {
    line-height: 1.55;
    min-height: 2.6em;
    word-break: break-word;
}

#dialog-box.choices-active {
    cursor: default;
}

#dialog-box.choices-active #dialog-text {
    min-height: 0 !important;
    max-height: 2em !important;
    margin-bottom: 2px;
}

#dialog-box.choices-active #dialog-text:empty {
    display: none !important;
}

.speech-bubble-tail::before {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 40px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 10px solid rgba(9, 9, 11, 0.95);
    display: none;
}

@media (min-width: 768px) {
    .speech-bubble-tail::before {
        display: block;
        bottom: 24px;
        left: -14px;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-right: 14px solid rgba(9, 9, 11, 0.92);
        border-left: none;
    }
}

/* Valgknapper */
.choice-btn {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.choice-btn:hover {
    transform: translateX(-4px) scale(1.01);
}

/* Nedtellingstimer */
.timer-urgent {
    animation: urgentBlink 1s ease-in-out infinite alternate;
    color: #ef4444 !important;
}

@keyframes urgentBlink {
    0% { opacity: 1; text-shadow: 0 0 15px rgba(239, 68, 68, 0.8); }
    100% { opacity: 0.5; text-shadow: none; }
}

/* ----------------------------------------------------------------------------
   Poengsum i HUD (Klasseromskonkurranse)
   ---------------------------------------------------------------------------- */
.score-badge {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.score-badge.penalty-pulse {
    border-color: #ef4444 !important;
    animation: shakeScore 0.4s ease;
}
@keyframes shakeScore {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1) rotate(-1deg); }
}

/* ----------------------------------------------------------------------------
   DYNAMISKE DOKUMENT-OVERLEGG (Tekstfrie bilder, 4 stiler)
   ---------------------------------------------------------------------------- */
/* 1. Gammelt Pergament */
.doc-theme-parchment {
    background: radial-gradient(circle at 50% 45%, #f4ecd8 0%, #e2d3b4 60%, #c9b48c 100%);
    color: #2b1d0c;
    border: 3px solid #855829;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), inset 0 0 40px rgba(133, 88, 41, 0.25);
    font-family: var(--font-serif);
}

/* 2. Telegram / 1900-talls kurer */
.doc-theme-telegram {
    background: #fdfaf2;
    color: #1c1917;
    border: 3px dashed #78716c;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    font-family: var(--font-courier);
}
.doc-theme-telegram .telegram-stamp {
    border: 2px solid #b91c1c;
    color: #b91c1c;
    transform: rotate(-8deg);
    padding: 4px 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 11px;
}

/* 3. Historisk Avisutklipp */
.doc-theme-newspaper {
    background: #f5f0e6;
    color: #111827;
    border: 2px solid #374151;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    font-family: var(--font-serif);
}
.doc-theme-newspaper .newspaper-columns {
    column-count: 2;
    column-gap: 24px;
    column-rule: 1px solid rgba(0, 0, 0, 0.15);
    text-align: justify;
}

/* 4. Inngravert Metallplate / Messing */
.doc-theme-metal {
    background: radial-gradient(circle at 35% 35%, #2a2d32 0%, #17191c 65%, #0f1012 100%);
    color: #e2e8f0;
    border: 3px solid #64748b;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), inset 0 0 30px rgba(255, 255, 255, 0.05);
    font-family: var(--font-mono);
}
.doc-theme-metal .metal-rivet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #94a3b8 0%, #334155 70%);
    border: 1px solid #1e293b;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.4);
}

/* 5. E-postklient / Moderne Dataterminal */
.doc-theme-email {
    background: linear-gradient(180deg, #0e1520 0%, #090e15 100%);
    color: #e2e8f0;
    border: 2px solid #2563eb;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.95), 0 0 35px rgba(37, 99, 235, 0.25);
    font-family: var(--font-sans);
}
.doc-theme-email .email-window-bar {
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid rgba(51, 65, 85, 0.8);
}
.doc-theme-email .email-header-table {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(51, 65, 85, 0.6);
}

/* 6. Fotogransking / Nærbilde */
.doc-theme-photo {
    background: linear-gradient(180deg, #18181b 0%, #09090b 100%);
    color: #f4f4f5;
    border: 2px solid #d97706;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.95), 0 0 35px rgba(217, 119, 6, 0.25);
    font-family: var(--font-sans);
}

/* 7. Hemmelig Dossier / Arkivmappe */
.doc-theme-dossier {
    background: radial-gradient(circle at 50% 30%, #241d14 0%, #17130d 100%);
    color: #f5f0e6;
    border: 2.5px solid #8e7343;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.95), inset 0 0 35px rgba(0, 0, 0, 0.6);
    font-family: var(--font-courier);
}
.doc-theme-dossier .dossier-stamp {
    border: 2px solid #dc2626;
    color: #dc2626;
    transform: rotate(-7deg);
    padding: 3px 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 11px;
}

/* 8. Teknisk Militær Plantegning / Blåkopi */
.doc-theme-blueprint {
    background-color: #0c1f38;
    background-image: 
        linear-gradient(rgba(14, 116, 144, 0.25) 1px, transparent 1px),
        linear-gradient(90deg, rgba(14, 116, 144, 0.25) 1px, transparent 1px),
        linear-gradient(rgba(14, 116, 144, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(14, 116, 144, 0.08) 1px, transparent 1px);
    background-size: 50px 50px, 50px 50px, 10px 10px, 10px 10px;
    color: #e0f2fe;
    border: 2px solid #06b6d4;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.95), 0 0 30px rgba(6, 182, 212, 0.35);
    font-family: var(--font-courier);
}

/* ----------------------------------------------------------------------------
   Stjernerangering på Resultat- & Seiersskjerm
   ---------------------------------------------------------------------------- */
.star-rating {
    font-size: 32px;
    letter-spacing: 6px;
    color: #f59e0b;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
}

/* ----------------------------------------------------------------------------
   Utskriftsdiplom (Print Styles)
   ---------------------------------------------------------------------------- */
@media print {
    body * {
        visibility: hidden !important;
    }
    #diploma-printable, #diploma-printable * {
        visibility: visible !important;
    }
    #diploma-printable {
        position: fixed !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: white !important;
        color: black !important;
        padding: 40px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
    }
}
/* ----------------------------------------------------------------------------
   CINEMATISKE KAMERA- & VISUELL ROMAN EFFEKTER (Filmisk Regi)
   ---------------------------------------------------------------------------- */

/* 1. Kamera-animasjoner */
.camera-pan-right {
    animation: cameraPanRight 20s ease-in-out infinite alternate;
}
@keyframes cameraPanRight {
    0% { transform: scale(1.08) translateX(-2.5%); }
    100% { transform: scale(1.08) translateX(2.5%); }
}

.camera-pan-left {
    animation: cameraPanLeft 20s ease-in-out infinite alternate;
}
@keyframes cameraPanLeft {
    0% { transform: scale(1.08) translateX(2.5%); }
    100% { transform: scale(1.08) translateX(-2.5%); }
}

.camera-pan-up {
    animation: cameraPanUp 18s ease-in-out infinite alternate;
}
@keyframes cameraPanUp {
    0% { transform: scale(1.08) translateY(2.5%); }
    100% { transform: scale(1.08) translateY(-2.5%); }
}

.camera-pan-down {
    animation: cameraPanDown 18s ease-in-out infinite alternate;
}
@keyframes cameraPanDown {
    0% { transform: scale(1.08) translateY(-2.5%); }
    100% { transform: scale(1.08) translateY(2.5%); }
}

.camera-zoom-in {
    animation: cameraZoomIn 22s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes cameraZoomIn {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

.camera-zoom-out {
    animation: cameraZoomOut 22s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes cameraZoomOut {
    0% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.camera-crash-zoom {
    animation: cameraCrashZoom 0.45s cubic-bezier(0.12, 0.9, 0.25, 1) forwards;
}
@keyframes cameraCrashZoom {
    0% { transform: scale(1); }
    70% { transform: scale(1.24); }
    100% { transform: scale(1.18); }
}

.camera-dolly {
    animation: cameraDolly 14s ease-in-out infinite alternate;
}
@keyframes cameraDolly {
    0% { transform: scale(1.02) translateZ(0); }
    100% { transform: scale(1.14) translateZ(50px); }
}

/* 2. Filmisk Letterbox (21:9 anamorfiske striper) */
.letterbox-bar {
    position: fixed;
    left: 0;
    width: 100vw;
    height: 0;
    background: #000000;
    z-index: 85;
    pointer-events: none;
    transition: height 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}
.letterbox-top {
    top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.letterbox-bottom {
    bottom: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
body.letterbox-active .letterbox-bar {
    height: 9.5vh;
}
@media (min-width: 1024px) {
    body.letterbox-active .letterbox-bar {
        height: 11vh;
    }
}

/* 3. Fargegradering (Color Grading) */
#vfx-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    transition: background 0.8s ease, backdrop-filter 0.8s ease, filter 0.8s ease;
}

body.grade-cold-thriller #vfx-overlay {
    background: radial-gradient(circle at center, rgba(14, 165, 233, 0.08) 0%, rgba(2, 6, 23, 0.42) 100%);
    backdrop-filter: saturate(0.65) contrast(1.15) hue-rotate(185deg);
}

body.grade-emergency-red #vfx-overlay {
    background: radial-gradient(circle at center, rgba(239, 68, 68, 0.18) 0%, rgba(69, 10, 10, 0.48) 100%);
    backdrop-filter: contrast(1.22) saturate(1.35);
    animation: emergencyPulse 2.2s ease-in-out infinite alternate;
}
@keyframes emergencyPulse {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

body.grade-sepia #vfx-overlay {
    background: radial-gradient(circle at center, rgba(217, 119, 6, 0.12) 0%, rgba(69, 39, 10, 0.38) 100%);
    backdrop-filter: sepia(0.55) contrast(1.05) brightness(0.95);
}

body.grade-night-vision #vfx-overlay {
    background: radial-gradient(circle at center, rgba(34, 197, 94, 0.15) 0%, rgba(5, 46, 22, 0.75) 100%);
    backdrop-filter: saturate(2) brightness(1.25) contrast(1.3) hue-rotate(85deg);
}
body.grade-night-vision #vfx-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.25) 0px, rgba(0, 0, 0, 0.25) 2px, transparent 2px, transparent 4px);
    pointer-events: none;
}

body.grade-noir #vfx-overlay {
    background: radial-gradient(circle at center, transparent 35%, rgba(0, 0, 0, 0.65) 100%);
    backdrop-filter: grayscale(1) contrast(1.45) brightness(0.9);
}

body.grade-warm-golden #vfx-overlay {
    background: radial-gradient(circle at 60% 40%, rgba(245, 158, 11, 0.14) 0%, rgba(120, 53, 15, 0.32) 100%);
    backdrop-filter: saturate(1.12) brightness(1.03);
}

/* 4. Dybdeskarphet (Depth of Field Blur) */
body.dof-character #bg-layer-back,
body.dof-character #bg-layer-mid,
body.dof-character #bg-layer-front {
    filter: blur(5px) brightness(0.85);
    transition: filter 0.5s ease;
}

body.dof-room #character-container,
body.dof-room #secondary-character-container {
    filter: blur(4px) brightness(0.75);
    transition: filter 0.5s ease;
}

/* 5. POV Overlays (Synsvinkel-effekter) */
#pov-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 55;
    transition: opacity 0.5s ease;
}

#pov-overlay.pov-flashlight {
    background: radial-gradient(circle 240px at var(--mouse-x, 50%) var(--mouse-y, 50%), transparent 0%, rgba(0, 0, 0, 0.88) 190px, rgba(0, 0, 0, 0.98) 320px);
}

#pov-overlay.pov-torch {
    background: radial-gradient(circle 260px at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(255, 185, 60, 0.16) 0%, rgba(210, 110, 20, 0.08) 130px, rgba(14, 8, 4, 0.93) 220px, rgba(4, 2, 1, 0.99) 340px);
    animation: torchFlicker 3.2s infinite alternate ease-in-out;
}

#pov-overlay.pov-lantern {
    background: radial-gradient(circle 230px at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(255, 230, 140, 0.18) 0%, rgba(180, 140, 50, 0.06) 130px, rgba(8, 10, 12, 0.93) 210px, rgba(2, 3, 4, 0.99) 320px);
}

#pov-overlay.pov-dark {
    background: radial-gradient(circle 190px at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.94) 160px, rgba(0, 0, 0, 0.99) 260px);
}

@keyframes torchFlicker {
    0% { filter: brightness(1) drop-shadow(0 0 10px rgba(255, 140, 20, 0.2)); }
    25% { filter: brightness(1.08) drop-shadow(0 0 14px rgba(255, 160, 40, 0.25)); }
    50% { filter: brightness(0.96) drop-shadow(0 0 8px rgba(255, 120, 10, 0.18)); }
    75% { filter: brightness(1.05) drop-shadow(0 0 12px rgba(255, 150, 30, 0.22)); }
    100% { filter: brightness(1.01) drop-shadow(0 0 10px rgba(255, 140, 20, 0.2)); }
}

#pov-overlay.pov-gasmask {
    background: radial-gradient(ellipse 46% 72% at 27% 50%, transparent 40%, rgba(8, 8, 10, 0.97) 82%),
                radial-gradient(ellipse 46% 72% at 73% 50%, transparent 40%, rgba(8, 8, 10, 0.97) 82%);
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.98);
}

#pov-overlay.pov-nightvision {
    background: radial-gradient(circle 340px at 50% 50%, rgba(34, 197, 94, 0.08) 0%, rgba(0, 20, 5, 0.92) 290px, rgba(0, 0, 0, 0.99) 360px);
}



/* 6. Comic Book Multi-Panels (Tegneseriestriper / Cutscenes) */
#comic-panels-container {
    position: absolute;
    inset: 0;
    z-index: 75;
    background: rgba(4, 4, 6, 0.95);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#comic-panels-container.active {
    opacity: 1;
    pointer-events: auto;
}

.comic-grid {
    display: grid;
    gap: 16px;
    width: 100%;
    max-width: 1050px;
    max-height: 82vh;
}

.comic-panel {
    position: relative;
    background: #000000;
    border: 3.5px solid #ffffff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.95), 0 16px 35px rgba(0, 0, 0, 0.85);
    opacity: 0;
    transform: translateY(24px) scale(0.96);
    transition: all 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.comic-panel.revealed {
    opacity: 1;
    transform: translateY(0) scale(1);
}

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

.comic-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fffcee;
    color: #18181b;
    padding: 8px 14px;
    font-family: var(--font-courier), monospace;
    font-size: 13px;
    font-weight: 700;
    border-top: 2.5px solid #18181b;
    letter-spacing: 0.02em;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.35);
}

.comic-speech-bubble {
    position: absolute;
    top: 14px;
    left: 14px;
    background: #ffffff;
    color: #09090b;
    border: 2px solid #09090b;
    border-radius: 14px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 800;
    max-width: 82%;
    box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.85);
}

.comic-close-hint {
    margin-top: 16px;
    font-size: 12px;
    color: #a1a1aa;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-family: var(--font-mono);
}

/* ----------------------------------------------------------------------------
   7. FILM- OG SCENEOVERGANGER (Cinematic Transitions)
   ---------------------------------------------------------------------------- */
#scene-transition-overlay {
    position: fixed;
    inset: 0;
    z-index: 84;
    background: #000000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.32s ease;
}

#scene-transition-overlay.transition-fade-black {
    opacity: 1;
}

#scene-transition-overlay.transition-wipe-left {
    opacity: 1;
    transform: translateX(100%);
    animation: sceneWipeLeft 0.65s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes sceneWipeLeft {
    0% { transform: translateX(100%); }
    45% { transform: translateX(0); }
    60% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ----------------------------------------------------------------------------
   8. MÅLRETTET KAMERAFOKUS (Targeted Camera Focus)
   ---------------------------------------------------------------------------- */
#parallax-container.camera-focusing {
    transition: transform 1.25s cubic-bezier(0.16, 1, 0.3, 1), transform-origin 1.25s ease !important;
}

/* ----------------------------------------------------------------------------
   9. TEGNESERIE-LYDEFFEKTER PÅ SKJERMEN (Comic FX Onomatopoetikon)
   ---------------------------------------------------------------------------- */
.comic-fx-burst {
    position: fixed;
    z-index: 95;
    pointer-events: none;
    font-family: var(--font-main);
    font-weight: 900;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: clamp(26px, 4.5vw, 46px);
    color: #fef08a;
    -webkit-text-stroke: 2px #09090b;
    text-shadow: 4px 4px 0px #000000, 0 0 25px rgba(245, 158, 11, 0.85);
    background: linear-gradient(135deg, #b45309 0%, #d97706 45%, #f59e0b 100%);
    padding: 8px 26px;
    border: 3.5px solid #09090b;
    border-radius: 9999px;
    box-shadow: 6px 6px 0px #000000, 0 12px 35px rgba(0, 0, 0, 0.75);
    transform-origin: center center;
    animation: comicBurstPop 0.95s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes comicBurstPop {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-18deg); opacity: 0; }
    22% { transform: translate(-50%, -50%) scale(1.25) rotate(-8deg); opacity: 1; }
    45% { transform: translate(-50%, -50%) scale(1.02) rotate(-6deg); opacity: 1; }
    80% { transform: translate(-50%, -60%) scale(1) rotate(-6deg); opacity: 1; }
    100% { transform: translate(-50%, -85%) scale(0.85) rotate(-4deg); opacity: 0; }
}

.comic-fx-burst.comic-fx-electric {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%);
    color: #eff6ff;
    text-shadow: 4px 4px 0px #000000, 0 0 25px rgba(59, 130, 246, 0.85);
}

.comic-fx-burst.comic-fx-danger {
    background: linear-gradient(135deg, #991b1b 0%, #dc2626 50%, #ef4444 100%);
    color: #fef2f2;
    text-shadow: 4px 4px 0px #000000, 0 0 25px rgba(239, 68, 68, 0.85);
}

.comic-fx-burst.comic-fx-success {
    background: linear-gradient(135deg, #065f46 0%, #059669 50%, #10b981 100%);
    color: #ecfdf5;
    text-shadow: 4px 4px 0px #000000, 0 0 25px rgba(16, 185, 129, 0.85);
}

/* ----------------------------------------------------------------------------
   10. HOTSPOT-MINNE (Utforskede vs Uutforskede spor)
   ---------------------------------------------------------------------------- */
.bg-hotspot.hotspot-explored .beacon-pulse-ring {
    display: none !important;
}

.bg-hotspot.hotspot-explored .beacon-core {
    background: radial-gradient(circle at 35% 35%, #064e3b 0%, #047857 55%, #022c22 100%);
    border-color: #10b981;
    color: #a7f3d0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.75), 0 0 10px rgba(16, 185, 129, 0.45);
    opacity: 0.85;
}

.bg-hotspot.hotspot-explored:hover .beacon-core {
    opacity: 1;
    transform: scale(1.1);
}

.bg-hotspot.hotspot-explored .bg-hotspot-label {
    border-color: #10b981;
    color: #a7f3d0;
    background: linear-gradient(135deg, rgba(6, 46, 34, 0.95), rgba(4, 30, 22, 0.98));
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.8), 0 0 12px rgba(16, 185, 129, 0.4);
    opacity: 0.85;
}

.bg-hotspot.hotspot-explored:hover .bg-hotspot-label {
    opacity: 1;
}

/* Dialog-risting ved [shake] i teksten */
.dialog-shaking {
    animation: dialogShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes dialogShake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-6px, 3px) rotate(-0.5deg); }
    40% { transform: translate(6px, -3px) rotate(0.5deg); }
    60% { transform: translate(-4px, 2px); }
    80% { transform: translate(4px, -1px); }
}

/* ----------------------------------------------------------------------------
   11. NYE MINIGAME-EFFEKTER (UV, RADIO, RIVET DOKUMENT)
   ---------------------------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes uvPulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.6)); }
    50% { filter: drop-shadow(0 0 20px rgba(56, 189, 248, 0.85)); }
}

.uv-neon-glow {
    animation: uvPulse 2s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   12. WORDLE & ORDGAATE-ANIMAJONER
   ---------------------------------------------------------------------------- */
@keyframes tileFlip {
    0% { transform: rotateX(0deg); }
    45% { transform: rotateX(90deg); }
    55% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

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

.tile-pop {
    animation: tilePop 0.15s ease-in-out;
}

/* ----------------------------------------------------------------------------
   13. AUTO-HIDE HEADER & VISNINGSKONTROLLER (FOR 12" ELEVSKJERMER)
   ---------------------------------------------------------------------------- */
#hud {
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

#hud.hud-pinned,
#hud.hud-visible,
#hud:hover,
#hud:focus-within {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

#hud-sensor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 18px;
    z-index: 89;
    pointer-events: auto;
}

#hud-pull-tab {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#hud.hud-pinned ~ #hud-pull-tab,
#hud.hud-visible ~ #hud-pull-tab,
#hud:hover ~ #hud-pull-tab {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translate(-50%, -10px) !important;
}

.view-controls button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ============================================================================
   14. CINEMATIC DIRECTOR CUTSCENE ENGINE v2 (Filmatisk Multi-Layer Regi)
   ============================================================================ */
#cinematic-cutscene-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 500 !important;
    background: #000000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#cinematic-cutscene-container.active {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.cinematic-letterbox-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000000;
}

/* 21:9 kinostriper som rammer inn scenen */
.cinematic-bar {
    position: absolute;
    left: 0;
    right: 0;
    background: #000000;
    z-index: 30;
    pointer-events: none;
    transition: height 0.4s ease;
}
.cinematic-bar-top { top: 0; height: 6.5vh; }
.cinematic-bar-bottom { bottom: 0; height: 6.5vh; }

/* Scenen (alle lag ligger her inni) */
.cinematic-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transform-origin: center center;
}

/* 1. Bakgrunn / Himmel / Horisont (Lag 1) */
.cinematic-layer-sky {
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    will-change: transform;
    transition: transform 4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.45s ease;
}

/* 2. Mellomgrunn / Miljø / Vei (Lag 2) */
.cinematic-layer-mid {
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 2;
    will-change: transform;
    transition: transform 3.5s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.45s ease;
}

/* 3. Frittstående Props & Rekvisitter (Lag 3) */
.cinematic-props-container {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}

.cinematic-prop {
    position: absolute;
    will-change: transform, opacity;
    user-select: none;
}

/* Animasjon: Skilt / Kjøretøy som suser forbi i full fart (Fly-by) */
@keyframes prop-flyby-right {
    0% {
        transform: translate3d(-30%, 15%, 0) scale(0.15) rotate(-6deg);
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    85% {
        opacity: 1;
    }
    100% {
        transform: translate3d(140%, -10%, 0) scale(2.4) rotate(8deg);
        opacity: 0;
    }
}

@keyframes prop-flyby-left {
    0% {
        transform: translate3d(120%, 15%, 0) scale(0.15) rotate(6deg);
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    85% {
        opacity: 1;
    }
    100% {
        transform: translate3d(-60%, -10%, 0) scale(2.4) rotate(-8deg);
        opacity: 0;
    }
}

.prop-flyby-right {
    animation: prop-flyby-right 0.65s cubic-bezier(0.32, 0, 0.67, 0) forwards;
}
.prop-flyby-left {
    animation: prop-flyby-left 0.65s cubic-bezier(0.32, 0, 0.67, 0) forwards;
}

/* Animasjon: Kjøretøy-fjæring (dupping på humpete vei/bølger) */
@keyframes prop-suspension-bob {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-3px) rotate(0.4deg); }
    50% { transform: translateY(2px) rotate(-0.3deg); }
    75% { transform: translateY(-1px) rotate(0.2deg); }
}

.prop-bob {
    animation: prop-suspension-bob 1.8s ease-in-out infinite;
}

/* Animasjon: Speedometernål som klatrer */
@keyframes prop-needle-rise {
    0% { transform: rotate(-80deg); }
    100% { transform: rotate(45deg); }
}
.prop-needle-rise {
    transform-origin: bottom center;
    animation: prop-needle-rise 2.2s cubic-bezier(0.12, 0.8, 0.32, 1) forwards;
}

/* 4. Forgrunnsramme / Cockpit / Dashbord (Lag 4) */
.cinematic-layer-cockpit {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center bottom;
    z-index: 10;
    pointer-events: none;
    will-change: transform;
    transition: transform 0.4s ease;
}

/* 5. Linse- & Lys-effekter (Lag 5) */
.cinematic-layer-fx {
    position: absolute;
    inset: 0;
    z-index: 15;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,0,0,0.65) 100%);
    box-shadow: inset 0 0 100px rgba(0,0,0,0.85);
}

/* Kamerabevegelser og risting */
@keyframes cinematic-high-speed-shake {
    0% { transform: translate(0, 0) scale(1.05); }
    20% { transform: translate(-1.5px, 1.2px) scale(1.05); }
    40% { transform: translate(1.8px, -1px) scale(1.05); }
    60% { transform: translate(-1.2px, -1.5px) scale(1.05); }
    80% { transform: translate(1.4px, 1.3px) scale(1.05); }
    100% { transform: translate(0, 0) scale(1.05); }
}

.cinematic-shake {
    animation: cinematic-high-speed-shake 0.14s linear infinite !important;
}

@keyframes cinematic-punch-in {
    0% { transform: scale(1.02); }
    100% { transform: scale(1.24); }
}
.cinematic-punch {
    animation: cinematic-punch-in 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Anime Action Speedlines (Motion Comic) */
.cinematic-speedlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 25;
    background: repeating-conic-gradient(
        from 0deg,
        rgba(255, 255, 255, 0) 0deg 6deg,
        rgba(255, 255, 255, 0.35) 7deg 8.5deg,
        rgba(255, 255, 255, 0) 9.5deg 16deg
    );
    mask-image: radial-gradient(circle at center, transparent 32%, black 78%);
    -webkit-mask-image: radial-gradient(circle at center, transparent 32%, black 78%);
    animation: anime-speedlines-flicker 0.08s steps(2) infinite;
    mix-blend-mode: overlay;
}

.cinematic-speedlines.danger {
    background: repeating-conic-gradient(
        from 0deg,
        rgba(239, 68, 68, 0) 0deg 5deg,
        rgba(239, 68, 68, 0.55) 6deg 8deg,
        rgba(239, 68, 68, 0) 9deg 15deg
    );
    mix-blend-mode: screen;
}

@keyframes anime-speedlines-flicker {
    0% { transform: scale(1) rotate(0deg); opacity: 0.95; }
    33% { transform: scale(1.05) rotate(4deg); opacity: 0.7; }
    66% { transform: scale(0.97) rotate(-3deg); opacity: 1; }
    100% { transform: scale(1.02) rotate(2deg); opacity: 0.85; }
}

/* Comic Impact Text / Onomatopoeia */
.cinematic-comic-fx {
    position: absolute;
    top: 36%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8) rotate(-6deg);
    z-index: 35;
    pointer-events: none;
    font-family: 'Outfit', 'Impact', sans-serif;
    font-size: clamp(38px, 6vw, 76px);
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fef08a;
    -webkit-text-stroke: 3px #dc2626;
    text-shadow: 0 0 25px rgba(239, 68, 68, 0.9), 4px 6px 0 #7f1d1d;
    animation: comic-fx-burst 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes comic-fx-burst {
    0% { transform: translate(-50%, -50%) scale(0.4) rotate(-14deg); opacity: 0; }
    40% { transform: translate(-50%, -50%) scale(1.22) rotate(-6deg); opacity: 1; }
    75% { transform: translate(-50%, -50%) scale(1.05) rotate(-5deg); opacity: 0.95; }
    100% { transform: translate(-50%, -50%) scale(1) rotate(-6deg); opacity: 0.85; }
}

/* Screen Flash Overlay */
.cinematic-flash-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    pointer-events: none;
    background: #ffffff;
    opacity: 0;
    transition: opacity 0.05s ease-out;
}
.cinematic-flash-overlay.flash-white {
    animation: cinematic-flash-burst 0.7s ease-out forwards;
}
.cinematic-flash-overlay.flash-orange {
    background: radial-gradient(circle at center, #fef08a 0%, #ea580c 60%, #7c2d12 100%);
    animation: cinematic-flash-burst 0.85s ease-out forwards;
}
@keyframes cinematic-flash-burst {
    0% { opacity: 0.95; }
    30% { opacity: 0.75; }
    100% { opacity: 0; }
}

/* HUD / UI for cutscenes */
.cinematic-ui-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 24px;
    pointer-events: none;
}

.cinematic-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 1.5vh;
}

.cinematic-chapter-badge {
    background: rgba(10, 10, 14, 0.85);
    border: 1px solid rgba(245, 158, 11, 0.45);
    color: #fcd34d;
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: 6px 14px;
    border-radius: 9999px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
}

.cinematic-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cinematic-dot {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.25);
    transition: all 0.3s ease;
}
.cinematic-dot.active {
    width: 16px;
    background: #f59e0b;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.8);
}

.cinematic-skip-btn {
    pointer-events: auto;
    background: rgba(15, 15, 20, 0.75);
    hover:bg-zinc-800;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e4e4e7;
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}
.cinematic-skip-btn:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
    color: #ffffff;
    transform: scale(1.03);
}

/* Undertekstfelt */
.cinematic-subtitles-bar {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 3vh auto;
    background: linear-gradient(180deg, rgba(8, 8, 12, 0.65) 0%, rgba(5, 5, 8, 0.92) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 14px 22px;
    backdrop-filter: blur(14px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.85);
    text-align: center;
    pointer-events: auto;
    cursor: pointer;
}

.cinematic-speaker-tag {
    display: inline-block;
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #38bdf8;
    margin-bottom: 4px;
}

.cinematic-text {
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    font-weight: 500;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.cinematic-hint-click {
    font-family: 'Roboto Mono', monospace;
    font-size: 10px;
    color: rgba(245, 176, 65, 0.75);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 6px;
    animation: cinematicBlink 1.4s infinite ease-in-out;
}

@keyframes cinematicBlink {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(2px); }
}

/* Karakter-lag i filmatiske visuelle romanser (sprites uten bakgrunn - Klassisk Visuell Roman midje-opp) */
.cinematic-layer-character {
    position: absolute;
    bottom: 0;
    left: 8%;
    height: 72vh;
    max-height: 640px;
    z-index: 12;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.cinematic-layer-character img {
    height: 100%;
    width: auto;
    object-fit: contain;
    object-position: bottom;
    filter: drop-shadow(0 14px 35px rgba(0, 0, 0, 0.9));
}

/* ----------------------------------------------------------------------------
   10. FILMISK STEDS- OG TIDSKORT / OVERGANGSBANNER (Location & Era Card)
   ---------------------------------------------------------------------------- */
.engine-location-card {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translate(-50%, -15px);
    z-index: 85;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.engine-location-card.active {
    opacity: 1;
    transform: translate(-50%, 0);
}

.loc-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: rgba(9, 9, 11, 0.88);
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 9999px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(245, 158, 11, 0.2);
    backdrop-filter: blur(12px);
    text-align: center;
}

.loc-card-title {
    font-family: var(--font-mono, monospace);
    font-size: clamp(12px, 1.8vw, 15px);
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #fbbf24;
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
}

.loc-card-sub {
    font-family: var(--font-mono, monospace);
    font-size: clamp(10px, 1.3vw, 12px);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #38bdf8;
    margin-top: 2px;
}

/* ----------------------------------------------------------------------------
   Rominspeksjon (POV Mode) - Skyv karakterer mykt ut av syne
   ---------------------------------------------------------------------------- */
body.pov-inspecting #character-container {
    transform: translateX(-150px) scale(0.94) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
body.pov-inspecting #secondary-character-container {
    transform: translateX(150px) scale(0.94) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
body.pov-inspecting #dialogue-container,
body.pov-inspecting #dialog-wrapper {
    opacity: 0.25 !important;
    transition: opacity 0.35s ease !important;
}
body.pov-inspecting #dialogue-container:hover,
body.pov-inspecting #dialog-wrapper:hover {
    opacity: 0.95 !important;
}

/* 2.5D WebGL Depth Parallax Canvas */
#webgl-depth-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* ============================================================================
   RESPONSIV MINISPILL-CONTAINER (OPTIMALISERT FOR 12-14" ELEV-CHROMEBOOKS)
   ============================================================================ */
#minigame-overlay {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    align-items: center !important;
}

#minigame-overlay > div {
    margin-top: auto !important;
    margin-bottom: auto !important;
    max-height: none !important;
}

/* ============================================================================
   11. CINEMATIC COUNTDOWN CLOCK (Sort bakgrunn med 3-sekunders nedtelling)
   ============================================================================ */
.cinematic-countdown-clock {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #000000;
    pointer-events: none;
    user-select: none;
    overflow: hidden;
}

.cinematic-clock-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.35) 0px,
        rgba(0, 0, 0, 0.35) 2px,
        rgba(0, 0, 0, 0) 2px,
        rgba(0, 0, 0, 0) 4px
    );
    pointer-events: none;
    opacity: 0.65;
    z-index: 2;
}

.cinematic-clock-badge {
    position: relative;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(20, 15, 18, 0.92);
    border: 1px solid rgba(239, 68, 68, 0.65);
    color: #f87171;
    font-family: 'Roboto Mono', monospace;
    font-size: clamp(11px, 1.6vw, 14px);
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    padding: 8px 22px;
    border-radius: 9999px;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.35), inset 0 0 12px rgba(239, 68, 68, 0.2);
    margin-bottom: 24px;
    animation: clockBadgePulse 2s ease-in-out infinite;
    backdrop-filter: blur(8px);
}

.cinematic-clock-pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background-color: #ef4444;
    box-shadow: 0 0 12px #ef4444;
    animation: clockDotBlink 1s infinite steps(2);
}

.cinematic-clock-digits {
    position: relative;
    z-index: 5;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: clamp(68px, 14vw, 140px);
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #4ade80;
    text-shadow: 
        0 0 12px rgba(74, 222, 128, 0.85),
        0 0 35px rgba(74, 222, 128, 0.55),
        0 0 75px rgba(74, 222, 128, 0.3);
    line-height: 1;
    margin: 6px 0 20px 0;
    transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease, text-shadow 0.2s ease;
}

.cinematic-clock-digits.tick-pulse {
    transform: scale(1.09);
    color: #fcd34d;
    text-shadow: 
        0 0 18px rgba(252, 211, 77, 0.95),
        0 0 45px rgba(252, 211, 77, 0.7),
        0 0 90px rgba(252, 211, 77, 0.4);
}

.cinematic-clock-digits.final-tick {
    transform: scale(1.15);
    color: #f87171;
    text-shadow: 
        0 0 25px rgba(248, 113, 113, 1),
        0 0 60px rgba(248, 113, 113, 0.8),
        0 0 120px rgba(248, 113, 113, 0.5);
}

.cinematic-clock-sub {
    position: relative;
    z-index: 5;
    font-family: 'Roboto Mono', monospace;
    font-size: clamp(11px, 1.8vw, 15px);
    font-weight: 600;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: #94a3b8;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
}

@keyframes clockBadgePulse {
    0%, 100% { 
        border-color: rgba(239, 68, 68, 0.55); 
        box-shadow: 0 0 25px rgba(239, 68, 68, 0.25); 
    }
    50% { 
        border-color: rgba(239, 68, 68, 0.95); 
        box-shadow: 0 0 40px rgba(239, 68, 68, 0.6); 
    }
}

@keyframes clockDotBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* ============================================================================
   12. ULTRA-RESPONSIVITET FOR SMÅ VINDUER, CHROMEBOOKS & DELTE SKJERMER
   ============================================================================ */

/* A. Lav Skjermhøyde (f.eks. bærbar PC, Chromebook, delt skjermbilde, h <= 760px) */
@media (max-height: 760px) {
    #dialog-wrapper {
        padding-top: 4px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        padding-bottom: clamp(6px, 1.4vh, 12px) !important;
        max-width: min(880px, 96vw) !important;
    }

    #dialog-box {
        padding: clamp(8px, 1.8vh, 14px) clamp(12px, 2.5vw, 22px) !important;
        border-radius: 16px !important;
    }

    #dialog-box.choices-active {
        padding: 6px 14px !important;
    }

    #dialog-text {
        font-size: clamp(13px, 1.5vh + 0.4vw, 16px) !important;
        line-height: 1.38 !important;
        min-height: auto !important;
    }

    #choices-container {
        gap: 6px !important;
        margin-bottom: 6px !important;
    }

    #choices-container button,
    .choice-btn {
        padding: clamp(6px, 1.2vh, 9px) 14px !important;
        font-size: clamp(12px, 1.3vh + 0.3vw, 14px) !important;
        border-radius: 10px !important;
    }

    #speaker-name {
        font-size: 11px !important;
        padding: 2px 8px !important;
        margin-bottom: 4px !important;
    }

    #character-container {
        height: 64vh !important;
        max-height: 440px !important;
        bottom: 0 !important;
    }

    #secondary-character-container {
        height: 58vh !important;
        max-height: 400px !important;
        bottom: 0 !important;
    }
}

/* Ekstremt lav skjermhøyde (h <= 560px) */
@media (max-height: 560px) {
    #dialog-wrapper {
        padding-bottom: 4px !important;
        max-width: min(800px, 98vw) !important;
    }

    #dialog-box {
        padding: 6px 12px !important;
        border-radius: 12px !important;
    }

    #dialog-text {
        font-size: 12.5px !important;
        line-height: 1.3 !important;
    }

    #choices-container {
        gap: 4px !important;
        margin-bottom: 4px !important;
    }

    #choices-container button,
    .choice-btn {
        padding: 5px 10px !important;
        font-size: 12px !important;
    }

    #character-container {
        height: 70vh !important;
        max-height: 330px !important;
    }

    #secondary-character-container {
        height: 64vh !important;
        max-height: 300px !important;
    }
}

/* B. Smal Skjermbredde (w <= 840px) */
@media (max-width: 840px) {
    #hud {
        padding: 4px 8px !important;
    }

    /* Skjul sekundære badges for å garantere at handlingsknapper og sekk aldri skyves ut */
    #hud #team-badge,
    #hud #score-badge,
    #hud #room-progress-badge,
    #hud #stat-container,
    #hud .view-controls {
        display: none !important;
    }

    #timer-container {
        padding: 3px 8px !important;
    }

    #timer-display {
        font-size: 13px !important;
    }

    #character-container {
        left: 8px !important;
        max-width: 48vw !important;
    }

    #secondary-character-container {
        left: 20% !important;
        max-width: 48vw !important;
    }
}

/* Veldig smal bredde (w <= 520px) */
@media (max-width: 520px) {
    #hud {
        padding: 3px 6px !important;
    }

    #btn-return-menu span.font-mono,
    #btn-request-next-hint span.font-mono,
    #btn-hint span:not(:first-child) {
        display: none !important;
    }

    #character-container {
        left: 4px !important;
        height: 52vh !important;
        max-height: 340px !important;
    }

    #secondary-character-container {
        left: 16% !important;
        height: 48vh !important;
        max-height: 310px !important;
    }
}

/* C. Minigame Overlegg på mindre skjermer */
#minigame-overlay > div {
    max-height: 94vh !important;
    overflow-y: auto !important;
    margin: auto !important;
}




