/* ==============================================================================
   Angband3D Web Client — Dark Fantasy CSS & Glassmorphic HUD
   ============================================================================== */

:root {
    --bg-dark: #07080b;
    --gold-primary: #d4af37;
    --gold-bright: #ffd700;
    --gold-dim: #8b7500;
    --accent-red: #e63946;
    --accent-blue: #3a86ff;
    --accent-green: #2a9d8f;
    --text-primary: #e0e6ed;
    --text-muted: #8c9ba5;
    --glass-bg: rgba(12, 14, 20, 0.78);
    --glass-border: rgba(212, 175, 55, 0.25);
    --font-fantasy: 'Cinzel', serif, -apple-system;
    --font-terminal: 'Fira Code', 'Courier New', monospace;
    --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: var(--font-fantasy);
    color: var(--text-primary);
    touch-action: none;
    -webkit-touch-callout: none;
}

#app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* 3D Viewport Canvas */
#viewport-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

/* Live Action & Combat Message Banner (1:1 with Godot Overlay.cs:1572-1587) */
.top-message-banner {
    position: absolute;
    top: var(--safe-top);
    left: var(--safe-left);
    right: var(--safe-right);
    height: 34px;
    background: rgba(6, 8, 14, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.35);
    display: flex;
    align-items: center;
    padding: 0 calc(min(52vw, 680px) + var(--safe-right)) 0 max(16px, var(--safe-left));
    z-index: 25;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.top-message-text {
    font-family: var(--font-terminal);
    font-size: 13.5px;
    font-weight: 500;
    color: #e0e6ed;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
}

.top-message-banner.prompt {
    background: rgba(40, 26, 4, 0.96);
    border-bottom-color: rgba(255, 215, 0, 0.85);
}

.top-message-banner.prompt .top-message-text {
    color: #ffd700;
    font-weight: bold;
}

/* Terminal Container Layer (Character creation, stores, help, death disclosure, and menus) */
#terminal-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(4, 5, 8, 0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
    transition: opacity 0.15s ease;
    padding: max(8px, var(--safe-top)) max(8px, var(--safe-right)) max(8px, var(--safe-bottom)) max(8px, var(--safe-left));
}

#terminal-container.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.terminal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #090b10;
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 8px;
    padding: 10px 14px 14px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.95), 0 0 20px rgba(212, 175, 55, 0.15);
    max-width: 98vw;
    max-height: 96vh;
    max-height: 96dvh;
    overflow: hidden;
}

.terminal-toolbar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding-bottom: 8px;
}

.terminal-title {
    font-size: 13px;
    letter-spacing: 2px;
    font-weight: 700;
    color: var(--gold-bright);
}

.terminal-actions {
    display: flex;
    gap: 10px;
}

.btn-gold {
    background: linear-gradient(180deg, #d4af37, #997a15);
    border: 1px solid #ffe270;
    color: #0b0c0e;
    font-family: var(--font-fantasy);
    font-weight: bold;
    font-size: 13px;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
    transition: all 0.15s ease;
}

.btn-gold:hover {
    background: linear-gradient(180deg, #ffe270, #bfa020);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    transform: translateY(-1px);
}

.btn-gold-outline {
    background: transparent;
    border: 1px solid var(--gold-primary);
    color: var(--gold-bright);
    font-family: var(--font-fantasy);
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-gold-outline:hover {
    background: rgba(212, 175, 55, 0.15);
    color: #fff;
}

#terminal-canvas {
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
}

/* Top Landscape Message Feed Window (Full message history with scrollback) */
#message-feed-window {
    position: absolute;
    top: 42px;
    left: 320px;
    transform: none;
    z-index: 6;
    width: min(580px, calc(100vw - 340px));
    min-width: 360px;
    max-width: 90vw;
    height: 180px;
    min-height: 90px;
    max-height: 80vh;
    background: rgba(8, 11, 18, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(212, 175, 55, 0.40);
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.85);
    display: none; /* Controlled by hud.js based on play phase */
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

@media (max-width: 960px) {
    #message-feed-window {
        top: 50px;
        left: 10px;
        right: 10px;
        transform: none;
        width: auto;
        max-width: none;
        min-width: 0;
    }
}

.message-feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(16, 20, 31, 0.95);
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
    padding: 4px 8px;
    cursor: grab;
    user-select: none;
}

.message-feed-header:active {
    cursor: grabbing;
}

.message-feed-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-feed-title {
    font-family: var(--font-fantasy);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--gold-bright);
}

.msg-more-chip {
    background: #e63946;
    color: #ffffff;
    font-family: var(--font-terminal);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    cursor: pointer;
    animation: pulseMore 1s ease-in-out infinite;
}

@keyframes pulseMore {
    0%, 100% {
        transform: scale(1);
        background: #e63946;
        box-shadow: 0 0 4px rgba(230, 57, 70, 0.6);
    }
    50% {
        transform: scale(1.05);
        background: #ffd700;
        color: #000;
        box-shadow: 0 0 8px rgba(255, 215, 0, 0.9);
    }
}

.message-feed-controls {
    display: flex;
    gap: 5px;
}

.msg-ctrl-btn {
    background: #171d2b;
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #cfd8e3;
    font-family: var(--font-terminal);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.msg-ctrl-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    color: #fff;
    border-color: var(--gold-bright);
}

.message-feed-scroll {
    flex: 1;
    min-height: 50px;
    height: auto;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    background: rgba(8, 11, 18, 0.92);
    scroll-behavior: smooth;
}

#message-feed-window.expanded {
    height: 320px;
    max-height: 85vh;
}

.message-feed-scroll::-webkit-scrollbar {
    width: 6px;
}

.message-feed-scroll::-webkit-scrollbar-track {
    background: #0d111a;
}

.message-feed-scroll::-webkit-scrollbar-thumb {
    background: #3a4459;
    border-radius: 3px;
}

.message-feed-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--gold-primary);
}

.message-feed-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
}

.feed-line {
    font-family: var(--font-terminal);
    font-size: 12px;
    line-height: 1.35;
    color: #f0f4f8;
    white-space: pre-wrap;
    word-break: break-word;
    animation: feedLinePop 0.15s ease-out;
}

.feed-line.latest {
    font-weight: 600;
    border-left: 2px solid #ffd700;
    padding-left: 5px;
}

@keyframes feedLinePop {
    from {
        opacity: 0.2;
        transform: translateY(2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Top Telemetry & Controls */
#top-right-bar {
    position: absolute;
    top: 3px;
    right: 12px;
    display: flex;
    gap: 6px;
    align-items: center;
    z-index: 1000; /* Always above all modal/terminal screens so sound & settings are accessible everywhere */
}

.badge {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--gold-primary);
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 3px 9px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11.5px;
    font-family: var(--font-fantasy);
    transition: all 0.2s ease;
}

.icon-btn:hover {
    border-color: var(--gold-primary);
    background: rgba(212, 175, 55, 0.15);
    color: #fff;
}

.icon-btn.active {
    border-color: #ffd700;
    background: rgba(212, 175, 55, 0.28);
    color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}

#btn-toggle-msg-feed,
#btn-toggle-minimap,
#btn-toggle-dpad,
#btn-toggle-invert {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-pause-invert {
    font-family: var(--font-terminal);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(20, 26, 40, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.5);
    color: #e0e6ed;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-pause-invert.active {
    background: rgba(212, 175, 55, 0.25);
    border-color: #ffd700;
    color: #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.map-close-btn {
    background: rgba(239, 68, 68, 0.25);
    border: 1px solid rgba(255, 123, 114, 0.5);
    color: #ff7b72;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    padding: 1px 7px;
    border-radius: 4px;
    transition: all 0.15s ease;
    margin-left: 6px;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.map-close-btn:hover {
    background: rgba(239, 68, 68, 0.5);
    color: #fff;
    border-color: #ff7b72;
}

#btn-msg-close {
    background: rgba(239, 68, 68, 0.25);
    color: #ff7b72;
    border-color: rgba(255, 123, 114, 0.5);
    font-weight: 700;
    flex-shrink: 0;
}

#btn-msg-close:hover {
    background: rgba(239, 68, 68, 0.5);
    color: #fff;
    border-color: #ff7b72;
}

/* Sound Control Group & Volume Slider */
.sound-control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sound-control-group:hover {
    border-color: var(--gold-primary);
    background: rgba(212, 175, 55, 0.08);
}

.sound-control-group .icon-btn {
    background: transparent;
    border: none;
    padding: 2px 4px;
    font-size: 11.5px;
}

.sound-control-group .icon-btn:hover {
    background: transparent;
    border: none;
    color: var(--gold-primary);
}

.volume-slider-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.volume-range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 65px;
    height: 4px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    accent-color: #ffd700;
    transition: background 0.15s ease;
}

.volume-range-slider:hover {
    background: rgba(255, 255, 255, 0.35);
}

.volume-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffd700;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
    border: 1px solid #ffffff;
    transition: transform 0.15s ease;
}

.volume-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.volume-range-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffd700;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
    border: 1px solid #ffffff;
    transition: transform 0.15s ease;
}

.volume-range-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.volume-label {
    font-family: var(--font-terminal);
    font-size: 11px;
    color: #cbd5e1;
    min-width: 28px;
    text-align: right;
    user-select: none;
}

/* Bottom HUD (Health, Mana, Depth, Gold, Quick stats) */
#hud-overlay {
    position: absolute;
    bottom: 16px;
    left: 18px;
    right: 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 5;
}

.hud-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px 18px;
    pointer-events: auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
}

/* Character & Health Panel */
#char-panel {
    min-width: 310px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.char-title {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--gold-bright);
    font-weight: 700;
    letter-spacing: 1px;
}

.gauge-container {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.gauge-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-family: var(--font-terminal);
    color: var(--text-muted);
}

.gauge-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.5);
}

.gauge-fill {
    height: 100%;
    transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.gauge-hp .gauge-fill {
    background: linear-gradient(90deg, #990000, #e63946, #ff6b6b);
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.6);
}

.gauge-sp .gauge-fill {
    background: linear-gradient(90deg, #1d3557, #3a86ff, #60a5fa);
    box-shadow: 0 0 10px rgba(58, 134, 255, 0.6);
}

/* Middle Stats Strip */
#stats-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-family: var(--font-terminal);
    font-size: 13px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;
}

.stat-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 1px;
    flex-shrink: 0;
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.stat-value {
    color: var(--gold-primary);
    font-weight: bold;
}

/* Center Column: Quick Action Bar & Detailed 3-Row Telemetry Footer */
#hud-center-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    max-width: 860px;
    margin: 0 12px;
    pointer-events: auto;
}

