:root {
  --paper: #d8dbcf;
  --ink: #10130f;
  --bg: #151713;
  --muted: #b6baad;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: #f3f4ec;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.demo-page {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 28px 18px 42px;
}

header {
  margin-bottom: 24px;
}

header p {
  margin: 0;
  color: var(--muted);
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.05;
}

.demo-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.display-comparison {
  display: flex;
  flex-wrap: wrap;
  gap: 26px 34px;
  align-items: flex-end;
  min-height: 170px;
  padding: 18px;
  border: 2px solid rgba(182, 186, 173, 0.45);
}

.display-card {
  margin: 0;
  display: grid;
  gap: 8px;
  align-items: end;
}

.display-card figcaption {
  max-width: 320px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.render-source {
  position: absolute;
  left: -9999px;
  width: 400px;
  height: 240px;
  opacity: 0;
  pointer-events: none;
}

.screen-canvas {
  image-rendering: pixelated;
  background: var(--paper);
  border: 3px solid #080906;
  border-radius: 3px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

.screen-480 {
  width: 260px;
  height: 156px;
}

.screen-calibration {
  align-self: stretch;
  min-width: 220px;
  display: grid;
  align-content: end;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.screen-calibration label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.screen-calibration input {
  width: 72px;
  border: 2px solid var(--muted);
  background: #10130f;
  color: #f3f4ec;
  padding: 5px 6px;
  font: inherit;
}

.screen-calibration p {
  margin: 0;
  line-height: 1.25;
}

.simulation-scale {
  align-self: stretch;
  min-width: 220px;
  display: grid;
  align-content: end;
  gap: 8px;
  color: var(--muted);
}

.simulation-scale h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
  color: #f3f4ec;
}

.button-row.compact {
  grid-template-columns: repeat(3, 64px);
}

.button-row.compact button {
  min-height: 42px;
  font-size: 18px;
}

.simulation-scale p {
  margin: 0;
  min-height: 18px;
  font-size: 12px;
  font-weight: 800;
}

.map-controls {
  align-self: stretch;
  min-width: 220px;
  display: grid;
  align-content: end;
  gap: 8px;
  color: var(--muted);
}

.map-controls h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
  color: #f3f4ec;
}

.map-controls label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  font-weight: 900;
}

.map-controls input {
  width: 18px;
  height: 18px;
  accent-color: #f3f4ec;
}

.map-controls p {
  margin: 0;
  min-height: 18px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.map-feature-disabled {
  display: none !important;
}

.world-section {
  margin-top: 28px;
  display: grid;
  gap: 12px;
}

.world-section h2 {
  margin: 0;
  font-size: 22px;
}

.world-section p {
  max-width: 760px;
  margin: 4px 0 0;
  color: var(--muted);
}

.real-map-controls {
  width: min(100%, 1000px);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 12px;
  border: 2px solid rgba(182, 186, 173, 0.55);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.real-map-controls label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.real-map-controls select {
  border: 2px solid var(--muted);
  background: #10130f;
  color: #f3f4ec;
  padding: 5px 7px;
  font: inherit;
}

.real-map-controls input {
  width: 16px;
  height: 16px;
  accent-color: #f3f4ec;
}

#map-status {
  color: #f3f4ec;
}

#real-map {
  width: min(100%, 1000px);
  height: 540px;
  border: 8px solid #080906;
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#world-map {
  width: min(100%, 1000px);
  aspect-ratio: 800 / 420;
  image-rendering: auto;
  background: var(--paper);
  border: 8px solid #080906;
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

.legacy-world-map {
  display: none;
}

.leaflet-container {
  background: #d8dbcf;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.sim-own-marker,
.sim-target-marker {
  display: grid;
  place-items: center;
  color: #10130f;
  font-weight: 900;
}

.sim-own-marker {
  width: 16px;
  height: 16px;
  border: 3px solid #10130f;
  border-radius: 50%;
  background: #f3f4ec;
}

.sim-target-marker {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 18px solid #10130f;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.device-controls {
  border: 2px solid var(--muted);
  padding: 12px;
}

.device-controls h2 {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.1;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.button-row button {
  min-height: 54px;
  border: 3px solid #f3f4ec;
  border-radius: 8px;
  background: #22251f;
  color: #f3f4ec;
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.32), 0 8px 18px rgba(0, 0, 0, 0.28);
  font: 900 26px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  text-transform: uppercase;
  cursor: pointer;
}

.button-row button:active,
.button-row button.is-pressed {
  transform: translateY(2px);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.32), 0 4px 10px rgba(0, 0, 0, 0.24);
}

#btn-set {
  font-size: 18px;
}

.device-controls p {
  min-height: 36px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.demo-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.demo-readout div {
  border: 2px solid var(--muted);
  padding: 10px;
}

.demo-readout small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.demo-readout b {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1;
}

.legend {
  border: 2px solid var(--muted);
  padding: 12px;
}

.legend h2 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.1;
}

.legend h2:not(:first-child) {
  margin-top: 16px;
}

.legend dl,
.legend ul {
  margin: 0;
}

.legend dl {
  display: grid;
  gap: 7px;
}

.legend dl div {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 8px;
}

.legend dt {
  color: #f3f4ec;
  font-weight: 900;
}

.legend dd {
  margin: 0;
  color: var(--muted);
}

.legend ul {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.legend li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
}

.legend-icon {
  position: relative;
  width: 30px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  color: #f3f4ec;
  font-weight: 900;
}

.legend-icon.compass::before {
  content: "";
  width: 22px;
  height: 22px;
  border: 2px solid #f3f4ec;
  transform: rotate(45deg);
}

.legend-icon.compass::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  background: #f3f4ec;
  clip-path: polygon(50% 0, 100% 50%, 50% 50%, 0 50%);
  transform: rotate(45deg);
}

.legend-icon.ring::before {
  content: "";
  width: 26px;
  height: 14px;
  border: 1px dashed #f3f4ec;
  border-radius: 50%;
}

.legend-icon.solid-line::before,
.legend-icon.dash-line::before {
  content: "";
  width: 28px;
  border-top: 2px solid #f3f4ec;
}

.legend-icon.dash-line::before {
  border-top-style: dashed;
}

.legend-icon.target::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 18px solid #f3f4ec;
}

.legend-icon.arrow::before {
  content: "";
  width: 22px;
  border-top: 3px solid #f3f4ec;
  transform: rotate(-25deg);
}

.legend-icon.arrow::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 4px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid #f3f4ec;
  transform: rotate(-25deg);
}

@media (max-width: 820px) {
  .demo-layout {
    grid-template-columns: 1fr;
  }

  .demo-readout {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
