        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { 
            background: #0a0a12;
            overflow: hidden;
            font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
            color: #e0e6f0;
            -webkit-font-smoothing: antialiased;
        }

        /* ═══════════════════════════════════════════════════════════════
           GLOBAL UX RULES (Transparency & Hierarchy)
           Rule: Max opacity 0.6 + blur for gameplay context
        ═══════════════════════════════════════════════════════════════ */
        .glass-panel {
            background: rgba(15, 23, 42, 0.6) !important;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            border: 1px solid rgba(255, 255, 255, 0.1) !important;
            box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
        }

        /* GAME MODE: hide dev/debug panes by default */
        html[data-vw-mode="game"] #sidebar { display: none !important; }
        html[data-vw-mode="game"] #btn-data { display: none !important; }
        html[data-vw-mode="game"] #snapshot-panel { display: none !important; }
        
        /* CLEAN VIEW MODE: Hide everything except Stats */
        body.clean-view #minimap-widget,
        body.clean-view #toolbar,
        body.clean-view #hotbar,
        body.clean-view #mobile-controls,
        body.clean-view #mobile-action-btns,
        body.clean-view #region-indicator,
        body.clean-view #camera-hint,
        body.clean-view #welcome-hint {
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
        }

        /* ═══════════════════════════════════════════════════════════════
           HUD TOP (Stats) - Always visible, minimal
        ═══════════════════════════════════════════════════════════════ */
        #hud-top {
            position: fixed; top: 0; left: 0; right: 0;
            height: 50px;
            background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
            display: flex; justify-content: space-between; align-items: center;
            padding: 0 16px;
            z-index: 100;
            pointer-events: none;
        }
        #hud-top > * { pointer-events: auto; }
        
        .title h1 {
            font-size: 14px; font-weight: 700;
            letter-spacing: 1px;
            background: linear-gradient(135deg, #a78bfa 0%, #22d3ee 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 2px 10px rgba(167, 139, 250, 0.3);
        }
        
        .stats { display: flex; gap: 16px; font-size: 12px; }
        .stat { display: flex; flex-direction: column; align-items: center; }
        .stat-value { font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
        .stat-label { font-size: 8px; color: #94a3b8; text-transform: uppercase; }
        
        #survival-bars { display: flex; gap: 6px; }
        .survival-bar { width: 40px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
        .survival-bar .fill { height: 100%; }
        
        /* ═══════════════════════════════════════════════════════════════
           MOBILE OPTIMIZATIONS (The "Readable" Rules)
        ═══════════════════════════════════════════════════════════════ */
        
        /* MINIMAP - Hidden by default on mobile, collapsible */
        #minimap-widget {
            /* Leave room for #aux-controls (top-right buttons) */
            position: fixed; top: 104px; right: 16px;
            width: 160px;
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 12px;
            padding: 10px;
            z-index: 90;
            transform-origin: top right;
            transition: transform 0.2s, opacity 0.2s;
        }

        /* Game-first: keep the Temporal HUD visible, but hide the Atlas map unless expanded. */
        #minimap-widget:not(.expanded) #minimap-header,
        #minimap-widget:not(.expanded) #minimap-canvas-wrap {
            display: none;
        }
        #minimap-widget:not(.expanded) {
            width: auto;
            padding: 8px 10px;
        }
        
        @media (max-width: 600px) {
            #minimap-widget {
                transform: scale(0.8); /* Smaller on mobile */
                right: 8px;
                top: 104px; /* below #aux-controls */
                display: none; /* Rule 2: Hidden by default */
            }
            #minimap-widget.active { display: block; }
            
            .title h1 { display: none; } /* Hide title on mobile to save space */
            #connection-status { display: none; }
        }
        
        /* CELESTIAL CLOCK + TEMPORAL TRACK (Compact, "Temporal Rust" friendly) */
        #celestial-clock {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding-bottom: 8px;
            margin-bottom: 8px;
            border-bottom: 1px solid rgba(255,255,255,0.08);
        }
        #celestial-clock,
        #minimap-header {
            cursor: pointer;
            user-select: none;
            -webkit-user-select: none;
        }
        #sun-arc { display: block; margin: 0 auto; }
        
        .moon-row {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 11px;
            color: rgba(226,232,240,0.85);
        }
        .moon-icon { font-size: 14px; }
        .moon-text { font-size: 10px; color: rgba(148,163,184,0.9); }
        
        .world-date {
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.2px;
            color: rgba(251,191,36,0.95);
            text-align: center;
        }
        .world-hour {
            font-size: 10px;
            color: rgba(226,232,240,0.7);
        }
        
        #temp-badge {
            margin-top: 4px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 3px 8px;
            border-radius: 999px;
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.08);
            font-size: 10px;
            color: rgba(226,232,240,0.85);
        }
        #temp-badge .temp-value { font-weight: 700; }
        
        #minimap-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            font-size: 11px;
            color: rgba(226,232,240,0.8);
            margin-bottom: 8px;
        }
        
        #minimap-canvas-wrap {
            width: 100%;
            overflow: hidden;
            border-radius: 10px;
            border: 1px solid rgba(255,255,255,0.08);
            background: rgba(0,0,0,0.15);
        }
        #minimap-canvas {
            width: 100%;
            height: auto;
            display: block;
        }
        
        #temporal-track {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 6px;
        }
        
        .temporal-item {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 8px;
            border-radius: 10px;
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.06);
            font-size: 11px;
            line-height: 1;
        }
        .temporal-item .icon { opacity: 0.9; }
        .temporal-item .value { font-weight: 700; color: #e2e8f0; }
        .temporal-item .label { margin-left: auto; font-size: 9px; color: rgba(148,163,184,0.9); text-transform: uppercase; }
        
        #drift-indicator.warning {
            border-color: rgba(245, 158, 11, 0.55);
            background: rgba(245, 158, 11, 0.08);
        }
        #drift-indicator.alert {
            border-color: rgba(239, 68, 68, 0.6);
            background: rgba(239, 68, 68, 0.08);
        }

        /* WELCOME HINT - Less intrusive */
        #welcome-hint {
            position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
            background: rgba(15, 23, 42, 0.7);
            backdrop-filter: blur(8px);
            border: 1px solid rgba(139, 92, 246, 0.3);
            border-radius: 20px;
            padding: 8px 16px;
            font-size: 11px;
            color: #e2e8f0;
            z-index: 80;
            pointer-events: auto;
            text-align: center;
            max-width: 90%;
        }

        /* TOOLBAR - Left side */
        #toolbar {
            position: fixed; left: 16px; top: 50%; transform: translateY(-50%);
            display: flex; flex-direction: column; gap: 8px;
            z-index: 90;
        }
        .tool-btn {
            width: 44px; height: 44px;
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(4px);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 10px;
            font-size: 18px;
            cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            color: #cbd5e1;
        }
        .tool-btn.active {
            border-color: #a855f7;
            background: rgba(168, 85, 247, 0.2);
            color: #fff;
        }

        /* HOTBAR - Bottom Center */
        #hotbar {
            position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
            display: flex; gap: 6px;
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(8px);
            padding: 6px; border-radius: 14px;
            border: 1px solid rgba(255,255,255,0.1);
            z-index: 90;
        }
        .hotbar-slot {
            width: 40px; height: 40px;
            border-radius: 8px;
            background: rgba(255,255,255,0.05);
            display: flex; align-items: center; justify-content: center;
            font-size: 18px;
            border: 1px solid transparent;
        }
        .hotbar-slot.active {
            border-color: #f59e0b;
            background: rgba(245, 158, 11, 0.1);
        }

        /* MOBILE CONTROLS - Transparency is key */
        #mobile-controls, #mobile-action-btns { z-index: 80; }
        #joystick-base {
            background: rgba(255, 255, 255, 0.05) !important;
            border: 1px solid rgba(255, 255, 255, 0.1) !important;
        }
        #joystick-knob {
            background: rgba(255, 255, 255, 0.2) !important;
        }
        .mobile-btn {
            width: 56px; height: 56px; border-radius: 50%;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(4px);
            display: flex; align-items: center; justify-content: center;
            font-size: 20px; color: rgba(255,255,255,0.8);
            margin-bottom: 12px;
        }
        .mobile-btn:active { background: rgba(255,255,255,0.15); transform: scale(0.95); }

        /* AUX BUTTONS (Clean View, Map Toggle) */
        #aux-controls {
            position: fixed; top: 60px; right: 16px;
            display: flex; gap: 8px;
            z-index: 95;
        }
        .aux-btn {
            width: 36px; height: 36px;
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(8px);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 8px;
            color: #cbd5e1;
            font-size: 16px;
            display: flex; align-items: center; justify-content: center;
            cursor: pointer;
        }

        /* Region Indicator - Subtle top center */
        #region-indicator {
            position: fixed; top: 55px; left: 50%; transform: translateX(-50%);
            background: rgba(15, 23, 42, 0.0); /* Transparent */
            text-shadow: 0 2px 4px rgba(0,0,0,0.8);
            color: #e2e8f0;
            font-size: 12px;
            z-index: 80;
            display: flex; gap: 6px; align-items: center;
            pointer-events: none;
        }

        /* Panels (Inventory, Craft, Time) - Centered, Single Overlay Rule */
        .overlay-panel {
            position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
            background: rgba(15, 23, 42, 0.55); /* Nemeton-style glass */
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 16px;
            padding: 20px;
            z-index: 200;
            max-width: 90%;
            width: 320px;
            max-height: min(75vh, 560px);
            overflow: auto;
            overscroll-behavior: contain;
            -webkit-overflow-scrolling: touch;
            box-shadow: 0 18px 50px rgba(0,0,0,0.42);
            display: none; /* Mutually exclusive */
        }
        .overlay-panel.active { display: block; animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

        @keyframes popIn {
            from { opacity: 0; transform: translate(-50%, -40%) scale(0.95); }
            to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
        }

        /* Hints (keep subtle; hidden in game mode) */
        #camera-hint {
            position: fixed;
            top: 58px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 10px;
            color: rgba(226, 232, 240, 0.75);
            background: rgba(15, 23, 42, 0.35);
            border: 1px solid rgba(255, 255, 255, 0.10);
            border-radius: 999px;
            padding: 6px 10px;
            z-index: 90;
            pointer-events: none;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            white-space: nowrap;
        }
        #camera-hint kbd {
            display: inline-block;
            min-width: 18px;
            padding: 2px 6px;
            margin: 0 2px;
            font-size: 10px;
            font-weight: 700;
            color: rgba(255, 255, 255, 0.85);
            background: rgba(255, 255, 255, 0.10);
            border: 1px solid rgba(255, 255, 255, 0.14);
            border-bottom-color: rgba(255, 255, 255, 0.18);
            border-radius: 7px;
        }
        #fps-hint {
            position: fixed;
            bottom: 90px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 10px;
            color: rgba(226, 232, 240, 0.75);
            background: rgba(15, 23, 42, 0.35);
            border: 1px solid rgba(255, 255, 255, 0.10);
            border-radius: 999px;
            padding: 6px 10px;
            z-index: 90;
            pointer-events: none;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            white-space: nowrap;
        }

        html[data-vw-mode="game"] #camera-hint,
        html[data-vw-mode="game"] #fps-hint,
        html[data-vw-mode="game"] #npr-style-indicator {
            display: none !important;
        }

        /* Existing styles preservation for specific internals... */
        canvas { display: block; }
        
        /* Feature markers on minimap */
        .feature-marker {
            position: absolute;
            width: 6px; height: 6px;
            border-radius: 50%;
            transform: translate(-50%, -50%);
        }

