:root {
  --night: #07090e;
  --baltic: #0b2744;
  --ice: #7eb6d9;
  --bone: #e8e4d9;
  --rye: #c4a35a;
  --pine: #3d6b5a;
  --root: #a65d57;
  --muted: color-mix(in srgb, var(--bone) 55%, transparent);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--bone);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

#app,
#viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#viewport canvas {
  display: block;
}

.label2d {
  color: var(--bone);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 12px var(--night);
  opacity: 0.9;
}

.label2d.axis {
  font-size: 12px;
  font-weight: 500;
  white-space: normal;
  max-width: 9.5em;
  text-align: center;
  line-height: 1.2;
}

.label2d.tick {
  opacity: 0.55;
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 26px;
  pointer-events: none;
}

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

h1 {
  margin: 0;
  font-family: "Newsreader", "Times New Roman", serif;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--ice) 70%, transparent);
  display: inline-block;
}

.legend {
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}

.swatch.ice {
  background: var(--ice);
  color: var(--ice);
}
.swatch.rye {
  background: var(--rye);
  color: var(--rye);
}
.swatch.pine {
  background: var(--pine);
  color: var(--pine);
}
.swatch.root {
  background: var(--root);
  color: var(--root);
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bucket-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

#bucket,
#reset,
#panel-close {
  pointer-events: auto;
  background: transparent;
  color: var(--bone);
  border: 1px solid color-mix(in srgb, var(--bone) 28%, transparent);
  font: inherit;
  cursor: pointer;
}

#bucket {
  max-width: min(280px, 70vw);
  padding: 8px 10px;
  letter-spacing: 0.04em;
  font-size: 12px;
}

#reset {
  padding: 8px 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
}

#reset:hover,
#panel-close:hover {
  border-color: var(--ice);
  color: var(--ice);
}

#reset:focus-visible,
#panel-close:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
}

#views {
  position: absolute;
  z-index: 4;
  right: 26px;
  bottom: 26px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  pointer-events: auto;
  width: min(240px, calc(100% - 52px));
}

.views-kicker {
  margin: 0 0 2px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.views-kicker span {
  letter-spacing: 0.2em;
  opacity: 0.7;
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--night) 72%, var(--baltic));
  color: var(--bone);
  border: 1px solid color-mix(in srgb, var(--bone) 18%, transparent);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  cursor: pointer;
  text-align: left;
}

.view-btn:hover {
  border-color: var(--ice);
}

.view-btn.active {
  border-color: var(--ice);
  color: var(--ice);
  box-shadow: 0 0 18px color-mix(in srgb, var(--ice) 22%, transparent);
}

.view-btn:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
}

.view-btn .swatch {
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  #views {
    top: 118px;
    right: 12px;
    left: auto;
    bottom: auto;
    width: min(210px, 58vw);
  }

  .view-btn {
    font-size: 10px;
    padding: 7px 8px;
  }
}

#tooltip {
  position: absolute;
  z-index: 4;
  padding: 6px 10px;
  background: color-mix(in srgb, var(--night) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--ice) 35%, transparent);
  font-size: 12px;
  pointer-events: none;
  transform: translate(12px, 12px);
}

#panel {
  position: absolute;
  z-index: 4;
  left: 26px;
  bottom: 26px;
  width: min(340px, calc(100% - 52px));
  padding: 20px 22px 18px;
  background: color-mix(in srgb, var(--night) 78%, var(--baltic));
  border: 1px solid color-mix(in srgb, var(--bone) 16%, transparent);
  box-shadow: 0 18px 50px color-mix(in srgb, var(--night) 70%, transparent);
  backdrop-filter: blur(10px);
}

#panel-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  font-size: 20px;
  line-height: 1;
}

.panel-kicker {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rye);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 8px;
}

#panel-photo {
  width: 56px;
  height: 56px;
  object-fit: cover;
  object-position: center 20%;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ice) 70%, transparent);
  flex: 0 0 auto;
}

#panel-name {
  margin: 0;
  font-family: "Newsreader", "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
}

#panel-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.meters {
  margin: 0;
}

.meters > div {
  margin-bottom: 10px;
}

.meters dt {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.meters dd {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 4px;
  background: color-mix(in srgb, var(--bone) 12%, transparent);
}

.bar i {
  display: block;
  height: 100%;
  width: 0%;
}

.bar i.ice {
  background: var(--ice);
}
.bar i.rye {
  background: var(--rye);
}
.bar i.pine {
  background: var(--pine);
}
.bar i.root {
  background: var(--root);
}

.coords {
  margin: 14px 0 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

@media (max-width: 640px) {
  .hud-top {
    padding: 12px 12px 0;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 20px;
  }

  .legend {
    font-size: 10px;
    gap: 6px 10px;
  }

  #panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
