/* Bell Snake — flat, clean, colourful.
   Shares the arcade's type, navy ink and chroma palette so it sits beside
   Whack-a-Bell and Treble Invaders without looking like a different product. */

:root {
  --bs-ink: #1b233e;
  --bs-sky: #aedcf2;
  --bs-grass: #b9dfa6;
  --bs-paper: #ffffff;
  --bs-soft: #eef4fb;
}

* { box-sizing: border-box; }

/* Every layout rule below sets display:flex/grid, and any of those outranks
   the user-agent's [hidden] { display: none }. Without this, hiding a panel
   in JS does nothing and the play HUD sits under the menu. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Nunito, system-ui, -apple-system, sans-serif;
  color: var(--bs-ink);
  background: linear-gradient(#cfeafb 0%, var(--bs-sky) 46%, #d9f0c8 100%);
  -webkit-text-size-adjust: 100%;
}
body { overscroll-behavior: none; }

/* ── Scenery ──────────────────────────────────────────────────────────── */
.bs-scenery {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.bs-scenery svg { width: 100%; height: 100%; display: block; }
.bs-cloud { animation: bs-drift 34s linear infinite; }
.bs-cloud-b { animation-duration: 52s; }
@keyframes bs-drift {
  from { transform: translateX(-140px); }
  to   { transform: translateX(1580px); }
}

/* ── App shell ────────────────────────────────────────────────────────── */
.bs-app {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* The steering pad measured 6px BELOW the viewport bottom on an iPad, and
     the home indicator takes ~21pt more on top of that, so the bottom row of
     arrows was partly unreachable. Must be part of THIS shorthand — a separate
     padding-bottom rule earlier in the file loses to it. */
  padding: 14px 14px calc(20px + env(safe-area-inset-bottom));
}


/* ── Menu ─────────────────────────────────────────────────────────────── */
.bs-menu {
  width: min(760px, 100%);
  margin: auto;
  padding: 8px 0 24px;
  text-align: center;
}
.bs-title {
  margin: 4px 0 2px;
  font-size: clamp(34px, 8vw, 62px);
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--bs-ink);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.6);
}
.bs-sub {
  margin: 0 0 20px;
  font-size: clamp(14px, 3.4vw, 19px);
  font-weight: 700;
  color: #4a5570;
}

.bs-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 520px) { .bs-modes { grid-template-columns: 1fr; } }

.bs-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 14px;
  border: 3px solid rgba(27, 35, 62, 0.12);
  border-radius: 20px;
  background: var(--bs-paper);
  box-shadow: 0 5px 0 rgba(27, 35, 62, 0.1);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.bs-mode:hover { transform: translateY(-2px); box-shadow: 0 7px 0 rgba(27, 35, 62, 0.12); }
