/* ---- Base ---- */
:root {
  --accent: #00ff88;
  --accent-dim: #00cc66;
  --bg1: #0f2027;
  --bg2: #203a43;
  --bg3: #2c5364;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  color: #f2f2f2;
  background: linear-gradient(135deg, var(--bg1), var(--bg2), var(--bg3));
  background-size: 300% 300%;
  animation: bgshift 20s ease infinite;
}

@keyframes bgshift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  max-width: 980px;
  margin: 0 auto;
}

.site-header h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent);
}

.btn {
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-1px);
  background: var(--accent);
  color: #0b0b0b;
  box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn.primary {
  background: var(--accent);
  color: #0b0b0b;
}

.btn.primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

.btn.back { font-size: 0.95rem; }

/* ---- Layout gioco ---- */
.game-wrap {
  max-width: 980px;
  margin: 0 auto 40px;
  padding: 0 24px 24px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px auto 12px;
  max-width: 600px;
  justify-content: center;
}

.toolbar label { opacity: .9; }

input[type="color"] {
  appearance: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.game-container {
  position: relative;
  width: 600px;
  margin: 0 auto;
  user-select: none;
}

#snakeCanvas {
  width: 600px;
  height: 600px;
  display: block;
  border-radius: 16px;
  background:
    linear-gradient(#1b1b1b 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, #1b1b1b 1px, transparent 1px) 0 0 / 20px 20px,
    #0c0c0c;
  outline: 3px solid var(--accent);
  box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 40%, transparent);
  image-rendering: pixelated;
}

.hud {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #2a2a2a;
  background: #101010;
  box-shadow: inset 0 0 12px rgba(0,0,0,.5), 0 0 16px rgba(0,0,0,.3);
}

/* ---- Modal ---- */
.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.5);
  border-radius: 16px;
}

.modal.hidden { display: none; }

.modal > * {
  grid-area: 1 / 1;
}

.modal h2 {
  margin: 0 0 8px;
}

.modal > div, .modal > section, .modal > article, .modal {
  text-align: center;
}

.modal .btn { margin-top: 12px; }

.modal > *:not(button) {
  background: #0d0d0d;
  border: 1px solid #2a2a2a;
  padding: 20px 24px;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45), 0 0 24px color-mix(in srgb, var(--accent) 28%, transparent);
}

/* ---- Hint ---- */
.hint {
  margin: 16px auto 0;
  text-align: center;
  opacity: .8;
  font-size: .95rem;
}