/* Quick Action Bar */
#action-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 2px;
}

.action-btn {
    background: rgba(20, 24, 34, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #dcdcdc;
    padding: 5px 10px;
    border-radius: 6px;
    font-family: var(--font-fantasy);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    user-select: none;
}

.action-btn kbd {
    font-family: var(--font-terminal);
    font-size: 9px;
    color: var(--gold-bright);
    opacity: 0.85;
    background: rgba(0, 0, 0, 0.35);
    padding: 0 4px;
    border-radius: 3px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.action-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold-bright);
    color: #fff;
    transform: translateY(-2px);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn.stair-btn {
    background: rgba(212, 175, 55, 0.25);
    border: 1px solid var(--gold-bright);
    color: #fff;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
    animation: pulseStair 1.5s infinite;
}

@keyframes pulseStair {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.35); transform: scale(1); }
    50% { box-shadow: 0 0 16px rgba(255, 215, 0, 0.75); transform: scale(1.04); }
}

/* Streamlined Glassmorphic Context & Status Bar */
#hud-footer.hud-status-bar {
    width: 100%;
    min-height: 28px;
    padding: 3px 10px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-family: var(--font-terminal);
    font-size: 11px;
    background: rgba(10, 14, 22, 0.82);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-radius: 6px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
    pointer-events: auto;
}

.status-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.status-left {
    justify-content: flex-start;
}

.status-center {
    justify-content: center;
    flex: 1;
    overflow: hidden;
}

.status-right {
    justify-content: flex-end;
}

.status-pill {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    white-space: nowrap;
}

.pill-depth {
    color: #ffd700;
    font-weight: 700;
    background: rgba(212, 175, 55, 0.12);
    border-color: rgba(212, 175, 55, 0.35);
}

.pill-level {
    color: #fbbf24;
    font-weight: 700;
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.35);
}

.pill-exp {
    color: #c084fc;
    font-weight: 600;
    background: rgba(192, 132, 252, 0.10);
    border-color: rgba(192, 132, 252, 0.30);
}

.pill-facing {
    color: #38bdf8;
    font-weight: 600;
}

.pill-light {
    color: #fde047;
}

.pill-speed {
    color: #a7f3d0;
}

.pill-gear {
    color: #e2e8f0;
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(148, 163, 184, 0.25);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-alert {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.stairs-alert {
    color: #fff;
    background: rgba(212, 175, 55, 0.3);
    border: 1px solid var(--gold-bright);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    animation: pulseStair 1.5s infinite;
}

.target-alert {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.25);
    border: 1px solid rgba(239, 68, 68, 0.6);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.diagonal-hint {
    color: #fbbf24;
    font-size: 10px;
}

.pill-help-trigger {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #cbd5e1;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-terminal);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.pill-help-trigger:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold-bright);
    color: #fff;
}

.footer-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.footer-badge {
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    white-space: nowrap;
}

.badge-study {
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.4);
}

.badge-resting {
    color: #60d0e6;
    border-color: rgba(96, 208, 230, 0.4);
}

.badge-recall {
    color: #d880ff;
    border-color: rgba(216, 128, 255, 0.4);
}

/* Minimap Radar */
#minimap-container {
    position: absolute;
    top: 42px;
    left: 18px;
    z-index: 5;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 100px);
}

.minimap-header {
    cursor: grab;
    user-select: none;
}

.minimap-header:active {
    cursor: grabbing;
}

/* Floating Window Resize Grip */
.window-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(212, 175, 55, 0.45) 50%, rgba(212, 175, 55, 0.85) 100%);
    border-bottom-right-radius: 6px;
    z-index: 10;
}

.window-resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, rgba(255, 215, 0, 0.7) 50%, rgba(255, 215, 0, 1.0) 100%);
}

/* Store Actions Toolbar */
.store-actions-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-store-action {
    background: rgba(26, 32, 44, 0.90);
    border: 1px solid rgba(212, 175, 55, 0.45);
    color: var(--gold-bright);
    font-family: var(--font-fantasy);
    font-size: 12px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: all 0.15s ease;
}

.btn-store-action:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--gold-bright);
    color: #fff;
    transform: translateY(-1px);
}

#minimap-container.compact {
    width: 220px;
}

#minimap-container.standard {
    width: 260px;
}

#minimap-container.expanded {
    width: 360px;
}

#minimap-container.tactical {
    width: 460px;
}

#minimap-container.command {
    width: 580px;
}

#minimap-canvas {
    width: 100%;
    flex: 1 1 auto;
    min-height: 120px;
    max-height: calc(100vh - 160px);
    image-rendering: pixelated;
    display: block;
}

/* Interactive Action & Item Selection Bar */
.item-actions-bar {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(12, 16, 26, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
    margin-bottom: 8px;
}

.item-buttons-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
    padding: 2px;
}

.btn-item-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(22, 28, 42, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 4px;
    color: #e2e8f0;
    font-family: var(--font-terminal);
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.btn-item-pill:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--gold-bright);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.btn-quiver-summary {
    background: rgba(30, 42, 65, 0.95);
    border-color: rgba(255, 215, 0, 0.6);
}

.btn-quiver-summary .item-key-letter {
    color: #48cae4;
}

.btn-item-pill .item-key-letter {
    color: var(--gold-bright);
    font-weight: bold;
    font-size: 12px;
}

.btn-item-pill .item-name-text {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-bar-controls {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    padding-top: 6px;
}

.btn-item-action {
    background: rgba(28, 36, 52, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--gold-bright);
    font-family: var(--font-fantasy);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-item-action:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold-bright);
    color: #fff;
}

.minimap-header {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
    color: var(--gold-primary);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
    transition: background 0.15s ease;
}

.minimap-header:hover {
    background: rgba(212, 175, 55, 0.15);
}

.minimap-hint {
    font-size: 9px;
    font-weight: normal;
    color: rgba(220, 220, 220, 0.5);
    margin: 0 4px;
    max-width: 105px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
}

/* Minimap Controls Bar */
.minimap-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 5px;
    background: rgba(10, 14, 22, 0.92);
    border-top: 1px solid rgba(212, 175, 55, 0.25);
    gap: 3px;
}

.map-ctrl-grp {
    display: flex;
    align-items: center;
    gap: 2px;
}

.map-ctrl-lbl {
    font-family: var(--font-terminal);
    font-size: 8.5px;
    font-weight: bold;
    color: rgba(220, 220, 220, 0.65);
    letter-spacing: 0.5px;
    margin-right: 1px;
}

.map-ctrl-btn {
    background: rgba(24, 30, 44, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 4px;
    color: var(--gold-bright);
    font-family: var(--font-terminal);
    font-size: 9.5px;
    padding: 2px 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 2px;
    user-select: none;
    flex-shrink: 0;
}

.map-ctrl-btn:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--gold-bright);
    color: #fff;
    transform: scale(1.05);
}

.map-btn-hide {
    background: rgba(239, 68, 68, 0.25) !important;
    border-color: rgba(255, 123, 114, 0.5) !important;
    color: #ff7b72 !important;
    font-weight: bold !important;
}

.map-btn-hide:hover {
    background: rgba(239, 68, 68, 0.55) !important;
    border-color: #ff7b72 !important;
    color: #fff !important;
}

.map-ctrl-btn kbd {
    font-family: var(--font-terminal);
    font-size: 9px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 3px;
    padding: 0 3px;
    font-weight: bold;
}

.map-ctrl-divider {
    width: 1px;
    height: 14px;
    background: rgba(212, 175, 55, 0.2);
}

.map-btn-hide {
    color: #ff7b72 !important;
    border-color: rgba(255, 123, 114, 0.45) !important;
}

.map-btn-hide:hover {
    background: rgba(239, 68, 68, 0.28) !important;
    color: #fff !important;
    border-color: #ff7b72 !important;
}

/* Mobile Minimap Floating Zoom Buttons (Hidden on desktop) */
.mobile-map-zoom-group {
    display: none;
}

/* Camera Head Tilt Bar */
.camera-tilt-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 6px;
    background: rgba(8, 11, 18, 0.95);
    border-top: 1px solid rgba(212, 175, 55, 0.18);
    gap: 4px;
}

.tilt-lbl {
    font-family: var(--font-terminal);
    font-size: 9px;
    font-weight: bold;
    color: rgba(220, 220, 220, 0.65);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.tilt-btn-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.tilt-btn {
    background: rgba(24, 30, 44, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 4px;
    color: #e0e6ed;
    font-family: var(--font-terminal);
    font-size: 10px;
    padding: 2px 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 3px;
    user-select: none;
}

.tilt-btn:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--gold-bright);
    color: #fff;
    transform: scale(1.05);
}

.tilt-btn kbd {
    font-family: var(--font-terminal);
    font-size: 9px;
    color: var(--gold-bright);
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 3px;
    padding: 0 3px;
    font-weight: bold;
}

/* Virtual D-Pad for Mobile & Desktop (Console / Roguelike Precision Grid) */
#touch-controls {
    position: absolute;
    bottom: 92px;
    right: 28px;
    width: 186px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    background: rgba(8, 12, 20, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 25;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.dpad-turn-wings {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
}

.dpad-turn-btn {
    flex: 1;
    height: 34px;
    background: rgba(14, 20, 32, 0.92);
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 8px;
    color: var(--gold-bright);
    font-size: 13px;
    font-family: var(--font-ui);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    transition: all 0.15s ease;
}

.dpad-turn-btn:active {
    background: rgba(212, 175, 55, 0.35);
    border-color: #ffd700;
    transform: scale(0.96);
}

.dpad-turn-symbol {
    font-size: 16px;
}

.dpad-turn-text {
    font-size: 11px;
    letter-spacing: 0.5px;
}

.dpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
    width: 100%;
    aspect-ratio: 1 / 1;
}

.dpad-btn {
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(18, 22, 34, 0.88);
    color: var(--gold-bright);
    font-size: 17px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    transition: all 0.1s ease;
    padding: 0;
}

.dpad-btn:active {
    background: rgba(212, 175, 55, 0.35);
    border-color: var(--gold-bright);
    transform: scale(0.94);
}

.dpad-cardinal {
    background: rgba(22, 28, 44, 0.92);
    border-color: rgba(212, 175, 55, 0.4);
    font-size: 18px;
}

.dpad-strafe {
    font-size: 15px;
    gap: 1px;
}

