* {
  box-sizing: border-box;
}

:root {
  --page-bg: #111827;
  --panel: #f8fafc;
  --panel-border: rgba(255, 255, 255, 0.2);
  --text: #102014;
  --muted: #64748b;
  --bg: #f7fee7;
  --snake: #22c55e;
  --snake-head: #15803d;
  --food: #f43f5e;
  --grid: rgba(21, 128, 61, 0.08);
}

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

body {
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(34, 197, 94, 0.22), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(244, 63, 94, 0.16), transparent 28%),
    linear-gradient(135deg, #0f172a 0%, #14532d 100%);
}

.container {
  position: relative;
  width: min(100%, 760px);
  padding: 24px;
  text-align: center;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.35);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

#score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  margin: 0 0 16px;
  padding: 8px 14px;
  font-weight: 800;
  color: #f8fafc;
  background: #166534;
  border-radius: 999px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  background: var(--bg);
  border: 4px solid #14532d;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.75),
    0 18px 40px rgba(20, 83, 45, 0.25);
}

canvas:focus {
  outline: 3px solid rgba(34, 197, 94, 0.45);
  outline-offset: 4px;
}

.hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#overlay {
  position: absolute;
  inset: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.68);
  border-radius: 8px;
  backdrop-filter: blur(3px);
}

#overlay.hidden {
  display: none;
}

#message {
  font-size: 1.5rem;
  font-weight: 800;
}

button {
  border: 0;
  padding: 10px 18px;
  color: #052e16;
  font-weight: 800;
  background: #86efac;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
  transition: transform 140ms ease, background 140ms ease;
}

button:hover {
  background: #bbf7d0;
}

button:active {
  transform: translateY(1px);
}

@media (max-width: 520px) {
  body {
    padding: 12px;
  }

  .container {
    padding: 16px;
  }

  #overlay {
    inset: 16px;
  }
}
