/* LiminalOS Client Style - Premium Dark Redesign */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=VT323&display=swap');

/* ============================
   DESIGN TOKENS (Style Guide)
   ============================ */
:root {
    --bg-core: #050505;
    --bg-grad-start: #0f1014;
    --bg-grad-end: #000000;

    /* Glassmorphism */
    --glass-panel: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    --glass-heavy: rgba(10, 10, 10, 0.85);
    --glass-light: rgba(255, 255, 255, 0.02);

    /* Text Colors */
    --text-main: #f0f0f0;
    --text-secondary: #9ca3af;
    --text-muted: #525252;

    /* Accents (Amber / Gold) */
    --accent-primary: #eab308;        /* Amber 500 */
    --accent-glow: rgba(234, 179, 8, 0.25);
    --accent-dim: #854d0e;
    --amber: #eab308;

    /* Statuses / States */
    --success: #10b981;
    --error: #ef4444;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Space Mono', monospace;
    --font-title: 'VT323', monospace;

    /* Borders & Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 24px;

    /* Transitions & Shadows */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);

    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --bg-margin: 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-color: var(--bg-core);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(30, 30, 35, 0.4) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(20, 20, 25, 0.4) 0%, transparent 25%);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

/* ============================
   APP CONTAINER
   ============================ */
#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-core);
}

/* 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.25) 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;
    will-change: transform, opacity;
    transform: translateZ(0);
}

#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.8) 100%);
    pointer-events: none;
    will-change: opacity;
}

/* Noise texture */
#scene-noise {
    position: absolute;
    inset: 0;
    opacity: 0.035;
    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.05) 2px,
            rgba(0, 0, 0, 0.05) 4px);
}

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

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

/* ============================
   TERMINAL LINE (v2 REDESIGN)
   ============================ */
#terminal-line-container {
    position: relative;
    z-index: 50;
    margin: 0.5rem 1rem;
    background: rgba(8, 8, 12, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0;
    pointer-events: auto;
    cursor: pointer;
    box-shadow:
        0 4px 24px -4px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    max-height: 42px; /* Collapsed: just header */
}

#terminal-line-container,
#terminal-line-container * {
    font-family: var(--font-mono) !important;
}

#terminal-line-container:hover {
    background: rgba(12, 12, 18, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow:
        0 6px 28px -4px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#terminal-line-container.expanded {
    max-height: 60vh;
    cursor: default;
    border-color: rgba(234, 179, 8, 0.2);
    background: rgba(6, 6, 10, 0.92);
    box-shadow:
        0 8px 40px -4px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(234, 179, 8, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    overflow-y: auto;
}

#terminal-line-container.focused {
    border-color: rgba(234, 179, 8, 0.3) !important;
}

#terminal-line-container::-webkit-scrollbar {
    width: 3px;
}
#terminal-line-container::-webkit-scrollbar-track {
    background: transparent;
}
#terminal-line-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

/* ---- Terminal Header ---- */
.terminal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid transparent;
    gap: 0.5rem;
    user-select: none;
    flex-shrink: 0;
    min-height: 40px;
    transition: border-color 0.3s ease;
}

#terminal-line-container.expanded .terminal-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
    padding-bottom: 0.5rem;
}

.terminal-header-left {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.terminal-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.terminal-status-dot.status-online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.terminal-status-dot.status-active {
    background: var(--accent-primary);
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
    animation: statusPulse 2s ease-in-out infinite;
}

.terminal-status-dot.status-busy {
    background: #38bdf8;
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.5);
    animation: statusPulse 0.8s ease-in-out infinite;
}

.terminal-status-dot.status-error {
    background: var(--error);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.terminal-status-text {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.terminal-header-title {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    font-weight: 700;
    opacity: 0.6;
}

.terminal-header-hint {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0.4;
    letter-spacing: 0.03em;
    transition: opacity 0.3s ease;
}

#terminal-line-container.expanded .terminal-header-hint {
    opacity: 0;
}

/* ---- Preview Text (visible in collapsed state) ---- */
.terminal-preview-text {
    flex: 1;
    font-size: 0.65rem;
    color: var(--accent-primary);
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.85;
    min-width: 0;
    text-shadow: 0 0 8px rgba(234, 179, 8, 0.2);
    transition: opacity 0.3s ease;
}

.terminal-preview-text:empty {
    display: none;
}

/* When preview text is present, hide the static title in collapsed state */
#terminal-line-container:not(.expanded) .terminal-preview-text:not(:empty) ~ .terminal-header-hint {
    display: none;
}

