/* © 2026 Steve Noll. All rights reserved. */
/* CSS Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* NerdRelic Color Palette */
    --primary: #06b6d4;
    --primary-dark: #0891b2;
    --accent: #5b86b8;
    --accent-dark: #3d5a80;
    --success: #10b981;
    --error: #ef4444;

    /* Gallery-themed accent palette (slate) */
    --federation-blue: #5b86b8;
    --command-gold: #8aa6c8;
    --operations-red: #ef4444;
    --science-blue: #5b86b8;
    --lcars-orange: #5b86b8;
    --lcars-tan: #8aa6c8;
    --lcars-purple: #5b86b8;

    /* Environment Colors - NerdRelic */
    --bg-dark: #1e293b;
    --bg-darker: #121832;
    --text-light: #f1f5f9;
    --text-dim: #cbd5e1;

    /* System Font Stack */
    --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-system);
    background-color: var(--bg-darker);
    color: var(--text-light);
}

/* Canvas */
#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

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

.loader-content {
    text-align: center;
}

.loader-title {
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    color: var(--lcars-orange);
    margin-bottom: 2rem;
}

.loader-bar {
    width: 300px;
    height: 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 1rem;
}

.loader-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--lcars-orange), var(--command-gold));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.loader-status {
    font-size: 0.875rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

/* Blocker / Instructions Screen */
#blocker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 20, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

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

#instructions {
    text-align: center;
    padding: 2rem;
}

#instructions .title {
    font-size: clamp(1.5rem, 5vw, 3rem);
    font-weight: 300;
    letter-spacing: 0.3em;
    color: var(--lcars-orange);
    margin-bottom: 0.25rem;
}

#instructions .subtitle {
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 300;
    letter-spacing: 0.2em;
    color: var(--command-gold);
    margin-bottom: 3rem;
}

#instructions .click-prompt {
    font-size: 1.25rem;
    color: var(--text-light);
    margin-bottom: 2rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.controls-hint {
    font-size: 0.875rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

.controls-hint span {
    display: inline-block;
    background: var(--lcars-orange);
    color: var(--bg-darker);
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    margin: 0 0.5rem 0 1rem;
    font-weight: 600;
}

.controls-hint span:first-child {
    margin-left: 0;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#hud.visible {
    opacity: 1;
}

.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background: rgba(91, 134, 184, 0.85);
}

.crosshair::before {
    width: 2px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
}

.crosshair::after {
    width: 100%;
    height: 2px;
    top: 50%;
    transform: translateY(-50%);
}

/* Cart Subtotal Display */
.cart-subtotal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(30, 41, 59, 0.9);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(45, 166, 237, 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.cart-subtotal.hidden {
    opacity: 0;
    transform: translateY(-10px);
}

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

.cart-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

@media (max-width: 768px) {
    .cart-subtotal {
        top: 15px;
        right: 15px;
        padding: 10px 14px;
    }

    .cart-label {
        font-size: 0.7rem;
    }

    .cart-amount {
        font-size: 1.25rem;
    }
}

/* Touch Controls */
#touch-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 60;
    display: none;
}

#touch-controls.visible {
    display: block;
}

#joystick-zone {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 180px;
    height: 200px;
    pointer-events: auto;
    z-index: 3;
    /* Above tap zone */
}

#look-joystick-zone {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 180px;
    height: 200px;
    pointer-events: auto;
    z-index: 3;
    /* Above tap zone */
}

#tap-zone {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    z-index: 1;
    /* Below joystick zones */
}

/* Fixed joystick - always visible on mobile */
.joystick-base-fixed {
    position: absolute;
    bottom: 40px;
    left: 30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(45, 166, 237, 0.2);
    border: 2px solid rgba(45, 166, 237, 0.65);
    /* Dark outer ring so the control stays visible over a bright daytime sky. */
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.28);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Right joystick positioning */
#look-joystick-zone .joystick-base-fixed {
    left: auto;
    right: 30px;
}

.joystick-thumb-fixed {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(45, 166, 237, 0.75);
    border: 1px solid rgba(0, 0, 0, 0.3);
    pointer-events: none;
    transition: transform 0.05s ease-out;
}

/* Old dynamic joystick styles (fallback/legacy) */
.joystick-base {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(45, 166, 237, 0.2);
    border: 2px solid rgba(45, 166, 237, 0.4);
    pointer-events: none;
}

.joystick-thumb {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(45, 166, 237, 0.6);
    transform: translate(-50%, -50%);
    pointer-events: none;
}


/* Settings Button & Panel */
.settings-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    cursor: pointer;
    z-index: 110;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    pointer-events: auto;
}

