body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Canvas Container */
#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    transition: height 0.3s ease-in-out;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* === Premium Glassmorphism Variables === */
:root {
    --glass-bg: rgba(8, 12, 16, 0.92);
    --glass-bg-light: rgba(15, 20, 28, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.15);
    --glass-blur: 20px;

    /* Accent Colors - Neon Cyan/Green Gradient */
    --accent-primary: #00ff9d;
    --accent-secondary: #00d4ff;
    --accent-gradient: linear-gradient(135deg, #00ff9d 0%, #00d4ff 100%);
    --accent-glow: rgba(0, 255, 157, 0.4);
    --accent-glow-soft: rgba(0, 255, 157, 0.15);

    /* Status Colors */
    --status-active: #00ff9d;
    --status-paused: #ffa500;
    --status-stopped: #ff4757;

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.35);

    /* Dimensions */
    --panel-height: 38vh;
    --tab-height: 52px;
    --border-radius: 12px;
    --border-radius-sm: 8px;

    /* Animations */
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* === Unified Bottom Panel === */
#bottom-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--panel-height);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-top: 1px solid var(--glass-border);
    box-shadow:
        0 -8px 32px rgba(0, 0, 0, 0.6),
        0 -2px 16px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);

    transform: translateY(calc(100% - var(--tab-height)));
    transition: transform 0.4s ease-out;

    display: flex;
    flex-direction: column;
    z-index: 1000;
}

body.split-screen #bottom-panel {
    transform: translateY(0);
}

body.split-screen #bottom-panel .toggle-icon {
    transform: rotate(180deg);
}

/* === Premium Tab Bar with Edge Drag === */
#unit-tabs {
    height: var(--tab-height);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 60px 0 20px;
    /* Right padding for toggle button */
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
    position: relative;
    /* Edge drag zone at top */
    border-top: 4px solid transparent;
    cursor: ns-resize;
    transition: border-color var(--transition-fast);
}

#unit-tabs:hover {
    border-top-color: rgba(0, 255, 157, 0.3);
}

#unit-tabs:active {
    border-top-color: var(--accent-primary);
}

/* Toggle button (right side of tabs row) */
.panel-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.panel-toggle-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(0, 255, 157, 0.1);
}

.toggle-icon {
    font-size: 16px;
    transition: transform var(--transition-smooth);
}

/* Glowing line accent under tabs */
#unit-tabs::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 1px;
    background: var(--accent-gradient);
    opacity: 0.3;
    filter: blur(1px);
}

.unit-tab {
    position: relative;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition-smooth);
    border-bottom: 2px solid transparent;
    background: transparent;
}

.unit-tab::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all var(--transition-smooth);
}

.unit-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.unit-tab:hover::before {
    background: var(--text-secondary);
}

.unit-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    background: linear-gradient(180deg, rgba(0, 255, 157, 0.08) 0%, transparent 100%);
}

.unit-tab.active::before {
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* P38.4e — inline play/pause toggle inside each .unit-tab. Two tiny
   icon buttons (play + pause). The one matching the unit's current
   state carries `.active` → BLUE. On hover, the hovered icon goes
   GREEN (preview of the state switch). Click sets the state
   directly on the unit; `Unit.setCommandPause(bool)` is the sole
   write path, so nothing else on the timeline is bypassed. */
.unit-tab-name {
    display: inline-block;
}
.unit-tab-pp {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 8px;
}
.unit-tab-pp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.unit-tab-pp-btn svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
    display: block;
}
.unit-tab-pp-btn.active {
    /* BLUE — "this state is currently the active one on the unit". */
    color: rgba(0, 170, 255, 1);
    border-color: rgba(0, 170, 255, 0.7);
    background: rgba(0, 170, 255, 0.12);
    box-shadow: 0 0 6px rgba(0, 170, 255, 0.35);
}
.unit-tab-pp-btn:hover {
    /* GREEN — "click this to switch to this state". */
    color: rgba(34, 221, 68, 1);
    border-color: rgba(34, 221, 68, 0.7);
    background: rgba(34, 221, 68, 0.12);
    box-shadow: 0 0 6px rgba(34, 221, 68, 0.35);
}