#terminal-line-container:not(.expanded) .terminal-header-title {
    flex-shrink: 0;
}

/* Hide preview when expanded — the full output is visible */
#terminal-line-container.expanded .terminal-preview-text {
    display: none;
}

/* ---- Prompt Styling ---- */
#terminal-prompt {
    color: var(--text-muted);
    font-weight: bold;
    font-size: 0.9rem;
    line-height: 1;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

#terminal-line-container.focused #terminal-prompt {
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(234, 179, 8, 0.4);
}

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

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

/* ---- History ---- */
#terminal-history {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.3s ease;
    padding: 0 0.85rem;
}

#terminal-line-container.expanded #terminal-history {
    max-height: 14rem;
    opacity: 1;
    overflow-y: auto;
    padding-top: 0.4rem;
    padding-bottom: 0.3rem;
}

#terminal-history::-webkit-scrollbar {
    width: 3px;
}
#terminal-history::-webkit-scrollbar-track {
    background: transparent;
}
#terminal-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.terminal-history-line {
    opacity: 0.8;
    font-size: 0.72rem;
    white-space: pre;
    overflow-x: auto;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.15rem 0;
    animation: historyFadeIn 0.2s ease;
}

.terminal-history-line::-webkit-scrollbar {
    height: 2px;
}
.terminal-history-line::-webkit-scrollbar-track {
    background: transparent;
}
.terminal-history-line::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
}

@keyframes historyFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 0.8; transform: translateY(0); }
}

.history-icon {
    flex-shrink: 0;
    font-size: 0.65rem;
    opacity: 0.6;
    width: 1rem;
    text-align: center;
    line-height: 1.5;
}

.history-text {
    flex: 1;
    min-width: 0;
}

/* Colors for system response logs */
.terminal-history-line.log-success, #terminal-text.log-success, .terminal-response-text.log-success {
    color: var(--success);
}
.terminal-history-line.log-error, #terminal-text.log-error, .terminal-response-text.log-error {
    color: var(--error);
}
.terminal-history-line.log-warning, #terminal-text.log-warning, .terminal-response-text.log-warning {
    color: var(--accent-primary);
}
.terminal-history-line.log-info, #terminal-text.log-info, .terminal-response-text.log-info {
    color: #38bdf8;
}

/* User input lines */
.terminal-history-line.log-user-input {
    color: var(--text-main);
    opacity: 1;
    font-weight: 500;
    border-left: 2px solid rgba(234, 179, 8, 0.25);
    padding-left: 0.5rem;
    margin-left: -0.15rem;
}

/* ---- Output Line (system responses) ---- */
.terminal-output-line {
    display: none;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    min-height: 0;
    flex-shrink: 0;
    max-height: 10rem;
    overflow-y: auto;
}

#terminal-line-container.expanded .terminal-output-line {
    display: flex;
}

.terminal-output-line::-webkit-scrollbar {
    width: 3px;
}
.terminal-output-line::-webkit-scrollbar-track {
    background: transparent;
}
.terminal-output-line::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.output-prompt {
    color: var(--accent-primary);
    font-size: 0.7rem;
    opacity: 0.5;
    line-height: 1.5;
    flex-shrink: 0;
}

#terminal-text {
    flex: 1;
    white-space: pre;
    overflow-x: auto;
    color: var(--text-main);
    line-height: 1.4;
    font-size: 0.75rem;
}

#terminal-text::-webkit-scrollbar {
    height: 3px;
}
#terminal-text::-webkit-scrollbar-track {
    background: transparent;
}
#terminal-text::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

#terminal-text:empty + .output-prompt,
.terminal-output-line:has(#terminal-text:empty) {
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* ---- Input Line (user typing) ---- */
.terminal-input-line {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

#terminal-line-container.expanded .terminal-input-line {
    display: flex;
}

#terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 0;
    margin: 0;
    caret-color: var(--accent-primary);
}