.settings-btn:hover {
    background: rgba(45, 166, 237, 0.25);
    border-color: var(--primary);
}

.settings-icon {
    width: 1.4rem;
    height: 1.4rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.settings-btn.visible {
    display: flex;
}

.cart-btn {
    position: fixed;
    top: 20px;
    left: 80px;
    width: 50px;
    height: 50px;
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    z-index: 110;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    pointer-events: auto;
    text-decoration: none;
    line-height: 1;
}

.cart-btn:hover {
    background: rgba(45, 166, 237, 0.25);
    border-color: var(--primary);
}

.cart-btn.visible {
    display: flex;
}

.cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--primary, #2da6ed);
    color: #0a0f1a;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    box-shadow: 0 0 6px rgba(45, 166, 237, 0.5);
}

.cart-badge.visible {
    display: flex;
}

.cart-icon {
    height: 1.5rem;
    width: 1.5rem;
    fill: none;
    stroke: var(--accent);
    /* object-view-box: 0 0 24 24; */
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

/* Cart panel */
.cart-panel {
    position: fixed;
    top: 80px;
    left: 40px;
    width: 280px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: rgba(18, 24, 50, 0.95);
    border: 2px solid var(--accent);
    border-radius: 8px;
    z-index: 110;
    pointer-events: auto;
    box-shadow: 0 4px 20px rgba(45, 166, 237, 0.2);
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
}

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

.cart-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(45, 166, 237, 0.3);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--accent);
    text-transform: uppercase;
}

.cart-panel-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: calc(100vh - 240px);
}

.cart-panel-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 20px 10px;
}

.cart-panel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(45, 166, 237, 0.08);
    border: 1px solid rgba(45, 166, 237, 0.2);
    border-radius: 6px;
}

.cart-panel-item-image {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(45, 166, 237, 0.3);
    flex-shrink: 0;
}

.cart-panel-item-info {
    flex: 1;
    min-width: 0;
}

.cart-panel-item-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-panel-item-price {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
}

.cart-panel-item-remove {
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 4px;
    color: var(--error);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
    line-height: 1;
}

.cart-panel-item-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--error);
}

.cart-panel-footer {
    padding: 10px 14px;
    border-top: 1px solid rgba(45, 166, 237, 0.3);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-panel-footer.hidden {
    display: none;
}

.cart-panel-total {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
}

.cart-panel-checkout-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: var(--accent);
    border: none;
    border-radius: 4px;
    color: #0a0f1a;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.cart-panel-checkout-btn:hover {
    background: var(--primary);
}

.floating-btn {
    position: fixed;
    top: 20px;
    left: 140px;
    width: 50px;
    height: 50px;
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    font-size: 1.25rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    cursor: pointer;
    z-index: 110;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    pointer-events: auto;
    text-decoration: none;
    line-height: 1;
}

.floating-btn:hover {
    background: rgba(45, 166, 237, 0.25);
    border-color: var(--primary);
}

.floating-btn.visible {
    display: flex;
}

.vr-btn {
    position: fixed;
    top: 20px;
    left: 170px;
    width: 40px;
    height: 40px;
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    z-index: 110;
    display: none;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.vr-btn:hover {
    background: rgba(45, 166, 237, 0.25);
    border-color: var(--primary);
}

.vr-btn.visible {
    display: flex;
}

.settings-panel {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 240px;
    background: rgba(18, 24, 50, 0.95);
    border: 2px solid var(--accent);
    border-radius: 8px;
    z-index: 110;
    pointer-events: auto;
    box-shadow: 0 4px 20px rgba(45, 166, 237, 0.2);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

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

/* Lighting control reuses the settings-panel look but sits bottom-center, out of
   the way, so the room stays visible while the dimmer is adjusted live. */
#light-panel {
    top: auto;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
}

#light-panel.hidden {
    transform: translateX(-50%) translateY(8px);
}

.light-hint {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-dim);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(45, 166, 237, 0.3);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--accent);
    text-transform: uppercase;
}

.settings-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.25rem;
    cursor: pointer;
    /* A comfortable, consistent hit area (was a bare ~20px glyph). */
    width: 36px;
    height: 36px;
    margin: -6px -6px -6px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    line-height: 1;
    transition: color 0.2s ease;
}

.settings-close:hover {
    color: var(--text-light);
}

.settings-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

.settings-label input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-dark);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.settings-label input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-darker);
    transition: transform 0.15s ease;
}

.settings-label input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.settings-label input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-darker);
}

