body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000510;
    color: white;
    /* Deep dark blue */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#star-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* #ui-overlay removed */

h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
}

#status-text {
    margin-top: 5px;
    font-size: 0.9rem;
    opacity: 0.7;
}

#location-modal,
#help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    /* Dim background */
    z-index: 100;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: rgba(20, 30, 50, 0.9);
    border: 1px solid rgba(100, 200, 255, 0.3);
    padding: 20px;
    border-radius: 8px;
    width: 300px;
    color: white;
    font-family: sans-serif;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Info Lists in Side Menu */
#events-list,
#highlights-list {
    font-size: 0.85rem;
    color: #ccc;
}

#events-list>div,
#highlights-list>div {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#events-list>div:last-child,
#highlights-list>div:last-child {
    border-bottom: none;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #aaa;
}

.close-btn:hover {
    color: white;
}

h2 {
    margin-top: 0;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

ul {
    padding-left: 20px;
    line-height: 1.6;
}

/* Chat Panel Styles */
#chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    height: 100%;
    background: rgba(10, 20, 40, 0.95);
    border-left: 1px solid rgba(100, 150, 255, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform 0.3s ease;
    backdrop-filter: blur(10px);
}

.chat-panel-closed {
    transform: translateX(100%);
}

.chat-panel-open {
    transform: translateX(0);
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(50, 80, 150, 0.3);
    border-bottom: 1px solid rgba(100, 150, 255, 0.2);
    font-size: 1.1em;
    font-weight: bold;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95em;
}

.chat-message.user {
    align-self: flex-end;
    background: rgba(100, 150, 255, 0.3);
    border: 1px solid rgba(100, 150, 255, 0.4);
}

.chat-message.ai {
    align-self: flex-start;
    background: rgba(50, 70, 100, 0.5);
    border: 1px solid rgba(100, 150, 255, 0.2);
}

.chat-message.error {
    align-self: center;
    background: rgba(255, 100, 100, 0.3);
    border: 1px solid rgba(255, 100, 100, 0.5);
    color: #ffaaaa;
}

.chat-message.loading {
    align-self: flex-start;
    background: rgba(50, 70, 100, 0.3);
    color: #aaa;
    font-style: italic;
}

#chat-input-area {
    display: flex;
    gap: 8px;
    padding: 15px;
    background: rgba(30, 50, 80, 0.5);
    border-top: 1px solid rgba(100, 150, 255, 0.2);
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(100, 150, 255, 0.3);
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.95em;
}

#btn-now,
#btn-play-pause {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#chat-input:focus {
    outline: none;
    border-color: rgba(100, 150, 255, 0.6);
}

#chat-send-btn {
    background: rgba(100, 150, 255, 0.4);
    border: 1px solid rgba(100, 150, 255, 0.5);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

#chat-send-btn:hover {
    background: rgba(100, 150, 255, 0.6);
}

#chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* Moon Phase Panel - Top Right */
#moon-phase-panel {
    position: absolute;
    top: 20px;
    right: 70px;
    /* Left of the settings gear (which is at right: 20px, ~30px wide) */
    background: rgba(10, 20, 30, 0.6);
    border: 1px solid rgba(255, 220, 100, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    color: white;
    pointer-events: none;
    display: flex;
    align-items: center;
    backdrop-filter: blur(4px);
}

/* Side Menu */
#side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    max-height: 100vh;
    background: rgba(10, 20, 30, 0.95);
    border-right: 1px solid rgba(100, 150, 255, 0.2);
    backdrop-filter: blur(10px);
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for side menu */
#side-menu::-webkit-scrollbar {
    width: 6px;
}

#side-menu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

#side-menu::-webkit-scrollbar-thumb {
    background: rgba(100, 150, 255, 0.3);
    border-radius: 3px;
}

#side-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 150, 255, 0.5);
}

.side-menu-closed {
    transform: translateX(-100%);
}

#side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(50, 80, 150, 0.2);
    border-bottom: 1px solid rgba(100, 150, 255, 0.15);
    position: sticky;
    top: 0;
    z-index: 10;
}

#side-menu-header h3 {
    margin: 0;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 1rem;
    color: #add8e6;
}