/* ---- Options List ---- */
#terminal-options-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.3s ease;
    padding: 0 0.6rem;
    flex-shrink: 0;
}

#terminal-line-container.expanded #terminal-options-list {
    max-height: 16rem;
    opacity: 1;
    padding-bottom: 0.6rem;
    overflow-y: auto;
}

/* Options separator label */
.terminal-options-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.25rem 0.35rem;
    user-select: none;
}

.options-label-text {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0.7;
}

.options-label-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
}

/* Individual option items */
.terminal-option-item {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.55rem 0.65rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: transparent;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    margin-bottom: 2px;
}

.terminal-option-item:hover {
    background: rgba(234, 179, 8, 0.06);
    border-color: rgba(234, 179, 8, 0.12);
    color: var(--accent-primary);
    padding-left: 0.85rem;
    box-shadow: 0 2px 12px rgba(234, 179, 8, 0.06);
}

.terminal-option-item:active {
    transform: scale(0.98);
    background: rgba(234, 179, 8, 0.12);
}

/* Option number key badge */
.opt-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.terminal-option-item:hover .opt-key {
    background: rgba(234, 179, 8, 0.12);
    border-color: rgba(234, 179, 8, 0.3);
    color: var(--accent-primary);
}

/* Option icon */
.opt-icon {
    font-size: 0.65rem;
    opacity: 0.5;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.terminal-option-item:hover .opt-icon {
    opacity: 0.9;
    color: var(--accent-primary);
}

/* Option label */
.opt-label {
    flex: 1;
    letter-spacing: 0.02em;
    font-weight: 500;
}

/* Option arrow */
.opt-arrow {
    font-size: 0.9rem;
    opacity: 0;
    transform: translateX(-6px);
    transition: all 0.2s ease;
    color: var(--accent-primary);
}

.terminal-option-item:hover .opt-arrow {
    opacity: 0.7;
    transform: translateX(0);
}

/* Ripple effect */
.option-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(234, 179, 8, 0.15);
    transform: scale(0);
    animation: rippleAnim 0.6s ease-out forwards;
    pointer-events: none;
    width: 120px;
    height: 120px;
    margin-left: -60px;
    margin-top: -60px;
}

@keyframes rippleAnim {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(3); opacity: 0; }
}

/* Failed sanity option items: Orange/Amber with subtle glow */
.terminal-option-item.opt-failed-sanity {
    color: #f97316 !important;
    opacity: 0.65;
    border-color: rgba(249, 115, 22, 0.1);
}

.terminal-option-item.opt-failed-sanity:hover {
    background: rgba(249, 115, 22, 0.08);
    border-color: rgba(249, 115, 22, 0.25);
    color: #fb923c !important;
    opacity: 0.95;
    box-shadow: 0 2px 12px rgba(249, 115, 22, 0.1);
}

.terminal-option-item.opt-failed-sanity .opt-key {
    border-color: rgba(249, 115, 22, 0.2);
    color: #f97316 !important;
}

.terminal-option-item.opt-failed-sanity:hover .opt-key {
    background: rgba(249, 115, 22, 0.15);
    border-color: rgba(249, 115, 22, 0.4);
    color: #fb923c !important;
}

.terminal-option-item.opt-failed-sanity .opt-icon,
.terminal-option-item.opt-failed-sanity .opt-arrow {
    color: #f97316 !important;
}

.terminal-option-item.opt-failed-sanity .option-ripple {
    background: rgba(249, 115, 22, 0.15) !important;
}

/* Collapsed state: hide everything except header */
#terminal-line-container:not(.expanded) .terminal-output-line {
    display: none;
}

#terminal-line-container:not(.expanded) .terminal-input-line {
    display: none;
}

#terminal-line-container:not(.expanded) #terminal-history {
    display: none;
}

#terminal-line-container:not(.expanded) #terminal-options-list {
    display: none;
}

/* ============================
   HUD BAR (top)
   ============================ */
#hud-bar {
    position: relative;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 1.5rem;
    background: rgba(10, 10, 10, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    gap: 0.5rem;
    flex-shrink: 0;
}

.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-mono);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-logo::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary);
    border-radius: 50%;
}