/* Keyboard focus indicator for the sliders (they set outline:none above). */
.settings-label input[type="range"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

.settings-value {
    align-self: flex-end;
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    min-width: 2.5em;
    text-align: right;
}

/* Filter button */
.filter-btn {
    position: fixed;
    top: 20px;
    left: 140px;
    width: 50px;
    height: 50px;
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    cursor: pointer;
    z-index: 110;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    pointer-events: auto;
}

.filter-btn:hover {
    background: rgba(45, 166, 237, 0.25);
    border-color: var(--primary);
}

.filter-btn.visible {
    display: flex;
}

.filter-btn.has-filter {
    border-color: var(--primary);
    background: rgba(45, 166, 237, 0.2);
}

.filter-icon {
    width: 1.4rem;
    height: 1.4rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Home button */
.home-btn {
    position: fixed;
    top: 20px;
    left: 200px;
    width: 50px;
    height: 50px;
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    cursor: pointer;
    z-index: 110;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    pointer-events: auto;
    text-decoration: none;
}

.home-btn:hover {
    background: rgba(45, 166, 237, 0.25);
    border-color: var(--primary);
}

.home-btn.visible {
    display: flex;
}

.home-icon {
    width: 1.4rem;
    height: 1.4rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Filter panel */
.filter-panel {
    position: fixed;
    top: 80px;
    left: 40px;
    width: 240px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: rgba(18, 24, 50, 0.95);
    border: 2px solid var(--accent);
    border-radius: 8px;
    z-index: 110;
    pointer-events: auto;
    box-shadow: 0 4px 20px rgba(45, 166, 237, 0.2);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(45, 166, 237, 0.3);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--accent);
    text-transform: uppercase;
}

.filter-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-show-all {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    margin-bottom: 4px;
}

.filter-show-all:hover {
    background: rgba(45, 166, 237, 0.15);
    color: var(--text-light);
}

.filter-show-all.active {
    background: rgba(45, 166, 237, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

.filter-category-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--accent);
    text-transform: uppercase;
    padding: 8px 4px 4px;
    margin: 0;
}

.filter-sub-btn {
    width: 100%;
    padding: 7px 12px;
    background: transparent;
    border: 1px solid rgba(45, 166, 237, 0.25);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-sub-btn:hover {
    background: rgba(45, 166, 237, 0.1);
    color: var(--text-light);
    border-color: var(--accent);
}

.filter-sub-btn.active {
    background: rgba(45, 166, 237, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

/* Mobile adjustments for settings */
@media (min-width: 900px) {
    .settings-btn {
        left: calc(50vw - 120px);
        width: 50px;
        height: 50px;
    }

    .cart-btn {
        left: calc(50vw - 55px);
        width: 50px;
        height: 50px;
    }

    .filter-btn {
        left: calc(50vw + 10px);
        width: 50px;
        height: 50px;
    }

    .home-btn {
        left: calc(50vw + 75px);
        width: 50px;
        height: 50px;
    }

    .settings-panel {
        top: 90px;
        left: calc(50vw - 220px);
    }

    .filter-panel {
        top: 90px;
        left: calc(50vw - 90px);
    }

    .cart-panel {
        top: 90px;
        left: calc(50vw - 195px);
    }

    .cart-badge {
        top: -8px;
        right: -8px;
        font-size: 0.75rem;
        font-weight: 700;
        min-width: 20px;
        height: 20px;
        border-radius: 12px;
    }

    .filter-panel {
        top: 90px;
    }
}

@media (min-width: 1600px) {
    .settings-btn {
        left: calc(50vw - 140px);
        width: 60px;
        height: 60px;
    }

    .cart-btn {
        left: calc(50vw - 60px);
        width: 60px;
        height: 60px;
    }

    .filter-btn {
        left: calc(50vw + 20px);
        width: 60px;
        height: 60px;
    }

    .home-btn {
        left: calc(50vw + 100px);
        width: 60px;
        height: 60px;
    }

    .settings-panel {
        top: 100px;
        left: calc(50vw - 240px);
    }

    .filter-panel {
        top: 90px;
        left: calc(50vw - 100px);
    }

    .cart-panel {
        top: 100px;
        left: calc(50vw - 200px);
    }

    .cart-badge {
        top: -6px;
        right: -6px;
        font-size: 0.85rem;
        font-weight: 700;
        min-width: 22px;
        height: 22px;
        border-radius: 15px;
    }

    .filter-panel {
        top: 100px;
    }
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    .loader-bar {
        width: 200px;
    }

    .loader-title {
        font-size: 1.25rem;
        letter-spacing: 0.3em;
    }

    .controls-hint {
        display: none;
    }

    #instructions .click-prompt {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .loader-bar {
        width: 150px;
    }

    #instructions .title {
        letter-spacing: 0.2em;
    }

    #instructions .subtitle {
        letter-spacing: 0.1em;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #instructions {
        padding: 1rem;
    }

    #instructions .title {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    #instructions .subtitle {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    #instructions .click-prompt {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
}

/* Product Modal */
#product-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

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

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 20, 0.92);
    cursor: pointer;
}

