@import url('https://fonts.googleapis.com/css2?family=VT323&family=Share+Tech+Mono&family=Inter:wght@400;600&display=swap');

/* ============================
   DESIGN TOKENS
   ============================ */
:root {
    --bg: #050505;
    --green: #33ff33;
    --green-dim: #1db91d;
    --green-ghost: rgba(51, 255, 51, 0.08);
    --green-glow: rgba(51, 255, 51, 0.35);
    --red: #ff4444;
    --red-dim: rgba(255, 68, 68, 0.25);
    --amber: #ffbb33;
    --panel-bg: rgba(5, 5, 5, 0.75);
    --panel-border: 1px solid rgba(51, 255, 51, 0.2);
    --glass: rgba(8, 8, 8, 0.65);
    --glass-heavy: rgba(5, 5, 5, 0.85);
    --font-mono: 'VT323', monospace;
    --font-tech: 'Share Tech Mono', monospace;
    --font-sans: 'Inter', sans-serif;
    --radius: 6px;
    --radius-lg: 12px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

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

html,
body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background: var(--bg);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

/* ============================
   APP CONTAINER – fullscreen
   ============================ */
#app-container {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}

/* ============================
   SCENE BACKGROUND (fullscreen image)
   ============================ */
#scene-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--bg);
}

/* Blurred background layer */
#scene-bg img#room-image-blur {
    position: absolute;
    inset: -20px;
    width: calc(100% + 40px);
    height: calc(100% + 40px);
    object-fit: cover;
    filter: blur(20px) brightness(0.4) saturate(0.8);
    opacity: 1;
    z-index: 0;
    transition: opacity 0.6s ease;
}

/* Sharp foreground layer */
#scene-bg img#room-image {
    position: absolute;
    top: var(--bg-margin, 0px);
    bottom: var(--bg-margin, 0px);
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100% - (2 * var(--bg-margin, 0px)));
    object-fit: contain;
    z-index: 1;
    filter: brightness(0.55) contrast(1.15) saturate(0.7);
    transition: opacity 0.6s ease;
    /* removed filter transition to avoid frame drops */
    will-change: transform, opacity;
    transform: translateZ(0);
    /* Force GPU */
}

#scene-bg img.fade-out {
    opacity: 0;
}

/* Vignette */
#scene-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.7) 100%);
    pointer-events: none;
    will-change: opacity;
}

/* Noise texture */
#scene-noise {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* ============================
   CRT OVERLAY
   ============================ */
#crt-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.06) 2px,
            rgba(0, 0, 0, 0.06) 4px);
}

#crt-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent, rgba(51, 255, 51, 0.03), transparent);
    height: 120px;
    animation: scanline 6s linear infinite;
}

@keyframes scanline {
    0% {
        transform: translateY(-120px);
    }

    100% {
        transform: translateY(100vh);
    }
}

/* ============================
   TERMINAL LINE
   ============================ */
#terminal-line-container {
    position: relative;
    z-index: 50;
    margin: 0.5rem 1rem;
    padding: 0.4rem 0.8rem;
    background: var(--glass-light);
    border: 1px solid rgba(51, 255, 51, 0.1);
    border-radius: var(--radius);
    font-family: var(--font-tech);
    font-size: 0.75rem;
    color: var(--green-dim);
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    gap: 0;
    pointer-events: auto;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: background 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}

#terminal-line-container.interactive-prompt #terminal-prompt {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
    animation: terminal-blink 1s step-end infinite;
}

@keyframes terminal-blink {
    50% {
        opacity: 0;
    }
}

#terminal-line-container.expanded {
    padding-top: 0.6rem;
    gap: 0.2rem;
}

#terminal-line-container:hover {
    background: rgba(51, 255, 51, 0.08);
}

#terminal-prompt {
    color: var(--green);
    font-weight: bold;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

#terminal-history {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

#terminal-line-container.expanded #terminal-history {
    max-height: 3.5rem;
    opacity: 1;
}

.terminal-history-line {
    opacity: 0.4;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.terminal-current-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#terminal-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--green);
}