.hud-logo-dim {
    color: var(--text-muted);
    font-weight: 400;
}

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

.hud-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hud-icon svg,
.hud-badge svg,
.hud-badge-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2px;
    display: inline-block;
    vertical-align: middle;
}

.hud-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-main);
    font-weight: 500;
}

.hud-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass-panel);
    line-height: 1;
    transition: var(--transition-fast);
    gap: 0.3rem;
}

/* Badge-style buttons */
.hud-badge-btn {
    cursor: pointer;
    background: var(--glass-panel);
    border: 1px solid var(--glass-border);
}

.hud-badge-btn:hover {
    transform: none !important;
    background: var(--glass-highlight);
    border-color: var(--accent-primary);
    color: var(--text-main);
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.15);
}

.hud-badge-btn:active {
    transform: scale(0.95);
}

/* Sanity Bar */
.sanity-bar {
    width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

#sanity-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--error), var(--accent-primary), var(--success));
    border-radius: var(--radius-sm);
    transition: width 0.5s var(--transition-fast);
}

.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(2.8rem + var(--safe-top));
    right: 1.5rem;
    z-index: 120;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-card);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    min-width: 240px;
}

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

.settings-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

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

.control-group label {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

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

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

input[type=range]::-webkit-slider-thumb:hover {
    background: #facc15;
    box-shadow: 0 0 12px var(--accent-primary);
}

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

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

/* Narrative Panel */
#narrative-panel {
    background: rgba(10, 10, 10, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    padding-right: 2.8rem;
    margin-left: 2rem;
    margin-bottom: 1rem;
    max-width: 650px;
    box-shadow: var(--shadow-card);
    position: relative;
    transition: max-width 0.3s ease, padding 0.3s ease, max-height 0.4s ease;
    cursor: pointer;
}

/* Narrative toggle button styling */
.narrative-toggle {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    z-index: 10;
    min-width: unset;
    height: unset;
    min-height: unset;
}
.narrative-toggle::before {
    display: none !important;
}
.narrative-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-primary);
    border-color: transparent;
    box-shadow: none;
    transform: none;
}
.narrative-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

#narrative-panel.collapsed {
    padding-bottom: 0.8rem;
}

#narrative-panel.collapsed #room-subtitle,
#narrative-panel.collapsed #room-desc,
#narrative-panel.collapsed .interactable-desc {
    display: none !important;
}

#narrative-panel.collapsed .narrative-toggle svg {
    transform: rotate(180deg);
}

#room-title {
    font-family: var(--font-title);
    font-size: 1.8rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    margin-bottom: 0.15rem;
    line-height: 1.1;
    text-transform: uppercase;
}

#room-subtitle {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    opacity: 0.9;
    font-weight: 600;
}

#room-desc {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    color: rgba(240, 240, 240, 0.85);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.05);
    max-height: 22vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.interactable-desc {
    margin-top: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-primary);
    opacity: 0.95;
    font-style: italic;
    line-height: 1.4;
    padding-left: 0.75rem;
    border-left: 2px solid var(--accent-primary);
    text-shadow: 0 0 6px var(--accent-glow);
}

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

/* ============================
   BUTTONS
   ============================ */
button {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex: 0 1 auto;
    min-width: 100px;
    position: relative;
    overflow: hidden;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    height: auto;
    min-height: 2.3rem;
}

button::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-primary);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform var(--transition-fast);
    z-index: 2;
}

button:hover::before {
    transform: scaleY(1);
}

button:hover {
    border-color: var(--accent-primary);
    color: var(--text-main);
    background: rgba(234, 179, 8, 0.03);
    box-shadow: 0 4px 15px rgba(234, 179, 8, 0.08);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0px) scale(0.98);
}

/* Interaction groups & buttons */
.interaction-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.8rem;
    margin-bottom: 0.1rem;
}

.interaction-group-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-right: 0.4rem;
}

button.interaction-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    min-height: auto;
    min-width: 70px;
    flex: 0 1 auto;
    justify-content: center;
    text-align: center;
    border-radius: 3px;
}

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

button.interaction-btn.active::before {
    transform: scaleY(1);
    background: var(--error);
}

button.interaction-btn:hover {
    border-color: var(--error) !important;
    background: rgba(239, 68, 68, 0.05);
    color: var(--text-main);
    opacity: 1;
}