.modal-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--bg-dark);
    border: 2px solid var(--lcars-orange);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(255, 153, 68, 0.3);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: var(--lcars-orange);
    color: var(--bg-darker);
    border: none;
    border-radius: 4px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.modal-close:hover {
    background: var(--command-gold);
    transform: scale(1.1);
}

/* Product Detail Modal */
.product-detail-modal {
    width: 800px;
    max-width: 90vw;
}

.product-modal-content {
    display: flex;
    flex-direction: row;
    min-height: 400px;
}

.product-image-section {
    flex: 0 0 50%;
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: hidden;
}

.product-image-section img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 4px;
    transform: scale(1.3);
}

.product-details-section {
    flex: 0 0 50%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.product-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-light);
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.product-category {
    font-size: 0.875rem;
    color: var(--lcars-orange);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(45, 166, 237, 0.3);
}

.product-description {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-dim);
    margin: 0 0 1.5rem 0;
    flex-grow: 1;
}

.product-meta-info {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-dim);
    gap: 1rem;
}

.product-condition {
    color: var(--lcars-blue, #4488ff);
}

.product-sku {
    color: var(--text-dim);
    font-family: monospace;
    font-size: 0.8rem;
}

.product-purchase-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.product-price {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--success);
}

.product-stock {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.product-stock.low-stock {
    color: var(--error);
}

.product-stock.in-stock {
    color: var(--success);
}

.product-add-to-cart {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--lcars-orange);
    color: var(--bg-darker);
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.product-add-to-cart:hover {
    background: var(--command-gold);
    transform: translateY(-2px);
}

.product-add-to-cart:active {
    transform: translateY(0);
}

.product-add-to-cart:disabled {
    background: var(--text-dim);
    cursor: not-allowed;
    transform: none;
}

/* Modal responsive adjustments */
@media (max-width: 768px) {
    .modal-container {
        max-width: 95vw;
        max-height: 95vh;
    }

    .product-detail-modal {
        width: 95vw;
    }

    .product-modal-content {
        flex-direction: column;
        min-height: auto;
    }

    .product-image-section {
        flex: 0 0 auto;
        padding: 1rem;
    }

    .product-image-section img {
        max-height: 250px;
    }

    .product-details-section {
        flex: 0 0 auto;
        padding: 1.5rem;
    }

    .product-name {
        font-size: 1.25rem;
    }

    .product-price {
        font-size: 1.5rem;
    }

    .modal-close {
        top: 5px;
        right: 5px;
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }

    /* Prevent layout shift on mobile by reserving space for image */
    .is-touch-device .product-image-section {
        min-height: 280px;
        /* 250px image + 2rem padding */
    }

    .is-touch-device .product-image-section img {
        min-height: 200px;
        background: var(--bg-darker);
    }
}

/* Shopkeeper, Customer, Pedestrian & Not-For-Sale Dialog Modals */
#shopkeeper-modal,
#customer-modal,
#pedestrian-modal,
#not-for-sale-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

#shopkeeper-modal.hidden,
#customer-modal.hidden,
#pedestrian-modal.hidden,
#not-for-sale-modal.hidden,
#shoplifting-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Shoplifting modal */
#shoplifting-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.shoplifting-dialog .dialog-header {
    color: var(--error);
    border-bottom-color: var(--error);
}

.dialog-joke {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-dim);
    font-style: italic;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border-left: 3px solid var(--lcars-orange);
}

.shopkeeper-dialog {
    max-width: 500px;
    padding: 0;
}

.dialog-content {
    padding: 2rem;
    text-align: center;
}

.dialog-header {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--lcars-orange);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--lcars-orange);
}

.dialog-message {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-light);
    margin-bottom: 1.5rem;
    min-height: 80px;
}

.dialog-footer {
    font-size: 0.9rem;
    color: var(--command-gold);
    font-style: italic;
    letter-spacing: 0.05em;
}

/* Dialog Carousel */
.dialog-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-top: 0.5rem;
}

.carousel-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-darker);
    color: var(--lcars-orange);
    border: 2px solid var(--lcars-orange);
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-btn:hover {
    background: var(--lcars-orange);
    color: var(--bg-darker);
    transform: scale(1.1);
}

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

.carousel-counter {
    font-size: 0.9rem;
    color: var(--text-dim);
    min-width: 60px;
    text-align: center;
    letter-spacing: 0.05em;
}