/* Choice Menu */
.terminal-choice-menu {
    position: fixed;
    z-index: 1000;
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Gap between buttons like terminal lines */
    box-shadow: none;
    backdrop-filter: none;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.terminal-choice-btn {
    background: var(--glass-light);
    border: 1px solid rgba(51, 255, 51, 0.1);
    border-radius: var(--radius);
    color: var(--green-dim);
    padding: 0.4rem 0.8rem;
    font-family: var(--font-tech);
    font-size: 0.75rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    backdrop-filter: blur(12px);
}

.terminal-choice-btn:hover {
    background: rgba(51, 255, 51, 0.08);
    border-color: rgba(51, 255, 51, 0.3);
    color: var(--green);
    padding-left: 1rem;
}

.terminal-choice-btn::before {
    content: '>';
    color: var(--green);
    opacity: 0.5;
    font-weight: bold;
    transition: opacity 0.2s;
}

.terminal-choice-btn:hover::before {
    opacity: 1;
}

/* ============================
   HUD BAR (top)
   ============================ */
#hud-bar {
    position: relative;
    z-index: 100;
    /* Ensure it's above everything */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    /*padding-top: calc(0.6rem + var(--safe-top));*/
    background: linear-gradient(to bottom,
            rgba(5, 5, 5, 0.95) 0%,
            rgba(5, 5, 5, 0.8) 70%,
            transparent 100%);
    backdrop-filter: blur(4px);
    gap: 0.5rem;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(51, 255, 51, 0.05);
}

.hud-left,
.hud-center,
.hud-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.hud-logo {
    font-family: var(--font-tech);
    font-size: 1rem;
    letter-spacing: 3px;
    color: var(--green);
    text-shadow: 0 0 8px var(--green-glow);
    opacity: 0.7;
}

.hud-logo-dim {
    opacity: 0.4;
    margin-left: 2px;
}

.hud-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.hud-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.hud-number {
    font-family: var(--font-tech);
    font-size: 0.85rem;
    color: var(--green);
    letter-spacing: 1px;
}

.hud-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    /* stała wysokość */
    padding: 0 0.6rem;
    /* tylko poziomy padding */
    font-family: var(--font-tech);
    font-size: 0.8rem;
    color: var(--green-dim);
    border: 1px solid rgba(51, 255, 51, 0.15);
    border-radius: var(--radius);
    background: rgba(51, 255, 51, 0.04);
    line-height: 1;
    /* zapobiega dodatkowym odstępom */
}

/* Badge-style buttons */
.hud-badge-btn {
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid rgba(51, 255, 51, 0.15);
}

.hud-badge-btn:hover {
    background: rgba(51, 255, 51, 0.1);
    border-color: rgba(51, 255, 51, 0.3);
    color: var(--green);
    box-shadow: 0 0 8px rgba(51, 255, 51, 0.2);
}

.hud-badge-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 4px rgba(51, 255, 51, 0.15);
}

/* Sanity Bar */
.sanity-bar {
    width: 70px;
    height: 6px;
    background: rgba(51, 255, 51, 0.1);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(51, 255, 51, 0.2);
}

#sanity-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
    border-radius: 3px;
    transition: width 0.5s var(--transition);
    box-shadow: 0 0 6px var(--green-glow);
}

/* HUD Buttons */
.hud-btn {
    background: rgba(51, 255, 51, 0.04);
    border: 1px solid rgba(51, 255, 51, 0.15);
    color: var(--green-dim);
    font-size: 0.8rem;
    height: 28px;
    padding: 0 0.6rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-family: var(--font-tech);
}

.hud-btn:hover,
.hud-btn:active {
    background: rgba(51, 255, 51, 0.1);
    border-color: rgba(51, 255, 51, 0.3);
    color: var(--green);
    box-shadow: 0 0 8px rgba(51, 255, 51, 0.2);
}

.debug-btn {
    min-width: 28px;
    height: 28px;
    font-size: 0.8rem;
    opacity: 0.5;
    padding: 0;
}

.debug-btn:hover {
    opacity: 1;
}

/* ============================
   SETTINGS PANEL
   ============================ */
