:root {
  color-scheme: dark;
  --bg: #0b0e17;
  --panel: #131826;
  --text: #e8ecf4;
  --muted: #8b93a7;
  --accent: #4cc9f0;
}

* {
  box-sizing: border-box;
}

/* Visually hidden but still announced by screen readers, for labels whose text is
   otherwise conveyed by an adjacent placeholder or control. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2.5rem;
}

header {
  text-align: center;
  max-width: 640px;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.8rem;
}

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

main {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 1080px;
}

.stage-wrap {
  position: relative;
  max-width: 100%;
  line-height: 0;
}

#stage {
  background: radial-gradient(circle at 50% 50%, #10162a 0%, #05070d 100%);
  border-radius: 12px;
  border: 1px solid #232a3d;
  max-width: 100%;
  height: auto;
  cursor: grab;
  touch-action: none;
}

#minimap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 160px;
  height: 120px;
  background: rgba(5, 7, 13, 0.75);
  border: 1px solid #232a3d;
  border-radius: 8px;
  pointer-events: none;
}

#stage.panning {
  cursor: grabbing;
}

#stage.aiming {
  cursor: crosshair;
}

.controls {
  background: var(--panel);
  border: 1px solid #232a3d;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

select,
button,
input[type="range"],
input[type="number"] {
  font: inherit;
}

select,
button,
input[type="text"],
input[type="number"] {
  background: #1a2136;
  color: var(--text);
  border: 1px solid #2c3550;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
}

select,
button {
  cursor: pointer;
}

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

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="range"] {
  flex: 1;
  min-width: 100px;
}

input[type="text"] {
  flex: 1;
  min-width: 120px;
  font: inherit;
}

input[type="number"] {
  width: 6rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.shortcuts {
  font-size: 0.85rem;
  color: var(--muted);
}

.shortcuts summary {
  cursor: pointer;
  color: var(--text);
}

.shortcuts ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.shortcuts li {
  margin-bottom: 0.25rem;
}

kbd {
  background: #1a2136;
  border: 1px solid #2c3550;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-family: inherit;
  font-size: 0.85em;
}

.stats {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  white-space: pre-line;
}

.diagnostics-panel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Both panels are toggled with the `hidden` attribute from JS, but each also has its own
   `display: flex` rule above/below for when it's shown — same specificity as the browser's
   default `[hidden] { display: none }`, and author rules win ties over the UA stylesheet, so
   without this the attribute alone would not actually hide either panel. */
.inspector-panel[hidden],
.diagnostics-panel[hidden] {
  display: none;
}

#diagnostics-chart {
  width: 100%;
  height: auto;
  background: #0b0e17;
  border: 1px solid #232a3d;
  border-radius: 6px;
}

.diagnostics-legend {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.15rem;
  border-radius: 1px;
}

.swatch.energy {
  background: #f8961e;
}

.swatch.momentum {
  background: #4cc9f0;
  margin-left: 0.5rem;
}

.inspector-panel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-top: 1px solid #232a3d;
  padding-top: 0.85rem;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
}

.inspector-header button {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  max-width: 640px;
}
