:root {
    --bg-color: #050505;
    --panel-bg: #0f0f0f;
    --border-color: #333;
    --primary-color: #00ffcc;
    /* Cyan */
    --accent-color: #ff0055;
    /* Red/Pink */
    --secondary-color: #0088ff;
    /* Blue */
    --text-main: #e0e0e0;
    --text-dim: #666;

    --font-head: 'Orbitron', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
    --font-body: 'Noto Sans KR', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
    /* App feel */
    background-image:
        radial-gradient(circle at 50% 50%, #111 0%, #000 100%),
        linear-gradient(rgba(0, 255, 204, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 204, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 20px 20px, 20px 20px;
}

.hud-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 10px;
}

/* Header */
.hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 2px solid var(--primary-color);
    background: rgba(0, 20, 20, 0.8);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.2);
}

.header-title h1 {
    font-family: var(--font-head);
    font-size: 1.8rem;
    margin: 0;
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-color);
    letter-spacing: 2px;
}

.brand-sub {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--secondary-color);
    display: block;
    letter-spacing: 4px;
    margin-bottom: 5px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.control-group label {
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.hud-input {
    background: #000;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 5px;
    width: 80px;
    font-family: var(--font-mono);
    text-align: center;
    font-size: 1rem;
    outline: none;
}

select {
    background: #000;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 5px;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: bold;
    outline: none;
    cursor: pointer;
    width: 140px;
}

select:hover {
    background: rgba(0, 255, 204, 0.1);
}

/* Main Layout */
.hud-main {
    display: flex;
    flex: 1;
    gap: 20px;
    padding: 20px;
    overflow: hidden;
}

.panel {
    background: rgba(15, 15, 15, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.panel::before {
    /* Corner accent */
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    width: 20px;
    height: 20px;
    border-top: 2px solid var(--primary-color);
    border-left: 2px solid var(--primary-color);
}

.panel::after {
    /* Corner accent */
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    border-bottom: 2px solid var(--primary-color);
    border-right: 2px solid var(--primary-color);
}

.panel-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 15px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 1px;
}

/* Left Panel */
.left-panel {
    flex: 0 0 450px;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
}

.status-display {
    text-align: center;
    margin-top: 10px;
}

.bon-text {
    font-family: var(--font-head);
    color: var(--secondary-color);
    font-size: 1.2rem;
    margin-bottom: 5px;
    letter-spacing: 2px;
    text-shadow: 0 0 5px var(--secondary-color);
}

.digital-text {
    font-family: var(--font-mono);
}

.time-lg {
    font-size: 2.5rem;
    color: var(--text-main);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.sub-info {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-top: 5px;
}

.compass-wrapper {
    position: relative;
    margin: 10px 0;
    width: 360px;
    height: 360px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.compass-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px dashed rgba(0, 255, 204, 0.3);
    animation: spin 60s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

canvas {
    z-index: 2;
}

.result-box {
    width: 100%;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--primary-color);
    padding: 15px;
    text-align: center;
    box-shadow: inset 0 0 20px rgba(0, 255, 204, 0.1);
}

.result-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.result-value {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
}

.result-desc {
    color: var(--text-main);
    font-size: 1rem;
    margin-top: 5px;
}

/* Right Panel - Timeline */
.right-panel {
    flex: 1;
    overflow: hidden;
}

.timeline-controls {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    justify-content: flex-end;
}

.hud-btn {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
    padding: 5px 15px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.2s;
}

.hud-btn.active,
.hud-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(0, 255, 204, 0.1);
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.2);
}

.timeline-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.timeline-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid #222;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all 0.2s;
}

.timeline-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(5px);
}

.timeline-item.active-preview {
    border-color: var(--accent-color);
    background: rgba(255, 0, 85, 0.1);
}

.timeline-item.highlighted {
    border-left: 4px solid var(--primary-color);
    background: rgba(0, 255, 204, 0.05);
}

.t-time {
    font-family: var(--font-mono);
    color: var(--text-dim);
    width: 60px;
}

.t-ganzhi {
    color: var(--text-main);
    width: 80px;
    font-weight: bold;
}

.t-dir {
    color: var(--primary-color);
    width: 80px;
}

.t-god {
    color: var(--accent-color);
    font-weight: bold;
    text-align: right;
    flex: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #000;
}

::-webkit-scrollbar-thumb {
    background: #333;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Footer */
.hud-footer {
    display: flex;
    gap: 20px;
    padding: 5px 10px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: #444;
    border-top: 1px solid #222;
}

/* Responsiveness */
@media (max-width: 900px) {
    .hud-main {
        flex-direction: column;
        overflow-y: auto;
    }

    .left-panel {
        flex: none;
        width: 100%;
    }

    .right-panel {
        flex: none;
        height: 400px;
    }

    body {
        overflow: auto;
    }
}

/* Legend Styles */
.gate-legend {
    width: 100%;
    margin-top: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* Align to top for multi-line */
    padding: 8px 0;
    border-bottom: 1px dashed #333;
    color: #888;
}

.legend-item:last-child {
    border-bottom: none;
}

.legend-icon {
    width: 25px;
    /* Slightly more space */
    padding-top: 2px;
}

.legend-name {
    color: var(--text-main);
    width: 70px;
    /* More width for name */
    font-weight: bold;
    padding-top: 2px;
}

.legend-desc {
    flex: 1;
    color: #999;
    text-align: left;
    /* Better for multi-line */
    font-size: 0.75rem;
    line-height: 1.4;
    padding-left: 10px;

    /* 2-Line Clamp Logic */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}

/* Save Button Toast */
.toast-msg {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: #000;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

.toast-msg.show {
    opacity: 1;
}