/* === Panel Content Area === */
.panel-content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    /* Added scrollbar */
    color: var(--text-primary);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* === Premium Panel Container === */
.panel-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    height: 100%;
}

/* === Unit Info Card === */
.unit-info {
    background: var(--glass-bg-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.unit-info h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-size: 10px;
    color: var(--text-muted);
}

.unit-info h3::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    text-align: center;
}

.stat-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 18px;
    font-weight: 300;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-value.accent {
    color: var(--accent-primary);
    text-shadow: 0 0 12px var(--accent-glow-soft);
}

/* === Command Queue Section === */
.command-queue {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.command-queue h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin: 0 0 16px 0;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-size: 10px;
    color: var(--text-muted);
}

.command-queue h3::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

/* === Playback Controls Bar === */
.playback-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
}

.ctrl-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all var(--transition-fast);
    overflow: hidden;
}

.ctrl-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.ctrl-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.ctrl-btn:hover::before {
    opacity: 0.1;
}

.ctrl-btn:active {
    transform: scale(0.98);
}

.ctrl-btn.primary {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #051510;
    font-weight: 700;
}

.ctrl-btn.primary:hover {
    box-shadow: 0 0 20px var(--accent-glow-soft);
}

.ctrl-btn.danger {
    border-color: rgba(255, 71, 87, 0.3);
    color: #ff4757;
}

.ctrl-btn.danger:hover {
    border-color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
}

/* === Command Queue List (Horizontal Timeline) === */
.command-queue-list {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0;
    margin-bottom: 12px;
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: stretch;
}

.command-queue-list::-webkit-scrollbar {
    height: 6px;
}

.command-queue-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* === Individual Command Item (Horizontal Card) === */
.command-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    cursor: grab;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    min-width: 120px;
    flex-shrink: 0;
}

/* Timeline connector arrow */
.command-item::after {
    content: '→';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
    z-index: 1;
}

.command-item:last-child::after {
    display: none;
}

.command-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.command-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border-hover);
}

.command-item:hover::before {
    opacity: 1;
}

.command-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.command-item.start-point {
    border-color: rgba(0, 255, 157, 0.2);
    background: rgba(0, 255, 157, 0.03);
}

/* === Waypoint State Colors (Blue/Orange) === */
.command-item.state-target {
    border-color: rgba(255, 170, 0, 0.6);
    background: rgba(255, 170, 0, 0.2);
    box-shadow: 0 0 12px rgba(255, 170, 0, 0.3);
}