.dpad-sub-lbl {
    font-size: 8px;
    font-family: var(--font-ui);
    color: var(--gold-dim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 700;
}

.dpad-diag {
    font-size: 13px;
    background: rgba(12, 16, 26, 0.85);
    border-style: dashed;
    border-color: rgba(212, 175, 55, 0.3);
}

.diag-num {
    font-size: 9px;
    color: var(--gold-bright);
    margin-left: 2px;
    font-weight: bold;
}

.dpad-center {
    border-radius: 10px;
    font-size: 15px;
    background: rgba(30, 36, 54, 0.95);
    border-color: rgba(212, 175, 55, 0.55);
}

.dpad-center.smart-stairs {
    background: linear-gradient(135deg, rgba(70, 50, 12, 0.95), rgba(24, 28, 40, 0.95));
    border-color: #ffd700;
    color: #fff6a8;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.55);
    animation: smartPulseGold 1.8s infinite ease-in-out;
}

.dpad-center.smart-door {
    background: linear-gradient(135deg, rgba(14, 45, 55, 0.95), rgba(20, 24, 34, 0.95));
    border-color: #38bdf8;
    color: #bae6fd;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.55);
    animation: smartPulseCyan 1.8s infinite ease-in-out;
}

.dpad-center.smart-attack {
    background: linear-gradient(135deg, rgba(80, 16, 22, 0.95), rgba(24, 18, 24, 0.95));
    border-color: #ef4444;
    color: #fecaca;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.65);
    animation: smartPulseRed 1.4s infinite ease-in-out;
}

@keyframes smartPulseGold {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.35); transform: scale(1); }
    50% { box-shadow: 0 0 18px rgba(255, 215, 0, 0.75); transform: scale(1.06); }
}

@keyframes smartPulseCyan {
    0%, 100% { box-shadow: 0 0 8px rgba(56, 189, 248, 0.35); transform: scale(1); }
    50% { box-shadow: 0 0 18px rgba(56, 189, 248, 0.75); transform: scale(1.06); }
}

@keyframes smartPulseRed {
    0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); transform: scale(1); }
    50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.85); transform: scale(1.08); }
}

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #06070a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 100;
    transition: opacity 0.5s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(212, 175, 55, 0.2);
    border-top: 3px solid var(--gold-bright);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Atmospheric Death Screen Modal (Matches Godot Overlay.cs:840-935) */
#death-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(30, 8, 12, 0.94) 0%, rgba(8, 2, 4, 0.98) 100%);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    transition: opacity 0.3s ease;
}

#death-modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.death-panel {
    width: 880px;
    max-width: 95vw;
    max-height: 92vh;
    background: rgba(14, 6, 8, 0.95);
    border: 2px solid rgba(180, 45, 45, 0.75);
    box-shadow: 0 0 35px rgba(220, 40, 40, 0.35), inset 0 0 20px rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.death-panel::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border: 1px solid rgba(100, 25, 25, 0.45);
    pointer-events: none;
    border-radius: 6px;
}

.death-header {
    padding: 20px 24px 14px;
    text-align: center;
    border-bottom: 1px solid rgba(180, 45, 45, 0.3);
    background: linear-gradient(180deg, rgba(60, 15, 20, 0.4), transparent);
}

.death-title {
    font-family: var(--font-fantasy);
    font-size: 26px;
    letter-spacing: 4px;
    color: #ff5555;
    text-shadow: 0 0 15px rgba(255, 60, 60, 0.6);
    margin: 0 0 6px;
}

.death-epitaph {
    font-family: var(--font-fantasy);
    font-size: 16px;
    color: #ffd770;
    margin-bottom: 4px;
}

.death-cause {
    font-size: 13px;
    color: #d8c8bc;
    margin-bottom: 4px;
}

.death-score {
    font-size: 12px;
    color: #9cb8d4;
    font-family: var(--font-terminal);
}

.death-tabs {
    display: flex;
    background: rgba(8, 3, 4, 0.9);
    border-bottom: 1px solid rgba(180, 45, 45, 0.3);
    padding: 0 16px;
}

.death-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #9a9095;
    font-family: var(--font-fantasy);
    font-size: 13px;
    padding: 10px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.death-tab:hover {
    color: #ffd770;
    background: rgba(255, 255, 255, 0.03);
}

.death-tab.active {
    color: #ffe8aa;
    border-bottom: 2px solid #ff5555;
    background: rgba(90, 25, 30, 0.35);
}

.death-body {
    flex: 1;
    min-height: 360px;
    max-height: 480px;
    overflow-y: auto;
    padding: 16px 20px;
    background: rgba(10, 4, 6, 0.9);
}

.death-tab-content {
    display: none;
    height: 100%;
}

.death-tab-content.active {
    display: block;
}

#death-terminal-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 4px;
    padding: 8px;
}

#death-terminal-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: 3px;
}

.death-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--font-terminal);
    font-size: 13px;
}

.death-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: rgba(30, 12, 16, 0.4);
    border: 1px solid rgba(80, 30, 35, 0.3);
    border-radius: 4px;
}

.death-list-item .item-slot {
    color: #d4a055;
    font-weight: bold;
    min-width: 160px;
}

.death-list-item .item-name {
    color: #e0e0e0;
    flex: 1;
}

.death-list-item .item-weight {
    color: #8899aa;
    font-size: 11px;
}

.death-list-empty {
    text-align: center;
    color: #888;
    padding: 24px;
    font-style: italic;
}

.death-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.death-stat-card {
    background: rgba(35, 14, 18, 0.5);
    border: 1px solid rgba(100, 35, 40, 0.4);
    border-radius: 6px;
    padding: 12px;
    text-align: center;
}

.death-stat-card .stat-name {
    font-size: 11px;
    color: #b0a0a5;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.death-stat-card .stat-num {
    font-size: 18px;
    font-weight: bold;
    color: #ffd770;
    font-family: var(--font-terminal);
}

.death-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 14px 20px;
    background: rgba(8, 3, 4, 0.95);
    border-top: 1px solid rgba(180, 45, 45, 0.3);
}

.death-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-family: var(--font-fantasy);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.death-btn kbd {
    font-family: var(--font-terminal);
    font-size: 11px;
    padding: 1px 4px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 3px;
}