.settings-panel {
    position: absolute;
    top: calc(3rem + var(--safe-top));
    right: 1rem;
    z-index: 20;
    background: var(--glass-heavy);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--panel-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
    transition: opacity var(--transition), transform var(--transition);
    min-width: 200px;
}

.settings-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.97);
}

.settings-title {
    font-family: var(--font-tech);
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--green-dim);
    opacity: 0.6;
    text-transform: uppercase;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.control-group label {
    font-family: var(--font-tech);
    font-size: 0.75rem;
    color: var(--green-dim);
    letter-spacing: 1px;
}

/* Range Input */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(51, 255, 51, 0.15);
    border-radius: 2px;
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 6px;
    background: var(--green);
    border-radius: 2px;
    cursor: pointer;
    box-shadow: 0 0 6px var(--green-glow);
}

input[type=range]::-moz-range-thumb {
    height: 16px;
    width: 6px;
    background: var(--green);
    border: none;
    border-radius: 2px;
    cursor: pointer;
}

/* ============================
   GAME VIEWPORT (narrative)
   ============================ */
#game-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    z-index: 5;
    min-height: 0;
    overflow: hidden;
}

/* Narrative Panel - glass footer over the image */
#narrative-panel {
    background: linear-gradient(to top, var(--glass-heavy) 40%, var(--glass) 80%, transparent 100%);
    padding: 2.5rem 1.5rem 1rem;
    position: relative;
}

#narrative-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 1.5rem;
    right: 1.5rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--green-dim), transparent);
    opacity: 0.3;
}

#room-title {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    letter-spacing: 3px;
    color: var(--green);
    text-shadow: 0 0 12px var(--green-glow), 0 0 30px rgba(51, 255, 51, 0.1);
    margin-bottom: 0.2rem;
    line-height: 1.2;
}

#room-subtitle {
    font-family: var(--font-tech);
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: var(--green-dim);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    opacity: 0.8;
}

#room-desc {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    line-height: 1.5;
    color: rgba(51, 255, 51, 0.85);
    max-height: 30vh;
    overflow-y: auto;
}

.interactable-desc {
    margin-top: 0.8rem;
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--amber);
    opacity: 0.9;
    font-style: italic;
    line-height: 1.4;
    padding-left: 0.8rem;
    border-left: 2px solid rgba(255, 187, 51, 0.3);
}

/* ============================
   ACTIONS CONTAINER
   ============================ */
#actions-container {
    position: relative;
    z-index: 10;
    padding: 0.8rem 1rem;
    padding-bottom: calc(0.8rem + var(--safe-bottom));
    background: var(--glass-heavy);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    border-top: 1px solid rgba(51, 255, 51, 0.1);
    flex-shrink: 0;
}

/* ============================
   BUTTONS
   ============================ */
button {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(51, 255, 51, 0.06);
    border: 1px solid rgba(51, 255, 51, 0.25);
    color: var(--green);
    font-family: var(--font-tech);
    font-size: 0.9rem;
    letter-spacing: 1px;
    padding: 0.7rem 1.2rem;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
    position: relative;
    overflow: hidden;
    white-space: normal;
    text-align: center;
    line-height: 1.1;
    height: auto;
    min-height: 3.5rem;
}

button::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(51, 255, 51, 0.1) 0%, transparent 60%);
    opacity: 0;
    transition: opacity var(--transition);
}

button:hover::before,
button:active::before {
    opacity: 1;
}

button:hover {
    border-color: var(--green);
    box-shadow: 0 0 12px var(--green-glow), inset 0 0 12px rgba(51, 255, 51, 0.05);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0px) scale(0.98);
    box-shadow: 0 0 6px var(--green-glow);
}

/* Interaction buttons */
button.interaction-btn {
    background: rgba(51, 255, 51, 0.03);
    border-color: rgba(51, 255, 51, 0.1);
    color: var(--green-dim);
    opacity: 0.8;
    flex: 1 1 100%;
    min-width: 90px;
    font-size: 0.85rem;
    padding: 0.7rem 1.2rem;
    text-align: left;
    justify-content: flex-start;
}

