:root {
  color-scheme: light;
  --bg: #f7f0e6;
  --surface: #fffdf9;
  --surface-muted: #f4ece2;
  --border: #e3d8ca;
  --border-soft: #ede4d9;
  --text: #322b26;
  --text-soft: #6c6259;
  --accent: #6f927f;
  --accent-dark: #4d6d5d;
  --food: #d38f7d;
  --shadow: 0 14px 36px rgba(84, 73, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.72), transparent 34%),
    linear-gradient(180deg, #fbf6ef 0%, var(--bg) 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 28px 16px 40px;
  display: grid;
  gap: 16px;
}

.panel {
  background: rgba(255, 253, 249, 0.92);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.status-panel {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 14px;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 16px 18px;
  display: grid;
  gap: 6px;
}

.status-label,
.eyebrow,
.description,
.help-text {
  color: var(--text-soft);
}

.status-card strong {
  font-size: 1.4rem;
}

.game-panel,
.controls-panel {
  padding: 22px;
}

.panel-copy {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.77rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-size: clamp(1.35rem, 2vw, 1.8rem);
}

.description {
  margin-top: 8px;
  line-height: 1.55;
}

.board-stage {
  position: relative;
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 0;
  background: transparent;
}

.board-wrap {
  position: relative;
  box-sizing: content-box;
  width: var(--board-pixel-size, 300px);
  height: var(--board-pixel-size, 300px);
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.board {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 1px;
  padding: 1px;
  background: var(--border);
  border-radius: 0;
  overflow: visible;
}

.cell {
  position: relative;
  background: var(--surface-muted);
  width: 23px;
  height: 23px;
  overflow: visible;
}

.cell-snake {
  background: linear-gradient(145deg, #7aa28d 0%, var(--accent) 60%, #5b7d6b 100%);
  border-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -2px 0 rgba(47, 70, 58, 0.18);
}

.cell-head {
  --head-eye-y: 34%;
  --head-eye-left-x: 34%;
  --head-eye-right-x: 66%;
  --head-pupil-y: 35%;
  --head-pupil-left-x: 35%;
  --head-pupil-right-x: 65%;
  --head-snout-x: 75%;
  --head-snout-y: 50%;
  border-radius: 8px;
  background:
    radial-gradient(circle at var(--head-eye-left-x) var(--head-eye-y), #f6f1ea 0 9%, transparent 10%),
    radial-gradient(circle at var(--head-eye-right-x) var(--head-eye-y), #f6f1ea 0 9%, transparent 10%),
    radial-gradient(circle at var(--head-snout-x) var(--head-snout-y), rgba(255, 255, 255, 0.16) 0 18%, transparent 19%),
    linear-gradient(145deg, #6f977f 0%, #4d6c5d 58%, #2f473c 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -2px 0 rgba(21, 31, 26, 0.34);
}

.cell-head::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at var(--head-pupil-left-x) var(--head-pupil-y), #2c2520 0 4%, transparent 5%),
    radial-gradient(circle at var(--head-pupil-right-x) var(--head-pupil-y), #2c2520 0 4%, transparent 5%),
    radial-gradient(circle at var(--head-snout-x) calc(var(--head-snout-y) - 12%), rgba(255, 255, 255, 0.12) 0 10%, transparent 11%);
}

.cell-head::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 4px;
  left: calc(var(--head-snout-x) - 4px);
  top: calc(var(--head-snout-y) - 2px);
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 50%, rgba(44, 37, 32, 0.7) 0 18%, transparent 19%),
    radial-gradient(circle at 65% 50%, rgba(44, 37, 32, 0.7) 0 18%, transparent 19%);
  opacity: 0.75;
}

.cell-head.head-up {
  --head-eye-y: 34%;
  --head-eye-left-x: 34%;
  --head-eye-right-x: 66%;
  --head-pupil-y: 35%;
  --head-pupil-left-x: 35%;
  --head-pupil-right-x: 65%;
  --head-snout-x: 50%;
  --head-snout-y: 22%;
}

.cell-head.head-down {
  --head-eye-y: 66%;
  --head-eye-left-x: 34%;
  --head-eye-right-x: 66%;
  --head-pupil-y: 65%;
  --head-pupil-left-x: 35%;
  --head-pupil-right-x: 65%;
  --head-snout-x: 50%;
  --head-snout-y: 78%;
}

.cell-head.head-left {
  --head-eye-y: 34%;
  --head-eye-left-x: 36%;
  --head-eye-right-x: 58%;
  --head-pupil-y: 35%;
  --head-pupil-left-x: 37%;
  --head-pupil-right-x: 58%;
  --head-snout-x: 18%;
  --head-snout-y: 50%;
}

.cell-head.head-right {
  --head-eye-y: 34%;
  --head-eye-left-x: 42%;
  --head-eye-right-x: 64%;
  --head-pupil-y: 35%;
  --head-pupil-left-x: 42%;
  --head-pupil-right-x: 63%;
  --head-snout-x: 82%;
  --head-snout-y: 50%;
}

.cell-food {
  border-radius: 9px 9px 10px 10px;
  background:
    radial-gradient(circle at 36% 34%, rgba(255, 246, 239, 0.82) 0 14%, transparent 15%),
    radial-gradient(circle at 46% 54%, #efae9e 0 34%, var(--food) 58%, #b85c4b 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 0 rgba(118, 52, 40, 0.22);
}

.cell-food::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 50%;
  width: 3px;
  height: 8px;
  background: #6d5136;
  border-radius: 999px;
  transform: translateX(-40%) rotate(-18deg);
}

.cell-food::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 11px;
  width: 9px;
  height: 6px;
  border-radius: 9px 9px 2px 9px;
  background: linear-gradient(135deg, #8ec180 0%, #5f9151 100%);
  transform: rotate(-24deg);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(251, 246, 239, 0.9);
  border-radius: 0;
}

.overlay.is-hidden {
  display: none;
}

.overlay p {
  line-height: 1.5;
  color: var(--text-soft);
}

.button-row {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.button {
  flex: 1;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.button:active,
.control-button:active {
  transform: translateY(1px);
}

.button-primary {
  background: var(--accent);
  color: white;
}

.button-secondary {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

.help-text {
  margin-top: 14px;
  line-height: 1.5;
}

.control-pad {
  display: grid;
  justify-items: center;
  gap: 10px;
}

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

.control-button {
  width: 72px;
  height: 72px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
}

@media (max-width: 640px) {
  .app-shell {
    padding-top: 16px;
  }

  .status-panel {
    grid-template-columns: 1fr;
  }

  .game-panel,
  .controls-panel {
    padding: 18px;
  }

  .button-row {
    flex-direction: column;
  }
}