.btn-reload {
    background: linear-gradient(180deg, #441810, #280a06);
    border: 1px solid #e67e22;
    color: #ffd8a8;
}
.btn-reload:hover {
    background: linear-gradient(180deg, #5c2014, #360d08);
    box-shadow: 0 0 12px rgba(230, 126, 34, 0.5);
}

.btn-reroll {
    background: linear-gradient(180deg, #183820, #0c2012);
    border: 1px solid #2ecc71;
    color: #b8f2cb;
}
.btn-reroll:hover {
    background: linear-gradient(180deg, #204c2c, #102a18);
    box-shadow: 0 0 12px rgba(46, 204, 113, 0.5);
}

.btn-menu {
    background: linear-gradient(180deg, #281e3c, #161022);
    border: 1px solid #9b59b6;
    color: #e3c9f2;
}
.btn-menu:hover {
    background: linear-gradient(180deg, #362952, #1e152e);
    box-shadow: 0 0 12px rgba(155, 89, 182, 0.5);
}

/* ==============================================================================
   Splash Screen & Thunderbear Studios Presentation (Overlay.cs:236-324)
   ============================================================================== */
#splash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #0a0e18 0%, #030407 100%);
    z-index: 50;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    padding: 20px;
}

#splash-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-card {
    position: relative;
    max-width: 820px;
    width: 100%;
    background: rgba(8, 11, 18, 0.94);
    border: 2px solid rgba(212, 175, 55, 0.55);
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(212, 175, 55, 0.08);
    padding: 36px 32px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Ornate Corner Accents */
.splash-ornament-corner, .main-menu-ornament-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: #ffd700;
    pointer-events: none;
}
.splash-ornament-corner.top-left, .main-menu-ornament-corner.top-left {
    top: 6px;
    left: 6px;
    border-top: 2px solid #ffd700;
    border-left: 2px solid #ffd700;
}
.splash-ornament-corner.top-right, .main-menu-ornament-corner.top-right {
    top: 6px;
    right: 6px;
    border-top: 2px solid #ffd700;
    border-right: 2px solid #ffd700;
}
.splash-ornament-corner.bottom-left, .main-menu-ornament-corner.bottom-left {
    bottom: 6px;
    left: 6px;
    border-bottom: 2px solid #ffd700;
    border-left: 2px solid #ffd700;
}
.splash-ornament-corner.bottom-right, .main-menu-ornament-corner.bottom-right {
    bottom: 6px;
    right: 6px;
    border-bottom: 2px solid #ffd700;
    border-right: 2px solid #ffd700;
}

.splash-presentation {
    font-size: 18px;
    letter-spacing: 4px;
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
    margin-bottom: 4px;
    font-weight: 700;
}

.splash-presents {
    font-size: 12px;
    letter-spacing: 6px;
    color: #8c9ba5;
    margin-bottom: 18px;
}

.splash-logo-container {
    margin: 6px 0 18px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.splash-logo {
    max-height: 200px;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 25px rgba(212, 175, 55, 0.3);
    border: 1px solid rgba(212, 175, 55, 0.4);
    transition: transform 0.3s ease;
}
.splash-logo:hover {
    transform: scale(1.02);
}

.splash-title {
    font-size: clamp(22px, 6.8vw, 42px);
    letter-spacing: clamp(3px, 1.8vw, 8px);
    white-space: nowrap !important;
    text-align: center;
    color: #fff2a8;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.9);
    margin-bottom: 6px;
    font-weight: 900;
}

.splash-subtitle {
    font-size: 15px;
    color: #d1d5db;
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.splash-engine-tag {
    font-size: 12px;
    color: #7b889b;
    margin-bottom: 26px;
    font-family: var(--font-terminal);
}

.btn-splash-start {
    width: 100%;
    max-width: 520px;
    padding: 14px 20px;
    background: linear-gradient(180deg, #3d2b0e 0%, #1f1405 100%);
    border: 2px solid #ffd700;
    border-radius: 8px;
    color: #fff9db;
    font-family: var(--font-fantasy);
    font-size: 15px;
    letter-spacing: 2px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.25);
    transition: all 0.2s ease;
    animation: pulseGlow 2.4s infinite ease-in-out;
}

.btn-splash-start:hover {
    background: linear-gradient(180deg, #593f14 0%, #2f1e08 100%);
    border-color: #ffffff;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.55);
    transform: translateY(-1px);
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 16px rgba(255, 215, 0, 0.25); }
    50% { box-shadow: 0 0 28px rgba(255, 215, 0, 0.55); }
}

.splash-shortcuts {
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.splash-shortcut-btn {
    background: rgba(14, 18, 28, 0.7);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    padding: 6px 14px;
    color: #cbd5e1;
    font-family: var(--font-fantasy);
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.splash-shortcut-btn kbd {
    font-family: var(--font-terminal);
    color: #ffd700;
}

.splash-shortcut-btn:hover {
    background: rgba(30, 40, 60, 0.85);
    border-color: #ffd700;
    color: #ffffff;
    transform: translateY(-1px);
}

/* ==============================================================================
   Main Menu Overlay (Overlay.cs:569-657)
   ============================================================================== */
#main-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(3, 4, 7, 0.88);
    backdrop-filter: blur(6px);
    z-index: 48;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

#main-menu-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.main-menu-card {
    position: relative;
    max-width: 780px;
    width: 100%;
    background: rgba(8, 11, 18, 0.95);
    border: 2px solid rgba(212, 175, 55, 0.45);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    padding: 30px 28px 22px;
    display: flex;
    flex-direction: column;
}

.main-menu-header {
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 14px;
    margin-bottom: 18px;
    text-align: center;
}

.main-menu-title {
    font-size: clamp(18px, 5.2vw, 28px);
    letter-spacing: clamp(2px, 1.2vw, 4px);
    white-space: nowrap !important;
    text-align: center;
    color: #ffd700;
    font-weight: 700;
    margin-bottom: 4px;
}

.main-menu-subtitle {
    font-size: 13px;
    color: #94a3b8;
}

.main-menu-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.menu-option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    background: rgba(12, 15, 24, 0.7);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-fantasy);
    color: #cbd5e1;
    transition: all 0.15s ease;
}

.menu-option-btn .menu-bullet {
    font-size: 14px;
    color: transparent;
    transition: color 0.15s ease;
    width: 14px;
}

.menu-option-btn .menu-num {
    font-family: var(--font-terminal);
    font-size: 13px;
    color: #8c9ba5;
    font-weight: 600;
    min-width: 28px;
}

.menu-text-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-label {
    font-size: 15px;
    font-weight: 600;
    color: #e2e8f0;
}

.menu-desc {
    font-size: 12px;
    color: #7b889b;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.menu-option-btn:hover, .menu-option-btn.selected {
    background: linear-gradient(90deg, rgba(61, 43, 14, 0.85) 0%, rgba(20, 24, 36, 0.85) 100%);
    border-color: #ffd700;
    box-shadow: 0 0 14px rgba(212, 175, 55, 0.35);
    transform: translateX(4px);
}

.menu-option-btn:hover .menu-bullet, .menu-option-btn.selected .menu-bullet {
    color: #ffd700;
}

.menu-option-btn:hover .menu-num, .menu-option-btn.selected .menu-num {
    color: #ffd700;
}

.menu-option-btn:hover .menu-label, .menu-option-btn.selected .menu-label {
    color: #ffffff;
}

.menu-option-btn:hover .menu-desc, .menu-option-btn.selected .menu-desc {
    color: #cbd5e1;
}

.main-menu-footer {
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    padding-top: 12px;
    text-align: center;
    font-size: 12px;
    color: #7b889b;
    font-family: var(--font-terminal);
}

/* ==============================================================================
   Game Guide & Primer Modal (Overlay.cs:352-450)
   ============================================================================== */
#guide-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(3, 4, 7, 0.88);
    backdrop-filter: blur(8px);
    z-index: 55;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

#guide-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.guide-card {
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    background: rgba(8, 11, 18, 0.98);
    border: 2px solid rgba(212, 175, 55, 0.5);
    border-radius: 12px;
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(14, 18, 28, 0.9);
    border-bottom: 1px solid rgba(212, 175, 55, 0.35);
}

.guide-title {
    font-size: 17px;
    letter-spacing: 2px;
    color: #ffd700;
    font-weight: 700;
}

.btn-guide-close {
    background: transparent;
    border: none;
    color: #8c9ba5;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.15s ease;
    padding: 0 4px;
}
.btn-guide-close:hover {
    color: #ff5555;
}

.guide-tabs {
    display: flex;
    flex-wrap: wrap;
    background: rgba(10, 13, 20, 0.95);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding: 6px 16px 0;
    gap: 4px;
}

.guide-tab {
    background: rgba(18, 22, 34, 0.7);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 8px 16px;
    font-family: var(--font-fantasy);
    font-size: 13px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s ease;
}

.guide-tab:hover {
    color: #ffffff;
    background: rgba(32, 40, 60, 0.85);
}

.guide-tab.active {
    background: linear-gradient(180deg, rgba(61, 43, 14, 0.9) 0%, rgba(20, 24, 36, 0.95) 100%);
    border-color: #ffd700;
    color: #ffd700;
    font-weight: 700;
}

.guide-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
}

.guide-tab-content {
    display: none;
    flex-direction: column;
    gap: 12px;
}
.guide-tab-content.active {
    display: flex;
}

.guide-section-header {
    font-size: 16px;
    letter-spacing: 2px;
    color: #ffd700;
    font-weight: 700;
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.guide-p {
    font-size: 14px;
    line-height: 1.6;
    color: #cbd5e1;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.guide-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    line-height: 1.55;
    color: #cbd5e1;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.guide-list kbd {
    font-family: var(--font-terminal);
    font-size: 12px;
    color: #ffd700;
    background: rgba(0, 0, 0, 0.5);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.guide-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(14, 18, 28, 0.9);
    border-top: 1px solid rgba(212, 175, 55, 0.25);
    font-size: 12px;
    color: #8c9ba5;
    font-family: var(--font-terminal);
}

/* ==============================================================================
   Load Saved Game Modal & Save Manager
   ============================================================================== */
#load-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(3, 4, 7, 0.88);
    backdrop-filter: blur(8px);
    z-index: 52;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

#load-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.load-card {
    position: relative;
    max-width: 820px;
    width: 100%;
    max-height: 88vh;
    background: rgba(8, 11, 18, 0.96);
    border: 2px solid rgba(212, 175, 55, 0.5);
    border-radius: 12px;
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.load-save-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 220px;
    max-height: 55vh;
}

.save-item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(14, 18, 28, 0.75);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 8px;
    padding: 12px 16px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.save-item-card:hover, .save-item-card.selected {
    background: linear-gradient(90deg, rgba(61, 43, 14, 0.85) 0%, rgba(20, 26, 40, 0.85) 100%);
    border-color: #ffd700;
    box-shadow: 0 0 16px rgba(212, 175, 55, 0.35);
    transform: translateX(3px);
}

.save-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.save-bullet {
    font-size: 14px;
    color: transparent;
    transition: color 0.15s ease;
    width: 14px;
}

.save-item-card:hover .save-bullet, .save-item-card.selected .save-bullet {
    color: #ffd700;
}

.save-item-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.save-item-name {
    font-family: var(--font-fantasy);
    font-size: 16px;
    font-weight: 700;
    color: #ffd700;
}

.save-item-summary {
    font-size: 13px;
    color: #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.save-item-meta {
    font-size: 11px;
    color: #7b889b;
    font-family: var(--font-terminal);
}

.save-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-save-load {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-save-download {
    padding: 6px 12px;
    font-size: 12px;
}

.load-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.18);
    background: rgba(8, 11, 18, 0.65);
}

.save-status-msg {
    font-size: 12px;
    font-family: var(--font-terminal);
    color: #38bdf8;
    margin-left: 8px;
    font-weight: 500;
}

.load-card.drag-over {
    border-color: #ffd700 !important;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6) !important;
    transform: scale(1.01);
}

.btn-danger-outline {
    background: rgba(40, 10, 15, 0.6);
    border: 1px solid rgba(220, 53, 69, 0.5);
    color: #ff8585;
    border-radius: 4px;
    padding: 6px 12px;
    font-family: var(--font-fantasy);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger-outline:hover {
    background: rgba(220, 53, 69, 0.3);
    border-color: #ff4d4d;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.5);
}

.save-empty-state, .save-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
    color: #8c9ba5;
}

.save-empty-icon {
    font-size: 36px;
}

.save-empty-title {
    font-family: var(--font-fantasy);
    font-size: 18px;
    color: #ffd700;
}

.save-empty-desc {
    font-size: 13px;
    color: #94a3b8;
    max-width: 400px;
    line-height: 1.5;
}

.load-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(14, 18, 28, 0.95);
    border-top: 1px solid rgba(212, 175, 55, 0.25);
    font-size: 12px;
    color: #8c9ba5;
    font-family: var(--font-terminal);
}

/* ==============================================================================
   In-Game Pause Menu Modal
   ============================================================================== */
#pause-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(3, 4, 7, 0.85);
    backdrop-filter: blur(8px);
    z-index: 54;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 20px;
}

#pause-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.pause-card {
    max-width: 680px;
}

.pause-audio-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
    background: rgba(18, 24, 36, 0.75);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 6px;
    margin-bottom: 14px;
}