.command-item.state-target::before {
    background: linear-gradient(135deg, #ffaa00 0%, #ff7700 100%);
    opacity: 1;
}

.command-item.state-from {
    border-color: rgba(0, 170, 255, 0.6);
    background: rgba(0, 170, 255, 0.2);
    box-shadow: 0 0 12px rgba(0, 170, 255, 0.3);
}

.command-item.state-from::before {
    background: linear-gradient(135deg, #00aaff 0%, #0077ff 100%);
    opacity: 1;
}

.command-item.state-active {
    border-color: rgba(0, 255, 136, 0.8);
    background: rgba(0, 255, 136, 0.25);
    box-shadow: 0 0 16px rgba(0, 255, 136, 0.4);
    animation: pulse-active 1.5s ease-in-out infinite;
}

.command-item.state-active::before {
    background: linear-gradient(135deg, #00ff88 0%, #00cc66 100%);
    opacity: 1;
}

@keyframes pulse-active {
    0%, 100% { box-shadow: 0 0 16px rgba(0, 255, 136, 0.4); }
    50% { box-shadow: 0 0 24px rgba(0, 255, 136, 0.7); }
}

.command-item.start-point::before {
    opacity: 1;
}

/* === Gate 2: Location Box Nested Layout === */
.location-box {
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s ease;
    overflow: hidden;
    min-width: 140px;
    flex-shrink: 0;
    cursor: grab;
}

.location-box.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.location-box.drop-target {
    border-color: rgba(0, 255, 200, 0.8);
    background: rgba(0, 255, 200, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 200, 0.3);
}

/* P36-D: selection overlay — white ring/glow on top of the underlying
   lifecycle-colored box. Orthogonal to loc-transit / loc-actions /
   loc-completed / loc-pending (those set background/border for the
   state; this adds a distinct border highlight on top). */
.location-box.loc-selected {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: -2px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.action-item.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.action-item[draggable="true"] {
    cursor: grab;
}

.location-box .location-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
}

.location-box .location-header .cmd-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.location-box .location-header .cmd-info {
    flex: 1;
    min-width: 0;
}

.location-box .location-header .cmd-type {
    font-size: 9px;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 1px;
}

.location-box .location-header .cmd-coords {
    font-size: 12px;
    font-weight: 600;
}

.location-box .location-header .cmd-details {
    font-size: 10px;
    opacity: 0.4;
}

/* P38.4b: Location state colors — aligned to the map palette so the
   timeline and the 3D markers show the same hue for the same state.
   Hex values are derived from src/UI/visualConfig.js:
     loc-transit (NEXT target)  → MAP_WAYPOINT_COLOR_NEXT   = #22dd44
     loc-actions (ACTIVE action) → MAP_WAYPOINT_COLOR_ACTIVE = #ff8800
     loc-completed (LAST left)   → MAP_WAYPOINT_COLOR_LAST   = #00aaff
     loc-pending (NEUTRAL)       → MAP_WAYPOINT_COLOR_NEUTRAL = #9adddf
   Pre-P38.4b had loc-transit orange and loc-actions green — the
   inverse of the map — so users saw the two surfaces disagree
   about what each color meant. */
.location-box.loc-transit {
    border-color: rgba(34, 221, 68, 0.6);
    background: rgba(34, 221, 68, 0.1);
    box-shadow: 0 0 12px rgba(34, 221, 68, 0.2);
}

.location-box.loc-actions {
    border-color: rgba(255, 136, 0, 0.6);
    background: rgba(255, 136, 0, 0.1);
    box-shadow: 0 0 12px rgba(255, 136, 0, 0.2);
}

.location-box.loc-completed {
    border-color: rgba(0, 170, 255, 0.4);
    background: rgba(0, 170, 255, 0.05);
    opacity: 0.7;
}

.location-box.loc-pending {
    border-color: rgba(154, 221, 223, 0.3);
    background: rgba(154, 221, 223, 0.05);
    opacity: 0.6;
}

/* Nested action list inside Location Box */
.location-box .action-list {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 4px 8px 6px 36px; /* indent to align under location header */
}

.action-item {
    display: flex;
    align-items: center;
    /* P35-F: flex-wrap lets the full-width progress bar drop to a
       second row BELOW the icon + info + delete-button row. */
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 11px;
    transition: all 0.2s ease;
}

.action-item .action-icon {
    font-size: 12px;
    opacity: 0.6;
}

.action-item .action-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-item .action-type {
    font-weight: 500;
    text-transform: uppercase;
    font-size: 10px;
    opacity: 0.7;
}

.action-item .action-param {
    font-size: 11px;
    color: rgba(0, 255, 136, 0.8);
    font-weight: 600;
}

/* P35-I: editable wait duration input */
.action-item .action-seconds-input {
    width: 56px;
    height: 20px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(0, 255, 136, 0.95);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(0, 255, 136, 0.35);
    border-radius: 4px;
    padding: 0 4px;
    text-align: right;
}
.action-item .action-seconds-input:focus {
    outline: none;
    border-color: rgba(0, 255, 136, 0.75);
    background: rgba(0, 0, 0, 0.5);
}
.action-item .action-param-unit {
    font-size: 11px;
    color: rgba(0, 255, 136, 0.8);
    font-weight: 600;
    margin-left: 2px;
}

/* D2 / P35-F: Action progress bar (Wait % indicator) — full-width
   across the waypoint box. Bar is now a direct sibling of
   .action-info; flex-basis: 100% + the parent's flex-wrap: wrap
   drops it to its own row, making the bar span the entire
   .action-item width. */
.action-item .action-progress-bar {
    position: relative;
    flex: 0 0 100%;
    width: 100%;
    height: 16px;
    margin-top: 6px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}
/* P38.4h — progress fill gradient: BLUE at the base (older / already
   played) → ORANGE at the tip (newest / currently playing).
   Blue is the shared "completed" hue (matches
   MAP_WAYPOINT_COLOR_LAST = 0x00aaff); orange is the shared
   "currently happening" hue (matches MAP_WAYPOINT_COLOR_ACTIVE =
   0xff8800). So the right edge of the bar always reads as "this
   is what's happening right now" regardless of % progress. */
.action-item .action-progress-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: linear-gradient(90deg, rgba(0, 170, 255, 1.0), rgba(255, 136, 0, 1.0));
    box-shadow: 0 0 8px rgba(255, 136, 0, 0.5);
    transition: width 0.1s linear, background 0.3s ease;
}
.action-item .action-progress-label {
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 4px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.5px;
    z-index: 2;
    pointer-events: none;
}

/* P38.4b: the action that is currently executing. Colored ORANGE
   (MAP_WAYPOINT_COLOR_ACTIVE = #ff8800) to match the map's ACTIVE
   waypoint hue — same state, same color across both surfaces. */
.action-item.state-active {
    background: rgba(255, 136, 0, 0.15);
    border: 1px solid rgba(255, 136, 0, 0.4);
    animation: pulse-active 1.5s ease-in-out infinite;
}

/* P38.4h — completed action. User spec: "when they're completed
   they should be blue (with the filled slider inside also blue)".
   Blue matches MAP_WAYPOINT_COLOR_LAST = 0x00aaff, the shared
   "already done / left behind" hue across map + timeline. */
.action-item.act-completed {
    background: rgba(0, 170, 255, 0.15);
    border: 1px solid rgba(0, 170, 255, 0.4);
    opacity: 0.75;
}

/* The filled slider inside a completed action loses the blue→orange
   gradient (no "currently happening" tip) and becomes fully blue. */
.action-item.act-completed .action-progress-fill {
    background: rgba(0, 170, 255, 1.0);
    box-shadow: 0 0 8px rgba(0, 170, 255, 0.5);
}

.action-item .delete-act-btn {
    background: none;
    border: none;
    color: rgba(255, 100, 100, 0.5);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.action-item:hover .delete-act-btn {
    opacity: 1;
}

.location-box .delete-loc-btn {
    background: none;
    border: none;
    color: rgba(255, 100, 100, 0.5);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.location-box:hover .delete-loc-btn {
    opacity: 1;
    color: rgba(255, 100, 100, 0.9);
}

/* Command Icon */
.cmd-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px var(--accent-glow-soft);
}

/* Command Info */
.cmd-info {
    flex: 1;
    min-width: 0;
}

.cmd-type {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.cmd-coords {
    font-size: 10px;
    font-weight: 500;
    color: var(--accent-primary);
    letter-spacing: 0.5px;
}

.cmd-details {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Consolas', monospace;
    letter-spacing: 0;
    margin-top: 2px;
}

/* Command Actions */
.cmd-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.command-item:hover .cmd-actions,
.location-box:hover .cmd-actions {
    opacity: 1;
}

.cmd-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--transition-fast);
}

.cmd-action-btn:hover {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
}

/* === Empty State === */
.no-commands {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
}

.no-commands-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.no-commands-text {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
}

.no-commands-hint {
    font-size: 11px;
    opacity: 0.6;
}

/* Hint Text */
.hint-text {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0;
    border-top: 1px solid var(--glass-border);
    margin-top: auto;
}

.hint-text kbd {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    font-family: inherit;
    font-size: 10px;
    margin: 0 2px;
}

/* === Preloader === */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: background 0.8s ease-out;
}

/* Staged fadeout: background goes transparent first */
#loader.fade-stage-1 {
    background: transparent;
}

