/* ============================================================
   SNAKE — Cute Edition  |  style.css
   Cartoon / bubbly aesthetic matching the reference image:
   - Glossy blue snake with round head & big eyes
   - Checkerboard lime-green floor
   - Shiny red apple food
   - Soft rounded UI with pastel colours
   ============================================================ */

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
  --snake-blue:   #5b8dee;
  --snake-dark:   #3a6bd4;
  --snake-shine:  #a8c8ff;
  --floor-light:  #8bc34a;
  --floor-dark:   #7cb342;
  --apple-red:    #e53935;
  --apple-shine:  #ff8a80;
  --bg-sky:       #b3e5fc;
  --bg-sky2:      #e1f5fe;
  --panel:        rgba(255,255,255,0.88);
  --panel-border: rgba(255,255,255,0.6);
  --text-main:    #2d3a4a;
  --text-dim:     #8a9bb0;
  --gold:         #ffca28;
  --radius-pill:  999px;
  --font:         'Nunito', 'Segoe UI', sans-serif;
  --shadow-soft:  0 8px 32px rgba(80,120,200,0.18);
}

/* ── Base ─────────────────────────────────────────────────────── */
html, body {
  width: 100%; height: 100%;
  background: linear-gradient(160deg, var(--bg-sky2) 0%, var(--bg-sky) 100%);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── App Layout ──────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 10px 8px;
  gap: 10px;
}

/* ── HUD bar ─────────────────────────────────────────────────── */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 540px;
  gap: 10px;
}

#hud-title {
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 900;
  color: var(--snake-dark);
  letter-spacing: .04em;
  text-shadow: 0 3px 0 rgba(59,107,212,.25), 0 5px 12px rgba(59,107,212,.15);
  flex: 1;
  text-align: center;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius-pill);
  padding: 6px 16px 6px 10px;
  box-shadow: var(--shadow-soft);
  min-width: 80px;
}

.hud-icon { font-size: 18px; line-height: 1; }

.hud-pill span:last-child {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-main);
  min-width: 28px;
  text-align: right;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1);
}

.hud-pill span:last-child.pop {
  transform: scale(1.5);
  color: var(--snake-dark);
}

/* ── Game Wrapper ────────────────────────────────────────────── */
#game-wrap {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 0 0 4px rgba(255,255,255,0.7),
    0 12px 48px rgba(80,120,200,0.28);
  /* Size set by JS */
}

#game-canvas {
  display: block;
  image-rendering: crisp-edges;
}

/* ── Overlays ────────────────────────────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(240, 248, 255, 0.92);
  backdrop-filter: blur(8px);
  border-radius: inherit;
  z-index: 30;
  transition: opacity .35s ease, transform .35s cubic-bezier(.34,1.2,.64,1);
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(.92);
}

.overlay-snake-icon {
  font-size: clamp(48px, 10vw, 72px);
  line-height: 1;
  animation: bounce 1.2s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.overlay h1 {
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 900;
  color: var(--snake-dark);
  text-shadow: 0 4px 0 rgba(59,107,212,.2);
  letter-spacing: .02em;
}

.overlay p {
  font-size: clamp(12px, 2.5vw, 15px);
  color: var(--text-dim);
  font-weight: 700;
  text-align: center;
  line-height: 1.6;
}

#go-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.go-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#go-score {
  font-size: clamp(48px, 10vw, 80px);
  font-weight: 900;
  color: var(--snake-blue);
  text-shadow: 0 4px 0 rgba(59,107,212,.2);
  line-height: 1;
}

/* ── Play Button ─────────────────────────────────────────────── */
.play-btn {
  padding: 13px 44px;
  font-family: var(--font);
  font-size: clamp(14px, 2.5vw, 17px);
  font-weight: 900;
  letter-spacing: .06em;
  color: #fff;
  background: linear-gradient(160deg, #5b8dee 0%, #3a6bd4 100%);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 6px 0 #2a52aa, 0 10px 24px rgba(59,107,212,.35);
  transition: transform .12s, box-shadow .12s;
}

.play-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #2a52aa, 0 14px 28px rgba(59,107,212,.4);
}

.play-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #2a52aa, 0 6px 14px rgba(59,107,212,.3);
}

.controls-hint {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ── Level Bar ───────────────────────────────────────────────── */
#level-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 540px;
}

.lv-tag {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  color: var(--text-dim);
  text-transform: uppercase;
}

#lv-bar-bg {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.55);
  border-radius: 99px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.08);
}

#lv-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #5b8dee, #a8c8ff);
  border-radius: 99px;
  transition: width .35s cubic-bezier(.34,1.2,.64,1);
  width: 0%;
  box-shadow: 0 0 8px rgba(91,141,238,.5);
}

#lv-num {
  font-size: 13px;
  font-weight: 900;
  color: var(--snake-dark);
  min-width: 24px;
  text-align: right;
}

/* ── Mobile D-Pad ────────────────────────────────────────────── */
#dpad {
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 5px;
}

.dp-btn {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  font-size: 20px;
  color: var(--snake-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 rgba(59,107,212,.2), var(--shadow-soft);
  transition: transform .1s, box-shadow .1s;
  touch-action: manipulation;
}

.dp-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(59,107,212,.2), 0 2px 6px rgba(80,120,200,.1);
}

.dp-mid {
  background: rgba(255,255,255,.35);
  border-radius: 50%;
}

/* Show d-pad on touch / small screens */
@media (max-width: 600px), (pointer: coarse) {
  #dpad { display: grid; }
}