.pause-mute-btn {
    background: rgba(14, 18, 28, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 4px;
    color: #ffd700;
    font-family: var(--font-fantasy);
    font-size: 13px;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pause-mute-btn:hover {
    background: rgba(30, 40, 60, 0.9);
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
}

.pause-audio-toolbar .volume-slider-wrap {
    gap: 10px;
}

.pause-audio-toolbar .volume-slider-wrap label {
    font-family: var(--font-fantasy);
    font-size: 13px;
    color: #ffd700;
    letter-spacing: 0.5px;
}

.pause-audio-toolbar .volume-range-slider {
    width: 140px;
    height: 6px;
}

.pause-audio-toolbar .volume-label {
    font-size: 12px;
    color: #ffffff;
    min-width: 34px;
}

/* Splash Screen Credits Footer */
.splash-credits-footer {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    font-size: 11.5px;
    color: #718096;
    font-family: var(--font-terminal);
    width: 100%;
    text-align: center;
    letter-spacing: 0.5px;
}

/* Guide Modal Enhancements */
.guide-tab-content strong {
    color: #ffd700;
}

.guide-list li {
    padding-left: 4px;
    border-left: 2px solid transparent;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.guide-list li:hover {
    border-left-color: #ffd700;
    padding-left: 8px;
}

/* ==============================================================================
   RESPONSIVE DESIGN SYSTEM: Tablet & Phone Adaptive Architecture
   Preserves 100% pixel-parity on Desktop PC (>=1024px) while transforming
   fluidly for Tablet (600-1023px) and Phone (<600px).
   ============================================================================== */

/* Default Desktop: Action drawer toggle button is hidden */
#btn-action-more {
    display: none !important;
}

/* Action button active mechanical micro-scale */
.action-btn:active, .dpad-btn:active {
    transform: scale(0.94);
}

/* Contextual Action Button Pulses */
.action-btn.stair-btn {
    border-color: #ffd700 !important;
    color: #fff6a8 !important;
    background: linear-gradient(180deg, #44320e, #201503) !important;
    animation: smartPulseGold 1.8s infinite ease-in-out;
}

.action-btn.smart-low-hp {
    border-color: #ef4444 !important;
    color: #fecaca !important;
    background: linear-gradient(180deg, #4a1216, #200608) !important;
    animation: smartPulseRed 1.4s infinite ease-in-out;
}

.action-btn.smart-door-active {
    border-color: #38bdf8 !important;
    color: #bae6fd !important;
    background: linear-gradient(180deg, #103348, #071926) !important;
    animation: smartPulseCyan 1.8s infinite ease-in-out;
}

/* Universal Tactile Button & Touch Optimization */
button, .action-btn, .menu-option-btn, .splash-shortcut-btn, .dpad-btn, .icon-btn, .m-action-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ------------------------------------------------------------------------------
   COMPACT TOP-RIGHT BAR & MODAL TOP OFFSET (< 768px or Touch Screen)
   ------------------------------------------------------------------------------ */
@media (max-width: 768px), (max-width: 850px) and (pointer: coarse), (max-height: 500px) and (orientation: landscape) {
    #top-right-bar {
        top: max(4px, var(--safe-top)) !important;
        right: max(6px, var(--safe-right)) !important;
        gap: 6px !important;
        z-index: 1000 !important;
    }
    #top-right-bar #ping-badge,
    #top-right-bar #btn-controls,
    #top-right-bar .volume-slider-wrap {
        display: none !important;
    }
    #top-right-bar .msg-label,
    #top-right-bar .map-label,
    #top-right-bar .dpad-label,
    #top-right-bar .sound-label,
    #top-right-bar .menu-label,
    #top-right-bar .ctrl-label,
    #top-right-bar .fs-label,
    #top-right-bar .dpad-label,
    #top-right-bar .invert-label {
        display: none !important;
    }
    #top-right-bar #btn-toggle-msg-feed,
    #top-right-bar #btn-toggle-minimap,
    #top-right-bar #btn-toggle-dpad,
    #top-right-bar #btn-toggle-invert,
    #top-right-bar #btn-sound,
    #top-right-bar #btn-fullscreen,
    #top-right-bar #btn-menu {
        min-width: 36px !important;
        min-height: 36px !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 15px !important;
        border-radius: 8px !important;
        background: rgba(14, 18, 28, 0.92) !important;
        border: 1px solid rgba(212, 175, 55, 0.35) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
    }
    #top-right-bar #btn-toggle-msg-feed[style*="display: none"],
    #top-right-bar #btn-toggle-minimap[style*="display: none"],
    #top-right-bar #btn-toggle-dpad[style*="display: none"],
    #top-right-bar #btn-toggle-invert[style*="display: none"] {
        display: none !important;
    }
    #top-right-bar #btn-toggle-msg-feed.active,
    #top-right-bar #btn-toggle-minimap.active,
    #top-right-bar #btn-toggle-dpad.active,
    #top-right-bar #btn-toggle-invert.active {
        border-color: #ffd700 !important;
        background: rgba(45, 36, 16, 0.95) !important;
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.45) !important;
    }
    .sound-control-group {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
    }

    /* Full-Screen Overlays Safe Top Offsets (prevents modal headers from colliding with top buttons) */
    #splash-overlay,
    #main-menu-overlay,
    #terminal-container,
    #guide-modal,
    #load-modal,
    #pause-modal,
    #death-modal {
        padding-top: calc(52px + var(--safe-top)) !important;
        padding-bottom: max(8px, var(--safe-bottom)) !important;
        padding-left: max(8px, var(--safe-left)) !important;
        padding-right: max(8px, var(--safe-right)) !important;
        box-sizing: border-box !important;
    }
    .splash-card,
    .main-menu-card,
    .load-card,
    .guide-card,
    .death-card {
        max-height: calc(100dvh - 58px - var(--safe-top) - var(--safe-bottom)) !important;
        overflow-y: auto !important;
        touch-action: pan-y !important;
        -webkit-overflow-scrolling: touch !important;
        box-sizing: border-box !important;
    }
    .splash-card {
        padding: 16px 14px 18px !important;
        width: min(94vw, 460px) !important;
    }
    .splash-logo {
        width: clamp(75px, 18vw, 115px) !important;
        height: auto !important;
    }
    .splash-presentation, .splash-presents {
        font-size: 10px !important;
        letter-spacing: 2px !important;
    }
    .splash-title {
        font-size: clamp(18px, 5.2vw, 28px) !important;
        letter-spacing: clamp(1.5px, 1vw, 4px) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        margin-bottom: 4px !important;
    }
    .splash-subtitle {
        font-size: 11.5px !important;
        line-height: 1.35 !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        max-width: 92% !important;
        margin-bottom: 3px !important;
    }
    .splash-engine-tag {
        font-size: 9.5px !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        max-width: 92% !important;
        margin-bottom: 12px !important;
    }
    .btn-splash-start {
        padding: 10px 12px !important;
        font-size: 12px !important;
        letter-spacing: 1px !important;
        line-height: 1.35 !important;
        white-space: normal !important;
        width: 100% !important;
        min-height: 44px !important;
    }
    .splash-shortcuts {
        margin-top: 14px !important;
        gap: 6px !important;
    }
    .splash-shortcut-btn {
        min-height: 44px !important;
        padding: 8px 10px !important;
        font-size: 12px !important;
    }
    .menu-option-btn {
        min-height: 48px !important;
        padding: 8px 12px !important;
    }
    .menu-label {
        font-size: 13px !important;
    }
    .menu-desc {
        font-size: 10.5px !important;
    }
}

/* ------------------------------------------------------------------------------
   TABLET RESPONSIVE TIER (600px - 1023px)
   ------------------------------------------------------------------------------ */
@media (max-width: 1023px) {
    .top-message-banner {
        padding-right: calc(min(45vw, 420px) + var(--safe-right)) !important;
    }
}

@media (max-width: 768px) {
    .top-message-banner {
        position: fixed !important;
        top: calc(44px + var(--safe-top)) !important;
        left: max(8px, var(--safe-left)) !important;
        right: max(8px, var(--safe-right)) !important;
        width: auto !important;
        height: 32px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        border-radius: 6px !important;
        background: rgba(6, 9, 16, 0.95) !important;
        border: 1px solid rgba(212, 175, 55, 0.45) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8) !important;
        z-index: 28 !important;
    }
    .top-message-text {
        font-size: 12px;
        width: 100% !important;
        text-align: left !important;
    }
}

@media (max-width: 1023px) {

    #hud-overlay {
        padding-bottom: max(8px, var(--safe-bottom));
        padding-left: max(10px, var(--safe-left));
        padding-right: max(10px, var(--safe-right));
        gap: 8px;
    }

    #char-panel {
        min-width: 220px;
        padding: 8px 12px;
        gap: 6px;
    }

    #stats-strip {
        font-size: 11px;
        gap: 4px;
    }

    .stat-label {
        font-size: 9px;
    }

    #btn-action-more {
        display: inline-flex !important;
        background: rgba(30, 40, 60, 0.9);
        border-color: #ffd700;
        color: #ffd700;
    }

    /* Collapsed Action Bar on Tablet: Display 6 primary actions + More */
    #action-bar:not(.drawer-open) #btn-throw,
    #action-bar:not(.drawer-open) #btn-fire,
    #action-bar:not(.drawer-open) #btn-read,
    #action-bar:not(.drawer-open) #btn-pickup,
    #action-bar:not(.drawer-open) #btn-equipment,
    #action-bar:not(.drawer-open) #btn-guide-hud {
        display: none;
    }

    /* Expanded Drawer State (Floating Grid Overlay) */
    #action-bar.drawer-open {
        position: fixed;
        bottom: calc(56px + var(--safe-bottom));
        left: 50%;
        transform: translateX(-50%);
        width: min(94vw, 560px);
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        z-index: 45;
        padding: 14px;
        background: rgba(10, 14, 22, 0.96);
        border: 2px solid rgba(212, 175, 55, 0.55);
        border-radius: 12px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.95), 0 0 25px rgba(212, 175, 55, 0.25);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    #action-bar.drawer-open .action-btn {
        display: inline-flex !important;
        justify-content: center;
        text-align: center;
        padding: 8px 6px;
        font-size: 12px;
    }

    #action-bar.drawer-open #btn-action-more {
        grid-column: span 4;
        background: rgba(40, 16, 20, 0.9);
        border-color: #ff6b6b;
        color: #ff9999;
    }
}

/* ------------------------------------------------------------------------------
   PHONE RESPONSIVE TIER (< 600px or <= 500px landscape height)
   ------------------------------------------------------------------------------ */
@media (max-width: 599px), (max-height: 500px) and (orientation: landscape) {
    .top-message-banner {
        position: fixed !important;
        top: calc(44px + var(--safe-top)) !important;
        left: max(8px, var(--safe-left)) !important;
        right: max(8px, var(--safe-right)) !important;
        width: auto !important;
        height: 32px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        border-radius: 6px !important;
        background: rgba(6, 9, 16, 0.95) !important;
        border: 1px solid rgba(212, 175, 55, 0.45) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8) !important;
        z-index: 28 !important;
        cursor: pointer;
    }

    .top-message-text {
        font-size: 12px;
        width: 100% !important;
        text-align: left !important;
    }

    /* Streamlined Non-Truncating Footer on Phone */
    #hud-footer {
        padding: 2px 8px;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
        -webkit-overflow-scrolling: touch !important;
    }
    #hud-footer::-webkit-scrollbar {
        display: none !important;
    }
    #hud-footer .status-group {
        flex-shrink: 0 !important;
    }

    .status-pill {
        font-size: 10px;
        padding: 2px 6px;
    }

    .pill-exp, .pill-light {
        display: none !important;
    }

    #compass-container {
        display: none !important;
    }
}