@media (max-width: 768px) {
    .shopkeeper-dialog {
        max-width: 90vw;
    }

    .dialog-content {
        padding: 1.5rem;
    }

    .dialog-header {
        font-size: 1.25rem;
    }

    .dialog-message {
        font-size: 1rem;
    }

    .carousel-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

/* Checkout Button */
.checkout-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--success);
    color: var(--bg-darker);
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.25rem;
}

.checkout-btn:hover {
    background: #0d9668;
    transform: translateY(-2px);
}

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

.checkout-btn.hidden {
    display: none;
}

/* Back to 2D Store Button */
.back-to-2d-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--accent);
    color: var(--bg-darker);
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.25rem;
}

.back-to-2d-btn:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
}

.back-to-2d-btn:active {
    transform: translateY(0);
}

/* ================================================
   MOBILE/TOUCH DEVICE SPECIFIC STYLES
   ================================================ */

/* Hide crosshair on mobile (tap to interact instead) */
.is-touch-device .crosshair {
    display: none;
}

/* Show touch controls only on touch devices when visible */
.is-touch-device #touch-controls.visible {
    display: block;
}

/* Larger modal close buttons on mobile */
.is-touch-device .modal-close {
    width: 48px;
    height: 48px;
    font-size: 1.75rem;
    top: 8px;
    right: 8px;
}

/* Larger carousel buttons on mobile */
.is-touch-device .carousel-btn {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
}

/* Larger product add-to-cart button on mobile */
.is-touch-device .product-add-to-cart {
    padding: 1.25rem 1.5rem;
    font-size: 1.15rem;
}

/* Larger checkout button on mobile */
.is-touch-device .checkout-btn {
    padding: 1.25rem 1.5rem;
    font-size: 1.15rem;
}

/* Larger back-to-2d button on mobile */
.is-touch-device .back-to-2d-btn {
    padding: 1.25rem 1.5rem;
    font-size: 1.15rem;
}

/* Better modal scrolling on mobile */
.is-touch-device .modal-container {
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.is-touch-device .product-details-section {
    max-height: none;
    overflow-y: visible;
}

/* Touch-friendly control hints on mobile (hidden by default) */
.is-touch-device .controls-hint {
    display: none;
}

/* Mobile touch controls indicator styling */
.is-touch-device #touch-controls {
    pointer-events: none;
}

.is-touch-device #joystick-zone,
.is-touch-device #look-joystick-zone,
.is-touch-device #tap-zone {
    pointer-events: auto;
}

/* Joystick active state feedback */
.is-touch-device .joystick-base-fixed {
    transition: border-color 0.15s ease, background 0.15s ease;
}

.is-touch-device #joystick-zone:active .joystick-base-fixed,
.is-touch-device #look-joystick-zone:active .joystick-base-fixed {
    border-color: rgba(45, 166, 237, 0.6);
    background: rgba(45, 166, 237, 0.25);
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .is-touch-device #joystick-zone {
        width: calc(180px + env(safe-area-inset-left));
        height: calc(200px + env(safe-area-inset-bottom));
    }

    .is-touch-device #look-joystick-zone {
        width: calc(180px + env(safe-area-inset-right));
        height: calc(200px + env(safe-area-inset-bottom));
    }

    .is-touch-device #joystick-zone .joystick-base-fixed {
        bottom: max(40px, calc(40px + env(safe-area-inset-bottom)));
        left: max(30px, calc(30px + env(safe-area-inset-left)));
    }

    .is-touch-device #look-joystick-zone .joystick-base-fixed {
        bottom: max(40px, calc(40px + env(safe-area-inset-bottom)));
        right: max(30px, calc(30px + env(safe-area-inset-right)));
    }

    .is-touch-device .modal-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Wide screens (VR headset 2D browser panels): move joysticks toward center */
@media (min-width: 1500px) {
    #joystick-zone {
        left: calc(50% - 350px);
    }

    #look-joystick-zone {
        right: calc(50% - 350px);
    }

    #joystick-zone .joystick-base-fixed {
        left: 30px;
    }

    #look-joystick-zone .joystick-base-fixed {
        right: 30px;
    }
}

/* Zoomable product image */
.product-image-section {
    position: relative;
}

.product-image-section img.zoomable {
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.product-image-section img.zoomable:hover {
    /* transform: scale(1.02); */
    transform: scale(1.4);
}

.product-image-section img.zoomable:active {
    /* transform: scale(0.98); */
    transform: scale(1.2);
}

.zoom-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.8);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-image-section:hover .zoom-hint,
.is-touch-device .zoom-hint {
    opacity: 1;
}

/* Product Image Carousel */
.product-carousel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s ease, opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.product-carousel:hover .carousel-nav,
.is-touch-device .carousel-nav {
    opacity: 1;
}

