:root {
  color-scheme: dark;
  --bg: #0b0b0f;
  --card: #14141b;
  --line: #262631;
  --text: #ebebf0;
  --muted: #9b9bab;
  --accent: #ff4d2e;
  --gyro: #4da3ff;
  --warn: #ffb020;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

header h1 {
  margin: 8px 0 2px;
  font-size: 30px;
  letter-spacing: 0.02em;
}

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

.card {
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.card h2,
.card summary {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card summary {
  cursor: pointer;
}

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 24px;
}

/* Controls built by ui.js */
.ctl {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 6px 0;
}

.ctl-checkbox {
  grid-template-columns: auto 1fr;
}

.ctl-color input {
  width: 48px;
  height: 30px;
  padding: 0;
  background: none;
  border: 0;
}

.ctl output {
  min-width: 4ch;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.ctl input[type="range"],
.ctl input[type="text"],
.ctl select {
  grid-column: 1 / -1;
  width: 100%;
}

input,
select,
button {
  accent-color: var(--accent);
  font: inherit;
}

input[type="text"],
select {
  padding: 8px 10px;
  color: var(--text);
  background: #0f0f15;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.preview-wrap {
  margin-top: 8px;
  padding: 10px;
  overflow-x: auto;
  background: #050507;
  border-radius: 10px;
}

#preview {
  display: block;
}

.meta,
.hint,
.stats,
footer {
  color: var(--muted);
  font-size: 13px;
}

.meta {
  margin: 8px 0 0;
}

.hint {
  margin: 10px 2px;
}

.warn {
  margin: 10px 2px;
  color: var(--warn);
  font-size: 14px;
}

button.primary {
  display: block;
  width: 100%;
  padding: 16px;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--accent);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
}

button.secondary {
  margin-top: 10px;
  padding: 9px 14px;
  color: var(--text);
  background: #1e1e28;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

#scope {
  display: block;
  width: 100%;
  height: 90px;
  background: #050507;
  border-radius: 8px;
}

.key::before {
  display: inline-block;
  width: 14px;
  height: 3px;
  margin: 0 6px 3px 0;
  vertical-align: middle;
  content: "";
}

.key + .key {
  margin-left: 16px;
}

.key-accel::before {
  background: var(--accent);
}

.key-gyro::before {
  background: var(--gyro);
}

.sim-stage {
  position: relative;
  overflow: hidden;
  background: #000;
  border-radius: 10px;
}

#sim-eye {
  display: block;
  width: 100%;
}

#sim-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stats {
  margin: 10px 0 6px;
}

footer {
  margin-top: 24px;
  text-align: center;
}

/* Wave mode */
#wave {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#wave canvas {
  position: absolute;
  inset: 0;
}

#wave .hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 0;
  left: 0;
  color: #4a4a55;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  white-space: pre;
  pointer-events: none;
}
