:root {
  color-scheme: light;
  --page: #edf3ee;
  --ink: #203432;
  --muted: #667a75;
  --panel: #fbfcf8;
  --panel-strong: #ffffff;
  --line: #c7d3ce;
  --accent: #e68d2d;
  --accent-dark: #9d5420;
  --teal: #2f9c95;
  --plum: #7b5fb4;
  --danger: #c64f5f;
  --shadow: 0 18px 42px rgba(32, 52, 50, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(135deg, rgba(47, 156, 149, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(198, 79, 95, 0.12), transparent 38%),
    var(--page);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0 16px;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(32, 52, 50, 0.38);
  box-shadow: 0 8px 18px rgba(32, 52, 50, 0.12);
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid rgba(47, 156, 149, 0.34);
  outline-offset: 2px;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button.primary {
  border-color: transparent;
  background: var(--accent);
  color: #241305;
}

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

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

.eyebrow,
.label {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.game-layout {
  align-items: stretch;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
}

.panel {
  background: rgba(251, 252, 248, 0.94);
  border: 1px solid rgba(199, 211, 206, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.objective p,
.readout p {
  color: #334a46;
  font-size: 0.98rem;
  line-height: 1.45;
  margin: 0;
}

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

.stat {
  background: #f2f6f2;
  border: 1px solid rgba(199, 211, 206, 0.9);
  border-radius: 8px;
  min-height: 70px;
  padding: 10px;
}

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

.stat strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.15;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.batch-card,
.readout {
  background: var(--panel-strong);
  border: 1px solid rgba(199, 211, 206, 0.9);
  border-radius: 8px;
  padding: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  align-items: center;
  border: 1px solid rgba(32, 52, 50, 0.14);
  border-radius: 999px;
  color: #1c2f2b;
  display: inline-flex;
  font-size: 0.86rem;
  font-weight: 900;
  gap: 7px;
  min-height: 32px;
  padding: 5px 10px 5px 7px;
}

.chip-dot {
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(32, 52, 50, 0.18);
  height: 18px;
  width: 18px;
}

.target-list {
  display: grid;
  gap: 8px;
}

.target-row {
  align-items: center;
  background: #f2f6f2;
  border: 1px solid rgba(199, 211, 206, 0.82);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 7px 9px;
}

.target-row strong {
  font-size: 0.92rem;
}

.target-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.stage {
  background: #d9e7e1;
  border: 1px solid rgba(199, 211, 206, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

canvas {
  aspect-ratio: 96 / 62;
  display: block;
  height: auto;
  max-height: min(74vh, 680px);
  touch-action: none;
  width: 100%;
}

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

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

  .button-row {
    justify-content: stretch;
    width: 100%;
  }

  .button-row button {
    flex: 1 1 140px;
  }

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

  .panel {
    order: 2;
  }

  .stage {
    order: 1;
  }
}

@media (max-width: 520px) {
  .shell {
    width: calc(100vw - 12px);
  }

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

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

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

  canvas {
    max-height: 58vh;
  }
}
