:root {
  color-scheme: light;
  --page: #f1eee5;
  --ink: #211d18;
  --muted: #6f6658;
  --panel: #fbfaf4;
  --line: #cfc5b3;
  --line-dark: #9b8d78;
  --accent: #d7a43c;
  --accent-dark: #8a5e17;
  --leaf: #58a972;
  --berry: #cc5b67;
  --blue: #527a9f;
  --shadow: 0 18px 40px rgba(39, 31, 20, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(135deg, rgba(82, 122, 159, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(215, 164, 60, 0.17), transparent 42%),
    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 rgba(138, 94, 23, 0.38);
  border-radius: 8px;
  background: var(--accent);
  color: #211704;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: 0 18px;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

button:hover {
  box-shadow: 0 10px 20px rgba(39, 31, 20, 0.15);
  transform: translateY(-1px);
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(82, 122, 159, 0.34);
  outline-offset: 3px;
}

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

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

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

h1 {
  font-size: clamp(2.25rem, 6vw, 4.35rem);
  line-height: 0.95;
  margin: 0;
}

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

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.objective,
.readout {
  background: rgba(251, 250, 244, 0.94);
  border: 1px solid rgba(207, 197, 179, 0.92);
  border-radius: 8px;
  padding: 14px;
}

.objective p,
.readout p {
  color: #40382f;
  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: rgba(251, 250, 244, 0.88);
  border: 1px solid rgba(207, 197, 179, 0.92);
  border-radius: 8px;
  min-height: 72px;
  padding: 10px;
}

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

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

.stage {
  align-items: center;
  background: #ded6c6;
  border: 1px solid rgba(155, 141, 120, 0.55);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  padding: 10px;
}

canvas {
  aspect-ratio: 960 / 620;
  background: #fbfaf4;
  border-radius: 6px;
  display: block;
  max-height: calc(100vh - 172px);
  max-width: 100%;
  min-height: 320px;
  touch-action: none;
  width: 100%;
}

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

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

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

  .panel {
    order: 2;
  }

  .stage {
    order: 1;
    padding: 7px;
  }

  canvas {
    max-height: none;
    min-height: 250px;
  }
}

@media (max-width: 520px) {
  .topbar {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

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