.bs-mode:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(27, 35, 62, 0.12); }
.bs-mode.is-primary { border-color: #6abb4a; }
.bs-mode-emoji { font-size: 30px; line-height: 1; }
.bs-mode-name { font-size: 20px; font-weight: 900; }
.bs-mode-blurb { font-size: 13px; font-weight: 600; color: #5b6580; }

.bs-optrow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.bs-optlabel {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #5b6580;
  margin-right: 4px;
}
.bs-opt {
  padding: 9px 16px;
  border: 2px solid rgba(27, 35, 62, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: #46506b;
  cursor: pointer;
}
.bs-opt.is-on {
  background: var(--bs-ink);
  border-color: var(--bs-ink);
  color: #fff;
}
.bs-opthint {
  width: 100%;
  margin: 2px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: #5b6580;
}

/* ── Levels ───────────────────────────────────────────────────────────── */
.bs-levels-title {
  margin: 22px 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #5b6580;
}
.bs-levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.bs-level {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 12px 12px 42px;
  border: 2px solid rgba(27, 35, 62, 0.12);
  border-radius: 16px;
  background: var(--bs-paper);
  box-shadow: 0 3px 0 rgba(27, 35, 62, 0.08);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  text-align: left;
}
.bs-level:hover:not(.is-locked) { transform: translateY(-2px); }
.bs-level-no {
  position: absolute;
  left: 10px; top: 12px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bs-ink);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.bs-level-name { font-size: 15px; font-weight: 900; }
.bs-level-blurb { font-size: 11.5px; font-weight: 600; color: #5b6580; line-height: 1.25; }
.bs-level-best {
  position: absolute;
  right: 10px; top: 10px;
  font-size: 11px;
  font-weight: 800;
  color: #b8860b;
}
.bs-level.is-locked { opacity: 0.5; cursor: not-allowed; }
.bs-level.is-locked .bs-level-no { background: #9aa3b8; }

/* ── Play ─────────────────────────────────────────────────────────────── */
.bs-playwrap {
  width: 100%;
  max-width: 760px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.bs-hud {
  width: 100%;
  max-width: min(78vh, 640px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.bs-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(27, 35, 62, 0.1);
}
.bs-chip b { font-size: 20px; font-weight: 900; line-height: 1.1; }
.bs-chip small {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #6b7590;
}

/* The scale strip: only Scale Snake shows it. */
.bs-strip {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 30px;
}
.bs-step {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 2px solid var(--c);
  background: rgba(255, 255, 255, 0.85);
  color: var(--c);
  font-size: 13px;
  font-weight: 900;
  opacity: 0.45;
}
.bs-step.is-done { background: var(--c); color: #fff; opacity: 1; }
.bs-step.is-now {
  opacity: 1;
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(27, 35, 62, 0.12);
}

/* The board is square and sized off the SHORT axis, so it never scrolls. */
.bs-board {
  position: relative;
  /* 78vh left the play screen 6px taller than an iPad's viewport once the HUD,
     the scale strip, the steering pad and the hint were stacked under it — the
     bottom row of arrows sat below the fold before the home indicator was even
     considered. The board is the only flexible piece, so it yields. */
  width: min(92vw, 58vh, 640px);
  aspect-ratio: 1 / 1;
}
#bsCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 22px;
  border: 3px solid rgba(27, 35, 62, 0.14);
  box-shadow: 0 8px 0 rgba(27, 35, 62, 0.1);
  background: #f4fbf6;
  touch-action: none;   /* swipes steer the snake; they must not scroll */
}

.bs-toast {
  position: absolute;
  left: 50%;
  top: 14%;
  transform: translate(-50%, -6px) scale(0.9);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--bs-ink);
  color: #fff;
  font-size: clamp(13px, 3vw, 17px);
  font-weight: 900;
  letter-spacing: 0.4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.bs-toast.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.bs-toast.is-scale { background: linear-gradient(90deg, #e72829, #f39422, #f1e606, #6abb4a, #099695, #7b569e); }
.bs-toast.is-chord { background: #099695; }
.bs-toast.is-melody { background: #7b569e; }

/* ── Directional pad ──────────────────────────────────────────────────── */
.bs-pad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 48px);
  gap: 6px;
  justify-content: center;
}
.bs-pad button {
  display: grid;
  place-items: center;
  border: 2px solid rgba(27, 35, 62, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--bs-ink);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.bs-pad button:active { background: var(--bs-ink); color: #fff; }
.bs-pad .bs-up { grid-column: 2; grid-row: 1; }
.bs-pad .bs-left { grid-column: 1; grid-row: 2; }
.bs-pad .bs-down { grid-column: 2; grid-row: 2; }
.bs-pad .bs-right { grid-column: 3; grid-row: 2; }

.bs-hint {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #5b6580;
  text-align: center;
}

/* ── Countdown ────────────────────────────────────────────────────────── */
.bs-count {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  font-size: clamp(60px, 18vw, 140px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 6px 0 rgba(27, 35, 62, 0.28);
  pointer-events: none;
}
.bs-count.is-pop { animation: bs-pop 0.5s ease; }
@keyframes bs-pop {
  0% { transform: scale(0.5); opacity: 0; }
  40% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Results ──────────────────────────────────────────────────────────── */
.bs-veil {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(27, 35, 62, 0.55);
  backdrop-filter: blur(3px);
}
.bs-veil[hidden] { display: none; }
.bs-card {
  width: min(430px, 100%);
  padding: 26px 22px;
  border-radius: 26px;
  background: var(--bs-paper);
  box-shadow: 0 16px 40px rgba(27, 35, 62, 0.3);
  text-align: center;
}
.bs-card h2 {
  margin: 0 0 10px;
  font-size: clamp(22px, 5.5vw, 30px);
  font-weight: 900;
  letter-spacing: 0.5px;
}
.bs-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 12px;
}
.bs-big span {
  font-size: clamp(48px, 13vw, 74px);
  font-weight: 900;
  line-height: 1;
  color: #6abb4a;
}
.bs-big small {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #6b7590;
}
.bs-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: #5b6580;
}
.bs-stats b { display: block; font-size: 17px; font-weight: 900; color: var(--bs-ink); }

.bs-melodyrow {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 12px;
}
.bs-mel {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--c);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  opacity: 0.75;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.bs-mel.is-on { opacity: 1; transform: scale(1.24) translateY(-2px); }

.bs-again, .bs-mine {
  width: 100%;
  height: 54px;
  margin-bottom: 8px;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
}
.bs-again { background: #6abb4a; color: #fff; box-shadow: 0 4px 0 #55993a; }
.bs-again:active { transform: translateY(3px); box-shadow: 0 1px 0 #55993a; }
.bs-mine { background: #fff; color: var(--bs-ink); border: 3px solid var(--bs-ink); }
.bs-mine:disabled { opacity: 0.55; cursor: default; }
.bs-menu-btn2 {
  width: 100%;
  padding: 10px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: #6b7590;
  cursor: pointer;
}

/* ── Accessibility ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .bs-cloud, .bs-cloud-b { animation: none; }
  .bs-count.is-pop { animation: none; }
  .bs-mode, .bs-level, .bs-mel, .bs-toast { transition: none; }
}
@media (prefers-contrast: more) {
  .bs-chip, .bs-opt, .bs-mode, .bs-level { border-color: var(--bs-ink); }
}

/* ── Speed picker ─────────────────────────────────────────────────────────
   Five settings, turtle to rabbit. Icon over label so the row reads at a
   glance for a child who cannot yet read "Turtle" — the animal IS the
   control, the word underneath is for the grown-up. */
.bs-speedrow {
  gap: 6px;
}
.bs-speed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 12px;
  line-height: 1.1;
}
.bs-speed span { font-size: 20px; }
.bs-speed small {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  opacity: 0.75;
}
.bs-speed.is-on small { opacity: 1; }
@media (max-width: 520px) {
  .bs-speed { padding: 6px 9px; }
  .bs-speed span { font-size: 18px; }
  .bs-speed small { font-size: 8.5px; letter-spacing: 0.4px; }
}
