/* ===== Snake — game UI =====
   Page chrome uses the shared --gc-* tokens (follows light/dark), but the
   LCD screen keeps its own fixed pea-green palette for the retro Nokia look. */

.wrap {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: clamp(24px, 6vw, 48px) 20px 40px;
  text-align: center;
}
.head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title { margin: 0; font-size: clamp(26px, 6vw, 34px); letter-spacing: -.02em; }
.sub { margin: 0; color: var(--gc-text-muted); font-weight: 600; min-height: 1.4em; }

.scoreboard { display: flex; gap: 8px; }
.score {
  display: flex; flex-direction: column; gap: 2px; min-width: 74px;
  padding: 8px 12px; background: var(--gc-surface); border: 1px solid var(--gc-border); border-radius: 12px;
}
.score__k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--gc-text-muted); font-weight: 700; }
.score__v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--gc-border); background: var(--gc-surface); color: var(--gc-text);
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--gc-accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--gc-ring); }
.btn--primary { background: var(--gc-accent); border-color: var(--gc-accent); color: var(--gc-on-accent); }
.btn--primary:hover { filter: brightness(1.05); }

/* ---- Speed picker (segmented) ---- */
.segmented {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--gc-surface-2); border: 1px solid var(--gc-border); border-radius: 12px;
}
.seg {
  appearance: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
  padding: 7px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--gc-text-muted);
  transition: background .15s ease, color .15s ease;
}
.seg--sm { padding: 6px 12px; font-size: 13px; }
.seg:hover { color: var(--gc-text); }
.seg[aria-selected="true"] { background: var(--gc-accent); color: var(--gc-on-accent); box-shadow: var(--gc-shadow); }
.seg:focus-visible { outline: none; box-shadow: var(--gc-ring); }

.speedrow { display: flex; align-items: center; gap: 10px; }
.speedrow__label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: var(--gc-text-muted); }

/* ---- On-screen control hint ---- */
.hintline { margin: 0; font-size: 12.5px; color: var(--gc-text-muted); line-height: 2; }

/* ---- Device / LCD screen ---- */
.device {
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(#3a4049, #23272e);
  box-shadow: var(--gc-shadow-hi), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.screen {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #9db854;                 /* pea-green LCD glass */
  box-shadow: inset 0 0 0 3px #1c2110, inset 0 2px 14px rgba(0, 0, 0, .35);
  line-height: 0;
}
.screen canvas {
  display: block;
  width: min(80vw, 440px);
  height: auto;
  image-rendering: pixelated;          /* crisp chunky pixels when upscaled */
  touch-action: none;                  /* let us capture swipes without scroll */
}
.overlay {
  touch-action: manipulation;
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(20, 30, 8, .72);
  color: #eaffd0;
  line-height: 1.4;
}
.overlay[hidden] { display: none; }
.overlay__msg { font-size: 26px; font-weight: 800; letter-spacing: .02em; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.overlay .btn { background: #eaffd0; border-color: #eaffd0; color: #1c2a08; }
.overlay .btn:hover { filter: brightness(.96); }

/* ---- Rules modal ---- */
.modal { position: fixed; inset: 0; z-index: 1100; overflow: auto; display: grid; place-content: center; place-content: safe center; padding: 16px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: fixed; inset: 0; background: rgba(6, 12, 20, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal__panel {
  position: relative; z-index: 1; width: min(94vw, 520px);
  padding: 0; border-radius: 16px;
  background: var(--gc-surface); color: var(--gc-text);
  border: 1px solid var(--gc-border); box-shadow: var(--gc-shadow-hi);
}
.modal__head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--gc-border); }
.modal__head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.modal__x { margin-left: auto; border: 0; background: transparent; cursor: pointer; font-size: 26px; line-height: 1; color: var(--gc-text-muted); padding: 0 4px; }
.modal__x:hover { color: var(--gc-text); }
.modal__body { padding: 6px 20px 4px; font-size: 14px; line-height: 1.6; color: var(--gc-text-muted); }
.modal__lead { margin: 10px 0 12px; color: var(--gc-text); }
.modal__body h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--gc-accent); }
.modal__body ul { margin: 0 0 6px; padding-left: 20px; }
.modal__body li { margin: 3px 0; }
.modal__body b { color: var(--gc-text); }
kbd { font: 600 12px/1.4 ui-monospace, "Segoe UI", monospace; padding: 1px 6px; border-radius: 5px; color: var(--gc-text); background: var(--gc-surface-2); border: 1px solid var(--gc-border); }
.modal__foot { display: flex; justify-content: flex-end; padding: 12px 20px 16px; }

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