/* Tablet Portrait Movement D-Pad Quarantine (Keeps D-pad on bottom-left thumb) */
@media (min-width: 601px) and (max-width: 1023px) and (orientation: portrait),
       html.device-tablet.is-portrait {
    #touch-controls {
        position: fixed !important;
        left: max(16px, var(--safe-left)) !important;
        right: auto !important;
        bottom: calc(52px + var(--safe-bottom)) !important;
        display: block !important;
    }
}

/* ------------------------------------------------------------------------------
   PHONE & PORTRAIT SPLIT-THUMB ERGONOMIC HUD
   Left thumb: Movement & Orientation D-pad
   Right thumb: Tactical 2-Column Action Cluster
   Top: Slim HP/Mana Status Capsule + Circular Radar Minimap
   Zero overlaps, >70% unobstructed 3D viewport!
   ------------------------------------------------------------------------------ */
@media (max-width: 600px) and (orientation: portrait), 
       html.device-phone:not(.is-landscape),
       html.device-phone.is-portrait {
    #hud-overlay {
        position: fixed !important;
        inset: 0 !important;
        pointer-events: none !important;
        display: block !important;
        padding: 0 !important;
        z-index: 20 !important;
    }

    /* Top Left: Slim Character Vitals Capsule */
    #char-panel {
        position: fixed !important;
        top: calc(80px + var(--safe-top)) !important;
        left: max(8px, var(--safe-left)) !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 215px !important;
        padding: 5px 8px !important;
        background: rgba(8, 12, 20, 0.88) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(212, 175, 55, 0.45) !important;
        border-radius: 8px !important;
        z-index: 30 !important;
        pointer-events: auto !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 3px !important;
    }

    .char-title {
        font-size: 11px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 195px !important;
    }

    .gauge-header {
        font-size: 9.5px !important;
    }

    .gauge-track {
        height: 6px !important;
    }

    #stats-strip {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 2px 4px !important;
        margin-top: 3px !important;
        padding-top: 3px !important;
        border-top: 1px solid rgba(212, 175, 55, 0.25) !important;
    }

    #stats-strip .stat-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 2px !important;
        white-space: nowrap !important;
    }

    #stats-strip .stat-label {
        font-size: 8px !important;
        color: var(--gold-dim) !important;
        font-weight: 700 !important;
    }

    #stats-strip .stat-value {
        font-size: 9px !important;
        color: #fff !important;
        font-weight: 600 !important;
    }

    #stats-strip .stat-divider {
        display: none !important;
    }

    #hud-center-column {
        position: static !important;
        width: auto !important;
        pointer-events: none !important;
        margin: 0 !important;
    }

    /* Top Right: Compact Circular Minimap Radar */
    #minimap-container {
        position: fixed !important;
        top: calc(80px + var(--safe-top)) !important;
        right: max(6px, var(--safe-right)) !important;
        left: auto !important;
        width: 102px !important;
        height: 102px !important;
        border-radius: 50% !important;
        overflow: visible !important;
        z-index: 30 !important;
        border: 1.5px solid rgba(212, 175, 55, 0.6) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7) !important;
        pointer-events: auto !important;
    }

    #minimap-header,
    #minimap-controls-bar,
    #camera-tilt-bar,
    #map-resize-handle {
        display: none !important;
    }

    #minimap-canvas {
        width: 100% !important;
        height: 100% !important;
        border-radius: 50% !important;
    }

    .mobile-map-zoom-group {
        display: flex !important;
        flex-direction: column !important;
        position: absolute !important;
        left: -38px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        gap: 6px !important;
        z-index: 35 !important;
        pointer-events: auto !important;
    }

    .mobile-map-btn {
        width: 32px !important;
        height: 32px !important;
        border-radius: 50% !important;
        background: rgba(12, 16, 26, 0.94) !important;
        border: 1.5px solid rgba(212, 175, 55, 0.75) !important;
        color: #ffd700 !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.7) !important;
        user-select: none !important;
        -webkit-user-select: none !important;
    }

    .mobile-map-btn:active {
        background: rgba(212, 175, 55, 0.4) !important;
        transform: scale(0.92) !important;
    }

    /* Bottom Left Thumb: Movement & Orientation D-Pad */
    #touch-controls {
        position: fixed !important;
        left: max(8px, var(--safe-left)) !important;
        right: auto !important;
        bottom: calc(40px + var(--safe-bottom)) !important;
        top: auto !important;
        transform: none !important;
        width: 148px !important;
        height: auto !important;
        z-index: 35 !important;
        pointer-events: auto !important;
        background: rgba(8, 12, 20, 0.82) !important;
        border: 1px solid rgba(212, 175, 55, 0.35) !important;
        border-radius: 10px !important;
        padding: 4px !important;
        gap: 3px !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
    }

    .dpad-turn-wings {
        display: flex !important;
        gap: 4px !important;
    }

    .dpad-turn-btn {
        height: 28px !important;
        font-size: 11px !important;
    }

    .dpad-turn-symbol {
        font-size: 13px !important;
    }

    .dpad-turn-text {
        font-size: 9.5px !important;
    }

    .dpad-grid {
        gap: 3px !important;
    }

    .dpad-btn {
        width: 100% !important;
        height: 100% !important;
        min-height: 36px !important;
        font-size: 15px !important;
        border-radius: 6px !important;
    }

    .dpad-cardinal {
        font-size: 16px !important;
    }

    .dpad-strafe {
        font-size: 13px !important;
    }

    .dpad-sub-lbl {
        font-size: 7px !important;
    }

    .dpad-diag {
        font-size: 11px !important;
    }

    .diag-num {
        font-size: 7.5px !important;
    }

    /* Bottom Right Thumb: 2-Column Action Bar Cluster */
    #action-bar:not(.drawer-open) {
        position: fixed !important;
        right: max(8px, var(--safe-right)) !important;
        left: auto !important;
        bottom: calc(44px + var(--safe-bottom)) !important;
        width: 146px !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 5px !important;
        z-index: 35 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        pointer-events: auto !important;
    }

    #action-bar:not(.drawer-open) .action-btn {
        display: none;
        height: 44px !important;
        min-height: 44px !important;
        width: 100% !important;
        padding: 2px 4px !important;
        font-size: 11px !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
        border-radius: 8px !important;
        background: rgba(14, 18, 28, 0.88) !important;
        border: 1px solid rgba(212, 175, 55, 0.4) !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5) !important;
    }

    #action-bar:not(.drawer-open) .action-btn kbd {
        display: none !important;
    }

    /* Primary tactile thumb actions */
    #action-bar:not(.drawer-open) #btn-attack,
    #action-bar:not(.drawer-open) #btn-cast,
    #action-bar:not(.drawer-open) #btn-inventory,
    #action-bar:not(.drawer-open) #btn-quaff,
    #action-bar:not(.drawer-open) #btn-terminal,
    #action-bar:not(.drawer-open) #btn-action-more {
        display: inline-flex !important;
    }

    #action-bar:not(.drawer-open) #btn-stair.stair-active {
        display: inline-flex !important;
    }

    #action-bar.drawer-open #btn-stair:not(.stair-active),
    #action-bar #btn-stair:not(.stair-active),
    #btn-stair:not(.stair-active) {
        display: none !important;
    }

    /* Action Drawer on Phone (Expanded state) */
    #action-bar.drawer-open {
        position: fixed !important;
        bottom: calc(44px + var(--safe-bottom)) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 16px) !important;
        max-width: 480px !important;
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        z-index: 60 !important;
        padding: 10px !important;
        background: rgba(8, 12, 18, 0.98) !important;
        border: 2px solid rgba(212, 175, 55, 0.6) !important;
        border-radius: 12px !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.95) !important;
        pointer-events: auto !important;
    }

    #action-bar.drawer-open .action-btn {
        display: inline-flex !important;
        justify-content: center !important;
        padding: 10px 4px !important;
        font-size: 12px !important;
        min-height: 48px !important;
        border-radius: 8px !important;
    }

    #action-bar.drawer-open #btn-action-more {
        grid-column: span 3 !important;
        background: rgba(45, 14, 18, 0.95) !important;
        border-color: #ff5555 !important;
        color: #ffaaaa !important;
    }

    /* Bottom Status Bar */
    #hud-footer {
        position: fixed !important;
        bottom: var(--safe-bottom) !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 36px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 2px 8px !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        background: rgba(6, 9, 14, 0.96) !important;
        border-top: 1px solid rgba(212, 175, 55, 0.3) !important;
        border-radius: 0 !important;
        z-index: 32 !important;
        pointer-events: auto !important;
    }

    /* Hide Desktop Message Feed Window on Phone by default */
    #message-feed-window:not(.mobile-expanded) {
        display: none !important;
    }

    /* Message Feed Drawer on Phone when opened */
    #message-feed-window.mobile-expanded {
        display: flex !important;
        position: fixed !important;
        inset: auto 0 0 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 60vh !important;
        max-height: 80vh !important;
        z-index: 100 !important;
        border-radius: 16px 16px 0 0 !important;
        border: 2px solid rgba(212, 175, 55, 0.7) !important;
        border-bottom: none !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.95) !important;
        background: rgba(10, 14, 22, 0.97) !important;
        backdrop-filter: blur(16px) !important;
        -webkit-backdrop-filter: blur(16px) !important;
        animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }
}

@keyframes slideUpSheet {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ------------------------------------------------------------------------------
   ZOOMABLE TERMINAL VIEWPORT & CLASSIC TOUCH CONTROLS
   ------------------------------------------------------------------------------ */
.terminal-header-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.term-facing-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(30, 24, 10, 0.90);
    border: 1px solid rgba(255, 215, 0, 0.65);
    color: #ffd700;
    font-family: var(--font-terminal);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.25);
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.4);
}

.terminal-viewport {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    max-height: calc(92vh - 90px);
    max-height: calc(92dvh - 90px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    position: relative;
    border-radius: 6px;
    background: #04060a;
    border: 1px solid rgba(212, 175, 55, 0.25);
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.4) transparent;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.terminal-viewport:active,
.terminal-viewport.is-dragging {
    cursor: grabbing;
}

#terminal-canvas {
    display: block;
    touch-action: none; /* Native browser gestures disabled so terminal pan & pinch-zoom work cleanly */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

#terminal-canvas:active {
    cursor: grabbing;
}

.terminal-viewport::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.terminal-viewport::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.4);
}

.terminal-viewport::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.4);
    border-radius: 3px;
}

.terminal-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(18, 24, 38, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 6px;
    padding: 2px 4px;
}

