:root {
  color-scheme: dark;
  --ink: #f4f7fb;
  --muted: #aeb7c4;
  --panel: #18202a;
  --line: #2a3542;
  --green: #69d18f;
  --amber: #f4b84e;
  --red: #ff6b5e;
  --blue: #67b7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(105, 209, 143, 0.18), transparent 28rem),
    radial-gradient(circle at 82% 18%, rgba(255, 107, 94, 0.1), transparent 24rem),
    linear-gradient(135deg, #111614 0%, #202229 46%, #241d24 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

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

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(76px, 1fr));
  gap: 8px;
  min-width: min(620px, 100%);
}

.stats span,
.legend span {
  border: 1px solid var(--line);
  background: rgba(24, 32, 42, 0.86);
  border-radius: 8px;
}

.stats span {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  color: var(--muted);
  font-size: 0.78rem;
}

.stats strong {
  color: var(--ink);
  font-size: 1.1rem;
}

.game-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 360px;
  max-height: calc(100vh - 170px);
  overflow: hidden;
  border: 1px solid #34414f;
  border-radius: 8px;
  background: #2c3632;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(10, 16, 22, 0.8);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.legend i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex: 0 0 13px;
}

.legend .player {
  background: var(--blue);
}

.legend .convert {
  background: var(--green);
}

.legend .smoker {
  background: var(--red);
}

.legend .citizen {
  background: #f3d06f;
}

.legend .smoke {
  background: #9aa3ad;
}

.legend .event {
  background: #9f8cff;
}

@media (max-width: 780px) {
  .shell {
    width: min(100vw - 14px, 760px);
    padding-top: 10px;
  }

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

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

  .game-wrap {
    aspect-ratio: 10 / 13;
    max-height: none;
  }
}