#menu-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

#menu-close-btn:hover {
    color: white;
}

.menu-section {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.menu-section h4 {
    margin: 0 0 15px 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #6daecc;
    letter-spacing: 1px;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.control-row label {
    color: #ccc;
    font-size: 0.95rem;
}

.control-row input[type="number"] {
    width: 80px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #445566;
    color: white;
    padding: 6px;
    border-radius: 4px;
    text-align: right;
    font-size: 0.95rem;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.toggle-row:hover {
    color: white;
}

#view-mode-select {
    width: 100%;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #445566;
    color: white;
    border-radius: 4px;
    font-size: 0.95rem;
    cursor: pointer;
}

.menu-btn-action {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(100, 150, 255, 0.1);
    border: 1px solid rgba(100, 150, 255, 0.3);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.menu-btn-action:hover {
    background: rgba(100, 150, 255, 0.2);
    border-color: rgba(100, 150, 255, 0.5);
}

/* Refined Bottom Panel */
#bottom-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 15, 25, 0.85);
    border: 1px solid rgba(100, 150, 255, 0.2);
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(5px);
    width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#search-bar {
    display: flex;
    gap: 8px;
}

#search-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #445566;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.95rem;
}

#search-btn {
    padding: 8px 16px;
    background: rgba(100, 200, 255, 0.2);
    border: 1px solid rgba(100, 200, 255, 0.4);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

#time-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: space-between;
}

#date-picker {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #445566;
    color: white;
    padding: 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
}



/* Moon Phase Panel */
#moon-phase-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    background: rgba(10, 20, 30, 0.6);
    border: 1px solid rgba(255, 220, 100, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    color: white;
    pointer-events: none;
    display: flex;
    align-items: center;
    backdrop-filter: blur(4px);
}

#btn-now:hover,
#btn-play-pause:hover {
    background: rgba(255, 255, 255, 0.2);
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.night-mode {
    filter: sepia(100%) hue-rotate(-50deg) saturate(600%) brightness(0.7);
}

/* HUD Panel */
#hud-panel {
    position: absolute;
    top: 60px;
    left: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(100, 200, 255, 0.2);
    padding: 10px;
    border-radius: 6px;
    pointer-events: none;
    /* Let clicks pass through */
    backdrop-filter: blur(2px);
}

#hud-direction {
    font-size: 1.1rem;
    color: #00ffff;
    font-weight: bold;
    margin-bottom: 4px;
}

#hud-coordinates {
    font-size: 0.85rem;
    color: #88ccff;
    font-family: monospace;
}

/* Modal Specifics for Location Map */
#world-map-canvas {
    background: #000810;
    cursor: crosshair;
}

/* Settings Panel */
#settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: rgba(10, 20, 30, 0.95);
    border-left: 1px solid rgba(100, 150, 255, 0.2);
    backdrop-filter: blur(10px);
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.5);
}

.settings-panel-closed {
    transform: translateX(100%);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(50, 80, 150, 0.2);
    border-bottom: 1px solid rgba(100, 150, 255, 0.15);
}

.settings-header h3 {
    margin: 0;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 1rem;
    color: #add8e6;
}

#settings-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

#settings-close-btn:hover {
    color: white;
}

/* Tabs */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid rgba(100, 150, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: #88aadd;
    padding: 12px 0;
    cursor: pointer;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    background: rgba(100, 150, 255, 0.1);
    color: white;
}

.tab-btn.active {
    color: #fff;
    border-bottom: 2px solid #00c8fa;
    background: rgba(100, 150, 255, 0.1);
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#main-settings-btn {
    transition: transform 0.3s ease;
}

#main-settings-btn:hover {
    transform: rotate(90deg);
}

#auto-demo-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(0, 200, 255, 0.8);
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 10px rgba(0, 200, 255, 0.4);
    }

    50% {
        box-shadow: 0 0 20px rgba(0, 200, 255, 0.8);
    }

    100% {
        box-shadow: 0 0 10px rgba(0, 200, 255, 0.4);
    }
}

#auto-demo-btn {
    animation: pulse-glow 2s infinite;
}