:root {
  color-scheme: dark;
  --bg: #101519;
  --panel: #192126;
  --panel-soft: #202b31;
  --line: #334047;
  --text: #f1f6f5;
  --muted: #9fb0ad;
  --accent: #4ed5c7;
  --accent-strong: #8bffe8;
  --warn: #f4b35d;
  --danger: #f05d62;
  --ok: #a7e66a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(78, 213, 199, 0.08), transparent 36rem),
    var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

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

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

.eyebrow,
.label,
.controls {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: 3rem;
  line-height: 0.95;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.panel,
.stage {
  border: 1px solid var(--line);
  background: rgba(25, 33, 38, 0.88);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.panel {
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.objective,
.readout {
  padding: 12px;
  border: 1px solid rgba(159, 176, 173, 0.22);
  border-radius: 8px;
  background: var(--panel-soft);
}

.objective p,
.readout p {
  margin: 7px 0 0;
  color: #dbe7e4;
  font-size: 0.95rem;
  line-height: 1.45;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(159, 176, 173, 0.2);
  border-radius: 8px;
  background: #131a1e;
}

.stat > span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 1.25rem;
}

.meter-group {
  display: grid;
  gap: 8px;
}

.meter-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

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

.meter {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(159, 176, 173, 0.22);
  border-radius: 999px;
  background: #101519;
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warn), var(--danger));
  transition: width 120ms linear;
}

.restart,
.latch {
  border: 1px solid rgba(139, 255, 232, 0.42);
  border-radius: 8px;
  color: var(--text);
  background: #172327;
  cursor: pointer;
}

.restart {
  min-height: 42px;
  padding: 0 16px;
}

.latch {
  min-height: 58px;
  margin-top: auto;
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(180deg, #24615b, #17353a);
}

.restart:hover,
.latch:hover,
.restart:focus-visible,
.latch:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.controls {
  text-align: center;
}

.stage {
  position: relative;
  min-height: 360px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(32, 43, 49, 0.86), rgba(13, 18, 21, 0.9)),
    #12181c;
}

canvas {
  display: block;
  width: 100%;
  max-height: calc(100vh - 140px);
  aspect-ratio: 760 / 520;
  touch-action: manipulation;
}

@media (max-width: 820px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    margin-bottom: 10px;
  }

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

  .panel {
    order: 2;
  }

  .stage {
    order: 1;
    min-height: 260px;
  }

  canvas {
    max-height: none;
  }
}

@media (max-width: 460px) {
  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 2.35rem;
  }

  .restart {
    min-width: 92px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat {
    padding: 8px 6px;
  }

  .stat span {
    font-size: 0.64rem;
  }

  .stat strong {
    font-size: 1rem;
  }
}

@media (min-width: 900px) {
  h1 {
    font-size: 4.1rem;
  }
}
