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

:root {
    --bg: #060810;
    --bg2: #0a0e1e;
    --bg3: #0f1428;
    --border: rgba(255, 255, 255, 0.07);
    --gold: #d4a843;
    --red: #e84040;
    --blue: #4a8fd4;
    --green: #3cb87a;
    --orange: #e07820;
    --text: #dde0f5;
    --text-dim: #5a5f80;
    --panel-w: 300px;
    --header-h: 64px;
    --status-h: 46px;
    --radius: 14px;
    /* boundary colours */
    --div-col: #ff4444;
    --conv-col: #4488ff;
    --trans-col: #ffcc00;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ──────────────────────────────── */
.header {
    flex: 0 0 var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    gap: 16px;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo {
    font-size: 28px;
    flex-shrink: 0;
}

h1 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #e8d88a, #60c0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.subtitle {
    font-size: 11px;
    color: var(--text-dim);
}

.view-tabs {
    display: flex;
    gap: 4px;
}

.tab {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 9px;
    padding: 7px 14px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}

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

.tab.active {
    background: rgba(212, 168, 67, 0.15);
    border-color: rgba(212, 168, 67, 0.5);
    color: var(--gold);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.fullscreen-btn,
.theme-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 9px;
    padding: 7px 11px;
    font-size: 16px;
    cursor: pointer;
    transition: all .2s;
}

.fullscreen-btn:hover,
.theme-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}

