* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    background: #000;
    color: #fff;
}

#mobile-gate {
    position: fixed;
    inset: 0;
    z-index: 2600;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #05070b;
}

#mobile-gate.hidden {
    display: none;
}

#mobile-gate #starfield-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#mobile-gate-message {
    position: relative;
    max-width: 90vw;
    padding: 16px 20px;
    text-align: center;
    font-size: 20px;
    line-height: 1.35;
    color: #e6f3ff;
    border: 1px solid rgba(130, 180, 240, 0.5);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 0 22px rgba(105, 155, 220, 0.35);
}

#edit-mode-banner {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2500;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 190, 90, 0.75);
    background: rgba(35, 20, 0, 0.74);
    color: #ffd66e;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    animation: edit-mode-pulse 2.4s ease-in-out infinite;
}

#edit-mode-banner.hidden {
    display: none;
}

@keyframes edit-mode-pulse {
    0%, 100% {
        opacity: 0.72;
        box-shadow: 0 0 8px rgba(255, 190, 90, 0.25);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 20px rgba(255, 190, 90, 0.55);
    }
}

#canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    opacity: 1;
    transition: box-shadow 0.3s ease, border 0.3s ease, opacity 0.9s ease;
}

#canvas.pending-reveal {
    opacity: 0;
}

#canvas.world-visible {
    opacity: 1;
}

/* Message notification glow */
#canvas.message-glow {
    border: 1px solid rgba(0, 255, 255, 0.75);
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.45),
                inset 0 0 8px rgba(0, 255, 255, 0.2);
    animation: neon-pulse 1.8s ease-in-out infinite;
}

@keyframes neon-pulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(0, 255, 255, 0.35),
                    inset 0 0 6px rgba(0, 255, 255, 0.15);
    }
    50% {
        box-shadow: 0 0 18px rgba(0, 255, 255, 0.55),
                    inset 0 0 10px rgba(0, 255, 255, 0.25);
    }
}

#canvas.admin-border {
    border: 1px solid rgba(255, 90, 90, 0.45);
    box-shadow: 0 0 8px rgba(255, 90, 90, 0.25);
}

#canvas.admin-border.message-glow {
    border: 1px solid rgba(0, 255, 255, 0.75);
    box-shadow: 0 0 14px rgba(0, 255, 255, 0.5),
                inset 0 0 8px rgba(0, 255, 255, 0.2);
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#controls {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

button {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

button:hover {
    background: rgba(255, 255, 255, 0.2);
}

button:active {
    background: rgba(255, 255, 255, 0.15);
}

#user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

#user-info label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

#username {
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    width: 150px;
}

#username::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#info {
    position: absolute;
    top: 20px;
    right: 20px;
    pointer-events: auto;
}

#info.hidden {
    display: none;
}

#system-status-container {
    padding: 6px 10px;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

#world-selector-wrap {
    position: relative;
    min-width: 220px;
}

#world-selector-current {
    background: rgba(0, 0, 0, 0.8);
    color: #00ff88;
    border: 1px solid #00ff88;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.2;
}

#world-selector-panel {
    position: fixed;
    min-width: 250px;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid rgba(0, 255, 136, 0.35);
    border-radius: 6px;
    background: rgba(10, 18, 14, 0.94);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 1500;
}

#world-selector-panel.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.world-selector-option {
    width: 100%;
    margin: 0;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: rgba(0, 255, 136, 0.06);
    color: rgba(210, 255, 230, 0.95);
    text-align: left;
    font-size: 11px;
    font-family: 'Courier New', monospace;
}

.world-selector-option + .world-selector-option {
    margin-top: 5px;
}

.world-selector-option:hover {
    background: rgba(0, 255, 136, 0.14);
    border-color: rgba(0, 255, 136, 0.35);
}

.world-selector-option.active {
    background: rgba(0, 255, 136, 0.22);
    border-color: rgba(0, 255, 136, 0.55);
    color: #00ff88;
}

#help-text {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    line-height: 1.5;
}

#help-text.hidden {
    display: none;
}

#message-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 900;
}

.user-message {
    background: rgba(0, 255, 136, 0.2);
    border: 2px solid rgba(0, 255, 136, 0.6);
    border-radius: 4px;
    padding: 15px 20px;
    margin: 10px 0;
    font-size: 18px;
    color: #00ff88;
    text-align: center;
    animation: fadeInOut 5s ease-in-out;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(20px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

#console {
    position: fixed;
    bottom: 20px;
    left: 20px;
    transform: translateY(0);
    width: 90%;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ff88;
    border-radius: 4px;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #00ff88;
    z-index: 1000;
    opacity: 1;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

#console.hidden {
    transform: translateY(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
}

#console-output {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 5px;
}

#console-output div {
    margin: 2px 0;
}