button.interaction-btn strong {
    color: var(--green);
    text-shadow: 0 0 8px var(--green-glow);
    font-weight: bold;
    border-bottom: 2px solid var(--green);
}

button.interaction-btn .sep {
    opacity: 0.25;
    margin: 0 0.4rem;
}

button.interaction-btn .inter-label {
    opacity: 0.4;
    margin-right: 0.6rem;
    font-size: 0.7rem;
    letter-spacing: 1px;
}

button.interaction-btn.active {
    background: rgba(255, 68, 68, 0.2);
    border-color: var(--red);
    color: #fff;
    opacity: 1;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.2);
}

button.interaction-btn::before {
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.1) 0%, transparent 60%);
}

button.interaction-btn:hover {
    border-color: var(--green);
    background: rgba(51, 255, 51, 0.08);
    color: var(--green);
    opacity: 1;
}

button.interaction-btn.active:hover {
    border-color: #ff6666;
    background: rgba(255, 85, 85, 0.3);
}

button.interaction-btn:active {
    transform: scale(0.99);
}

/* Exit buttons */
button.exit-btn {
    flex: 1 1 calc(50% - 0.3rem);
    min-width: 120px;
}

/* Continue button */
button.continue-btn {
    flex: 1 1 100%;
    border-color: var(--amber);
    color: var(--amber);
    background: rgba(255, 187, 51, 0.06);
    font-size: 1rem;
    padding: 1rem;
}

button.continue-btn::before {
    background: linear-gradient(135deg, rgba(255, 187, 51, 0.12) 0%, transparent 60%);
}

button.continue-btn:hover {
    border-color: var(--amber);
    box-shadow: 0 0 12px rgba(255, 187, 51, 0.3);
    color: #ffd180;
}

/* Custom Category Colors */
button.custom-category-btn:hover {
    border-color: var(--btn-color) !important;
    box-shadow: 0 0 15px var(--btn-glow), inset 0 0 10px var(--btn-dim) !important;
    color: #fff !important;
}

button.custom-category-btn:active {
    box-shadow: 0 0 8px var(--btn-glow) !important;
}

/* ============================
   EXIT BUTTON – BADGES (NEW / EXPLORE)
   ============================ */

/* Button that has any badge — stack label above badges row */
button.exit-btn--unknown {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

.exit-label {
    display: block;
    line-height: 1.2;
}

/* Wrapper that holds one or more badges side by side */
.exit-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    pointer-events: none;
}

/* ◈ NEW  — amber, unvisited room */
.exit-badge-unknown {
    display: inline-block;
    font-size: 0.62rem;
    letter-spacing: 2px;
    color: var(--amber);
    opacity: 0.9;
    padding: 0.1rem 0.4rem;
    border: 1px solid rgba(255, 187, 51, 0.35);
    border-radius: 3px;
    background: rgba(255, 187, 51, 0.08);
    animation: badgePulse 2.5s ease-in-out infinite;
    text-shadow: 0 0 6px rgba(255, 187, 51, 0.5);
}

/* ▹ EXPLORE  — green, recommended path toward unvisited rooms */
.exit-badge-recommend {
    display: inline-block;
    font-size: 0.62rem;
    letter-spacing: 2px;
    color: var(--green);
    opacity: 0.9;
    padding: 0.1rem 0.4rem;
    border: 1px solid rgba(51, 255, 51, 0.3);
    border-radius: 3px;
    background: rgba(51, 255, 51, 0.07);
    animation: badgePulse 3s ease-in-out infinite 0.5s;
    text-shadow: 0 0 6px rgba(51, 255, 51, 0.4);
}

@keyframes badgePulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

/* ============================
   MAP PANEL
   ============================ */
.map-panel {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    height: 70vh;
    background: var(--glass-heavy);
    border: var(--panel-border);
    border-right: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    z-index: 90;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: row;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.5);
}

.map-panel.collapsed {
    transform: translate(300px, -50%);
    /* Ukryte po prawej */
}