/* MISSING OVERLAYS */
#portal-overlay {
    position: fixed; inset: 0;
    background: #050914;
    z-index: 9999;
    display: none;
    align-items: center; justify-content: center; flex-direction: column;
}
#portal-overlay.active { display: flex; }
.portal-text { color: #a78bfa; margin-top: 20px; font-family: monospace; font-size: 14px; }

#death-screen {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 9990;
    display: none;
    align-items: center; justify-content: center;
}
#death-card {
    background: #111; border: 1px solid #333; padding: 40px; border-radius: 8px;
    text-align: center; color: #fff;
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.2);
}
#death-title { font-size: 32px; font-weight: 900; color: #ef4444; margin-bottom: 10px; }
#death-sub { color: #888; font-size: 12px; margin-bottom: 20px; }
.death-btn {
    padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; margin: 0 5px;
}
.death-btn.primary { background: #ef4444; color: #fff; }
.death-btn.secondary { background: #333; color: #ccc; }

/* FIX UI OVERLAP */
/* Move World Selector down */
#minimap-widget {
    top: 120px !important; /* Push it down below HUD */
}
/* Ensure generic container for selector is positioned? */
/* Actually selector is usually Top Left. The Title is center. */
/* The screenshot shows selector covering title. */
/* We can hide title on mobile or move selector. */
/* Just let it be for now, fixing overlays is priority. */

/* SIDEBAR FIX (Restored) */
#sidebar {
    position: fixed; top: 0; right: 0; bottom: 0; width: 280px;
    transform: translateX(100%); transition: transform 0.3s;
    background: rgba(15,23,42,0.95); z-index: 200;
    padding: 20px; overflow-y: auto;
    border-left: 1px solid rgba(255,255,255,0.1);
}
#sidebar.active { transform: translateX(0); }

