/* Snake Kids — base styles (AC-2: child-friendly, on-brand visuals) */

:root {
  --candy-pink: #ff8fb1;
  --candy-yellow: #ffd86b;
  --candy-mint: #8be8c8;
  --candy-lavender: #c5a8ff;
  --candy-cream: #fff6e4;
  --candy-grass: #b6e2a1;
  --candy-sky: #b6e0f5;
  --snake-head: #4fc89e;
  --snake-body: #8be8c8;
  --snake-belly: #d6f7e8;
  --snake-eye: #2c2540;
  --snake-cheek: #ff8fb1;
  --food: #ff6b6b;
  --food-stem: #6abf69;
  --grid-line: rgba(255, 255, 255, 0.55);
  --grid-bg: #fff7e8;
  --ink: #2c2540;
  --ink-soft: #5a4f76;
  --shadow: 0 6px 18px rgba(60, 30, 90, 0.18);
  --radius: 16px;
  --font-stack: "Fredoka", "Comic Sans MS", "Trebuchet MS", system-ui,
    -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  font-family: var(--font-stack);
  color: var(--ink);
  background: linear-gradient(180deg, #fff7f0 0%, #e8f4ff 60%, #f3e8ff 100%);
  font-size: 18px;
}

body {
  display: flex; align-items: center; justify-content: center; padding: 16px;
}

.stage {
  width: min(620px, 100%);
  display: flex; flex-direction: column; gap: 14px; align-items: stretch;
}

.hud {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 14px; padding: 12px 16px;
  background: var(--candy-cream);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.hud-item { display: flex; flex-direction: column; align-items: flex-start; min-width: 60px; }

.hud-label {
  font-size: 18px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-soft); font-weight: 600;
}

.hud-value { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--ink); }

.hud-toggle { margin-left: auto; }
.hud-toggle + .hud-toggle { margin-left: 0; }

.switch {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
  font-size: 18px; font-weight: 600; color: var(--ink);
  min-height: 44px; min-width: 44px; padding: 4px 6px;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
  position: relative; width: 50px; height: 28px;
  background: #e0d7ec; border-radius: 999px;
  transition: background 0.18s ease;
}

.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; background: #fff; border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track { background: var(--candy-mint); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--candy-lavender); outline-offset: 2px; }

.audio-btn {
  appearance: none; border: 2px solid var(--candy-lavender);
  background: #fff; color: var(--ink);
  font-family: inherit; font-weight: 600; font-size: 18px;
  border-radius: 999px; padding: 6px 14px 6px 10px;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; min-height: 44px; min-width: 44px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.18s ease;
}

.audio-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(180, 150, 220, 0.5); }
.audio-btn:active { transform: translateY(1px); }
.audio-btn:focus-visible { outline: 3px solid var(--candy-lavender); outline-offset: 2px; }
.audio-btn[aria-pressed="false"] { background: #f0e8fa; color: var(--ink-soft); }
.audio-icon { font-size: 22px; line-height: 1; }

.canvas-wrap {
  position: relative; aspect-ratio: 1 / 1; width: 100%;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); background: var(--grid-bg);
  border: 4px solid #fff;
}

#game { display: block; width: 100%; height: 100%; background: var(--grid-bg); touch-action: none; }

.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 246, 228, 0.9); backdrop-filter: blur(4px);
}

.overlay[hidden] { display: none; }

.overlay-card {
  background: #fff; border-radius: 24px; padding: 28px 32px;
  text-align: center; box-shadow: var(--shadow);
  max-width: 80%; border: 4px solid var(--candy-pink);
}

.overlay-title { margin: 0 0 8px; font-size: 38px; color: var(--candy-pink); font-weight: 700; }
.overlay-subtitle { margin: 0 0 6px; font-size: 22px; color: var(--ink-soft); font-weight: 500; }
.overlay-score { margin: 0 0 18px; font-size: 24px; font-weight: 700; color: var(--ink); }
.overlay-hint { margin: 16px 0 0; font-size: 18px; color: var(--ink-soft); }

.btn {
  appearance: none; border: none; border-radius: 999px;
  padding: 14px 28px; font-family: inherit; font-weight: 700; font-size: 20px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  min-width: 44px; min-height: 44px;
}

.btn.primary {
  background: var(--candy-mint); color: var(--ink);
  box-shadow: 0 4px 0 #4fc19a;
}

.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 5px 0 #4fc19a; }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #4fc19a; }
.btn:focus-visible { outline: 3px solid var(--candy-lavender); outline-offset: 3px; }

.btn.secondary {
  background: var(--candy-lavender);
  color: #ffffff;
  box-shadow: 0 4px 0 #8a6cff;
}
.btn.secondary:hover { transform: translateY(-1px); box-shadow: 0 5px 0 #8a6cff; }
.btn.secondary:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6cff; }
.btn.secondary:focus-visible { outline: 3px solid var(--candy-pink); outline-offset: 3px; }

/* ----- AC-4: start screen ----------------------------------------- */
.start-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 26px 28px;
  border-color: var(--candy-mint);
}
.start-emoji {
  font-size: 54px; line-height: 1; margin-bottom: 4px;
  filter: drop-shadow(0 4px 0 rgba(60, 30, 90, 0.18));
  animation: start-bob 2.2s ease-in-out infinite;
}
@keyframes start-bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-6px) rotate(3deg); }
}
.start-actions {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 12px; margin-top: 12px;
}
.start-play { min-width: 140px; }
.how-to-play { min-width: 140px; }