.map-toggle-btn {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--glass-heavy);
    border: var(--panel-border);
    border-right: none;
    color: var(--green);
    padding: 1.5rem 0.6rem;
    cursor: pointer;
    font-family: var(--font-tech);
    letter-spacing: 2px;
    border-radius: var(--radius) 0 0 var(--radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-weight: bold;
}

.map-toggle-btn:hover {
    background: rgba(51, 255, 51, 0.1);
    color: #fff;
}

.map-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

#map-svg {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: block;
}

/* Legenda mapy */
.map-legend {
    flex-shrink: 0;
    padding: 0.5rem 0.8rem;
    border-top: 1px solid rgba(51, 255, 51, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-family: var(--font-tech);
    font-size: 0.62rem;
    letter-spacing: 1px;
    color: rgba(51, 255, 51, 0.5);
    text-transform: uppercase;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.map-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.map-legend-dot--current {
    background: #ffffff;
    box-shadow: 0 0 4px #ffffff;
}

.map-legend-dot--visited {
    background: #33ff33;
    box-shadow: 0 0 4px rgba(51, 255, 51, 0.5);
}

.map-legend-dot--unknown {
    background: rgba(80, 80, 80, 0.8);
    border: 1px solid #666;
}

/* Progress bar for auto-transition buttons */
.btn-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: var(--amber);
    width: 0;
    pointer-events: none;
    box-shadow: 0 0 8px var(--amber);
}

.btn-progress.animate {
    animation: btnProgressFill 11s linear forwards;
}

@keyframes btnProgressFill {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}

/* ============================
   SCROLLBAR
   ============================ */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--green-dim);
    border-radius: 2px;
}

/* ============================
   GLITCH FLASH
   ============================ */
.glitch-flash {
    animation: glitchFlash 0.08s steps(2) 2;
}

@keyframes glitchFlash {
    0% {
        filter: hue-rotate(0deg) brightness(1);
    }

    25% {
        filter: hue-rotate(90deg) brightness(1.5);
    }

    50% {
        filter: hue-rotate(-30deg) brightness(0.8);
    }

    100% {
        filter: hue-rotate(0deg) brightness(1);
    }
}

/* ============================
   GLITCH ARTIFACTS
   ============================ */
.glitch-slice {
    position: absolute;
    background: inherit;
    background-color: rgba(51, 255, 51, 0.1);
    mix-blend-mode: color-dodge;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.glitch-slice::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(51, 255, 51, 0.2), transparent);
    animation: glitchMove 0.2s linear infinite;
}

@keyframes glitchMove {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

#scene-bg {
    transition: transform 0.1s ease-out;
}

/* ============================
   IMAGE TRANSITION
   ============================ */
#scene-bg img.fade-out {
    opacity: 0;
}

/* ============================
   RESPONSIVE – TABLETS
   ============================ */
@media (min-width: 600px) and (max-width: 1024px) {
    #room-title {
        font-size: 1.8rem;
    }

    #room-desc {
        font-size: 1.2rem;
    }

    #actions-container {
        padding: 1rem 1.5rem;
    }

    button {
        padding: 0.8rem 1.5rem;
        font-size: 0.95rem;
    }

    #narrative-panel {
        padding: 3rem 2rem 1.2rem;
    }
}

/* ============================
   RESPONSIVE – DESKTOP
   ============================ */
@media (min-width: 1025px) {
    #app-container {
        max-width: 100%;
    }

    #hud-bar {
        padding: 0.8rem 2rem;
    }

    .sanity-bar {
        width: 100px;
    }

    #narrative-panel {
        padding: 3rem 3rem 1.5rem;
        max-width: 800px;
    }

    #room-title {
        font-size: 2rem;
    }

    #room-desc {
        font-size: 1.3rem;
    }

    #actions-container {
        padding: 1rem 3rem;
        max-width: 800px;
    }

    button {
        padding: 0.9rem 2rem;
        font-size: 1rem;
    }

    button.exit-btn {
        flex: 0 1 auto;
        min-width: 160px;
    }
}

/* ============================
   RESPONSIVE – SMALL PHONES
   ============================ */
