/* Flappy Bell — styles. Night-sky indigo stage, chroma bell cards. */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body.flappy-page {
  font-family: "Nunito", "Avenir Next Rounded", "Trebuchet MS", "Verdana", sans-serif;
  /* The game's night sky, page-wide: indigo air + violet stage floor */
  background:
    linear-gradient(0deg, #443fa5 0px, #443fa5 40px, rgba(255, 255, 255, 0.5) 40px, rgba(255, 255, 255, 0.5) 43px, transparent 43px),
    linear-gradient(180deg, #2b2f8e 0%, #20246c 55%, #161a4e 100%);
  color: #fff;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Starfield — the same starry sky the game renders, as a page backdrop */
body.flappy-page::before,
body.flappy-page::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
  z-index: 0;
}

body.flappy-page::before {
  opacity: 0.75;
  box-shadow:
    4vw 12vh 0 0 #fff, 11vw 34vh 0 1px #fff, 7vw 61vh 0 0 #9fd8ff,
    16vw 8vh 0 0 #fff, 21vw 47vh 0 0 #fff, 26vw 22vh 0 1px #9fd8ff,
    31vw 70vh 0 0 #fff, 36vw 15vh 0 0 #fff, 41vw 39vh 0 0 #fff,
    47vw 6vh 0 1px #fff, 52vw 55vh 0 0 #9fd8ff, 57vw 27vh 0 0 #fff,
    63vw 66vh 0 0 #fff, 68vw 10vh 0 0 #fff, 72vw 43vh 0 1px #fff,
    78vw 19vh 0 0 #9fd8ff, 83vw 58vh 0 0 #fff, 88vw 31vh 0 0 #fff,
    93vw 72vh 0 0 #fff, 97vw 14vh 0 1px #fff;
}

body.flappy-page::after {
  opacity: 0.5;
  animation: starTwinkle 3.2s ease-in-out infinite alternate;
  box-shadow:
    8vw 25vh 0 0 #fff, 14vw 68vh 0 0 #fff, 19vw 16vh 0 0 #9fd8ff,
    24vw 52vh 0 0 #fff, 29vw 5vh 0 0 #fff, 34vw 62vh 0 0 #fff,
    39vw 30vh 0 0 #fff, 44vw 74vh 0 0 #9fd8ff, 49vw 20vh 0 0 #fff,
    55vw 44vh 0 0 #fff, 60vw 9vh 0 0 #fff, 65vw 57vh 0 0 #fff,
    70vw 33vh 0 0 #9fd8ff, 76vw 65vh 0 0 #fff, 81vw 12vh 0 0 #fff,
    86vw 48vh 0 0 #fff, 91vw 24vh 0 0 #fff, 95vw 60vh 0 0 #fff;
}

@keyframes starTwinkle {
  from { opacity: 0.25; }
  to { opacity: 0.85; }
}

.app {
  position: relative;
  z-index: 1; /* above the body starfield */
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}






/* ---- character select ---- */

.select-screen {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  padding: calc(58px + env(safe-area-inset-top)) 16px 18px;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.select-head { text-align: center; }

.app-title {
  margin: 0;
  font-size: clamp(30px, 6vw, 40px);
  font-weight: 900;
  letter-spacing: 0.5px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.select-sub {
  margin: 4px 0 0;
  font-size: clamp(17px, 3.5vw, 21px);
  font-weight: 800;
  color: #bfc8ff;
}

.bell-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.bell-card {
  appearance: none;
  border: 3px solid transparent;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  padding: 10px 6px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.bell-card:hover { transform: translateY(-3px); }
.bell-card:active { transform: translateY(0) scale(0.97); }

.bell-card.is-selected {
  border-color: var(--bell-color);
  background: rgba(255, 255, 255, 0.20);
  animation: bellBounce 0.45s ease;
}

@keyframes bellBounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.09); }
  65% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.bell-card-img {
  width: 58px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bell-card-img img {
  max-width: 100%;
  max-height: 100%;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.bell-card-note {
  font-size: 15px;
  font-weight: 900;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--bell-color);
  color: #fff;
  min-width: 42px;
  text-align: center;
}

/* Yellow-family notes need dark text for contrast */
.bell-card[style*="#f1e606"] .bell-card-note,
.bell-card[style*="#ffd25b"] .bell-card-note {
  color: #512d1b;
}

.select-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: env(safe-area-inset-bottom);
}

.controls-hint {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #bfc8ff;
}

.controls-hint kbd {
  font-family: inherit;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 1px 7px;
}

.action-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 34px;
  font-family: inherit;
  font-size: 19px;
  font-weight: 900;
  cursor: pointer;
  color: #1b233e;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  min-height: 52px;
}

.action-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.action-btn.primary {
  background: #6ab845; /* Prodigies green — solid, no gradients */
  color: #fff;
}

.action-btn.save-btn {
  background: #099695; /* Prodigies teal */
  color: #fff;
  padding: 12px 22px;
  font-size: 16px;
  min-height: 46px;
}

/* ---- game stage ---- */

.game-screen {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

/* Stage size is set by JS: height fits the container, width widens from
   480 (portrait phones) up to 1280 logical px (iPad landscape / desktop),
   revealing more of the world left and right. */
.stage {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.score-hud {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  font-size: 46px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 10;
}

.score-hud.pop { animation: scorePop 0.3s ease; }

.harmony-hud {
  position: absolute;
  top: calc(76px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 19px;
  font-weight: 900;
  color: #ffd25b;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 10;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.harmony-hud.pop { animation: harmonyPop 0.35s ease; }

@keyframes harmonyPop {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.25); }
  100% { transform: translateX(-50%) scale(1); }
}

@keyframes scorePop {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.3); }
  100% { transform: translateX(-50%) scale(1); }
}

.ready-hint {
  position: absolute;
  top: 24%;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 10;
  animation: hintFloat 1.6s ease-in-out infinite;
}

.ready-title {
  font-size: 34px;
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.ready-sub {
  font-size: 16px;
  font-weight: 800;
  color: #bfc8ff;
}

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

/* ---- game over ---- */

.game-over-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(360px, 90%);
  max-height: 94%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(24, 28, 74, 0.94);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  padding: 18px 18px 20px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: panelIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes panelIn {
  from { transform: translate(-50%, -44%) scale(0.85); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.game-over-panel h2 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 900;
}

.go-bell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
}

.go-bell img {
  width: 64px;
  height: auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.go-bell-name {
  font-weight: 900;
  font-size: 16px;
}

.new-best {
  display: inline-block;
  margin: 4px 0 6px;
  padding: 5px 16px;
  border-radius: 999px;
  background: #f39422; /* solid Prodigies orange */
  font-weight: 900;
  font-size: 16px;
  animation: bellBounce 0.6s ease infinite alternate;
}

.go-scores {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 12px;
}

.go-score-row {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  padding: 10px 12px;
  flex: 1;
  min-width: 0;
}

.go-harmony-row dd { color: #ffd25b; }

.go-score-row dt {
  font-size: 13px;
  font-weight: 800;
  color: #bfc8ff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.go-score-row dd {
  margin: 2px 0 0;
  font-size: 30px;
  font-weight: 900;
}

.go-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.go-actions .action-btn { width: 100%; }

/* ---- save score + leaderboard ---- */

.save-score-row {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.save-score-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #bfc8ff;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.save-score-controls {
  display: flex;
  gap: 8px;
}

.save-score-controls input {
  flex: 1;
  min-width: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  padding: 8px 16px;
}

.save-score-controls input::placeholder { color: rgba(255, 255, 255, 0.45); }

.save-score-controls input:focus-visible {
  outline: 3px solid #9fd8ff;
  outline-offset: 1px;
}

.leaderboard { margin: 0 0 14px; }

.leaderboard-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 900;
  color: #bfc8ff;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 15px;
  font-weight: 800;
}

.lb-row.is-new {
  background: rgba(9, 150, 149, 0.4);
  outline: 2px solid #099695;
}

.lb-rank {
  width: 22px;
  text-align: center;
  color: #ffd25b;
  flex: none;
}

.lb-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score { flex: none; }

.lb-empty {
  padding: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #bfc8ff;
}

/* PK-5 class-score widget (injected by js/score-submit.js) — give it
   breathing room so it never crowds the Play Again button */
#classScoreSlot .pk5s-block {
  margin: 0 0 16px;
}

/* ---- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .bell-card,
  .bell-card.is-selected,
  .score-hud.pop,
  .harmony-hud.pop,
  .ready-hint,
  .new-best,
  .game-over-panel,
  body.flappy-page::after {
    animation: none;
    transition: none;
  }
}

/* ── Pipe tune picker ───────────────────────────────────────────────────── */
.tune-label {
  margin: 18px 0 8px; font-size: 10px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: rgba(253, 248, 238, 0.55); text-align: center;
}
.tune-grid {
  display: flex; flex-wrap: wrap; gap: 7px; justify-content: center;
  max-width: 560px; margin: 0 auto;
}
.tune-card {
  display: grid; gap: 2px; padding: 8px 13px;
  background: rgba(253, 248, 238, 0.08);
  border: 2px solid rgba(253, 248, 238, 0.16); border-radius: 12px;
  color: #fdf8ee; cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.14s;
}
.tune-card:hover { background: rgba(253, 248, 238, 0.14); transform: translateY(-2px); }
.tune-card.is-selected { background: #099695; border-color: #00706f; }
.tune-card-name { font-size: 13px; font-weight: 900; }
.tune-card-notes {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em;
  color: rgba(253, 248, 238, 0.62);
}
.tune-card.is-selected .tune-card-notes { color: rgba(253, 248, 238, 0.85); }
/* ── Difficulty cards ───────────────────────────────────────────────────────
   Same language as the tune cards above, wider because there are only two and
   each carries a line of explanation. Green for the chosen one, matching the
   .tune-card.is-selected teal family the screen already uses. */
.mode-grid {
  display: flex; flex-wrap: wrap; gap: 9px; justify-content: center;
  max-width: 560px; margin: 0 auto;
}
.mode-card {
  display: grid; gap: 3px; padding: 10px 22px; min-width: 150px;
  font-family: inherit; font-size: 15px; font-weight: 900;
  background: rgba(253, 248, 238, 0.08);
  border: 2px solid rgba(253, 248, 238, 0.16); border-radius: 12px;
  color: #fdf8ee; cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.14s;
  -webkit-tap-highlight-color: transparent;
}
.mode-card:hover { background: rgba(253, 248, 238, 0.14); transform: translateY(-2px); }
.mode-card.is-on { background: #099695; border-color: #00706f; }
.mode-card small {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.04em;
  color: rgba(253, 248, 238, 0.62);
}
.mode-card.is-on small { color: rgba(253, 248, 238, 0.85); }

.tune-blurb {
  margin: 9px auto 0; max-width: 42ch; text-align: center;
  font-size: 13px; font-weight: 700; color: rgba(253, 248, 238, 0.62);
}

/* ── Flights (levels) ───────────────────────────────────────────────────── */
.flight-label {
  margin: 4px 0 8px; font-size: 10px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: rgba(253, 248, 238, 0.55); text-align: center;
}
.flight-label.endless-label { margin-top: 26px; }
.flight-grid {
  display: grid; gap: 8px; max-width: 560px; margin: 0 auto;
}
@media (min-width: 620px) { .flight-grid { grid-template-columns: 1fr 1fr; } }
.flight-card {
  display: flex; align-items: center; gap: 11px; text-align: left;
  padding: 11px 13px; color: #fdf8ee;
  background: rgba(253, 248, 238, 0.08);
  border: 2px solid rgba(253, 248, 238, 0.16); border-radius: 14px;
  cursor: pointer; transition: background 0.14s, border-color 0.14s, transform 0.14s;
}
.flight-card:hover:not(:disabled) { background: rgba(253, 248, 238, 0.14); transform: translateY(-2px); }
.flight-card.is-locked { opacity: 0.45; cursor: not-allowed; }
.flight-num {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; background: #099695; font-weight: 900; font-size: 13px;
}
.flight-card.is-locked .flight-num { background: rgba(253, 248, 238, 0.22); }
.flight-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.flight-name { font-size: 15px; font-weight: 900; }
.flight-blurb { font-size: 11.5px; font-weight: 700; color: rgba(253, 248, 238, 0.6); }
.flight-meta { flex: none; display: grid; justify-items: end; gap: 2px; }
.flight-target {
  font-size: 10px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;
  color: rgba(253, 248, 238, 0.5);
}
.flight-stars i { font-style: normal; font-size: 11px; color: rgba(253, 248, 238, 0.22); }
.flight-stars i.on { color: #ffc21c; }

/* ── Level clear panel ──────────────────────────────────────────────────── */
.clear-panel { text-align: center; }
.clear-eyebrow {
  margin: 0 0 4px; font-size: 10px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: rgba(253, 248, 238, 0.55);
}
.clear-name { margin: 0 0 10px; font-size: 26px; font-weight: 900; }
.clear-stars i { font-style: normal; font-size: 30px; color: rgba(253, 248, 238, 0.22); }
.clear-stars i.on { color: #ffc21c; }
.clear-harmony { margin: 10px 0 16px; font-size: 14px; font-weight: 700; color: rgba(253, 248, 238, 0.7); }
.clear-harmony b { color: #ffd25b; font-size: 17px; }
.clear-actions { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
