:root {
  color-scheme: dark;
  --bg-1: #070c14;
  --bg-2: #10192a;
  --panel: #162339;
  --text: #f2f6ff;
  --muted: #b9c7e3;
  --accent: #40db9f;
  --accent-2: #7fd8ff;
  --border: rgb(138 181 255 / 22%);
  --danger: #ff6b6b;
  --grid: #2f4364;
  --snake: #42d392;
  --snake-head: #2ab57a;
  --food: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 12%, #1a2f4f 0%, transparent 34%),
    radial-gradient(circle at 88% 18%, #163d31 0%, transparent 31%),
    radial-gradient(circle at 70% 80%, #2a1b4a 0%, transparent 36%),
    radial-gradient(circle at 20% 10%, var(--bg-2) 0%, var(--bg-1) 62%);
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: repeating-linear-gradient(
    0deg,
    rgb(255 255 255 / 100%) 0 1px,
    transparent 1px 4px
  );
}

body::after {
  content: "";
  position: fixed;
  width: min(82vw, 920px);
  height: min(55vh, 500px);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  pointer-events: none;
  background: radial-gradient(circle, rgb(65 156 255 / 18%) 0%, transparent 68%);
  filter: blur(10px);
}

.page-shell {
  width: min(95vw, 620px);
  display: grid;
  gap: 14px;
}

.game-shell {
  width: 100%;
  background: rgb(22 35 57 / 86%);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 20px 20px;
  box-shadow:
    0 18px 44px rgb(0 0 0 / 40%),
    0 0 28px rgb(79 153 255 / 16%);
  backdrop-filter: blur(6px);
}

.back-link {
  display: inline-block;
  margin-bottom: 0;
  color: #9fd8ff;
  text-decoration: none;
  font-size: 0.82rem;
  opacity: 0.7;
  justify-self: start;
  transition:
    opacity 140ms ease,
    text-shadow 180ms ease;
}

.back-link:hover {
  opacity: 1;
  text-shadow: 0 0 10px rgb(127 216 255 / 35%);
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.top-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
}

.title {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: 0.16em;
  font-weight: 900;
  line-height: 1;
  color: var(--text);
  text-align: center;
  text-shadow:
    0 0 7px rgb(64 219 159 / 58%),
    0 0 16px rgb(64 219 159 / 30%);
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scores {
  display: flex;
  gap: 14px;
  font-weight: 700;
  align-items: center;
}

.scores p {
  margin: 0;
}

#game {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.05;
  border: 1px solid rgb(122 164 234 / 24%);
  border-radius: 12px;
  background: #111825;
  overflow: hidden;
  box-shadow: 0 8px 20px rgb(0 0 0 / 34%);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

#game:hover {
  border-color: rgb(122 164 234 / 40%);
  box-shadow:
    0 10px 22px rgb(0 0 0 / 36%),
    0 0 16px rgb(110 178 255 / 22%);
}

#game canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 2;
  pointer-events: none;
  color: #e8f3ff;
  font-size: clamp(1rem, 2.3vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 14px rgb(127 216 255 / 34%),
    0 0 26px rgb(64 219 159 / 20%);
  background: rgb(0 0 0 / 10%);
  opacity: 1;
  transition: opacity 180ms ease;
}

.start-overlay.hidden {
  opacity: 0;
}

.controls {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.controls p {
  margin: 0;
  font-size: 0.9rem;
  color: #d2def6;
}

button {
  border: 1px solid #4fe4a5;
  border-radius: 10px;
  background: linear-gradient(130deg, #184632 0%, #163a5a 100%);
  color: var(--text);
  padding: 7px 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
  box-shadow: 0 8px 20px rgb(19 68 50 / 38%);
}

button:hover {
  background: linear-gradient(130deg, #1f5a40 0%, #1f4c74 100%);
  border-color: #70f2bc;
  transform: translateY(-1px);
  box-shadow:
    0 11px 24px rgb(20 87 64 / 46%),
    0 0 16px rgb(79 228 165 / 30%);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 5px 14px rgb(20 87 64 / 34%);
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.35;
}

.status.game-over {
  color: var(--danger);
  font-weight: 700;
  text-shadow:
    0 0 10px rgb(255 107 107 / 38%),
    0 0 22px rgb(255 107 107 / 24%);
}

.status-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 140ms ease;
}

.status-line {
  display: block;
}

.status-head {
  font-size: 1.18em;
  margin-bottom: 2px;
}

.status-overlay:empty {
  opacity: 0;
}

.content-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #2a3650;
}

.content-block h2 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: #d9e6ff;
}

.content-block p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #bccced;
}

.updated {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: #9fb1d8;
}

.site-footer {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: #90b8e8;
}

.site-footer a {
  color: #90b8e8;
  text-decoration: none;
  opacity: 0.84;
}

.site-footer a:hover {
  color: #f2f6ff;
  text-decoration: underline;
  opacity: 1;
}

.legal-shell {
  width: min(92vw, 720px);
  margin: 32px auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgb(22 35 57 / 86%);
  box-shadow:
    0 18px 44px rgb(0 0 0 / 40%),
    0 0 28px rgb(79 153 255 / 16%);
  backdrop-filter: blur(6px);
}

.legal-shell h1 {
  margin-top: 0;
}

.legal-shell a {
  color: #9fd8ff;
}
