:root {
  color-scheme: light;
  --ink: #172022;
  --muted: #657074;
  --page: #f7f4ee;
  --panel: #ffffff;
  --line: #d8ddd8;
  --deep: #22343b;
  --teal: #24a99a;
  --coral: #ee6d58;
  --gold: #d6a923;
  --violet: #7d69c4;
  --shadow: 0 18px 50px rgba(31, 43, 48, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 244, 238, 0.92)),
    var(--page);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
canvas {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

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

.eyebrow,
.label {
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 1;
  margin: 0;
}

.restart {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: var(--deep);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  min-height: 44px;
  padding: 0 18px;
  box-shadow: 0 10px 28px rgba(34, 52, 59, 0.2);
}

.restart:focus-visible {
  outline: 3px solid rgba(238, 109, 88, 0.42);
  outline-offset: 3px;
}

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

.panel,
.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

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

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

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  min-height: 72px;
}

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

.stat strong {
  color: var(--ink);
  display: block;
  font-size: 1.35rem;
  line-height: 1.2;
  margin-top: 6px;
}

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

.meter-label {
  align-items: center;
  display: flex;
  font-size: 0.88rem;
  font-weight: 800;
  justify-content: space-between;
}

.meter {
  background: #edf0eb;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.meter-fill {
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
  height: 100%;
  transform-origin: left center;
  width: 100%;
}

.readout {
  border-left: 4px solid var(--coral);
  padding-left: 12px;
}

.controls {
  margin-top: auto;
}

.stage {
  min-height: 420px;
  overflow: hidden;
  padding: 10px;
}

canvas {
  background: #fbfcf7;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: block;
  height: auto;
  width: 100%;
  touch-action: none;
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 18px, 720px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

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

  .panel {
    order: 2;
  }

  .stage {
    min-height: 0;
    padding: 8px;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 10px;
  }

  .restart {
    padding: 0 14px;
  }

  .panel {
    padding: 14px;
  }

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

  .stat {
    min-height: 64px;
    padding: 9px;
  }

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