.carousel-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-nav.carousel-prev {
    left: 10px;
}

.carousel-nav.carousel-next {
    right: 10px;
}

.carousel-nav.hidden {
    display: none;
}

/* Image Lightbox */
#image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

#image-lightbox.hidden {
    opacity: 0;
    pointer-events: none;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    cursor: zoom-out;
}

#lightbox-image {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: zoom-out;
    border-radius: 4px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.lightbox-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    pointer-events: none;
}

/* Lightbox carousel container */
.lightbox-carousel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* Lightbox carousel navigation buttons */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 2rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-prev {
    left: 20px;
    position: fixed;
}

.lightbox-next {
    right: 20px;
    position: fixed;
}

.lightbox-nav.hidden {
    display: none;
}

/* Mobile adjustments for lightbox navigation */
@media (max-width: 768px) {
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }
}

/* Small mobile devices - hide description to keep Add to Cart visible */
@media (max-height: 700px) {
    .is-touch-device .product-description {
        display: none;
    }

    .is-touch-device .product-details-section {
        padding: 1rem;
    }

    .is-touch-device .product-name {
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
    }

    .is-touch-device .product-category {
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }

    .is-touch-device .product-purchase-info {
        margin-bottom: 0.75rem;
        padding: 0.75rem;
    }

    .is-touch-device .product-image-section {
        min-height: 210px;
        /* 180px image + 2rem padding */
    }

    .is-touch-device .product-image-section img {
        max-height: 180px;
        min-height: 150px;
    }
}

/* =========================================================================
   GALLERY PORTFOLIO UI
   Clean, modern overlay UI for the 3D portfolio gallery. Appended after the
   original styles so it takes precedence where selectors overlap.
   ========================================================================= */

:root {
    --gallery-ink: #1d1d1d;
    --gallery-muted: #6a6a6a;
    --gallery-paper: #f7f7f4;
    --gallery-accent: #3d5a80;
}

/* Skip link — visible only when focused (keyboard users) */
.skip-link {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    z-index: 1000;
    padding: 0.75rem 1.25rem;
    background: var(--gallery-ink);
    color: #fff;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    font-family: var(--font-system);
    transition: transform 0.2s ease;
}

.skip-link:focus {
    transform: translateX(-50%) translateY(0);
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Accessibility hint on the start screen */
.a11y-hint {
    margin: 1.5rem auto 0;
    font-size: 0.85rem;
    color: var(--text-dim);
    max-width: 26rem;
    text-align: center;
}

.a11y-hint a {
    color: var(--accent);
}

/* "Look at" label near the crosshair */
.look-label {
    position: absolute;
    top: calc(50% + 28px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.4rem 0.9rem;
    background: rgba(20, 20, 20, 0.72);
    color: #fff;
    font-family: var(--font-system);
    font-size: 0.85rem;
    letter-spacing: 0.3px;
    border-radius: 999px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.look-label.visible {
    opacity: 1;
}

/* Crosshair grows subtly when targeting a piece */
#hud.targeting .crosshair {
    transform: scale(1.6);
    opacity: 1;
}

.crosshair {
    transition: transform 0.15s ease, opacity 0.15s ease;
}

/* Floating round controls (menu + settings share a look) */
.ui-float {
    display: none;
}

.ui-float.visible {
    display: flex;
}

.menu-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(20, 20, 20, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    z-index: 110;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    pointer-events: auto;
}

.menu-btn:hover {
    background: rgba(60, 90, 128, 0.9);
}

.menu-btn svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

/* "Home (2D)" button: reuses the neutral .menu-btn circle look and sits in the
   top-right cluster, now leftmost of the three (home, settings, menu). Uses its
   own class so the legacy .home-btn rules and their media queries don't apply. */
.home-2d-btn {
    right: 144px;         /* menu (right:20) + settings slot (62px) + this slot (62px) */
    text-decoration: none;
}

.home-2d-btn svg {
    stroke-linejoin: round;
}

/* The Home button shows a "2D" text label instead of an icon. */
.btn-2d-label {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* Re-skin the settings button to the neutral gallery look and pin it into the
   top-right cluster between the Home and menu buttons. `left: auto` + `right`
   also override the retired multi-button toolbar's centering/resizing media
   queries (which otherwise move it mid-screen and grow it to 60px on wide
   viewports — those rules appear earlier in the file, so this later block wins). */
.settings-btn {
    top: 20px;
    left: auto;
    right: 82px;          /* menu button (right:20) + its 50px width + a 12px gap */
    width: 50px;
    height: 50px;
    background: rgba(20, 20, 20, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
}

.settings-btn:hover {
    background: rgba(60, 90, 128, 0.9);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Settings panel follows its button into the top-right cluster. `left: auto` +
   `right` also override the retired toolbar's centering media queries (which
   appear earlier in the file, so this later block wins). */
.settings-panel {
    top: 80px;
    left: auto;
    right: 20px;
}

/* Accessible site navigation menu */
.nav-menu {
    position: fixed;
    top: 84px;
    right: 20px;
    width: 280px;
    max-width: calc(100vw - 40px);
    background: rgba(255, 255, 255, 0.98);
    color: var(--gallery-ink);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    z-index: 120;
    overflow: hidden;
    font-family: var(--font-system);
}

.nav-menu.hidden {
    display: none;
}

.nav-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--gallery-muted);
    border-bottom: 1px solid #eee;
}

.nav-menu-list {
    list-style: none;
    margin: 0;
    padding: 0.4rem;
}

.nav-menu-list a {
    display: flex;
    flex-direction: column;
    padding: 0.7rem 0.9rem;
    border-radius: 9px;
    text-decoration: none;
    color: var(--gallery-ink);
    transition: background 0.15s ease;
}

.nav-menu-list a:hover,
.nav-menu-list a:focus {
    background: #f0f2f5;
    outline: none;
}

.nav-menu-list a:focus-visible {
    outline: 2px solid var(--gallery-accent);
    outline-offset: -2px;
}

.nav-link-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.nav-link-sub {
    font-size: 0.82rem;
    color: var(--gallery-muted);
}

/* Piece confirm card */
#piece-modal,
#help-modal,
#dialog-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

#piece-modal.hidden,
#help-modal.hidden,
#dialog-modal.hidden {
    display: none;
}

#piece-modal .modal-backdrop,
#help-modal .modal-backdrop,
#dialog-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 18, 0.55);
    backdrop-filter: blur(3px);
}

