:root {
  color-scheme: dark;
  --bg: #101312;
  --panel: #18201d;
  --panel-strong: #202a25;
  --line: #415047;
  --text: #f4efe4;
  --muted: #b9c1b7;
  --accent: #f2b84b;
  --accent-2: #58c6a6;
  --danger: #ee6f57;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(130deg, rgba(242, 184, 75, 0.08), transparent 34%),
    linear-gradient(310deg, rgba(88, 198, 166, 0.1), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  appearance: none;
  border: 1px solid rgba(244, 239, 228, 0.2);
  border-radius: 8px;
  background: #25312b;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  min-height: 42px;
  padding: 0.7rem 0.9rem;
}

button:hover {
  background: #314139;
}

button:focus-visible {
  outline: 3px solid rgba(242, 184, 75, 0.55);
  outline-offset: 2px;
}

button:disabled {
  color: rgba(244, 239, 228, 0.45);
  cursor: not-allowed;
  opacity: 0.75;
}

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

.topbar {
  align-items: end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.eyebrow,
.label {
  color: var(--accent);
  display: block;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 0.25rem;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
  margin: 0;
}

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

.controls button:first-child {
  background: var(--accent);
  border-color: rgba(0, 0, 0, 0.12);
  color: #201307;
}

.controls button:first-child:hover {
  background: #ffd46f;
}

.layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}

.panel,
.stage {
  background: rgba(24, 32, 29, 0.9);
  border: 1px solid rgba(244, 239, 228, 0.12);
  box-shadow: 0 18px 50px var(--shadow);
}

.panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

.objective p,
.readout p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
  margin: 0;
}

.stat-grid {
  border-bottom: 1px solid rgba(244, 239, 228, 0.12);
  border-top: 1px solid rgba(244, 239, 228, 0.12);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.stat {
  border-bottom: 1px solid rgba(244, 239, 228, 0.08);
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  padding: 0.72rem 0.55rem;
}

.stat:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.stat span {
  color: var(--muted);
  font-size: 0.78rem;
}

.stat strong {
  color: var(--text);
  font-size: clamp(1rem, 2.7vw, 1.28rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.stage {
  min-width: 0;
  padding: 10px;
}

canvas {
  background: #121615;
  display: block;
  height: min(70vh, 720px);
  min-height: 520px;
  outline: none;
  touch-action: none;
  width: 100%;
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .controls {
    justify-content: stretch;
  }

  .controls button {
    flex: 1 1 130px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    order: 2;
  }

  canvas {
    height: min(64vh, 560px);
    min-height: 420px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 14px, 1180px);
    padding-top: 10px;
  }

  .stage {
    padding: 6px;
  }

  .panel {
    padding: 14px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .stat:nth-last-child(-n + 2) {
    border-bottom: 1px solid rgba(244, 239, 228, 0.08);
  }

  .stat:last-child {
    border-bottom: 0;
  }
}