/* Asteroid fades early */
#loader.fade-stage-1 .spinner-asteroid {
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

/* Light and text stay, then fade */
#loader.fade-stage-2 .spinner-orbit,
#loader.fade-stage-2 .loader-title,
#loader.fade-stage-2 .loader-subtitle {
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

/* Final hide */
#loader.fade-complete {
    display: none;
}

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

/* === Spinner Container === */
.spinner-container {
    width: 60px;
    height: 60px;
    margin: 0 auto 25px;
    position: relative;
}

/* Static asteroid body - does NOT rotate */
.spinner-asteroid {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    /* Very dark asteroid - black center, dark gray edges */
    background: radial-gradient(circle at 40% 35%, #0a0a0a 0%, #050505 50%, #000 100%);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8);
}

/* Crater circles on asteroid - static */
.spinner-asteroid::before,
.spinner-asteroid::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: #000;
    box-shadow: inset 0 1px 2px rgba(30, 30, 30, 0.3);
}

.spinner-asteroid::before {
    width: 10px;
    height: 10px;
    top: 12px;
    left: 10px;
    box-shadow:
        20px 6px 0 4px #000,
        8px 22px 0 3px #000,
        26px 24px 0 2px #000,
        4px 38px 0 3px #000;
}

.spinner-asteroid::after {
    width: 7px;
    height: 7px;
    top: 30px;
    left: 34px;
    box-shadow:
        -10px -16px 0 2px #000,
        10px -8px 0 2px #000;
}

