:root {
  --hadal: #05080D;
  --abyss: #0A1320;
  --vent: #FF5A26;
  --sulfur: #E8B838;
  --bio: #1EE6C8;
  --silver: #8FA6B8;
  --line: rgba(143, 166, 184, 0.22);
  --mono: Menlo, Consolas, "SF Mono", "DejaVu Sans Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--hadal);
  color: var(--silver);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#viewport {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(120% 90% at 50% 88%, #0d1a28 0%, var(--abyss) 38%, var(--hadal) 100%);
  cursor: crosshair;
  touch-action: none;
}

#fauna {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stage-note {
  position: fixed;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 2;
  max-width: 360px;
  padding: 22px 26px;
  text-align: center;
  border: 1px solid var(--line);
  background: rgba(10, 19, 32, 0.72);
  border-radius: 4px;
}
.stage-note h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 300;
  letter-spacing: 0.3em;
  color: #EAF2F8;
}
.stage-note p { margin: 0; font-size: 12px; line-height: 1.6; color: var(--silver); }

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(115% 95% at 50% 55%, transparent 42%, rgba(5, 8, 13, 0.72) 100%);
}

.scan {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background: repeating-linear-gradient(to bottom, rgba(143, 166, 184, 0.09) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--silver);
  pointer-events: none;
}
.hud--top { top: 0; }
.hud--bottom { bottom: 0; }

.hud__id { display: flex; align-items: baseline; gap: 8px; }
.hud__tag { color: #EAF2F8; font-weight: 700; letter-spacing: 0.18em; }
.hud__place { color: var(--silver); }
.hud__sep { color: rgba(143, 166, 184, 0.45); }
.hud__meta { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }

.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bio);
  box-shadow: 0 0 8px var(--bio);
  animation: pulse 2.4s ease-in-out infinite;
}
.dot.warn { background: var(--vent); box-shadow: 0 0 8px var(--vent); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.depth {
  position: fixed;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.depth__scale {
  width: 1px;
  height: 210px;
  background: linear-gradient(to bottom, transparent, var(--line) 12%, var(--line) 88%, transparent);
  position: relative;
}
.depth__scale::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, var(--silver) 0 1px, transparent 1px 15px);
  opacity: 0.35;
}
.depth__now { display: flex; flex-direction: column; gap: 4px; }
.depth__label { font-family: var(--sans); font-size: 9px; letter-spacing: 0.3em; color: rgba(143, 166, 184, 0.7); }
.depth__value { font-family: var(--mono); font-size: 20px; color: #EAF2F8; letter-spacing: 0.04em; }
.unit { font-size: 0.62em; color: var(--silver); margin-left: 3px; letter-spacing: 0.08em; }

.readouts {
  position: fixed;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 186px;
  pointer-events: none;
}
.readout { display: flex; flex-direction: column; gap: 5px; }
.readout__k {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.26em;
  color: rgba(143, 166, 184, 0.78);
}
.readout__v {
  font-family: var(--mono);
  font-size: 17px;
  color: #EAF2F8;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.readout__v.hot { color: var(--vent); text-shadow: 0 0 14px rgba(255, 90, 38, 0.45); }
.readout__v.gold { color: var(--sulfur); }
.readout__bar { height: 1px; background: var(--line); position: relative; overflow: hidden; }
.readout__bar i {
  position: absolute; inset: 0 auto 0 0;
  width: 50%;
  background: var(--silver);
  transition: width 220ms linear;
}
.readout__v.hot + .readout__bar i { background: var(--vent); box-shadow: 0 0 10px var(--vent); }
.readout__v.gold + .readout__bar i { background: var(--sulfur); }

.controls {
  position: fixed;
  left: 22px;
  bottom: 46px;
  z-index: 4;
  width: 268px;
  padding: 14px 16px 12px;
  background: rgba(10, 19, 32, 0.62);
  border: 1px solid var(--line);
  border-radius: 4px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.controls__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.28em;
  color: rgba(143, 166, 184, 0.8);
  margin-bottom: 12px;
}

.ghost {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--silver);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 10px;
  min-height: 32px;
  min-width: 32px;
  cursor: pointer;
  transition: color 160ms, border-color 160ms, background 160ms;
}
.ghost:hover { color: #EAF2F8; border-color: rgba(30, 230, 200, 0.6); }
.ghost:focus-visible { outline: 2px solid var(--bio); outline-offset: 2px; }

.ctl {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 8px;
  margin-bottom: 10px;
}
.ctl label {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: rgba(143, 166, 184, 0.85);
}
.ctl output {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--bio);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  grid-column: 1 / -1;
  width: 100%;
  height: 32px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--vent) 0%, var(--sulfur) 55%, var(--bio) 100%);
  opacity: 0.55;
  border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: linear-gradient(to right, var(--vent), var(--sulfur), var(--bio));
  opacity: 0.55;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  margin-top: -6px;
  border-radius: 50%;
  background: #EAF2F8;
  border: 1px solid var(--abyss);
  box-shadow: 0 0 10px rgba(30, 230, 200, 0.55);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #EAF2F8;
  border: 1px solid var(--abyss);
  box-shadow: 0 0 10px rgba(30, 230, 200, 0.55);
}
input[type="range"]:focus-visible { outline: 2px solid var(--bio); outline-offset: 4px; border-radius: 2px; }

.hint {
  margin: 2px 0 0;
  font-family: var(--sans);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: rgba(143, 166, 184, 0.62);
}

.hud__chain, .hud__render { display: flex; gap: 8px; font-variant-numeric: tabular-nums; }
.hud__render { color: rgba(143, 166, 184, 0.55); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 8px);
  z-index: 6;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--bio);
  padding: 8px 14px;
  border: 1px solid rgba(30, 230, 200, 0.35);
  background: rgba(5, 8, 13, 0.8);
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms, transform 220ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .readouts { width: 140px; gap: 12px; right: 14px; }
  .readout__v { font-size: 14px; }
  .depth { left: 14px; }
  .depth__scale { height: 150px; }
  .hud { padding: 12px 14px; font-size: 9px; letter-spacing: 0.1em; }
  .hud__meta #fps { display: none; }
}

@media (max-width: 640px) {
  .readouts {
    top: auto;
    bottom: 300px;
    transform: none;
    right: 14px;
    width: 128px;
    gap: 10px;
  }
  .readout__k { font-size: 8px; letter-spacing: 0.16em; }
  .readout__v { font-size: 13px; }
  .depth { display: none; }
  .controls {
    left: 12px;
    right: 12px;
    bottom: 40px;
    width: auto;
    padding: 12px 14px 10px;
  }
  .hud--bottom { font-size: 8px; padding: 10px 14px; }
  .hud__render { display: none; }
  .toast { bottom: 250px; }
}

@media (prefers-reduced-motion: reduce) {
  .dot { animation: none; }
  .toast { transition: none; }
}


/* kc-contrast-resolver: one ink block, measured fg vs painted ground (S57); rewritten in place, never stacked */
/* k=light|*|div#render-mode.hud__render */ @media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) div#render-mode.hud__render { color: rgb(255, 255, 255) !important; } }
/* kc-contrast-resolver end */