.term-zoom-btn {
    background: transparent;
    border: none;
    color: var(--gold-bright);
    font-family: var(--font-terminal);
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.term-zoom-btn:hover,
.term-zoom-btn:active {
    background: rgba(212, 175, 55, 0.2);
    color: #fff;
}

/* Unified Intelligent Contextual Mobile Controls Dock */
.terminal-touch-controls {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 680px;
    margin: 4px auto 0;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(8, 12, 20, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 10px;
    box-sizing: border-box;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.term-letter-ribbon {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding: 2px 2px 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
}

.term-letter-ribbon::-webkit-scrollbar {
    height: 4px;
}

.term-letter-ribbon::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.4);
    border-radius: 2px;
}

.term-letter-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    background: rgba(20, 26, 40, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 6px;
    color: #ffd700;
    font-family: var(--font-terminal);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    flex-shrink: 0;
}

.term-letter-btn:active {
    background: rgba(255, 215, 0, 0.3);
    border-color: #fff;
    color: #fff;
    transform: scale(0.94);
}

.term-controls-main-row {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.term-touch-dpad-col {
    flex-shrink: 0;
}

.term-dpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 36px);
    gap: 3px;
    align-items: center;
    justify-items: center;
}

.term-dpad-ul { grid-column: 1; grid-row: 1; }
.term-dpad-up { grid-column: 2; grid-row: 1; }
.term-dpad-ur { grid-column: 3; grid-row: 1; }
.term-dpad-left { grid-column: 1; grid-row: 2; }
.term-dpad-center { grid-column: 2; grid-row: 2; }
.term-dpad-right { grid-column: 3; grid-row: 2; }
.term-dpad-dl { grid-column: 1; grid-row: 3; }
.term-dpad-down { grid-column: 2; grid-row: 3; }
.term-dpad-dr { grid-column: 3; grid-row: 3; }

.term-dpad-btn {
    width: 100%;
    height: 100%;
    background: rgba(18, 24, 36, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 6px;
    color: var(--gold-bright);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.1s ease;
}

.term-dpad-btn:active {
    background: rgba(45, 36, 16, 0.98);
    border-color: #ffd700;
    color: #fff;
    transform: scale(0.95);
}

/* 3D Forward Direction Highlight on Targeting D-pad */
.term-dpad-btn.fwd-highlight {
    background: rgba(90, 60, 15, 0.98) !important;
    border: 2px solid #ffd700 !important;
    color: #fff !important;
    font-weight: 800 !important;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.8), inset 0 0 8px rgba(255, 215, 0, 0.45) !important;
    animation: pulseGoldGlow 1.2s infinite alternate !important;
}

@keyframes pulseGoldGlow {
    0% { box-shadow: 0 0 6px rgba(255, 215, 0, 0.4); }
    100% { box-shadow: 0 0 18px rgba(255, 215, 0, 0.95), inset 0 0 10px rgba(255, 215, 0, 0.6); }
}

.term-touch-actions-col {
    flex: 1;
    min-width: 0;
}

.term-contextual-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    align-content: center;
}

.term-ctx-btn {
    min-height: 40px;
    padding: 5px 6px;
    background: rgba(18, 24, 36, 0.92);
    border: 1px solid rgba(212, 175, 55, 0.38);
    border-radius: 6px;
    color: #f0f4f8;
    font-family: var(--font-fantasy);
    font-size: 11px;
    line-height: 1.25;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    text-align: center;
    transition: all 0.1s ease;
}

.term-ctx-btn:active {
    background: rgba(50, 40, 18, 0.98);
    border-color: #ffd700;
    color: #fff;
    transform: scale(0.95);
}

.term-ctx-btn.btn-primary-action {
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.85), rgba(153, 122, 21, 0.95));
    border-color: #ffe270;
    color: #0b0c0e;
    font-weight: 700;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.35);
}

.term-ctx-btn.btn-cancel-action {
    background: rgba(35, 18, 22, 0.92);
    border-color: rgba(230, 60, 60, 0.5);
    color: #ffaaaa;
}

/* Character Creation Name Bar */
.birth-name-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.birth-name-input {
    flex: 1;
    height: 38px;
    padding: 0 12px;
    font-family: var(--font-terminal);
    font-size: 15px;
    background: rgba(4, 6, 12, 0.95);
    border: 1.5px solid rgba(212, 175, 55, 0.65);
    border-radius: 6px;
    color: #ffd700;
    outline: none;
    box-sizing: border-box;
}

.birth-name-input:focus {
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* ------------------------------------------------------------------------------
   PHONE LANDSCAPE ORIENTATION REFINEMENTS
   ------------------------------------------------------------------------------ */
@media (max-height: 500px) and (orientation: landscape) {
    /* Full-Screen Overlays Safe Top Offsets */
    #splash-overlay,
    #main-menu-overlay,
    #terminal-container,
    #guide-modal,
    #load-modal,
    #pause-modal,
    #death-modal {
        padding-top: max(4px, var(--safe-top)) !important;
        padding-bottom: max(4px, var(--safe-bottom)) !important;
        padding-left: max(6px, var(--safe-left)) !important;
        padding-right: max(6px, var(--safe-right)) !important;
    }

    .splash-card,
    .main-menu-card,
    .load-card,
    .guide-card,
    .death-card {
        padding: 8px 12px !important;
        gap: 6px !important;
        max-height: calc(100vh - 8px) !important;
    }

    .splash-title {
        font-size: clamp(20px, 4vw, 26px) !important;
        margin-bottom: 2px !important;
    }

    .menu-options {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }

    .menu-option-btn {
        min-height: 40px !important;
        padding: 4px 8px !important;
    }

    /* Top Left: Ultra-Slim Horizontal Character Status Capsule */
    #char-panel {
        position: fixed !important;
        top: max(3px, var(--safe-top)) !important;
        left: max(6px, var(--safe-left)) !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 320px !important;
        height: 28px !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 2px 8px !important;
        z-index: 30 !important;
        background: rgba(8, 12, 20, 0.92) !important;
        border: 1px solid rgba(212, 175, 55, 0.45) !important;
        border-radius: 6px !important;
    }

    #char-panel .char-title {
        display: none !important;
    }

    #char-panel .gauge-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 3px !important;
        min-width: 55px !important;
    }

    #char-panel .gauge-track {
        display: none !important;
    }

    #char-panel .gauge-header {
        font-size: 10px !important;
        gap: 2px !important;
    }

    #char-panel #stats-strip {
        font-size: 9.5px !important;
        gap: 3px !important;
    }

    #char-panel .stat-divider {
        display: none !important;
    }

    /* Top Live Banner fills top screen under toolbar options */
    .top-message-banner {
        position: fixed !important;
        top: calc(34px + var(--safe-top)) !important;
        height: 26px !important;
        left: max(6px, var(--safe-left)) !important;
        right: max(6px, var(--safe-right)) !important;
        width: auto !important;
        padding: 0 8px !important;
        border-radius: 6px !important;
        z-index: 28 !important;
    }

    /* Top Right Controls: Ultra-compact single row docked top-right */
    #top-right-bar {
        position: fixed !important;
        top: max(2px, var(--safe-top)) !important;
        right: max(6px, var(--safe-right)) !important;
        height: 30px !important;
        gap: 3px !important;
        padding: 0 4px !important;
        z-index: 30 !important;
    }

    #top-right-bar .badge {
        height: 24px !important;
        line-height: 22px !important;
        font-size: 9px !important;
        padding: 0 5px !important;
    }

    #top-right-bar .icon-btn {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        font-size: 13px !important;
        padding: 0 !important;
    }

    #top-right-bar .sound-control-group {
        height: 28px !important;
    }

    /* Compact 70px Circular Minimap Radar docked below message banner on right */
    #minimap-container {
        position: fixed !important;
        top: calc(64px + var(--safe-top)) !important;
        left: auto !important; /* CRITICAL: overrides desktop left: 18px */
        right: max(8px, var(--safe-right)) !important;
        width: 72px !important;
        height: 72px !important;
        border-radius: 50% !important;
        overflow: visible !important;
        z-index: 30 !important;
        border: 1.5px solid rgba(212, 175, 55, 0.6) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7) !important;
        pointer-events: auto !important;
    }

    #minimap-header,
    #minimap-controls-bar,
    #camera-tilt-bar,
    #map-resize-handle {
        display: none !important;
    }

    #minimap-canvas {
        width: 100% !important;
        height: 100% !important;
        border-radius: 50% !important;
    }

    .mobile-map-zoom-group {
        display: flex !important;
        flex-direction: column !important;
        position: absolute !important;
        left: -30px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        gap: 4px !important;
        z-index: 35 !important;
        pointer-events: auto !important;
    }

    .mobile-map-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 14px !important;
    }

    /* Bottom Left: Scaled Movement D-pad */
    #touch-controls {
        position: fixed !important;
        bottom: calc(2px + var(--safe-bottom)) !important;
        left: max(4px, var(--safe-left)) !important;
        right: auto !important;
        top: auto !important;
        transform: scale(0.78) !important;
        transform-origin: bottom left !important;
        margin: 0 !important;
        z-index: 35 !important;
        display: block !important;
    }

    /* Bottom Right: Tactical 2-Column Action Cluster (Scaled & Thumb-Optimized) */
    #action-bar:not(.drawer-open) {
        position: fixed !important;
        right: max(4px, var(--safe-right)) !important;
        left: auto !important;
        bottom: calc(2px + var(--safe-bottom)) !important;
        top: auto !important;
        width: 140px !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 3px !important;
        transform: scale(0.80) !important;
        transform-origin: bottom right !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        z-index: 35 !important;
        pointer-events: auto !important;
    }

    #action-bar:not(.drawer-open) .action-btn {
        display: none !important;
        height: 36px !important;
        min-height: 36px !important;
        width: 100% !important;
        padding: 2px 4px !important;
        font-size: 11px !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
        border-radius: 8px !important;
        background: rgba(14, 18, 28, 0.90) !important;
        border: 1px solid rgba(212, 175, 55, 0.4) !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5) !important;
    }

    #action-bar:not(.drawer-open) .action-btn kbd {
        display: none !important;
    }

    #action-bar:not(.drawer-open) #btn-attack,
    #action-bar:not(.drawer-open) #btn-cast,
    #action-bar:not(.drawer-open) #btn-inventory,
    #action-bar:not(.drawer-open) #btn-quaff,
    #action-bar:not(.drawer-open) #btn-terminal,
    #action-bar:not(.drawer-open) #btn-action-more {
        display: inline-flex !important;
    }

    #action-bar:not(.drawer-open) #btn-stair.stair-active {
        display: inline-flex !important;
    }

    #hud-center-column {
        position: static !important;
        width: auto !important;
        pointer-events: none !important;
        margin: 0 !important;
    }

    /* Bottom Center: Streamlined Status Pill Capsule (Safely quarantined between D-pad & Actions) */
    #hud-footer {
        position: fixed !important;
        bottom: calc(2px + var(--safe-bottom)) !important;
        left: max(160px, calc(150px + var(--safe-left))) !important;
        right: max(160px, calc(150px + var(--safe-right))) !important;
        width: auto !important;
        height: 28px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 4px !important;
        padding: 0 6px !important;
        background: rgba(8, 12, 20, 0.92) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
        border: 1px solid rgba(212, 175, 55, 0.4) !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7) !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
        z-index: 30 !important;
        pointer-events: auto !important;
    }

    #hud-footer::-webkit-scrollbar {
        display: none !important;
    }

    #hud-footer .status-group {
        display: flex !important;
        align-items: center !important;
        gap: 3px !important;
    }

    #hud-footer .status-pill,
    #hud-footer .status-alert,
    #hud-footer .status-hint {
        height: 20px !important;
        line-height: 18px !important;
        font-size: 9.5px !important;
        padding: 0 5px !important;
        border-radius: 4px !important;
    }

    #hud-footer #btn-quick-help {
        display: none !important;
    }

    /* Action Drawer on Phone Landscape (Expanded state) */
    #action-bar.drawer-open {
        position: fixed !important;
        bottom: calc(34px + var(--safe-bottom)) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: min(540px, calc(100vw - 20px)) !important;
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
        max-height: calc(100vh - 70px) !important;
        overflow-y: auto !important;
        z-index: 70 !important;
        padding: 8px !important;
        background: rgba(8, 12, 18, 0.98) !important;
        border: 2px solid rgba(212, 175, 55, 0.6) !important;
        border-radius: 10px !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.95) !important;
        pointer-events: auto !important;
    }

    #action-bar.drawer-open .action-btn {
        display: inline-flex !important;
        justify-content: center !important;
        padding: 6px 4px !important;
        font-size: 11px !important;
        min-height: 38px !important;
        border-radius: 6px !important;
    }

    #action-bar.drawer-open #btn-action-more {
        grid-column: span 4 !important;
        background: rgba(45, 14, 18, 0.95) !important;
        border-color: #ff5555 !important;
        color: #ffaaaa !important;
    }

    /* Terminal Isolation & Sizing in Landscape */
    #terminal-container:not(.hidden) ~ #top-right-bar,
    body.terminal-mode-active #top-right-bar {
        display: none !important;
    }

    .terminal-card {
        padding: 3px 6px !important;
        max-height: calc(100vh - 6px) !important;
        gap: 3px !important;
    }

    .terminal-toolbar {
        height: 32px !important;
        min-height: 32px !important;
        padding: 0 6px !important;
        gap: 6px !important;
    }

    .terminal-title {
        font-size: 11px !important;
    }

    .term-direction-indicator {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }

    .term-zoom-btn {
        height: 24px !important;
        min-width: 24px !important;
        font-size: 12px !important;
        padding: 0 5px !important;
    }

    .term-zoom-reset {
        font-size: 10px !important;
    }

    #terminal-viewport {
        height: calc(100vh - 120px) !important;
        max-height: calc(100vh - 120px) !important;
        min-height: 200px !important;
        flex: 1 1 auto !important;
    }

    .terminal-touch-controls {
        padding: 2px 6px !important;
        margin: 2px auto 0 !important;
        gap: 8px !important;
        max-height: 74px !important;
        flex-shrink: 0 !important;
    }

    .term-touch-dpad-col {
        width: 82px !important;
        flex-shrink: 0 !important;
    }

    .term-dpad-grid {
        grid-template-columns: repeat(3, 26px) !important;
        grid-template-rows: repeat(3, 22px) !important;
        gap: 2px !important;
    }

    .term-dpad-btn {
        font-size: 11px !important;
        border-radius: 4px !important;
    }

    .term-touch-actions-col {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .term-contextual-actions {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 3px !important;
    }

    .term-ctx-btn {
        min-height: 28px !important;
        height: 28px !important;
        padding: 2px 4px !important;
        font-size: 10px !important;
        border-radius: 4px !important;
    }

    .term-letter-ribbon {
        gap: 3px !important;
        padding: 2px 4px !important;
        max-height: 32px !important;
    }

    .term-letter-btn {
        min-width: 28px !important;
        height: 26px !important;
        font-size: 11px !important;
    }

    .birth-name-bar {
        height: 32px !important;
        gap: 4px !important;
    }

    .birth-name-input {
        height: 28px !important;
        font-size: 12px !important;
    }

    .btn-birth-action {
        height: 28px !important;
        font-size: 10px !important;
        padding: 0 8px !important;
    }
}