/* Rotating light beam around asteroid perimeter - SEMICIRCLE */
.spinner-orbit {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    position: absolute;
    top: -2px;
    left: -2px;
    animation: spin 3s linear infinite;
    /* Slower rotation */
    /* Conic gradient - SEMICIRCLE (180 degrees of light) */
    background: conic-gradient(from 0deg,
            transparent 0deg,
            transparent 90deg,
            #00d4ff 100deg,
            #4ade80 180deg,
            #00d4ff 260deg,
            transparent 270deg,
            transparent 360deg);
    /* Mask to create ring effect */
    -webkit-mask: radial-gradient(transparent 26px, #000 27px, #000 30px, transparent 31px);
    mask: radial-gradient(transparent 26px, #000 27px, #000 30px, transparent 31px);
    /* Glow effect */
    filter: blur(1px);
}

.loader-title {
    font-size: 28px;
    font-weight: 300;
    color: rgba(200, 200, 210, 0.9);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.loader-subtitle {
    font-size: 10px;
    font-weight: 500;
    color: rgba(120, 120, 130, 0.7);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    line-height: 1.8;
}

.loader-subtitle div {
    text-align: center;
}

.loader-text {
    font-size: 10px;
    font-weight: 500;
    color: rgba(120, 120, 130, 0.8);
    letter-spacing: 3px;
    text-transform: uppercase;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* === Status Indicators === */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-badge.active {
    background: rgba(0, 255, 157, 0.15);
    color: var(--status-active);
}

.status-badge.paused {
    background: rgba(255, 165, 0, 0.15);
    color: var(--status-paused);
}

.status-badge.stopped {
    background: rgba(255, 71, 87, 0.15);
    color: var(--status-stopped);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* === Command Queue Interaction === */
.command-item.highlighted {
    background: rgba(0, 255, 136, 0.2);
    border-color: #00ff88;
    transform: translateX(5px);
}

.cmd-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.command-item.start-point .cmd-icon {
    filter: drop-shadow(0 0 5px #00ff88);
}

/* === Visibility Indicator === */
#visibility-indicator {
    position: fixed;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    z-index: 500;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

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

.visibility-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff9d;
    box-shadow: 0 0 8px rgba(0, 255, 157, 0.6);
    animation: pulse 2s ease-in-out infinite;
}

.visibility-text {
    color: #00ff9d;
}

/* Obstructed state */
#visibility-indicator.obstructed .visibility-dot {
    background: #ff4757;
    box-shadow: 0 0 8px rgba(255, 71, 87, 0.6);
}

#visibility-indicator.obstructed .visibility-text {
    color: #ff4757;
}

#visibility-indicator.obstructed {
    border-color: rgba(255, 71, 87, 0.3);
}

/* === Start Screen === */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9200;   /* above the preloader (9100) + the warp window manager (9000) so the ENTER button stays clickable */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out;
}

#start-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.start-content {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* Initially hide start button, show when ready */
#start-btn {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
    pointer-events: none;

    background: transparent;
    border: 1px solid rgba(0, 255, 136, 0.4);
    color: #00ff88;
    padding: 10px 24px;
    /* Even smaller padding */
    font-size: 14px;
    /* Even smaller font */
    font-weight: 400;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 5px;
    /* Adjust spacing slightly */
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.1);
}