button.interaction-btn.active:hover {
    border-color: #ff6666 !important;
    background: rgba(239, 68, 68, 0.25) !important;
}

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

/* Exit buttons */
button.exit-btn {
    flex: 0 1 auto;
    min-width: 130px;
    display: inline-flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
}

/* Continue button */
button.continue-btn {
    flex: 1 1 100%;
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(234, 179, 8, 0.02);
    font-size: 0.95rem;
    padding: 1rem;
}

button.continue-btn::before {
    background: var(--accent-primary);
}

button.continue-btn:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 15px rgba(234, 179, 8, 0.15);
    color: #fff;
}

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

/* ============================
   EXIT BUTTON – BADGES (NEW / EXPLORE)
   ============================ */
.exit-label {
    display: block;
    line-height: 1.2;
}

.exit-icon-badges {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    pointer-events: none;
}

.exit-icon-badges svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.5px;
    animation: exitIconPulse 2s ease-in-out infinite;
}

.exit-icon-new {
    color: var(--accent-primary);
    filter: drop-shadow(0 0 4px var(--accent-glow));
}

.exit-icon-recommend {
    color: var(--success);
    filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.3));
    animation-delay: 0.5s !important;
}

@keyframes exitIconPulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* ============================
   MAP PANEL
   ============================ */
.map-panel {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 330px;
    height: 75vh;
    background: rgba(5, 5, 5, 0.75);
    border: 1px solid var(--glass-border);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    z-index: 90;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: row;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: var(--shadow-card), inset 0 0 20px rgba(255, 255, 255, 0.01);
}

.map-panel.collapsed {
    transform: translate(330px, -50%);
}

@media (min-width: 1024px) {
    .map-panel {
        height: 100%;
        top: 0;
        transform: translate3d(0, 0, 0);
        border-radius: 0;
        border-top: none;
        border-bottom: none;
    }
    
    .map-panel.collapsed {
        transform: translate3d(330px, 0, 0);
    }
}

.map-toggle-btn {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(5, 5, 5, 0.85);
    border: 1px solid var(--glass-border);
    border-right: none;
    color: var(--text-secondary);
    padding: 1.8rem 0.6rem;
    cursor: pointer;
    font-family: var(--font-mono);
    letter-spacing: 2px;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-weight: 700;
    font-size: 0.75rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
}

.map-toggle-btn::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 100%;
    background: var(--accent-primary);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.2s ease;
}

.map-toggle-btn:hover::before {
    transform: scaleY(1);
}

.map-toggle-btn:hover {
    transform: translateY(-50%) !important;
    background: rgba(234, 179, 8, 0.05);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: -5px 0 20px rgba(234, 179, 8, 0.1);
}

#map-svg text {
    paint-order: stroke fill;
    stroke: #050505;
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.map-panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.01);
}

.map-header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.map-header-tech {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-main);
    letter-spacing: 0.05em;
}

.map-header-sub {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--accent-primary);
    opacity: 0.8;
    letter-spacing: 0.03em;
    font-weight: 600;
}

.map-dot-pulse {
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-primary);
    animation: mapDotPulse 1.5s infinite ease-in-out;
}

@keyframes mapDotPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.25); box-shadow: 0 0 12px var(--accent-primary); }
}

.map-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}

.map-stat-box {
    background: rgba(5, 5, 5, 0.4);
    padding: 0.6rem;
    text-align: center;
    font-family: var(--font-mono);
}

.map-stat-label {
    font-size: 0.55rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 0.15rem;
}

.map-stat-value {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--accent-primary);
    text-shadow: 0 0 6px var(--accent-glow);
}

.map-svg-container {
    flex: 1;
    min-height: 0;
    position: relative;
    background-color: rgba(0, 0, 0, 0.2);
}

#map-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Detailed telemetry panel */
.map-node-details {
    border-top: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.01);
    padding: 0.8rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    min-height: 75px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.4);
    transition: background-color 0.2s ease;
}

.node-details-placeholder {
    color: var(--text-muted);
    text-align: center;
    letter-spacing: 0.02em;
    font-style: italic;
}