#console-output .error {
    color: #ff4444;
}

#console-output .success {
    color: #44ff44;
}

#console-output .event {
    color: #666666;
    font-style: italic;
}

#console-input-container {
    display: flex;
    align-items: center;
}

#console-prompt {
    color: #00ff88;
    margin-right: 5px;
    font-weight: bold;
}

#console-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #00ff88;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    outline: none;
}

#console-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #00ff88;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    max-height: 150px;
    overflow-y: auto;
    display: none;
}

#console-autocomplete.visible {
    display: block;
}

#console-autocomplete div {
    padding: 5px 10px;
    cursor: pointer;
    color: #888;
}

#console-autocomplete div:hover,
#console-autocomplete div.selected {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
}

#stats-overlay {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(0, 255, 136, 0.5);
    border-radius: 4px;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #00ff88;
    pointer-events: none;
}

#stats-overlay.hidden {
    display: none;
}

#stats-overlay div {
    margin: 2px 0;
}

#version-overlay {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    user-select: none;
}

body.layout-edit-mode [data-layout-panel] {
    outline: 2px dashed rgba(0, 255, 136, 0.7);
    outline-offset: 4px;
    cursor: move;
    pointer-events: auto !important;
    z-index: 1200;
}

body.layout-edit-mode [data-layout-panel].layout-dragging {
    outline-color: rgba(255, 210, 90, 0.9);
    box-shadow: 0 0 12px rgba(255, 210, 90, 0.45);
}

[data-layout-panel].layout-animate {
    transition: left 0.35s ease, top 0.35s ease;
}

#connection-status-wrap {
    position: relative;
    pointer-events: auto;
}

#view-mode-wrap {
    position: relative;
    pointer-events: auto;
}

#version-text {
    opacity: 0.6;
}

#version-coords {
    opacity: 0.75;
}

#version-username {
    opacity: 0.82;
}

#version-view-mode {
    opacity: 0.9;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 136, 255, 0.4);
    background: rgba(0, 136, 255, 0.15);
    color: rgba(140, 200, 255, 0.95);
}

#version-overlay #connection-status {
    padding: 6px 10px;
    margin-bottom: 0;
    font-size: 11px;
    line-height: 1;
    color: #ffffff;
    background: rgba(255, 0, 0, 0.3);
    border: 1px solid rgba(255, 0, 0, 0.5);
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.2);
    opacity: 0.95;
}

#connection-status-details {
    position: fixed;
    min-width: 210px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(10, 14, 18, 0.92);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(6px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 1500;
}

#connection-status-details.visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
}

#version-view-mode-selector {
    position: fixed;
    min-width: 120px;
    padding: 6px;
    border: 1px solid rgba(130, 185, 235, 0.35);
    border-radius: 6px;
    background: rgba(10, 14, 18, 0.92);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(6px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 1500;
}

#version-view-mode-selector.visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
}

.view-mode-option {
    width: 100%;
    padding: 5px 8px;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: rgba(90, 130, 170, 0.12);
    color: rgba(220, 235, 255, 0.95);
    font-family: 'Courier New', monospace;
    font-size: 11px;
    text-align: left;
}

.view-mode-option + .view-mode-option {
    margin-top: 5px;
}

.view-mode-option:hover {
    background: rgba(90, 160, 220, 0.22);
    border-color: rgba(130, 185, 235, 0.45);
}

.view-mode-option.active {
    background: rgba(0, 136, 255, 0.32);
    border-color: rgba(130, 185, 235, 0.7);
}

.connection-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 3px 0;
}

.connection-detail-row .detail-label {
    color: rgba(220, 230, 240, 0.9);
}

.connection-detail-row .detail-value {
    font-weight: 700;
}

.connection-detail-row.healthy .detail-value {
    color: #00ff88;
}

.connection-detail-row.unhealthy .detail-value {
    color: #ff6b6b;
}

#version-overlay #connection-status.disconnecting {
    background: rgba(255, 0, 0, 0.3);
    border-color: rgba(255, 0, 0, 0.5);
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.2);
}

#version-overlay #connection-status.connecting {
    background: rgba(255, 165, 0, 0.3);
    border-color: rgba(255, 165, 0, 0.5);
    box-shadow: 0 0 8px rgba(255, 165, 0, 0.2);
}

#version-overlay #connection-status.connected {
    background: rgba(0, 255, 0, 0.3);
    border-color: rgba(0, 255, 0, 0.5);
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.2);
}