/* ----- AC-4: tutorial overlay ------------------------------------- */
.tutorial-card {
  text-align: left; border-color: var(--candy-lavender);
  max-width: 86%;
}
.tutorial-icons {
  list-style: none; padding: 0; margin: 0 0 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.tutorial-icons li {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 8px; border-radius: 12px;
  background: var(--candy-cream);
  font-size: 18px; line-height: 1.3;
}
.tutorial-icons strong { color: var(--ink); font-weight: 700; }
.tut-icon {
  font-size: 28px; line-height: 1;
  width: 36px; text-align: center; flex-shrink: 0;
}
.tut-text { flex: 1; }
.tutorial-card .btn.primary { display: block; margin: 0 auto; min-width: 140px; }

/* ----- AC-4: on-screen dpad --------------------------------------- */
.dpad {
  display: flex; justify-content: center; align-items: center;
  gap: 18px; padding: 6px 0 2px;
}
.dpad-btn {
  appearance: none; border: 4px solid #fff;
  background: var(--candy-lavender); color: #ffffff;
  font-family: inherit; font-weight: 700; font-size: 28px;
  width: 64px; height: 64px; line-height: 1;
  border-radius: 50%;
  box-shadow: 0 4px 0 #8a6cff, var(--shadow);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  min-width: 44px; min-height: 44px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.dpad-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 #8a6cff, var(--shadow); }
.dpad-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6cff; }
.dpad-btn:focus-visible { outline: 3px solid var(--candy-pink); outline-offset: 3px; }
.dpad-glyph { display: inline-block; line-height: 1; transform: translateY(-1px); }

.hint { text-align: center; font-size: 18px; color: var(--ink-soft); font-weight: 500; }

.hint kbd {
  display: inline-block; padding: 2px 6px; margin: 0 1px;
  font-family: inherit; font-size: 16px; font-weight: 600;
  background: #fff; color: var(--ink);
  border-radius: 6px; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .start-emoji { animation: none; }
}

@media (max-width: 480px) {
  .dpad-btn { width: 60px; height: 60px; font-size: 24px; }
  .start-play, .how-to-play { min-width: 0; flex: 1 1 140px; }
}

/* ----- AC-5: HUD additions (level + power-up badge) ------------- */
.hud-powerup {
  align-items: center;
  transition: opacity 0.18s ease;
}
.hud-powerup[hidden] { display: none; }
.hud-powerup-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-block;
  margin-top: 2px;
}
.hud-powerup-emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  pointer-events: none;
}
.hud-powerup-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(0deg);
}
.hud-powerup-bg { stroke: rgba(44, 37, 64, 0.18); }
.hud-powerup-fg { transition: stroke-dashoffset 0.12s linear; }
.hud-powerup-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 2px;
}
.hud-powerup[data-type="slowMo"] .hud-powerup-fg { stroke: #9ed8ff; }
.hud-powerup[data-type="ghost"]  .hud-powerup-fg { stroke: #dbc6ff; }
.hud-powerup[data-type="shield"] .hud-powerup-fg { stroke: #ffd86b; }
.hud-powerup[data-type="bonus"]  .hud-powerup-fg { stroke: #ffe066; }

/* AC-5: difficulty-mode badge injected into the game-over card. */
.go-difficulty {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ----- AC-5: Difficulty selector on the start screen ------------- */
.difficulty {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0 4px;
  width: 100%;
}
.difficulty-card {
  flex: 1 1 90px;
  min-width: 90px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--candy-cream);
  border: 3px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  color: var(--ink);
  transition: transform 0.12s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.12s ease;
  position: relative;
}
.difficulty-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(180, 150, 220, 0.4);
}
.difficulty-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.difficulty-card input:checked ~ .difficulty-name { color: var(--candy-pink); }
.difficulty-card:has(input:checked) {
  border-color: var(--candy-mint);
  background: #ffffff;
  box-shadow: 0 3px 0 #4fc19a;
}
.difficulty-card input:focus-visible + .difficulty-emoji {
  outline: 3px solid var(--candy-lavender);
  outline-offset: 3px;
  border-radius: 12px;
}
.difficulty-emoji { font-size: 26px; line-height: 1; }
.difficulty-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.difficulty-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.2;
}

/* ----- AC-5: Pause overlay --------------------------------------- */
.pause-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 26px 28px;
  border-color: var(--candy-lavender);
}
.pause-emoji {
  font-size: 54px; line-height: 1; margin-bottom: 4px;
  filter: drop-shadow(0 4px 0 rgba(60, 30, 90, 0.18));
  animation: pause-pulse 1.6s ease-in-out infinite;
}
@keyframes pause-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

/* ----- AC-5: Game-Over stars ------------------------------------- */
.stars-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 6px 0 14px;
  font-size: 44px;
  line-height: 1;
}
.star {
  color: rgba(60, 30, 90, 0.18);
  transition: color 0.25s ease, transform 0.25s ease;
  display: inline-block;
  filter: drop-shadow(0 2px 0 rgba(60, 30, 90, 0.12));
}
.star.is-filled {
  color: #ffd86b;
  animation: star-pop 0.45s ease-out;
}
.star.is-empty {
  color: rgba(60, 30, 90, 0.18);
}
@keyframes star-pop {
  0%   { transform: scale(0.4) rotate(-15deg); }
  60%  { transform: scale(1.2) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.stars-row .star:nth-child(1).is-filled { animation-delay: 0.0s; }
.stars-row .star:nth-child(2).is-filled { animation-delay: 0.12s; }
.stars-row .star:nth-child(3).is-filled { animation-delay: 0.24s; }

/* AC-5 smooth fade-in for overlay cards */
.overlay-card {
  animation: overlay-in 0.22s ease-out;
}
@keyframes overlay-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

