:root {
  --bg-1: #04101f;
  --bg-2: #0d2446;
  --bg-3: #1b3f6b;
  --panel: rgba(7, 20, 39, 0.76);
  --line: rgba(121, 207, 255, 0.26);
  --text: #ecf7ff;
  --muted: #9fc4df;
  --accent: #ffd166;
  --accent-2: #63d7ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

body {
  background:
    radial-gradient(circle at 18% 18%, rgba(99, 215, 255, 0.18), transparent 24%),
    radial-gradient(circle at 82% 14%, rgba(255, 209, 102, 0.14), transparent 20%),
    radial-gradient(circle at 50% 100%, rgba(61, 107, 181, 0.3), transparent 38%),
    linear-gradient(180deg, var(--bg-3), var(--bg-2) 42%, var(--bg-1) 100%);
  overflow: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 10% 20%, rgba(255, 255, 255, 0.75), transparent),
    radial-gradient(1.5px 1.5px at 70% 30%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 30% 70%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(2px 2px at 80% 80%, rgba(255, 255, 255, 0.5), transparent);
  opacity: 0.3;
  pointer-events: none;
}

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(120px, 1fr);
  grid-template-areas:
    "topbar"
    "canvas";
  gap: 8px;
  padding: 8px;
}

.panel {
  background: linear-gradient(180deg, rgba(10, 28, 52, 0.82), var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.topbar {
  grid-area: topbar;
  padding: 5px 10px;
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 6px;
  align-items: start;
}

.topbar-head {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.0rem;
  letter-spacing: 0.04em;
}

.timestamp {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.head-actions #resetViewButton {
  width: auto;
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 7px;
}

.top-controls {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1.4fr) minmax(140px, 1fr);
  gap: 6px;
  min-width: 0;
  align-items: start;
}

.control-group {
  display: grid;
  gap: 3px;
}

.control-group.compact {
  align-content: start;
}

.filter-grid {
  display: grid;
  gap: 4px;
}

.vessel-group {
  padding-top: 4px;
  border-top: 1px solid rgba(201, 224, 255, 0.12);
}

#vesselTypeFilter {
  border: 1px solid rgba(201, 224, 255, 0.18);
  border-radius: 4px;
  padding: 3px 8px 4px;
  margin: 0;
  min-height: 0;
  max-height: 100px;
  overflow-y: auto;
}

#vesselTypeFilter legend {
  font-size: 0.75rem;
  color: rgba(201, 224, 255, 0.55);
  padding: 0 4px;
}

.type-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 10px;
}

.type-checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selection-panel {
  overflow-y: auto;
  max-height: 120px;
  padding: 0 0 2px 8px;
  border-left: 1px solid rgba(99, 215, 255, 0.14);
  min-width: 0;
}

.selection-heading {
  margin: 0 0 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-2);
}

#infoContent {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.canvas-wrap {
  grid-area: canvas;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(99, 215, 255, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(6, 18, 35, 0.35), rgba(2, 7, 16, 0.78));
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
}

.debug-toggle {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 120px;
  z-index: 100;
  font-size: 0.85rem;
}

.debug-panel {
  position: fixed;
  bottom: 60px;
  right: 12px;
  width: 400px;
  max-height: 400px;
  background: linear-gradient(180deg, rgba(10, 28, 52, 0.95), rgba(7, 20, 39, 0.95));
  border: 1px solid rgba(99, 215, 255, 0.24);
  border-radius: 12px;
  padding: 12px;
  overflow: auto;
  display: none;
  z-index: 100;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

.debug-panel.visible {
  display: block;
}

.debug-panel h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--accent-2);
  border-bottom: 1px solid rgba(99, 215, 255, 0.16);
  padding-bottom: 6px;
}

.debug-section {
  margin-bottom: 12px;
  font-size: 0.8rem;
}

.debug-item {
  margin: 4px 0;
  padding: 4px 0;
  border-bottom: 1px solid rgba(201, 224, 255, 0.08);
  color: var(--muted);
  word-break: break-all;
}

.debug-item strong {
  color: var(--text);
}

button {
  width: 100%;
  color: var(--text);
  background: linear-gradient(180deg, rgba(18, 43, 72, 0.88), rgba(11, 27, 46, 0.88));
  border: 1px solid rgba(99, 215, 255, 0.24);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.78rem;
}

select {
  width: 100%;
  color: var(--text);
  background: #0b1e38;
  border: 1px solid rgba(99, 215, 255, 0.24);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.78rem;
}

select option {
  background: #0b1e38;
  color: var(--text);
}

button {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease;
}

button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.2), 0 10px 24px rgba(15, 35, 58, 0.35);
  transform: translateY(-1px);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

#vesselTooltip {
  position: fixed;
  background: rgba(4, 14, 30, 0.9);
  border: 1px solid rgba(99, 215, 255, 0.32);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 0.78rem;
  color: var(--text);
  pointer-events: none;
  display: none;
  z-index: 50;
  white-space: pre-line;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  min-width: 180px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "topbar"
      "canvas";
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .top-controls {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    min-height: 48vh;
  }

  .debug-panel {
    width: calc(100% - 24px);
    left: 12px;
    right: 12px;
    bottom: auto;
    top: auto;
    max-height: 240px;
  }
}