#breadcrumbs {
    position: absolute;
    top: 60px;
    left: 20px;
    display: flex;
    gap: 5px;
    align-items: center;
    font-size: 13px;
    pointer-events: auto;
}

#breadcrumbs.hidden {
    display: none;
}

.breadcrumb {
    padding: 5px 10px;
    background: rgba(0, 136, 255, 0.3);
    border: 1px solid rgba(0, 136, 255, 0.5);
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s;
}

.breadcrumb:hover {
    background: rgba(0, 136, 255, 0.5);
}

.breadcrumb-separator {
    color: rgba(255, 255, 255, 0.5);
}

#loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ff88;
    border-radius: 8px;
    padding: 20px 40px;
    font-size: 16px;
    color: #00ff88;
    text-align: center;
    z-index: 2000;
    display: none;
}

#loading-overlay.visible {
    display: block;
}

#webgl-error-overlay {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.9);
    color: #ff9b9b;
    text-align: center;
    padding: 20px;
}

#webgl-error-overlay.hidden {
    display: none;
}

#webgl-error-overlay .webgl-error-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

#webgl-error-overlay .webgl-error-detail {
    max-width: 780px;
    font-size: 14px;
    color: #ffd9d9;
    line-height: 1.45;
}

#webgl-error-overlay .webgl-error-advice {
    max-width: 780px;
    font-size: 13px;
    color: #d7e8ff;
    line-height: 1.4;
}

#webgl-error-overlay .webgl-error-advice code {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 1px 6px;
}

#disconnected-overlay {
    position: fixed;
    inset: 0;
    z-index: 2100;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #ff6b6b;
    text-align: center;
    pointer-events: auto;
}

#disconnected-overlay.hidden {
    display: none;
}

#disconnected-overlay .disconnected-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#disconnected-overlay .disconnected-detail {
    font-size: 15px;
    color: #ffd2d2;
}

.spinner {
    border: 3px solid rgba(0, 255, 136, 0.3);
    border-top: 3px solid #00ff88;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 10px auto;
}

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

/* Modal styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
}

.modal-content {
    position: relative;
    background: #1a1a1a;
    border: 2px solid #00ff88;
    border-radius: 8px;
    padding: 30px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 10001;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #00ff88;
}

.modal-content input[type="text"],
.modal-content input[type="range"],
.modal-content select {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
}

.modal-content button {
    margin: 10px 5px 0 0;
}

.search-filters {
    display: flex;
    gap: 15px;
    margin: 15px 0;
}

.search-filters label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

#search-results {
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
}

#search-results h3 {
    color: #00ff88;
    margin: 10px 0 5px 0;
}

#search-results ul {
    list-style: none;
    padding: 0;
}

#search-results li {
    padding: 8px 12px;
    margin: 2px 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

#search-results li:hover {
    background: rgba(0, 255, 136, 0.2);
}

.pref-group {
    margin: 15px 0;
}

.pref-group label {
    display: block;
    margin-bottom: 5px;
    color: #00ff88;
}

.pref-group input[type="checkbox"] {
    margin-right: 8px;
}

/* Keyboard shortcut feedback */
.shortcut-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 255, 136, 0.9);
    color: #000;
    padding: 20px 40px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    z-index: 10002;
    animation: shortcutPulse 0.5s ease-in-out;
    pointer-events: none;
}

@keyframes shortcutPulse {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Keyboard shortcuts help overlay */
#shortcuts-help {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a1a1a;
    border: 2px solid #00ff88;
    border-radius: 8px;
    padding: 30px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 10001;
}

#shortcuts-help h2 {
    color: #00ff88;
    margin-bottom: 20px;
}

.shortcut-section {
    margin: 20px 0;
}

.shortcut-section h3 {
    color: #00ff88;
    font-size: 16px;
    margin-bottom: 10px;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.shortcut-key {
    font-family: monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
}

.shortcut-desc {
    color: #ccc;
}

/* Cluster visualization */
.cluster-boundary {
    pointer-events: none;
}

/* Error toast notifications */
.error-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(255, 68, 68, 0.95);
    color: #fff;
    padding: 15px 20px;
    border-radius: 6px;
    border: 2px solid #ff4444;
    max-width: 400px;
    z-index: 10000;
    animation: slideInRight 0.3s ease-out;
}

.success-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(0, 255, 136, 0.95);
    color: #000;
    padding: 15px 20px;
    border-radius: 6px;
    border: 2px solid #00ff88;
    max-width: 400px;
    z-index: 10000;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Settings page badge */
.settings-badge {
    display: inline-block;
    background: #00ff88;
    color: #000;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 5px;
}
