:root {
  color-scheme: light;
  --page-bg: #f3f3ef;
  --panel-bg: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(17, 17, 17, 0.12);
  --text-main: #151515;
  --text-muted: #595959;
  --grid-line: rgba(255, 255, 255, 0.05);
  --board-bg: #111111;
  --snake-head: #f6f6f2;
  --snake-body: #9f9f95;
  --food: #f97316;
  --button-bg: #121212;
  --button-text: #f6f6f2;
  --button-muted: #ecece6;
  --button-muted-text: #1a1a1a;
  --shadow: 0 24px 60px rgba(17, 17, 17, 0.12);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Avenir Next", "Helvetica Neue", "Noto Sans SC", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 38%),
    linear-gradient(135deg, #ecebe4 0%, var(--page-bg) 45%, #e1e0d8 100%);
}

body,
button {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
}

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

.info-panel,
.game-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.info-panel {
  padding: 28px;
}

.eyebrow,
.controls-title,
.stat-label,
.chip,
.fine-print {
  letter-spacing: 0.04em;
}

.eyebrow,
.controls-title {
  margin: 0 0 12px;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  line-height: 0.92;
}

.lede {
  margin: 18px 0 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.66);
}

.meta-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: rgba(17, 17, 17, 0.04);
  border: 1px solid rgba(17, 17, 17, 0.08);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
}

.action-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.primary-button,
.ghost-button,
.control-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    opacity 160ms ease;
  touch-action: manipulation;
}

.primary-button,
.ghost-button {
  padding: 14px 20px;
  min-height: 48px;
}

.primary-button {
  background: var(--button-bg);
  color: var(--button-text);
}

.ghost-button {
  background: var(--button-muted);
  color: var(--button-muted-text);
}

.primary-button:hover,
.ghost-button:hover,
.control-button:hover {
  transform: translateY(-1px);
}

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

.fine-print {
  margin: 16px 0 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.game-panel {
  padding: 24px;
}

.board-shell {
  position: relative;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    var(--board-bg);
  border-radius: calc(var(--radius-xl) - 4px);
  overflow: hidden;
  min-height: 440px;
  padding: 20px;
}

#game-board {
  width: min(100%, 440px);
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 24px;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    #111111;
  background-size: 20px 20px;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.board-overlay {
  position: absolute;
  inset: auto 20px 20px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(14, 14, 14, 0.84);
  color: #f5f5ef;
  backdrop-filter: blur(12px);
}

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

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

.overlay-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.overlay-copy {
  margin: 6px 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(245, 245, 239, 0.82);
}

.controls-panel {
  margin-top: 18px;
  padding: 4px 2px 0;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  justify-content: center;
  gap: 10px;
}

.control-button {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  background: rgba(17, 17, 17, 0.06);
  color: var(--text-main);
  font-size: 1.5rem;
  border: 1px solid rgba(17, 17, 17, 0.08);
}

.control-button:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible {
  outline: 3px solid rgba(249, 115, 22, 0.35);
  outline-offset: 2px;
}

html.embed-mode,
html.embed-mode body {
  height: 100%;
  overflow: hidden;
}

html.embed-mode body {
  background: linear-gradient(180deg, #efeee7 0%, #e6e4dc 100%);
}

html.embed-mode .app-shell {
  width: 100%;
  min-height: 100vh;
  max-height: 100vh;
  grid-template-columns: minmax(190px, 220px) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  align-items: stretch;
}

html.embed-mode .info-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

html.embed-mode .lede,
html.embed-mode .chip-row,
html.embed-mode .fine-print {
  display: none;
}

html.embed-mode h1 {
  font-size: 1.9rem;
}

html.embed-mode .meta-grid {
  margin-top: 14px;
}

html.embed-mode .action-row {
  margin-top: 14px;
}

html.embed-mode .game-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
}

html.embed-mode .board-shell {
  flex: 1;
  min-height: 0;
  padding: 10px;
}

html.embed-mode #game-board {
  width: min(100%, 300px);
  max-height: calc(100vh - 170px);
}

html.embed-mode .controls-panel {
  margin-top: 12px;
}

html.embed-mode .controls-grid {
  grid-template-columns: repeat(3, 56px);
}

html.embed-mode .control-button {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  font-size: 1.2rem;
}

@media (max-width: 720px) {
  html.embed-mode .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .board-shell {
    min-height: 0;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100vw - 20px, 100%);
    padding: 10px 0;
  }

  .info-panel,
  .game-panel {
    border-radius: 22px;
  }

  .info-panel,
  .game-panel {
    padding-inline: 16px;
  }

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

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .board-shell {
    padding: 14px;
  }

  .board-overlay {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }
}