#start-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#start-btn:hover {
    background: rgba(0, 255, 136, 0.05);
    border-color: rgba(0, 255, 136, 0.8);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}

#start-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 136, 0.2), transparent);
    transition: 0.5s;
}

#start-btn:hover::before {
    left: 100%;
}

@keyframes blink {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* === START SCREEN === */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9200;
    /* Higher than the preloader (9100) + the warp window manager (9000) */
    opacity: 1;
    transition: opacity 0.4s ease-out;
    background: radial-gradient(ellipse at center, rgba(10, 15, 25, 0.95) 0%, rgba(0, 0, 0, 0.98) 100%);
}

#start-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

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

/* === DUAL MODE BUTTONS (Basic/High) === */
.mode-selection h2 {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    letter-spacing: 4px;
    margin-bottom: 30px;
    font-weight: 300;
    text-align: center;
    /* CENTERED */
}

.mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
}

.mode-btn {
    padding: 15px 30px;
    background: rgba(10, 15, 25, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.05s cubic-bezier(0.1, 0.7, 0.1, 1);
    /* Instant response */
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 120px;
}

.mode-btn:hover {
    transform: translateY(-5px) scale(1.05) !important;
    box-shadow: 0 20px 50px rgba(0, 255, 157, 0.5) !important;
    background: rgba(30, 50, 70, 1) !important;
    border-color: rgba(0, 255, 157, 0.8) !important;
}

.mode-btn:active {
    transform: translateY(2px) scale(0.95) !important;
    box-shadow: 0 5px 15px rgba(0, 255, 157, 0.4) !important;
    background: rgba(20, 40, 60, 1) !important;
    transition: all 0.05s ease !important;
}

.btn-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 2px;
}

.btn-desc {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
}

/* DEV Mode - Orange/Amber accent */
.mode-btn.dev {
    border-color: rgba(255, 170, 50, 0.3);
}

.mode-btn.dev:hover {
    border-color: #ffaa32;
    box-shadow: 0 0 30px rgba(255, 170, 50, 0.25);
}

.mode-btn.dev .btn-title {
    color: #ffaa32;
}

/* GAME Mode - Cyan/Blue accent */
.mode-btn.game {
    border-color: rgba(0, 212, 255, 0.3);
}

.mode-btn.game:hover {
    border-color: #00d4ff;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.25);
}

.mode-btn.game .btn-title {
    color: #00d4ff;
}

/* prompt_399 — Four-Panel Adaptive Mosaic (feature-flagged ?panelLayout=four).
   Additive: every rule targets a NEW id/class, so the default route is unaffected. */
