:root {
  --bg: #f3f9f1;
  --panel: #ffffff;
  --ink: #15301f;
  --muted: #5a6f60;
  --accent: #177245;
  --accent-strong: #125235;
  --danger: #bb2f2f;
  --board: #0f2e20;
  --board-grid: #1f4a37;
  --snake-head: #74f39f;
  --snake-body: #30c56c;
  --food: #ff6b58;
  --border: #d7e3d9;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 15% 15%, #ffffff 0%, var(--bg) 55%);
  color: var(--ink);
  overscroll-behavior: none;
}

body {
  padding: 14px;
  overflow: hidden;
  touch-action: manipulation;
}

.app {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.03em;
}

.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 150ms ease, transform 80ms ease;
}

.home-btn:active {
  transform: scale(0.96);
  background: rgba(0, 0, 0, 0.12);
}

.home-btn .icon {
  font-size: 1.1rem;
  line-height: 1;
}

.hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.label {
  color: var(--muted);
  font-size: 0.88rem;
}

.stat strong {
  font-size: 1.28rem;
}

.board-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}

#game-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 10px;
  touch-action: none;
  background: var(--board);
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--accent);
}

.btn:active {
  transform: translateY(1px);
}

#restart-btn {
  background: var(--danger);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

@media (min-width: 720px) {
  body {
    padding: 20px;
  }

  .app {
    gap: 14px;
  }

  .btn {
    cursor: pointer;
  }
}