/* ── Main layout ─────────────────────────── */
.main-wrap {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* ── Map ─────────────────────────────────── */
.map-wrap {
    flex: 1;
    position: relative;
    background: #04081a;
    cursor: crosshair;
}

#mapCanvas,
.overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.overlay-canvas {
    pointer-events: none;
}

.map-tooltip {
    position: absolute;
    background: rgba(10, 14, 30, 0.92);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
    pointer-events: none;
    max-width: 220px;
    z-index: 100;
    backdrop-filter: blur(8px);
    white-space: nowrap;
}

.map-tooltip.hidden {
    display: none;
}

.map-tooltip strong {
    color: var(--gold);
    display: block;
    margin-bottom: 2px;
}

/* ── Side panel ──────────────────────────── */
.side-panel {
    flex: 0 0 var(--panel-w);
    background: var(--bg2);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.side-panel::-webkit-scrollbar {
    width: 4px;
}

.side-panel::-webkit-scrollbar-track {
    background: transparent;
}

.side-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.panel-hint {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
}

.legend-block {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.legend-block h4 {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .7px;
    margin-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.leg-line {
    display: inline-block;
    width: 28px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

.leg-line.divergent {
    background: var(--div-col);
}

.leg-line.convergent {
    background: var(--conv-col);
}

.leg-line.transform {
    background: var(--trans-col);
}

.leg-dot {
    display: inline-block;
    border-radius: 50%;
    flex-shrink: 0;
}

.leg-dot.volcano {
    width: 10px;
    height: 10px;
    background: #ff5500;
    box-shadow: 0 0 6px #ff5500;
}

.leg-dot.eq-large {
    width: 12px;
    height: 12px;
    background: #ff3030;
    opacity: .8;
}

.leg-dot.eq-med {
    width: 8px;
    height: 8px;
    background: #ff8030;
    opacity: .7;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-dim);
    cursor: pointer;
    margin-bottom: 5px;
}

.filter-row input[type=checkbox] {
    accent-color: var(--gold);
}

.mag-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mag-filter select {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 11px;
    font-family: inherit;
}

.history-controls h4 {
    font-size: 11px;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: .6px;
}

.time-display {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
    margin: 6px 0;
}

.time-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 4px;
}

.history-btn-row {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.btn-sm {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 8px;
    padding: 7px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
}

.btn-sm:hover {
    background: rgba(212, 168, 67, 0.15);
    color: var(--gold);
    border-color: rgba(212, 168, 67, 0.4);
}

/* Detail panel */
.back-btn {
    background: none;
    border: none;
    color: var(--gold);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    margin-bottom: 12px;
    display: block;
}

.back-btn:hover {
    color: var(--text);
}

.detail-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.detail-type {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.detail-stat {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}

.detail-stat-label {
    font-size: 9px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 3px;
}

.detail-stat-val {
    font-size: 14px;
    font-weight: 600;
    color: var(--gold);
}

.detail-section-title {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin: 10px 0 6px;
}

.detail-border-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.detail-border-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cross-section-canvas {
    width: 100%;
    border-radius: 8px;
    display: block;
    margin-top: 8px;
}

/* ── Status bar ──────────────────────────── */
.status-bar {
    flex: 0 0 var(--status-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-dim);
    gap: 16px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-play {
    background: linear-gradient(135deg, #c49a30, #7a5e10);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
}

.btn-play:hover {
    transform: translateY(-1px);
}

.btn-play.paused {
    background: linear-gradient(135deg, #3c6080, #1a3050);
}

.speed-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.speed-label {
    white-space: nowrap;
}

#speedVal {
    color: var(--gold);
    min-width: 22px;
}

/* ── Slider ──────────────────────────────── */
.slider {
    -webkit-appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.10);
    border-radius: 2px;
    outline: none;
}

.slider.slim {
    width: 80px;
}

.slider.full-width {
    width: 100%;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(212, 168, 67, 0.6);
}

.hidden {
    display: none !important;
}

/* ── Fullscreen ──────────────────────────── */
:fullscreen .header {
    padding: 0 24px;
}

:fullscreen #app {
    background: var(--bg);
}

/* ── Animations ──────────────────────────── */
@keyframes volcanoPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .6;
        transform: scale(1.4);
    }
}

/* ── Light mode ──────────────────────────── */
.light {
    --bg: #eef1f8;
    --bg2: #e0e5f0;
    --bg3: #d0d8ea;
    --border: rgba(0, 0, 0, 0.09);
    --gold: #84570a;
    --text: #18192e;
    --text-dim: #5a6280;
    --div-col: #cc1111;
    --conv-col: #1155cc;
    --trans-col: #997700;
}

.light body {
    background: var(--bg);
    color: var(--text);
}

.light .app {
    background: var(--bg);
}

.light .header {
    background: var(--bg2);
    border-bottom-color: var(--border);
}

.light h1 {
    background: linear-gradient(135deg, #84570a, #1a508a);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.light .tab {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-dim);
    border-color: var(--border);
}

.light .tab:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text);
}

.light .tab.active {
    background: rgba(132, 87, 10, 0.12);
    border-color: rgba(132, 87, 10, 0.4);
    color: var(--gold);
}

.light .fullscreen-btn,
.light .theme-btn {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--border);
    color: var(--text-dim);
}

.light .fullscreen-btn:hover,
.light .theme-btn:hover {
    background: rgba(0, 0, 0, 0.10);
    color: var(--text);
}

.light .side-panel {
    background: var(--bg2);
    border-left-color: var(--border);
}

.light .legend-block {
    background: var(--bg3);
    border-color: var(--border);
}

.light .map-tooltip {
    background: rgba(230, 235, 248, 0.96);
    border-color: var(--border);
    color: var(--text);
}

.light .map-wrap {
    background: #b8cce4;
}

.light .status-bar {
    background: var(--bg2);
    border-top-color: var(--border);
}

.light .detail-stat {
    background: var(--bg3);
    border-color: var(--border);
}

.light .btn-sm {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--border);
    color: var(--text-dim);
}

.light .btn-sm:hover {
    background: rgba(132, 87, 10, 0.12);
    border-color: rgba(132, 87, 10, 0.4);
    color: var(--gold);
}

.light .slider {
    background: rgba(0, 0, 0, 0.12);
}

.light .mag-filter select {
    background: var(--bg3);
    border-color: var(--border);
    color: var(--text);
}

.light .side-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

/* ── Play button full-width variant (in side panel) ── */
.btn-play.full-btn {
    width: 100%;
    display: block;
    padding: 8px 14px;
    font-size: 12px;
}
/* ── Mode description block ──────────────── */
.mode-desc-block h4 {
    font-size: 11px;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 6px;
}
.mode-desc-text {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.55;
}
.mode-desc-text strong { color: var(--text); }
.mode-desc-text em { font-style: italic; }
