:root {
  color-scheme: dark;
  --bg: #061018;
  --panel: #0c1822;
  --line: #31576b;
  --text: #e7eef1;
  --muted: #9eb1bb;
  --cyan: #8ef4f4;
  --yellow: #e8db45;
  --danger: #ff6a7a;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, #143041 0, transparent 46%),
    linear-gradient(180deg, #050b10, var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, canvas { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.controls-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar { margin-bottom: 12px; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.4vw, 1.8rem);
  line-height: 1.15;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0b1620;
  padding: 7px 11px;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.badge-loading { color: var(--yellow); }
.badge-ready { color: var(--cyan); }
.badge-error { color: var(--danger); }

.stage-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #020609;
  box-shadow: 0 18px 55px rgb(0 0 0 / 45%);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1376 / 768;
  outline: none;
  image-rendering: pixelated;
  cursor: crosshair;
}

canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--cyan); }

.fatal-error[hidden] { display: none; }

.fatal-error {
  position: absolute;
  inset: 20px;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: rgb(20 5 8 / 90%);
  color: #ffd9de;
  text-align: center;
  font-weight: 700;
}

.controls-panel {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.control-copy {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.mode-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101f2a;
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
button.active {
  border-color: var(--cyan);
  background: #13313b;
  color: var(--cyan);
}

.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.notes p {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--yellow);
  background: rgb(12 24 34 / 72%);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.notes strong { color: var(--text); }

@media (max-width: 820px) {
  .app-shell { padding: 10px; }
  .topbar, .controls-panel { align-items: flex-start; flex-direction: column; }
  .status-stack, .mode-buttons { justify-content: flex-start; }
  .notes { grid-template-columns: 1fr; }
}
