:root {
  --bg: #0b1020;
  --panel: rgba(255,255,255,0.06);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.70);
  --grid: rgba(255,255,255,0.08);
  --snake: #35d07f;
  --snakeHead: #69f5a8;
  --apple: #ff4d4d;
  --danger: #ff6b6b;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: radial-gradient(1200px 700px at 20% 10%, rgba(105,245,168,0.14), transparent 60%),
              radial-gradient(900px 600px at 90% 0%, rgba(138,160,255,0.12), transparent 60%),
              var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 12px;
}

.wrap {
  width: 100%;
  height: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

.title {
  display: grid;
  gap: 2px;
}

.title h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.title .sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.stats {
  display: grid;
  grid-auto-flow: column;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-weight: 600;
}

.row {
  display: grid;
  place-items: center;
  min-height: 0;
}

.play-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
  width: 100%;
}

@media (max-width: 820px) {
  .play-container {
    grid-template-columns: 1fr;
    width: 100%;
  }
}

.side {
  width: 150px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  display: grid;
  gap: 10px;
  align-content: start;
  justify-self: end;
}

.side-title {
  font-weight: 750;
  font-size: 13px;
  color: rgba(255,255,255,0.86);
}

.side-value {
  font-size: 28px;
  font-weight: 800;
  color: rgba(255,255,255,0.92);
}

.side-meta {
  font-size: 13px;
  color: rgba(255,255,255,0.78);
}

.side-button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  font-weight: 700;
  cursor: pointer;
}

.side-button:hover {
  background: rgba(255,255,255,0.10);
}

.shop-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0,0,0,0.55);
  z-index: 20;
  padding: 18px;
}

.shop-overlay.show {
  display: grid;
}

.shop {
  width: min(720px, calc(100vw - 24px));
  border-radius: 14px;
  background: rgba(15,18,25,0.92);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
  padding: 14px;
}

.shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.shop-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shop-title {
  font-size: 18px;
  font-weight: 800;
  color: rgba(255,255,255,0.92);
}

.shop-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.76);
}

.shop-close {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  font-weight: 700;
  cursor: pointer;
}

.shop-reset {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  font-weight: 800;
  cursor: pointer;
}

.shop-reset:hover {
  background: rgba(255,255,255,0.10);
}

.shop-close:hover {
  background: rgba(255,255,255,0.10);
}

.shop-items {
  display: grid;
  gap: 10px;
}

.shop-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
}

.shop-item-title {
  font-weight: 800;
  color: rgba(255,255,255,0.92);
  font-size: 14px;
}

.shop-item-desc {
  margin-top: 2px;
  font-size: 13px;
  color: rgba(255,255,255,0.74);
}

.shop-buy {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.shop-buy:hover {
  background: rgba(255,255,255,0.10);
}

.shop-buy:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

canvas {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.10);
  display: block;
}

.game-area {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 650px;
  max-height: 650px;
  aspect-ratio: 1 / 1;
  justify-self: center;
}

.palette {
  width: 170px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  justify-self: start;
}

.palette-title {
  font-weight: 750;
  font-size: 13px;
  margin-bottom: 10px;
  color: rgba(255,255,255,0.86);
}

.palette-title--spaced {
  margin-top: 14px;
}

.palette-meta {
  font-size: 13px;
  color: rgba(255,255,255,0.82);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.swatch:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.40);
}

.swatch.is-selected {
  border-color: rgba(255,255,255,0.95);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25), 0 16px 35px rgba(0,0,0,0.30);
}

.swatch.c1 { background: #1d4ed8; }
.swatch.c2 { background: #2563eb; }
.swatch.c3 { background: #3b82f6; }
.swatch.c4 { background: #60a5fa; }
.swatch.c5 { background: #0ea5e9; }
.swatch.c6 { background: #22d3ee; }
.swatch.c7 { background: #14b8a6; }
.swatch.c8 { background: #06b6d4; }
.swatch.c9 { background: #8b5cf6; }
.swatch.c10 { background: #a78bfa; }
.swatch.c11 { background: #ec4899; }
.swatch.c12 { background: #f59e0b; }

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0,0,0,0.55);
  border-radius: 12px;
}

.overlay.show {
  display: grid;
}

.menu {
  width: min(560px, calc(100% - 28px));
  padding: 24px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(15, 20, 40, 0.78);
  backdrop-filter: blur(10px);
  display: grid;
  gap: 12px;
  text-align: center;
}

.menu h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 750;
}

.menu .meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.menu input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

.palette input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

.menu .buttons {
  display: grid;
  grid-auto-flow: row;
  gap: 10px;
  margin-top: 6px;
}

.is-hidden {
  display: none !important;
}

.bottom {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

.help {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

button {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  background: rgba(255,255,255,0.10);
}

.danger {
  color: var(--danger);
  font-weight: 700;
}
