:root {
  color-scheme: dark;
  --ink: #ecf8ee;
  --muted: #9bb9aa;
  --deep: #041314;
  --panel: rgba(4, 22, 22, 0.82);
  --line: rgba(168, 228, 185, 0.2);
  --leaf: #8ed15d;
  --water: #4dc5c3;
  --gold: #f1bd56;
  --danger: #f07b6e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--deep);
  color: var(--ink);
}

body {
  background:
    radial-gradient(circle at 15% 10%, rgba(63, 160, 127, 0.18), transparent 34rem),
    #020a0c;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  height: 100%;
}

.brand-bar {
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 12, 13, 0.92);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0;
  color: var(--leaf);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.28em;
}

h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  font-weight: 500;
}

.connection-pill {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.78rem;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px currentColor;
}

.connection-pill[data-state="connected"] .connection-dot {
  background: var(--leaf);
}

.connection-pill[data-state="disconnected"] .connection-dot {
  background: var(--danger);
}

.viewer {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#aquarium-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.loading-panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  background: rgba(2, 12, 13, 0.86);
  transition: opacity 250ms ease;
}

.loading-panel[hidden] {
  display: none;
}

.loading-mark {
  color: var(--water);
  font-size: 3rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hud-panel {
  position: absolute;
  z-index: 3;
  width: min(260px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(14px);
}

.telemetry-panel {
  top: 16px;
  left: 16px;
}

.creature-panel {
  top: 16px;
  right: 16px;
}

.performance-panel {
  bottom: 104px;
  left: 16px;
  width: min(290px, calc(100vw - 32px));
}

.performance-panel[hidden] {
  display: none;
}

.performance-panel dl {
  max-height: min(38vh, 330px);
  overflow: auto;
}

#profile-download {
  width: 100%;
  min-height: 36px;
  margin-top: 12px;
  border: 1px solid rgba(77, 197, 195, 0.34);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(77, 197, 195, 0.12);
  cursor: pointer;
}

#profile-download:hover {
  background: rgba(77, 197, 195, 0.22);
}

.panel-label {
  margin: 0 0 10px;
  color: var(--water);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.hud-panel h2 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  font-weight: 500;
}

dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

dl div,
.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

dt,
.metric span {
  color: var(--muted);
  font-size: 0.78rem;
}

dd {
  margin: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.metric {
  margin-top: 9px;
}

progress {
  width: 110px;
  height: 8px;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.09);
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--water), var(--leaf));
}

progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--water), var(--leaf));
}

.intervention-bar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  width: min(720px, calc(100vw - 32px));
  padding: 10px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(3, 18, 18, 0.88);
  backdrop-filter: blur(16px);
}

.intervention-bar button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(142, 209, 93, 0.32);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(142, 209, 93, 0.1);
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.intervention-bar button:hover {
  background: rgba(142, 209, 93, 0.2);
  transform: translateY(-1px);
}

.intervention-bar button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

#command-status {
  flex-basis: 100%;
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

footer {
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 24px;
  border-top: 1px solid var(--line);
  color: #779589;
  background: rgba(2, 12, 13, 0.96);
  font-size: 0.65rem;
}

@media (max-width: 720px) {
  .brand-bar {
    min-height: 64px;
    padding: 9px 14px;
  }

  .connection-pill {
    padding: 7px 9px;
  }

  .hud-panel {
    width: 190px;
    padding: 11px;
  }

  .telemetry-panel {
    top: 10px;
    left: 10px;
  }

  .creature-panel {
    top: 10px;
    right: 10px;
  }

  .performance-panel {
    bottom: 108px;
    left: 10px;
    width: 210px;
  }

  .creature-panel h2,
  .metric span {
    display: none;
  }

  progress {
    width: 100%;
  }

  footer span:last-child {
    display: none;
  }
}
