/* Palette is taken from real soap-film iridescence — the hues thin-film
   interference actually produces — on a deep blue-ink ground. Single
   deliberate visual world, so every colour is painted explicitly. */
:root {
  --ink: #0d1b2e;
  --ink-2: #16324f;
  --cream: #fdf6ef;
  --cream-dim: rgba(253, 246, 239, 0.62);
  --pink: #ff9ecd;
  --mint: #7ef0d0;
  --gold: #ffd98a;
  --lilac: #b8a6ff;
  --display: "Fredoka", "Trebuchet MS", "Segoe UI", sans-serif;
  --body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--body);
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
}

/* ---- scoreboard: score is the hero, record demoted to a small line ---- */
#scoreboard {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: max-content;
}

#score {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.5rem;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.55);
}

#recordLine {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cream-dim);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* combo floats free, only while it's actually running */
#comboStat {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.92rem;
  color: #2a1630;
  background: linear-gradient(135deg, var(--gold), var(--pink));
  border-radius: 999px;
  padding: 5px 15px;
  box-shadow: 0 5px 16px rgba(255, 217, 138, 0.35);
  white-space: nowrap;
}

#comboStat[hidden] {
  display: none;
}

/* ---- hold-to-activate fullscreen button ---- */
#fullscreenWrap {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 48px;
  height: 48px;
  pointer-events: auto;
}

#fsRing {
  position: absolute;
  inset: 0;
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
  pointer-events: none;
}

#fsRing circle {
  fill: none;
  stroke-width: 3;
}

.fsRingBg {
  stroke: rgba(253, 246, 239, 0.18);
}

.fsRingProgress {
  stroke: var(--gold);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.05s linear;
}

#fullscreenBtn {
  position: absolute;
  inset: 4px;
  pointer-events: auto;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.34);
  color: var(--cream);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- full-screen start overlay ---- */
.overlay-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
  color: var(--cream);
  z-index: 10;
  background:
    radial-gradient(120% 80% at 20% 8%, #26507a 0%, transparent 55%),
    radial-gradient(90% 70% at 85% 92%, #3a2a63 0%, transparent 60%),
    linear-gradient(180deg, var(--ink-2) 0%, var(--ink) 78%);
}

.overlay-screen h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.7rem, 8vw, 2.6rem);
  line-height: 1.12;
  text-wrap: balance;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

.overlay-screen p {
  max-width: 340px;
  font-size: 0.95rem;
  color: var(--cream-dim);
  line-height: 1.45;
}

.overlay-screen.hidden {
  display: none;
}

.irid {
  background: linear-gradient(95deg, var(--pink) 0%, var(--lilac) 38%, var(--mint) 68%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* the mascot rides inside an actual soap bubble */
.bubbleFrame {
  position: relative;
  width: clamp(150px, 42vw, 190px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.34), rgba(255, 158, 205, 0.16) 46%, rgba(126, 240, 208, 0.13) 72%, rgba(184, 166, 255, 0.12));
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 26px rgba(255, 158, 205, 0.28), inset 0 0 22px rgba(255, 255, 255, 0.14);
}

.bubbleFrame::after {
  content: "";
  position: absolute;
  top: 15%;
  left: 20%;
  width: 24%;
  height: 15%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  filter: blur(1px);
}

#mascot {
  width: 76%;
  height: auto;
}

.bigBtn {
  pointer-events: auto;
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 600;
  color: #2a1630;
  background: linear-gradient(135deg, var(--gold) 0%, var(--pink) 100%);
  box-shadow: 0 8px 20px rgba(255, 158, 205, 0.36);
}

.toggleRow {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--cream-dim);
  cursor: pointer;
}

.toggleRow input {
  width: 16px;
  height: 16px;
  accent-color: var(--pink);
  cursor: pointer;
}

/* ---- celebration / warning banner ---- */
#banner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -10px) scale(0.8);
  pointer-events: none;
  font-family: var(--display);
  font-size: clamp(1.4rem, 6vw, 2.4rem);
  font-weight: 600;
  text-align: center;
  color: var(--cream);
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
  opacity: 0;
  z-index: 20;
  width: 92%;
  max-width: 520px;
}

#banner.show {
  animation: bannerPop 0.9s ease-out forwards;
}

#banner.good {
  color: var(--gold);
}

#banner.warn {
  color: var(--mint);
}

@keyframes bannerPop {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -10px) scale(1.15);
  }
  35% {
    transform: translate(-50%, -10px) scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -30px) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  #banner.show {
    animation-duration: 0.01ms;
  }
}