.piece-card {
    position: relative;
    width: min(90vw, 380px);
    /* Scroll when the card is taller than the viewport (e.g. short desktop
       windows) so the action buttons stay reachable — matches the help card.
       Padding lives on the inner wrapper because browsers drop the bottom
       padding of an overflow container. */
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--gallery-paper);
    color: var(--gallery-ink);
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    text-align: center;
    font-family: var(--font-system);
}

.piece-card-content {
    padding: 2rem 1.75rem 1.75rem;
}

.piece-card .modal-close {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    background: none;
    border: none;
    /* 44px target (was a bare ~16px glyph on desktop). */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--gallery-muted);
    cursor: pointer;
}

.piece-title {
    margin: 0 0 0.25rem;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.piece-subtitle {
    margin: 0 0 1.5rem;
    color: var(--gallery-muted);
}

.piece-enter {
    display: inline-block;
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--gallery-accent);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    border-radius: 10px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.piece-enter:hover {
    background: #2f4763;
}

.piece-enter:focus-visible {
    outline: 3px solid #9db4d0;
    outline-offset: 2px;
}

.piece-cancel {
    display: block;
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.6rem;
    background: none;
    border: none;
    color: var(--gallery-muted);
    cursor: pointer;
    font-size: 0.9rem;
}

.piece-cancel:hover {
    color: var(--gallery-ink);
}

/* Primary dialog action ("Continue exploring"): the default button, sat on top.
   Reuses the accent .piece-enter look; these just reset the <button> defaults. */
.dialog-primary {
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
}

/* "Back to Gallery" shortcut: a secondary action shown only on the exterior
   dialogs (pedestrian / zombie / easter egg) to teleport the player back to the
   gallery entrance. Sits below, using the muted .piece-cancel look. */
.dialog-return.hidden {
    display: none;
}

/* Passerby / gallery-visitor dialog.
   The message reused the shared .piece-subtitle styling (small + muted), so it
   got lost between the big bold name and the dismiss button. Here we demote the
   name to a small "speaker" label and promote the spoken line into the focal
   point: full-ink, slightly larger, with its own padded "speech" panel. Scoped
   to #dialog-modal so the gallery-piece modal's real subtitle is unaffected. */
#dialog-modal .piece-title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gallery-accent);
    margin-bottom: 0.9rem;
}

#dialog-message {
    margin: 0 0 1.6rem;
    padding: 1rem 1.15rem;
    background: rgba(61, 90, 128, 0.08);
    border-radius: 12px;
    color: var(--gallery-ink);
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1.6;
}