#panel-layout-root {
    position: fixed;
    inset: 0;
    z-index: 1500;            /* above the canvas, below modal overlays */
    pointer-events: none;     /* root passes through; boxes + dividers opt back in */
}
#panel-layout-root .panel-box {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid #2a3340;
    background: rgba(18, 22, 28, 0.92);
    color: #cde;
    font: 12px/1.4 monospace;
    overflow: hidden;
    pointer-events: auto;
}
#panel-layout-root .panel-box.is-icon { background: rgba(30, 38, 48, 0.96); }
#panel-layout-root .panel-icon {
    position: absolute;
    left: 4px; top: 4px;
    width: 22px; height: 22px;
    border: 1px solid #456; border-radius: 4px;
    background: #1b2430; color: #9cf;
    font: 11px/20px monospace; text-align: center;
    cursor: pointer; padding: 0; z-index: 2;
}
#panel-layout-root .panel-body {
    position: absolute;
    inset: 30px 6px 6px 6px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.85;
}
#panel-layout-root #world-view {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(20, 40, 60, 0.5);
    border: 1px dashed #357; color: #7bd;
}
#panel-layout-root .panel-divider-layer { position: absolute; inset: 0; pointer-events: none; }
#panel-layout-root .panel-divider { position: absolute; background: #3a4a5a; pointer-events: auto; }
#panel-layout-root .panel-divider-h { height: 6px; transform: translateY(-3px); cursor: row-resize; }
#panel-layout-root .panel-divider-v { width: 6px; transform: translateX(-3px); cursor: col-resize; }
#panel-layout-root .panel-divider:hover { background: #5a82b0; }
/* Spine CONNECTOR — a DOUBLE line: transparent core with two outer strips drawn by border, so its
   OUTER edge spans the same 6px as the bold dividers (3px each side of the spine line). */
#panel-layout-root .panel-connector { background: transparent; }
#panel-layout-root .panel-connector.panel-divider-h {
    border-top: 2px solid #3a4a5a; border-bottom: 2px solid #3a4a5a; box-sizing: border-box;
}
#panel-layout-root .panel-connector.panel-divider-v {
    border-left: 2px solid #3a4a5a; border-right: 2px solid #3a4a5a; box-sizing: border-box;
}
#panel-layout-root .panel-connector:hover { background: transparent; border-color: #5a82b0; }
/* X/T junction free-move highlight: on hover within nodeRadiusPx, the actual crossing divider
   segments inside the radius light up (a T/+ of the real lines — NO circle). Cleared while dragging.
   pointer-events:none so it never blocks the drag. */
#panel-layout-root .panel-node-highlight-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
#panel-layout-root .panel-node-arm { position: absolute; background: #7bd; }
#panel-layout-root .panel-node-arm-h { height: 6px; transform: translateY(-3px); }
#panel-layout-root .panel-node-arm-v { width: 6px; transform: translateX(-3px); }
#panel-layout-root .panel-node-arm.is-cross { background: #9ce; }
/* whole-line highlight (hover on a divider segment or the spine connector — the line a drag moves) */
#panel-layout-root .panel-node-arm.is-line { background: rgba(123, 205, 255, 0.55); }

/* prompt_401 — arbitrary rows×cols grid with a TRANSPARENT world cell (the full-screen 3D canvas
   shows through it). Additive: every rule targets a NEW id, so the default route is unaffected. */
#grid-layout-root { position: fixed; inset: 0; z-index: 1500; pointer-events: none; user-select: none; }
#grid-layout-root .grid-cell-layer, #grid-layout-root .grid-divider-layer { position: absolute; inset: 0; }
#grid-layout-root .grid-cell {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid #2a3340;
    background: rgba(18, 22, 28, 0.92);   /* opaque panel */
    color: #9ab;
    font: 12px/1.4 monospace;
    display: flex; align-items: center; justify-content: center;
    pointer-events: auto;
}
#grid-layout-root .grid-cell.is-world {
    background: transparent;              /* the world shows through here */
    border: 1px dashed rgba(90, 130, 176, 0.6);
    pointer-events: none;                 /* clicks fall through to the world/canvas behind */
}
#grid-layout-root .grid-divider { position: absolute; background: #3a4a5a; pointer-events: auto; }
#grid-layout-root .grid-divider-h { height: 6px; transform: translateY(-3px); cursor: row-resize; }
#grid-layout-root .grid-divider-v { width: 6px; transform: translateX(-3px); cursor: col-resize; }
#grid-layout-root .grid-divider:hover { background: #5a82b0; }