@media (max-width: 380px) {
    #hud-bar {
        padding: 0.4rem 0.6rem;
        gap: 0.3rem;
    }

    #terminal-line-container {
        margin: 0.3rem 0.6rem;
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }

    .hud-logo {
        font-size: 0.8rem;
        letter-spacing: 2px;
    }

    .sanity-bar {
        width: 50px;
    }

    .hud-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.35rem;
    }

    .hud-btn {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    #room-title {
        font-size: 1.3rem;
        letter-spacing: 2px;
    }

    #room-desc {
        font-size: 1rem;
    }

    .interactable-desc {
        font-size: 0.9rem;
    }

    #narrative-panel {
        padding: 2rem 1rem 0.8rem;
    }

    #actions-container {
        padding: 0.6rem 0.8rem;
        gap: 0.4rem;
    }

    button {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* ============================
   LANDSCAPE PHONE
   ============================ */
@media (max-height: 500px) and (orientation: landscape) {
    #hud-bar {
        padding: 0.3rem 1rem;
    }

    .hud-logo {
        display: none;
    }

    #narrative-panel {
        padding: 1.5rem 1.5rem 0.6rem;
    }

    #room-title {
        font-size: 1.2rem;
        margin-bottom: 0.3rem;
    }

    #room-desc {
        font-size: 0.95rem;
        max-height: 15vh;
    }

    .interactable-desc {
        font-size: 0.85rem;
    }
}

/* ============================
   MOBILE UI FIXES – PORTRAIT
   ============================ */
@media (max-width: 600px) and (orientation: portrait) {

    /* 1. HUD Optimized Grid Layout */
    #hud-bar {
        display: grid;
        grid-template-areas:
            "center center center"
            "left gap right";
        grid-template-columns: auto 1fr auto;
        gap: 0.5rem;
        padding: 0.6rem 0.8rem;
        padding-top: calc(0.5rem + var(--safe-top));
        height: auto;
        background: rgba(5, 5, 5, 0.98);
        border-bottom: 1px solid rgba(51, 255, 51, 0.15);
    }

    .hud-center {
        grid-area: center;
        position: static;
        transform: none;
        width: 100%;
        justify-content: center;
        padding-bottom: 0.4rem;
        border-bottom: 1px solid rgba(51, 255, 51, 0.08);
        margin-bottom: 0.2rem;
    }

    .hud-left {
        grid-area: left;
        justify-content: flex-start;
    }

    .hud-right {
        grid-area: right;
        justify-content: flex-end;
    }

    .hud-logo {
        font-size: 0.85rem;
        letter-spacing: 4px;
    }

    .sanity-bar {
        width: 45px;
    }

    #sanity-value {
        font-size: 0.75rem;
    }

    .hud-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }

    .hud-btn {
        width: 32px;
        height: 20px;
        font-size: 0.9rem;
    }

    /* 2. Better Background Scaling (Solid Bottom Bar) */
    #scene-bg {
        height: 70%;
        /* Limit image to top 70% */
        bottom: auto;
        /* Clear absolute bottom */
        border-bottom: 1px solid var(--green-dim);
    }

    #app-container {
        justify-content: flex-end;
        /* Ensure actions are at bottom */
    }

    #game-viewport {
        flex: 1;
        margin-bottom: 0;
        z-index: 5;
        /* Position narrative within the upper area */
        justify-content: flex-end;
    }

    #actions-container {
        height: 30%;
        /* Fixed height for bottom bar */
        width: 100%;
        background: var(--bg);
        /* Solid background */
        backdrop-filter: none;
        border-top: 1px solid rgba(51, 255, 51, 0.2);
        overflow-y: auto;
        align-content: center;
        padding-bottom: max(1rem, var(--safe-bottom));
        z-index: 20;
    }

    /* Ensure narrative doesn't get hidden if it's long */
    #narrative-panel {
        max-height: 40vh;
        /* Limit narrative height */
        overflow-y: auto;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    }
}

/* ============================
   ACCESSIBILITY – reduce motion
   ============================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    #scene-bg img {
        animation: none;
    }
}