/* MOBILE CRAFTING FIX - Compact & Transparent */
@media (max-width: 600px) {
    /* Mobile: panels become a compact bottom sheet */
    .overlay-panel {
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 18px 18px 0 0 !important;
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom)) !important;
        max-height: 52vh !important;
        background: rgba(15, 23, 42, 0.55) !important; /* glass like Nemeton widgets */
        box-shadow: 0 -18px 50px rgba(0,0,0,0.55) !important;
    }
    .overlay-panel.active { animation: sheetUp 0.22s ease-out; }
    @keyframes sheetUp {
        from { opacity: 0; transform: translateY(22px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .overlay-panel h3, .overlay-panel h4 {
        font-size: 13px !important;
        margin-bottom: 10px !important;
    }

    #inventory-slots {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }

    #craft-recipes {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }
    #craft-recipes .craft-item { margin: 0 !important; }

    /* Make cards inside panels glassy too (override inline styles) */
    .overlay-panel .craft-item {
        background: rgba(255,255,255,0.06) !important;
        border: 1px solid rgba(255,255,255,0.10) !important;
        box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    }
    .overlay-panel .craft-item div { color: rgba(226,232,240,0.55) !important; }
    .overlay-panel .inv-slot {
        background: rgba(255,255,255,0.06) !important;
        border: 1px solid rgba(255,255,255,0.10) !important;
    }

    #toolbar { left: 10px !important; }
    .tool-btn { width: 40px !important; height: 40px !important; font-size: 17px !important; }
    #hotbar { bottom: 12px !important; }

    /* Kill desktop hints on phones */
    #camera-hint, #fps-hint { display: none !important; }
}

/* UI POLISH */
select {
    appearance: none;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #e0e6f0;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    backdrop-filter: blur(10px);
}
select:hover {
    border-color: #a78bfa;
    background: rgba(30, 41, 59, 0.9);
}
select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.5);
}

/* Hide debug buttons in main view */
#btn-data, #snapshot-panel {
    opacity: 0.8; transition: opacity 0.2s;
}
#snapshot-panel:hover { opacity: 1; }

/* Ensure Sidebar Text doesn't bleed if visible */
#sidebar {
    font-family: 'SF Mono', monospace;
    font-size: 11px;
    color: #94a3b8;
}
