:root {
  --bg: #0a0f1e;
  --panel: rgba(13, 20, 38, 0.78);
  --panel-border: rgba(127, 212, 255, 0.14);
  --text: #e8eef7;
  --text-dim: #9db0c8;
  --accent: #7fd4ff;
  --accent-strong: #35b6ff;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overscroll-behavior: none;
}

.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#map.dragging { cursor: grabbing; }

.glass {
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------------- loader ---------------- */

#loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  z-index: 50;
  transition: opacity 0.5s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
#loader svg { animation: spin 7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loader-text { color: var(--text-dim); letter-spacing: 0.04em; }
#loader-bar {
  width: 220px; height: 4px; border-radius: 2px;
  background: rgba(127, 212, 255, 0.15);
  overflow: hidden;
}
#loader-fill {
  width: 0%; height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width 0.2s ease;
}

/* ---------------- control panel ---------------- */

#panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 308px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  z-index: 20;
  overflow: hidden auto;
  scrollbar-width: thin;
  user-select: none;
}

#panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px 11px;
}
#panel-head h1 { font-size: 17px; font-weight: 650; letter-spacing: 0.02em; }
#tagline { font-size: 11.5px; color: var(--text-dim); margin-top: 1px; }
#collapse { margin-left: auto; transition: transform 0.25s ease; }
#panel.collapsed #collapse { transform: rotate(180deg); }
#panel.collapsed #panel-body { display: none; }

#panel-body { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 12px; }

.ctl {
  border-top: 1px solid rgba(127, 212, 255, 0.09);
  padding-top: 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ctl-row { display: flex; align-items: center; gap: 9px; }
.ctl-row label { color: var(--text-dim); font-size: 12.5px; flex: 1; }
#sea-value { font-size: 15px; font-weight: 600; color: var(--accent); }

input[type="range"] {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, #2fbf71 0%, #7fd4ff 50%, #123e77 100%);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: #eaf6ff;
  border: 2.5px solid var(--accent-strong);
  box-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #eaf6ff;
  border: 2.5px solid var(--accent-strong);
}

input[type="number"] {
  width: 64px;
  background: rgba(9, 14, 28, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 5px 7px;
  font: inherit;
}
input[type="number"]:focus { outline: 1px solid var(--accent-strong); }

select {
  background: rgba(9, 14, 28, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 5px 8px;
  font: inherit;
  cursor: pointer;
}

#sea-scale-row { margin-top: -5px; }
.scale-spacer-l { width: 30px; flex: none; }
.scale-spacer-r { width: 64px; flex: none; }
#sea-scale { flex: 1; position: relative; height: 15px; }
#sea-scale .tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 5px;
  background: rgba(127, 212, 255, 0.35);
}
#sea-scale .tick.zero { height: 8px; background: rgba(127, 212, 255, 0.8); }
#sea-scale b {
  position: absolute;
  top: 5px;
  font-size: 9px;
  font-weight: 400;
  color: var(--text-dim);
  opacity: 0.8;
  letter-spacing: 0.02em;
}

.presets { display: flex; gap: 7px; }
.preset {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 4px;
  background: rgba(127, 212, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.preset:hover { background: rgba(127, 212, 255, 0.16); }
.preset.active { background: rgba(53, 182, 255, 0.25); border-color: var(--accent-strong); }
.preset b { font-size: 13px; }
.preset span { font-size: 10.5px; color: var(--text-dim); }

.toggles { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
}
.toggle input { accent-color: var(--accent-strong); width: 14px; height: 14px; cursor: pointer; }

#panel-foot {
  display: flex;
  gap: 7px;
  border-top: 1px solid rgba(127, 212, 255, 0.09);
  padding-top: 11px;
}
#lang {
  border-radius: 999px;
  font-size: 12px;
  padding: 5px 8px;
  max-width: 118px;
  flex: none;
}

/* numeric scale keeps a fixed low-to-high direction even in RTL locales */
#sea-slider, #sea-scale-row, .presets { direction: ltr; }
#sea-value, #readout { direction: ltr; unicode-bidi: isolate; }
.chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(127, 212, 255, 0.07);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.chip:hover { background: rgba(127, 212, 255, 0.16); }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(127, 212, 255, 0.07);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  flex: none;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(127, 212, 255, 0.18); }

/* ---------------- readout & zoom ---------------- */

#readout {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 20;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-dim);
  pointer-events: none;
  white-space: nowrap;
}
#readout b { color: var(--text); font-weight: 600; }

#zoomctl {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 5px;
  gap: 5px;
}
#zoomctl .icon-btn { width: 34px; height: 34px; font-size: 17px; }

/* ---------------- about overlay ---------------- */

#about {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 7, 14, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#about[hidden] { display: none; }
#about-card {
  position: relative;
  max-width: 640px;
  max-height: min(82vh, 720px);
  overflow-y: auto;
  padding: 26px 30px;
  scrollbar-width: thin;
  line-height: 1.62;
}
#about-close { position: sticky; top: 0; float: right; margin: -6px -10px 0 12px; }
#about-card h2 { font-size: 20px; margin-bottom: 10px; }
#about-card h3 { font-size: 15px; margin: 18px 0 7px; color: var(--accent); }
#about-card p, #about-card dd { color: var(--text-dim); margin-bottom: 8px; }
#about-card ul { padding-left: 20px; color: var(--text-dim); }
#about-card li { margin-bottom: 5px; }
#about-card dt { font-weight: 600; margin-top: 10px; }
#about-card a { color: var(--accent); }
#about-card article[hidden] { display: none; }

/* ---------------- misc ---------------- */

#webgl-error {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  max-width: 420px;
  padding: 26px 30px;
  text-align: center;
}
#webgl-error h2 { margin-bottom: 10px; }
#webgl-error p { color: var(--text-dim); line-height: 1.6; }

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  padding: 12vh 8vw;
  line-height: 1.7;
}
.noscript h1 { font-size: 22px; margin-bottom: 14px; }
.noscript a { color: var(--accent); }

@media (max-width: 560px) {
  #panel { top: 10px; left: 10px; width: calc(100vw - 20px); }
  #readout { display: none; }
  #zoomctl { right: 10px; bottom: 10px; }
}
