/* Flower's Playtime. The pop-star look is shared with Flower Learns. */
:root {
  --pink: #FF6B9E; --purple: #996BF2; --blue: #4599FF; --teal: #21BDAD; --green: #52C761;
  --yellow: #FFC72E; --orange: #FF9438; --red: #F25C5C; --ink: #3D2E61; --paper: #FFFCF7;
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --hud: 72px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: #4A1E9E; color: var(--ink); font-family: var(--font);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation; -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; overflow: hidden; }

/* ---------- Screens ---------- */

.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--top) + 10px) 16px calc(var(--bottom) + 18px);
  transition: opacity .3s ease, transform .3s ease;
  overflow: hidden;
}
.screen.enter { opacity: 0; transform: scale(1.04); }
.screen.leave { opacity: 0; pointer-events: none; }
.screen > * { position: relative; z-index: 1; }
.spacer { flex: 1; min-height: 4px; }

/* The pop-star stage. */
.bg-stage {
  color: #fff;
  background: radial-gradient(120% 60% at 50% 0%, rgba(255, 138, 216, .85) 0%, rgba(255, 138, 216, 0) 60%),
              linear-gradient(165deg, #5A23B5 0%, #A0189A 55%, #F2457E 100%);
}
.stage-lights { position: absolute !important; inset: 0; pointer-events: none; z-index: 0 !important; overflow: hidden; }
.beam {
  position: absolute; top: -8%; width: 50%; height: 125%; transform-origin: 50% 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, .26), rgba(255, 255, 255, 0) 78%);
  clip-path: polygon(44% 0, 56% 0, 100% 100%, 0 100%);
}
.beam-l { left: -6%; animation: sweep-l 6s ease-in-out infinite alternate; }
.beam-r { right: -6%; animation: sweep-r 7.5s ease-in-out infinite alternate; background: linear-gradient(to bottom, rgba(255, 228, 120, .26), rgba(255, 228, 120, 0) 78%); }
@keyframes sweep-l { from { transform: rotate(-28deg); } to { transform: rotate(12deg); } }
@keyframes sweep-r { from { transform: rotate(28deg); } to { transform: rotate(-12deg); } }
.sparkle { position: absolute; color: #fff; opacity: 0; animation: twinkle 3s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4); } 50% { opacity: .85; transform: scale(1); } }

.app-title {
  margin: 0; font-size: clamp(34px, 5.6dvh, 46px); font-weight: 900; line-height: 1.02; text-align: center;
  text-shadow: 0 3px 0 rgba(60, 10, 90, .35), 0 0 22px rgba(255, 160, 225, .9);
}

/* ---------- Buttons ---------- */

.chunky {
  --c: var(--pink);
  position: relative; color: #fff; border-radius: 28px;
  background: linear-gradient(color-mix(in srgb, var(--c) 82%, #fff), var(--c));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 70%, #000),
              0 12px 22px color-mix(in srgb, var(--c) 38%, transparent),
              inset 0 0 0 3px rgba(255, 255, 255, .45);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s;
}
.chunky:active {
  transform: translateY(4px) scale(.98);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 70%, #000), 0 4px 10px color-mix(in srgb, var(--c) 30%, transparent),
              inset 0 0 0 3px rgba(255, 255, 255, .45);
}

.tile {
  width: 100%; display: flex; align-items: center; gap: 16px; padding: 0 22px; text-align: left;
  min-height: clamp(92px, 14dvh, 124px);
}
.tile-icon { font-size: clamp(44px, 7dvh, 58px); line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.15)); }
.tile-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.tile-title { font-size: clamp(24px, min(4.2dvh, 7.4vw), 34px); font-weight: 900; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { font-size: 19px; font-weight: 800; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-arrow svg { width: 22px; height: 22px; opacity: .85; }
.tile.small { min-height: 78px; }
.tile.small .tile-icon { font-size: 40px; }
.tile.small .tile-title { font-size: 26px; }
.tile.small .tile-sub { font-size: 16px; }

.round-btn {
  width: 52px; height: 52px; border-radius: 50%; background: #fff; color: var(--ink); flex: none;
  display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0,0,0,.13); transition: transform .12s;
}
.round-btn:active { transform: scale(.9); }
.round-btn svg { width: 24px; height: 24px; }

/* ---------- Mascot ---------- */

.mascot { display: block; overflow: visible; width: auto; flex: none; }
.mascot .head { transform-box: view-box; transform-origin: 100px 165px; }
.mascot.dance .head { animation: sway 1.1s ease-in-out infinite alternate; }
.mascot.cheer .head { animation: hop .32s ease-in-out infinite alternate; }
.mascot .petals { transform-box: view-box; transform-origin: 100px 100px; animation: spin 30s linear infinite; }
.mascot .eyes { transform-box: view-box; transform-origin: 100px 94px; animation: blink 4.2s infinite; }
.mascot .mouth { display: none; }
.mascot.happy .m-happy, .mascot.cheer .m-cheer, .mascot.oops .m-oops { display: inline; }
.mascot .glasses { display: none; }
.mascot.cheer .glasses { display: inline; }
@keyframes sway { from { transform: rotate(-6deg) translateY(0); } to { transform: rotate(6deg) translateY(-6px); } }
@keyframes hop { from { transform: rotate(-9deg) translateY(0); } to { transform: rotate(9deg) translateY(-16px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }

/* ---------- Effects ---------- */

.floating-notes { position: absolute !important; inset: 0; pointer-events: none; z-index: 0 !important; overflow: hidden; }
.floating-notes span { position: absolute; bottom: -60px; font-weight: 900; opacity: 0; animation: float-up linear infinite; }
@keyframes float-up {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: .35; }
  50% { transform: translateY(-55dvh) translateX(16px); }
  90% { opacity: .35; }
  100% { transform: translateY(-115dvh) translateX(-10px); opacity: 0; }
}
.confetti { position: absolute !important; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60 !important; }

.shake { animation: shake .4s ease; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-7px); } 80% { transform: translateX(7px); } }
.bounce { animation: pop-in .45s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop-in { 0% { transform: scale(.8); } 100% { transform: scale(1); } }

/* ---------- Grown-up lock ---------- */

.gate-screen { gap: 10px; }
.gate-top { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 420px; justify-content: center; }
.gate-top .mascot { max-height: 15dvh; }
.gate-sub { font-size: 18px; font-weight: 800; text-align: center; opacity: .95; margin-top: 6px; }
.gate-card {
  width: 100%; max-width: 360px; background: rgba(255, 255, 255, .96); color: var(--ink);
  border-radius: 28px; padding: 18px 18px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 18px 40px rgba(40, 0, 70, .35); transition: transform .5s cubic-bezier(.5, -0.4, .6, 1), opacity .5s;
}
.gate-card.opened { transform: translateY(-30px) scale(.9); opacity: 0; }
.gate-head { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 900; color: #7a4fe0; }
.gate-head svg { width: 22px; height: 22px; }
.gate-q { font-size: 28px; font-weight: 900; }
.gate-entry {
  width: 170px; height: 62px; border-radius: 16px; background: #F2ECFF; display: grid; place-items: center;
  font-size: 40px; font-weight: 900; letter-spacing: .05em;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.keypad button {
  height: 62px; border-radius: 16px; background: #fff; font-size: 28px; font-weight: 900; color: var(--ink);
  box-shadow: 0 3px 0 #D9CFF2, 0 0 0 2px #EEE8FB inset; transition: transform .08s;
}
.keypad button:active { transform: translateY(2px); box-shadow: 0 1px 0 #D9CFF2, 0 0 0 2px #EEE8FB inset; }
.keypad button.ok { background: var(--purple); color: #fff; box-shadow: 0 3px 0 #6C44C4; }
.keypad button.del { font-size: 24px; }

/* ---------- Games menu ---------- */

.menu-top { width: 100%; max-width: 560px; display: flex; justify-content: flex-end; }
.lock-pill {
  display: flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px; min-height: 44px;
  background: rgba(255, 255, 255, .22); color: #fff; font-weight: 900; font-size: 17px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
}
.lock-pill svg { width: 18px; height: 18px; }
.menu-hero { display: flex; align-items: center; gap: 6px; margin-top: -6px; }
.menu-hero .mascot { max-height: 19dvh; }
.menu-stack { display: flex; flex-direction: column; gap: 20px; width: 100%; max-width: 560px; }

.confirm {
  position: absolute !important; inset: 0; z-index: 80 !important; display: grid; place-items: center; padding: 24px;
  background: rgba(30, 6, 60, .55); animation: fade-in .2s ease;
}
.confirm-card {
  width: 100%; max-width: 360px; background: #fff; color: var(--ink); border-radius: 28px; padding: 22px;
  display: flex; flex-direction: column; gap: 14px; text-align: center; animation: pop-in .35s cubic-bezier(.3, 1.6, .5, 1);
}
.confirm-title { font-size: 28px; font-weight: 900; }
.confirm-sub { font-size: 17px; font-weight: 700; opacity: .7; margin-top: -6px; }
.confirm-btn { font-size: 24px; font-weight: 900; min-height: 66px; }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- Song list ---------- */

.screen-header { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 560px; }
.screen-header .header-title { flex: 1; text-align: center; font-size: 30px; font-weight: 900; text-shadow: 0 2px 0 rgba(60, 10, 90, .35); }
.songs-sub { font-size: 22px; font-weight: 900; margin: 12px 0 10px; opacity: .95; }
.song-list {
  width: 100%; max-width: 560px; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 16px; padding: 4px 2px 14px;
}
.song-list .tile.small { min-height: clamp(76px, 10.5dvh, 98px); }

/* ---------- Games ---------- */

.game { padding: 0; background-color: #2A0E5A; }
.game-area {
  position: absolute !important; left: 0; right: 0; top: calc(var(--top) + var(--hud)); bottom: var(--bottom);
  touch-action: none;
}
.game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.game.worm .game-area { top: 0; bottom: 0; }
.game.worm { background: #190C33; }

.hud {
  position: absolute !important; left: 0; right: 0; top: 0; z-index: 10 !important;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--top) + 10px) 14px 8px; height: calc(var(--top) + var(--hud));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.game.worm .hud { background: linear-gradient(rgba(25, 12, 51, .75), rgba(25, 12, 51, 0)); }
.score-pill {
  min-width: 96px; padding: 2px 20px; border-radius: 999px; text-align: center;
  background: rgba(255, 255, 255, .95); color: var(--ink); box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}
.score-num { display: inline-block; font-size: 38px; font-weight: 900; line-height: 1.2; }
.best-pill {
  display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 4px 12px; border-radius: 18px;
  background: rgba(255, 255, 255, .22); color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35); line-height: 1.05;
  transition: background .3s, color .3s;
}
.best-pill small { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.best-pill b { font-size: 22px; font-weight: 900; }
.best-pill.beaten { background: #FFD84D; color: var(--ink); box-shadow: 0 0 18px rgba(255, 216, 77, .8); }

.hint {
  position: absolute !important; left: 50%; bottom: calc(var(--bottom) + 22px); transform: translateX(-50%); z-index: 5 !important;
  padding: 10px 18px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--ink);
  font-size: 19px; font-weight: 900; white-space: nowrap; pointer-events: none;
  animation: hint-bob 1s ease-in-out infinite alternate; transition: opacity .3s;
}
.game.spin .hint { bottom: auto; top: calc(var(--top) + var(--hud) + 52%); }
.hint-mid { bottom: auto; top: 40%; white-space: normal; text-align: center; width: max-content; max-width: 86vw; }
.hint.gone { opacity: 0; }
@keyframes hint-bob { from { margin-top: 0; } to { margin-top: -8px; } }

.level-tag, .song-tag {
  position: absolute !important; z-index: 4 !important; pointer-events: none;
  padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .2); color: #fff;
  font-size: 17px; font-weight: 900; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .3);
}
.level-tag { right: 14px; bottom: calc(var(--bottom) + 14px); }
.song-tag { left: 50%; transform: translateX(-50%); top: calc(var(--top) + var(--hud) + 6px); white-space: nowrap; background: rgba(40, 10, 80, .45); }

.banner {
  position: absolute !important; left: 0; right: 0; top: 34%; z-index: 30 !important; text-align: center; pointer-events: none;
  font-size: 46px; font-weight: 900; color: #fff;
  text-shadow: 0 4px 0 rgba(60, 10, 90, .45), 0 0 26px rgba(255, 160, 225, 1);
  animation: banner 1.3s ease forwards;
}
.banner.gold { color: #FFE27A; }
@keyframes banner {
  0% { transform: scale(.3); opacity: 0; }
  18% { transform: scale(1.15); opacity: 1; }
  30% { transform: scale(1); }
  75% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}

.pause-card {
  position: absolute !important; inset: 0; z-index: 40 !important; display: grid; place-items: center;
  background: rgba(30, 6, 60, .6); color: #fff; font-size: 26px; font-weight: 900;
}
.pause-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: hint-bob 1s ease-in-out infinite alternate; }
.pause-icon { font-size: 64px; }

/* ---------- End of a round ---------- */

.results {
  position: absolute !important; inset: 0; z-index: 50 !important; display: grid; place-items: center;
  padding: calc(var(--top) + 16px) 18px calc(var(--bottom) + 16px);
  background: rgba(30, 6, 60, .55); animation: fade-in .3s ease;
}
.results-card {
  width: 100%; max-width: 400px; border-radius: 32px; padding: 14px 20px 22px; color: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  background: radial-gradient(110% 55% at 50% 0%, rgba(255, 138, 216, .75) 0%, rgba(255, 138, 216, 0) 60%),
              linear-gradient(170deg, #4A1E9E 0%, #8E1C9C 55%, #E23E83 100%);
  box-shadow: 0 20px 50px rgba(20, 0, 50, .5), inset 0 0 0 3px rgba(255, 255, 255, .25);
  animation: pop-in .45s cubic-bezier(.3, 1.6, .5, 1);
}
.results-card .mascot { max-height: 16dvh; }
.results-title { margin: 0; font-size: clamp(30px, 5dvh, 40px); font-weight: 900; text-shadow: 0 3px 0 rgba(60, 10, 90, .35); }
.results-card.new .results-title {
  color: #FFE27A; text-shadow: 0 3px 0 rgba(60, 10, 90, .45), 0 0 24px rgba(255, 216, 77, .9);
  animation: glow-pulse .6s ease-in-out infinite alternate;
}
@keyframes glow-pulse { from { transform: scale(1); } to { transform: scale(1.07); } }
.results-score { font-size: clamp(64px, 11dvh, 92px); font-weight: 900; line-height: 1; text-shadow: 0 4px 0 rgba(60, 10, 90, .35); }
.results-note { font-size: 19px; font-weight: 800; opacity: .95; margin-bottom: 10px; }
.results-buttons { display: flex; flex-direction: column; gap: 16px; width: 100%; }

/* ---------- Short screens (small iPhones, or Safari with its toolbars) ---------- */
@media (max-height: 700px) {
  .menu-stack { gap: 14px; }
  .tile { min-height: 84px; }
  .tile.small { min-height: 70px; }
  .gate-card { gap: 8px; padding: 14px; }
  .keypad { gap: 9px; }
  .keypad button { height: 52px; }
  .gate-entry { height: 52px; }
  .results-card .mascot { max-height: 12dvh; }
  .results-buttons { gap: 12px; }
  .song-list { gap: 12px; }
}
@media (max-height: 600px) {
  .gate-top .mascot { display: none; }
  .menu-hero .mascot { max-height: 14dvh; }
}
