:root {
  --bg: #05070c;
  --panel: rgba(12, 15, 24, 0.88);
  --panel-2: rgba(10, 13, 20, 0.74);
  --text: #e8eefc;
  --muted: rgba(232, 238, 252, 0.72);
  --soft: rgba(232, 238, 252, 0.52);
  --accent: #6ee7ff;
  --accent-2: #9b7bff;
  --danger: #ff4d7d;
  --ok: #7dff9b;
  --line: rgba(255, 255, 255, 0.09);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(1200px 800px at 20% 15%, rgba(110, 231, 255, 0.12), transparent 55%),
    radial-gradient(1000px 700px at 90% 30%, rgba(155, 123, 255, 0.10), transparent 55%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 14px;
  min-height: 100vh;
  padding: 14px;
}

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  box-shadow: var(--shadow);
}

.map-card {
  display: grid;
  grid-template-rows: auto minmax(520px, 1fr) auto;
}

.topbar,
.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.22);
}

.topbar {
  border-bottom: 1px solid var(--line);
}

.map-footer {
  align-items: flex-start;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.map-footer p {
  margin: 0;
}

.title-block {
  display: grid;
  gap: 3px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(16px, 2vw, 22px);
  letter-spacing: 0.01em;
}

h2 {
  margin-bottom: 10px;
  color: rgba(232, 238, 252, 0.92);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.status-badge {
  flex: 0 0 auto;
  max-width: 220px;
  padding: 6px 10px;
  overflow: hidden;
  border: 1px solid rgba(110, 231, 255, 0.25);
  border-radius: 999px;
  background: rgba(110, 231, 255, 0.10);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge[data-tone="ok"] {
  border-color: rgba(125, 255, 155, 0.25);
  background: rgba(125, 255, 155, 0.10);
}

.status-badge[data-tone="warn"] {
  border-color: rgba(255, 77, 125, 0.30);
  background: rgba(255, 77, 125, 0.12);
}

.canvas-wrap {
  position: relative;
  min-height: 520px;
  background: #000;
}

.map-visual {
  position: absolute;
  inset: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#overlayCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(420px, calc(100% - 24px));
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(10px);
}

.kpi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

.kpi-grid b {
  color: var(--text);
  font-weight: 650;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.swatch-flood {
  background: rgba(110, 231, 255, 0.55);
}

.swatch-storm {
  background: rgba(255, 77, 125, 0.55);
}

.panel {
  padding: 14px;
}

.panel-section + .panel-section {
  margin-top: 18px;
}

.box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

select,
input[type="number"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.timeline-control {
  margin-bottom: 12px;
}

.timeline-control b {
  color: var(--text);
  font-weight: 650;
}

input[aria-invalid="true"] {
  border-color: rgba(255, 77, 125, 0.65);
}

input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.toggle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 12px 0;
}

.toggle {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.toggle input {
  transform: scale(1.1);
}

details {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.26);
}

summary {
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

.details-grid {
  margin-top: 10px;
}

.hint,
.warning,
.edu p,
.edu li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.hint {
  margin: 10px 0 0;
}

.warning {
  min-height: 18px;
  margin: 0 0 10px;
  color: var(--danger);
}

.edu p:last-child,
.edu ul:last-child {
  margin-bottom: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(110, 231, 255, 0.10);
  color: var(--text);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  font-size: 12px;
}

button.secondary {
  background: rgba(155, 123, 255, 0.10);
}

button.ghost {
  background: rgba(255, 255, 255, 0.05);
}

button:active {
  transform: translateY(1px);
}

.mini {
  overflow: auto;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  color: rgba(232, 238, 252, 0.78);
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    min-height: 100vh;
  }

  .map-card {
    grid-template-rows: auto minmax(420px, 62vh) auto;
  }

  .canvas-wrap {
    min-height: 420px;
  }
}

@media (max-width: 620px) {
  .app {
    padding: 8px;
  }

  .topbar,
  .map-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .hud {
    right: 8px;
    left: 8px;
    bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