/* Gallery host help dialog */
.help-card {
    width: min(92vw, 460px);
    max-height: 85vh;
    /* dvh tracks the *visible* viewport on mobile (excludes the browser UI),
       so the card never extends behind the address bar and gets clipped. */
    max-height: 85dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    text-align: left;
    /* Padding lives on the inner wrapper, not this scroll container: browsers
       drop the bottom padding of an overflow container, which left the dismiss
       button flush against the card edge. */
    padding: 0;
}

.help-card .piece-card-content {
    padding: 2rem 1.75rem 1.75rem;
}

.help-card .piece-title,
.help-card .piece-subtitle {
    text-align: center;
}

.help-card .piece-title {
    /* keep the centered title clear of the close (×) button */
    padding: 0 1.5rem;
}

.help-list {
    margin: 0 0 1.25rem;
    padding-left: 1.1rem;
    list-style: none;
}

.help-list li {
    position: relative;
    margin: 0 0 0.7rem;
    padding-left: 1.1rem;
    line-height: 1.5;
    color: var(--gallery-ink);
}

.help-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gallery-accent);
}

.help-list strong {
    font-weight: 600;
}

.help-list kbd {
    display: inline-block;
    min-width: 1.1em;
    padding: 0.1em 0.4em;
    margin: 0 0.1em;
    font-family: var(--font-system);
    font-size: 0.82em;
    text-align: center;
    color: var(--gallery-ink);
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 5px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.help-list li[hidden] {
    display: none;
}

/* Loader wordmark tweak */
#loading-screen .loader-title {
    letter-spacing: 6px;
}

/* Respect reduced-motion preferences for overlay transitions */
@media (prefers-reduced-motion: reduce) {
    .look-label,
    .crosshair,
    .skip-link,
    .nav-menu-list a,
    .piece-enter {
        transition: none;
    }

    /* Stop the infinite opacity pulse on the start prompt. The day/night cycle
       and comet drift are frozen in JS (see scene.js). */
    #instructions .click-prompt {
        animation: none;
    }
}

@media (max-width: 600px) {
    .nav-menu {
        top: 80px;
        right: 12px;
    }

    /* Help dialog: tighten spacing so the full card fits a phone screen. */
    .help-card {
        width: 94vw;
        max-height: 90vh;
        max-height: 90dvh;
    }

    .help-card .piece-card-content {
        padding: 1.5rem 1.25rem 1.5rem;
    }

    .help-card .piece-title {
        font-size: 1.4rem;
        line-height: 1.2;
    }

    .help-card .piece-subtitle {
        margin-bottom: 1.1rem;
        font-size: 0.95rem;
    }

    .help-list {
        font-size: 0.95rem;
    }

    .help-list li {
        margin-bottom: 0.6rem;
    }
}

/* Short/landscape screens: let the dialog use nearly the full height and keep
   the dismiss control reachable by scrolling within the card. */
@media (max-height: 520px) {
    .help-card {
        max-height: 94vh;
        max-height: 94dvh;
    }

    .help-card .piece-card-content {
        padding-top: 1.25rem;
    }

    .help-card .piece-title {
        font-size: 1.25rem;
    }
}
/* ---- Telescope eyepiece view ------------------------------------------- */
#telescope-view {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #02030a;
}
#telescope-view.hidden { display: none; }
.telescope-backdrop {
    position: absolute;
    inset: 0;
    cursor: pointer;
}
.telescope-scope {
    position: relative;
    width: min(80vmin, 680px);
    height: min(80vmin, 680px);
    border-radius: 50%;
    overflow: hidden;
    box-shadow:
        0 0 0 14px #0a0d18,
        0 0 0 17px #2a3550,
        0 0 60px 10px rgba(80, 140, 255, 0.25),
        inset 0 0 80px 30px rgba(0, 0, 0, 0.85);
}
.telescope-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.telescope-reticle {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.telescope-reticle::before,
.telescope-reticle::after {
    content: "";
    position: absolute;
    background: rgba(170, 200, 255, 0.30);
}
.telescope-reticle::before {
    left: 50%;
    top: 10%;
    bottom: 10%;
    width: 1px;
    transform: translateX(-0.5px);
}
.telescope-reticle::after {
    top: 50%;
    left: 10%;
    right: 10%;
    height: 1px;
    transform: translateY(-0.5px);
}
.telescope-rim {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: inset 0 0 70px 24px rgba(0, 0, 0, 0.7);
}
.telescope-caption {
    position: relative;
    max-width: min(80vmin, 680px);
    margin: 22px 16px 0;
    text-align: center;
    color: #cfe0ff;
    font-size: 15px;
    line-height: 1.5;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}
.telescope-close {
    position: absolute;
    top: 18px;
    right: 22px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(20, 28, 48, 0.8);
    color: #dfe8ff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.telescope-close:hover { background: rgba(40, 52, 84, 0.9); }