/* ------------------------------------------------------------------------------
   NATIVE MOBILE HERO REVIEW CARD & TOUCH OVERLAYS
   Replaces microscopic 80-column ASCII terminal scaling with tactile touch UI
   ------------------------------------------------------------------------------ */
.mobile-hero-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    padding: 12px;
    background: rgba(12, 16, 26, 0.98);
    border: 2px solid rgba(212, 175, 55, 0.6);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    color: #f0f4f8;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    max-height: calc(100dvh - 72px - var(--safe-top) - var(--safe-bottom));
    box-sizing: border-box;
}

/* Hide duplicate desktop terminal toolbar buttons when mobile hero card is active */
#terminal-card.mobile-card-active .terminal-toolbar,
#terminal-card:has(#mobile-hero-card:not([style*="display: none"])) .terminal-toolbar {
    display: none !important;
}

#terminal-card.mobile-card-active,
#terminal-card:has(#mobile-hero-card:not([style*="display: none"])) {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 540px !important;
    width: 100% !important;
}

.m-hero-card-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.m-hero-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.m-hero-avatar-wrap {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.15);
    border: 2px solid var(--gold-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.m-hero-title-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.m-hero-name {
    font-family: var(--font-fantasy);
    font-size: 18px;
    font-weight: 700;
    color: var(--gold-bright);
    letter-spacing: 0.5px;
}

.m-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.m-meta-badge {
    font-family: var(--font-terminal);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
}

.m-race-badge {
    background: rgba(58, 134, 255, 0.2);
    border: 1px solid rgba(58, 134, 255, 0.5);
    color: #93c5fd;
}

.m-class-badge {
    background: rgba(230, 57, 70, 0.2);
    border: 1px solid rgba(230, 57, 70, 0.5);
    color: #fca5a5;
}

.m-title-badge {
    background: rgba(212, 175, 55, 0.2);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--gold-primary);
}

.m-hero-vitals-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.m-vital-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 6px;
    border-radius: 6px;
    background: rgba(18, 24, 36, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.m-vital-lbl {
    font-size: 9px;
    font-family: var(--font-terminal);
    color: #94a3b8;
    text-transform: uppercase;
}

.m-vital-val {
    font-family: var(--font-terminal);
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
}

.m-vital-hp .m-vital-val { color: #ff6b6b; }
.m-vital-sp .m-vital-val { color: #60a5fa; }
.m-vital-ac .m-vital-val { color: #ffd700; }
.m-vital-spd .m-vital-val { color: #4ade80; }

.m-section-label {
    font-family: var(--font-fantasy);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--gold-bright);
    margin-top: 4px;
    text-transform: uppercase;
}

.m-hero-stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.m-hero-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 3px;
    border-radius: 6px;
    background: rgba(20, 26, 40, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.35);
}

.m-stat-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.m-stat-key {
    font-family: var(--font-fantasy);
    font-size: 11px;
    font-weight: 700;
    color: var(--gold-primary);
}

.m-stat-val {
    font-family: var(--font-terminal);
    font-size: 16px;
    font-weight: 800;
    color: #ffffff;
}

.m-stat-bot {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 3px;
    font-family: var(--font-terminal);
    font-size: 8px;
    color: #94a3b8;
}

.m-hero-combat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.m-combat-chip {
    padding: 4px 7px;
    border-radius: 4px;
    background: rgba(16, 20, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--font-terminal);
    font-size: 11px;
    display: flex;
    justify-content: space-between;
}

.m-chip-lbl { color: #94a3b8; }
.m-chip-val { color: #e2e8f0; font-weight: 600; }

.m-hero-lore-box {
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(24, 18, 12, 0.7);
    border: 1px solid rgba(212, 175, 55, 0.25);
    font-style: italic;
}

.m-lore-scroll {
    font-size: 11.5px;
    line-height: 1.4;
    color: #e5d5be;
}

.m-hero-actions-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 6px;
    position: sticky;
    bottom: 0;
    background: rgba(12, 16, 26, 0.98);
    border-top: 1px solid rgba(212, 175, 55, 0.25);
    padding-top: 8px;
    padding-bottom: max(32px, calc(16px + var(--safe-bottom)));
    z-index: 50;
}

.m-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: var(--font-fantasy);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s ease, background 0.15s ease;
}

.m-action-btn:active {
    transform: scale(0.96);
}

.m-btn-accept {
    background: linear-gradient(135deg, #1b4332, #2d6a4f);
    border: 1.5px solid #52b788;
    color: #d8f3dc;
    grid-column: span 2;
}

.m-btn-reroll {
    background: rgba(30, 41, 59, 0.9);
    border: 1.5px solid rgba(212, 175, 55, 0.5);
    color: var(--gold-bright);
}

.m-btn-custom {
    background: rgba(30, 41, 59, 0.9);
    border: 1.5px solid rgba(148, 163, 184, 0.4);
    color: #e2e8f0;
}

.m-btn-back {
    background: rgba(20, 24, 34, 0.9);
    border: 1.5px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    grid-column: span 2;
}

/* Player Capacity Queue Modal */
#queue-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(6, 8, 14, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9500;
}

#queue-modal.hidden {
    display: none !important;
}

.queue-card {
    border: 1px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(212, 175, 55, 0.2);
    animation: queue-fade-in 0.3s ease-out;
}

@keyframes queue-fade-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.queue-spinner-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
}

.queue-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(212, 175, 55, 0.2);
    border-top-color: var(--gold-bright);
    border-right-color: #ffd700;
    border-radius: 50%;
    animation: queue-spin 1.2s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.35);
}

@keyframes queue-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.queue-lore-box {
    transition: opacity 0.3s ease;
}
