:root {
  color-scheme: dark;
  --ink: #14252c;
  --paper: #e3decb;
  --muted: #8caaa9;
  --line: #33464b;
  --accent: #cfb387;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  background: var(--ink);
  color: var(--paper);
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
body {
  overscroll-behavior: none;
}
main {
  width: min(100%, 1400px);
  height: 100%;
  margin: auto;
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
}
a {
  color: inherit;
  text-decoration: none;
}
[hidden] {
  display: none !important;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  min-height: 28px;
}
.location {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--paper);
}
.location-dot {
  width: 5px;
  height: 5px;
  border: 1px solid var(--accent);
  transform: rotate(45deg);
  flex-shrink: 0;
}
.coordinates {
  color: var(--muted);
  margin-left: 8px;
  font-size: 10px;
}
.header-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: #b3c3bb;
  text-align: right;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 62%;
  line-height: 1.45;
}
.hud-sep {
  color: #57706f;
}

.scene {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  box-shadow: 0 16px 48px #09161d55;
}
.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: #344c60;
  isolation: isolate;
  cursor: pointer;
}
.stage-wrap canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#fg {
  pointer-events: none;
}

.scene-caption {
  min-height: 44px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #172a31;
  font-size: 11px;
  flex-shrink: 0;
}
.live {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.live > span:first-child {
  width: 5px;
  height: 5px;
  background: #8ebcac;
  box-shadow: 0 0 7px #8ebcac30;
  flex-shrink: 0;
}
.live > span.manual:first-child {
  background: var(--accent);
}
#time-mode {
  color: var(--muted);
  white-space: nowrap;
}
#clock {
  font-size: 14px;
  letter-spacing: 0.04em;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#panel-toggle {
  background: none;
  border: 0;
  color: var(--muted);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin: -4px -6px -4px 0;
}
#panel-toggle:hover {
  color: var(--paper);
}

.outfit-controls {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  background: #172a31;
  flex-shrink: 0;
}
#outfit-btn {
  background: none;
  color: var(--paper);
  border: 1px solid #607675;
  padding: 8px 12px;
  font-size: 11px;
  min-height: 36px;
}
#outfit-btn:hover {
  background: #263f46;
}

#panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 18, 0.62);
  z-index: 30;
  backdrop-filter: blur(3px);
}
#panel {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 24px));
  max-height: min(85vh, 560px);
  overflow: auto;
  border: 1px solid var(--line);
  padding: 20px 18px;
  background: #182b32;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  border-radius: 8px;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
#panel-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  width: 36px;
  height: 36px;
}
#panel-close:hover {
  color: var(--paper);
}
h2 {
  font-family: Georgia, serif;
  font-size: 19px;
  font-weight: 400;
  margin: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}
label {
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: #bdcbc2;
}
.row {
  align-self: center;
  flex-wrap: nowrap;
  min-height: 34px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  min-height: 24px;
  margin: 0;
}
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
input[type="date"] {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 8px;
  font-size: 12px;
}
output {
  margin-left: auto;
  color: var(--accent);
}
#metrics,
#moon-info {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
  margin: 16px 0 0;
}

.sound-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 36px;
  color: var(--muted);
  font-size: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
#sound-toggle {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
  padding: 8px 12px;
  min-height: 36px;
  font-size: 11px;
  min-width: 130px;
  text-align: left;
}
#sound-toggle:hover,
#sound-toggle[aria-pressed="true"] {
  border-color: #75938e;
  background: #1b333a;
}
.sound-controls label {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  font-size: 10px;
}
.sound-controls input[type="range"] {
  width: 72px;
  min-height: 24px;
}
#sound-status {
  margin-right: auto;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.no-script {
  padding: 24px;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  main {
    padding: 8px 10px 10px;
    gap: 6px;
  }
  .masthead {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .header-hud {
    max-width: 100%;
    justify-content: flex-start;
    text-align: left;
    font-size: 9px;
  }
  .coordinates {
    display: none;
  }
  .scene-caption {
    padding: 8px 10px;
    min-height: 40px;
  }
  #clock {
    font-size: 13px;
  }
  .sound-controls {
    gap: 8px 12px;
  }
  .sound-controls #sound-status {
    width: 100%;
    margin: 0;
    order: 3;
  }
  .sound-controls label {
    flex: 1;
    min-width: 120px;
  }
  .sound-controls input[type="range"] {
    flex: 1;
    width: auto;
    min-width: 48px;
  }
  #panel {
    top: auto;
    bottom: 0;
    transform: translateX(-50%);
    width: 100vw;
    max-height: 78vh;
    border-radius: 12px 12px 0 0;
  }
}

