:root {
  --bg: #f7f1e8;
  --panel: rgba(255, 251, 245, 0.82);
  --panel-border: rgba(27, 31, 35, 0.12);
  --text: #1f1a17;
  --muted: #6d6259;
  --accent: #ff6b35;
  --accent-deep: #d9480f;
  --accent-soft: #ffd9c8;
  --grid: rgba(47, 42, 39, 0.08);
  --snake: #1f7a5c;
  --snake-head: #0b5d45;
  --food: #ff3366;
  --shadow: 0 30px 80px rgba(71, 34, 10, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Chivo", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 107, 53, 0.22), transparent 32%),
    radial-gradient(circle at bottom right, rgba(31, 122, 92, 0.18), transparent 28%),
    linear-gradient(135deg, #f7f1e8 0%, #efe0cc 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 90%);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(380px, 640px);
  gap: 28px;
  align-items: center;
  padding: 32px 0;
}

.hero,
.board-panel {
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  gap: 20px;
}

.title-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: fit-content;
}

.title-gif {
  display: block;
  width: clamp(90px, 11vw, 148px);
  height: auto;
  margin-bottom: 8px;
  transform: translateX(34px);
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(71, 34, 10, 0.16));
  mix-blend-mode: multiply;
}

.eyebrow {
  margin: 0;
  font-family: "Space Mono", monospace;
  font-size: 0.82rem;
  letter-spacing: 0.24em;
  color: var(--accent-deep);
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 0.94;
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  max-width: 34rem;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-card,
.board-frame {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
  border-radius: 22px;
}

.stat-card span {
  display: block;
  margin-bottom: 10px;
  font-size: 0.92rem;
  color: var(--muted);
}

.stat-card strong {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.action,
.touch-button,
.speed-option {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.action {
  padding: 14px 22px;
  background: rgba(31, 26, 23, 0.08);
  color: var(--text);
}

.speed-picker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 16px;
  border-radius: 999px;
  background: rgba(255, 251, 245, 0.82);
  border: 1px solid rgba(27, 31, 35, 0.08);
  box-shadow: 0 10px 24px rgba(71, 34, 10, 0.1);
  color: var(--muted);
}

.speed-picker span {
  font-size: 0.92rem;
}

.speed-options {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(31, 26, 23, 0.06);
}

.speed-option {
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  line-height: 1;
}

.speed-option:hover {
  transform: translateY(-1px);
  color: var(--text);
}

.speed-option.is-active {
  background: linear-gradient(135deg, #ff844f 0%, #ff6b35 100%);
  color: #fff8f5;
  box-shadow: 0 10px 20px rgba(217, 72, 15, 0.24);
}

.speed-option:focus-visible {
  outline: 2px solid rgba(217, 72, 15, 0.35);
  outline-offset: 2px;
}

.action.primary {
  background: var(--accent);
  color: #fff8f5;
  box-shadow: 0 14px 30px rgba(217, 72, 15, 0.28);
}

.action:hover,
.touch-button:hover {
  transform: translateY(-2px);
}

.board-panel {
  display: grid;
  gap: 20px;
  justify-items: center;
}

.board-frame {
  position: relative;
  width: min(100%, 640px);
  padding: 18px;
  border-radius: 28px;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(245, 238, 228, 0.95));
  background-size: 5% 5%, 5% 5%, 100% 100%;
}

.head-sprite {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  width: 28px;
  height: 28px;
  pointer-events: none;
  user-select: none;
  transform: translate(-9999px, -9999px);
  transform-origin: center center;
  transition: transform 140ms ease-out;
  filter: drop-shadow(0 6px 12px rgba(31, 26, 23, 0.18));
}

.overlay {
  position: absolute;
  inset: 18px;
  z-index: 4;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: rgba(20, 16, 14, 0.22);
  opacity: 1;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.instant-hide {
  transition: none;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.overlay-card {
  width: min(320px, calc(100% - 32px));
  padding: 24px;
  border-radius: 22px;
  background: rgba(255, 250, 245, 0.94);
  text-align: center;
  box-shadow: 0 16px 36px rgba(30, 16, 11, 0.18);
}

.overlay-tag {
  margin: 0 0 10px;
  font-family: "Space Mono", monospace;
  color: var(--accent-deep);
}

.overlay-card h2 {
  margin: 0 0 12px;
  font-size: 1.6rem;
}

.overlay-card p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.touch-controls {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.touch-row {
  display: flex;
  gap: 10px;
}

.touch-button {
  width: 64px;
  height: 64px;
  background: rgba(255, 251, 245, 0.88);
  border: 1px solid rgba(27, 31, 35, 0.08);
  box-shadow: 0 10px 24px rgba(71, 34, 10, 0.12);
  font-size: 1.4rem;
}

.touch-button.center {
  background: var(--accent-soft);
}

.touch-button:active,
.action:active {
  transform: translateY(1px) scale(0.98);
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 24px 0 40px;
  }

  .hero {
    order: 2;
  }

  .board-panel {
    order: 1;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 560px);
    gap: 20px;
  }

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

  .actions {
    align-items: stretch;
  }

  .speed-picker {
    width: 100%;
    justify-content: space-between;
    align-items: stretch;
    border-radius: 24px;
  }

  .speed-options {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .title-row {
    align-items: center;
    gap: 6px;
  }

  .title-gif {
    width: clamp(72px, 24vw, 112px);
    margin-bottom: 0;
    transform: translateX(12px);
  }

  .board-frame {
    padding: 12px;
    border-radius: 22px;
  }

  .overlay {
    inset: 12px;
  }

  .touch-button {
    width: 58px;
    height: 58px;
  }
}