.node-details-hint {
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.25rem;
    opacity: 0.7;
}

.node-details-active {
    background: rgba(234, 179, 8, 0.01);
}

.node-details-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--glass-border);
    padding-bottom: 0.25rem;
    margin-bottom: 0.35rem;
}

.node-details-name {
    font-weight: bold;
    color: var(--text-main);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.node-details-status {
    font-size: 0.55rem;
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 700;
}

.node-details-status--current {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.node-details-status--visited {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.node-details-status--unknown {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.node-details-row {
    display: flex;
    margin-bottom: 0.2rem;
}

.node-details-key {
    color: var(--text-secondary);
    width: 65px;
    flex-shrink: 0;
}

.node-details-val {
    color: var(--text-main);
    word-break: break-all;
}

/* SVG grid pattern and elements */
.map-grid-pattern {
    fill: none;
    stroke: rgba(255, 255, 255, 0.025);
    stroke-width: 1;
}

#map-svg g.map-node {
    cursor: pointer;
    pointer-events: all;
}

#map-svg g.map-node circle {
    transition: all var(--transition-fast);
}

#map-svg g.map-node:hover circle {
    stroke-width: 3px !important;
}

#map-svg g.map-node:hover text {
    font-weight: bold;
}

#map-svg line.map-edge {
    transition: stroke-width 0.2s ease;
}

#map-svg line.map-edge-flow {
    stroke-dasharray: 6 12;
    animation: edgeDashMove 4s linear infinite;
    pointer-events: none;
}

@keyframes edgeDashMove {
    to {
        stroke-dashoffset: -48;
    }
}

/* Legenda mapy */
.map-legend {
    flex-shrink: 0;
    padding: 0.6rem 0.8rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-secondary);
    background: rgba(5, 5, 5, 0.5);
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

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

.map-legend-dot--current {
    background: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary);
}

.map-legend-dot--visited {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.map-legend-dot--unknown {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
}

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

.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(--glass-border);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================
   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(234, 179, 8, 0.15);
    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(234, 179, 8, 0.25), 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;
}

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

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

    #actions-container {
        padding: 1.25rem 2rem;
    }

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

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

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

    #hud-bar {
        padding: 0.5rem 3rem;
    }

    .sanity-bar {
        width: 100px;
    }

    #narrative-panel {
        padding: 1rem 1.25rem;
        max-width: 900px;
    }

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

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

    #actions-container {
        padding: 0.6rem 3rem;
        max-width: 100%;
    }

    button {
        padding: 0.45rem 0.9rem;
        font-size: 0.78rem;
    }

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

/* ============================
   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.7rem;
    }

    .hud-logo {
        font-size: 0.9rem;
        letter-spacing: -0.05em;
    }

    .sanity-bar {
        width: 50px;
    }

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

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

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

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

    .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.8rem;
        margin-bottom: 0.3rem;
    }

    #room-desc {
        font-size: 0.82rem;
        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(10, 10, 10, 0.98);
        border-bottom: 1px solid var(--glass-border);
    }

    .hud-center {
        grid-area: center;
        position: static;
        transform: none;
        width: 100%;
        justify-content: center;
        padding-bottom: 0.4rem;
        border-bottom: 1px solid var(--glass-border);
        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.95rem;
    }

    .sanity-bar {
        width: 45px;
    }

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

    .hud-badge {
        font-size: 0.75rem;
        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%;
        bottom: auto;
        border-bottom: 1px solid var(--glass-border);
    }

    #app-container {
        justify-content: flex-end;
    }

    #game-viewport {
        flex: 1;
        margin-bottom: 0;
        z-index: 5;
        justify-content: flex-end;
    }

    #actions-container {
        height: 30%;
        width: 100%;
        background: var(--bg-core);
        backdrop-filter: none;
        border-top: 1px solid var(--glass-border);
        overflow-y: auto;
        align-content: center;
        padding-bottom: max(1rem, var(--safe-bottom));
        z-index: 20;
    }

    #narrative-panel {
        max-height: 40vh;
        overflow-y: auto;
        background: rgba(10, 10, 10, 0.9);
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        border-bottom: none;
        margin: 0;
        max-width: 100%;
        width: 100%;
    }
}

/* ============================
   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;
    }
}