:root {
  color-scheme: dark;
  --ground: #000;
  --text: #e6e6e6;
  --muted: #9a9a9a;
  --card: #111;
  --line: #333;
  --accent: #7fb3ff;
  --refused: #ff8a80;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--text);
  font: 15px/1.4 system-ui, sans-serif;
}

body[data-screen="page"] {
  overflow: hidden;
}

#view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: var(--ground);
  cursor: grab;
  touch-action: none;
}

#view:active {
  cursor: grabbing;
}

.notice {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 50%;
  margin: 0;
  transform: translateY(-50%);
  text-align: center;
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

.corner {
  position: fixed;
  top: 12px;
  right: 12px;
}

button {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
}

.screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

.card {
  width: min(360px, 100%);
  display: grid;
  gap: 10px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

input {
  background: var(--ground);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  font: inherit;
}

.said {
  margin: 0;
  min-height: 1.4em;
  color: var(--refused);
}

/* The HUD: a modal over the simulation, its panel under the button at the top right. */

#hud {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

#hud::backdrop {
  background: rgb(0 0 0 / 45%);
}

/* The restart's confirmation: a modal above the HUD's, centred. */

#hud-restart {
  width: min(480px, calc(100vw - 32px));
  padding: 16px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
}

#hud-restart::backdrop {
  background: rgb(0 0 0 / 45%);
}

#hud-restart h2 {
  margin: 0 0 8px;
  font-size: 1.1em;
}

.hud-panel {
  position: absolute;
  top: 52px;
  right: 12px;
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hud-status {
  margin: 0 0 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hud-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.hud-tabs [aria-selected="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.hud-tab h3,
.hud-tab h4 {
  margin: 14px 0 6px;
  font-size: 1em;
}

.hud-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.hud-form {
  display: grid;
  gap: 6px;
  margin: 16px 0 8px;
}

select,
textarea {
  background: var(--ground);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  font: inherit;
}

textarea {
  resize: vertical;
}

#hud-speed-value {
  width: 8em;
}

.muted {
  color: var(--muted);
}

.hud-said {
  margin: 8px 0 0;
  min-height: 1.4em;
  color: var(--accent);
}

.hud-cap {
  margin: 0 0 8px;
  color: var(--muted);
}

.hud-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hud-list > li {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.hud-list summary {
  cursor: pointer;
}

.hud-tick {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
}

.hud-text {
  margin: 4px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hud-detail {
  padding: 8px 0 4px 16px;
}

.hud-detail pre {
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.85em;
}

.hud-effect {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.hud-effect th,
.hud-effect td {
  padding: 2px 12px 2px 0;
  text-align: left;
}

.hud-legend .before,
.hud-chart .before {
  color: var(--muted);
  stroke: var(--muted);
}

.hud-legend .after,
.hud-chart .after {
  color: var(--accent);
  stroke: var(--accent);
}

.hud-chart {
  margin: 10px 0;
}

.hud-chart figcaption {
  color: var(--muted);
  font-size: 0.9em;
}

.hud-chart svg {
  display: block;
  width: 100%;
  height: 60px;
  overflow: visible;
}

.hud-chart polyline {
  fill: none;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.hud-chart .mark {
  stroke: var(--muted);
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
}
