/* Ocean Beats: beat pulses, dancers, hit bursts, word celebrations and Fever mode.
   Loaded after style.css; everything here is scoped to .game.rhythm. */

/* song select */
.game.rhythm .select-hero { position: relative; }
.game.rhythm .select-avatar { width: 110px; height: 170px; animation: rdance .9s ease-in-out infinite alternate; transform-origin: bottom center; }
.game.rhythm .select-mic { position: absolute; right: -18px; top: 70px; font-size: 40px; animation: bob 1.8s ease-in-out infinite; }

/* stage layout */
.game.rhythm .song-progress { height: 8px; background: rgba(255, 255, 255, .25); position: relative; z-index: 3; }
.game.rhythm .song-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--sun), var(--coral), var(--grape)); }
.game.rhythm .rhythm-stage { justify-content: center; gap: 4px; overflow: hidden; }
.game.rhythm .stage-glow { position: absolute; inset: 0; background: radial-gradient(ellipse 70% 55% at 50% 55%, rgba(170, 240, 255, .55), transparent 70%); opacity: .35; pointer-events: none; }
.game.rhythm .word-show, .game.rhythm .lane, .game.rhythm .dancers { position: relative; z-index: 2; }

/* word display */
.game.rhythm .word-show { display: flex; flex-direction: column; align-items: center; min-height: 104px; }
.game.rhythm .ws-word { opacity: 1; padding: 0 22px; border-radius: 26px; background: rgba(255, 255, 255, .12); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .08); border: 3px solid var(--nc, #fff); }
/* long phrases and sentences shrink to stay on one line (--len is the number of characters) */
.game.rhythm .ws-word { font-size: min(64px, calc((100vw - 60px) / (var(--len, 6) * .72))); letter-spacing: .09em; white-space: nowrap; }
.game.rhythm .ws-next { font-size: 20px; letter-spacing: 1px; opacity: .85; text-shadow: none; font-weight: 700; }

/* notes */
.game.rhythm .note { background: radial-gradient(circle at 35% 30%, #fff 0 20%, var(--nc, #d9f6ff) 70%); }
.game.rhythm .note.hit { animation: none; }
.game.rhythm .hit-zone { box-shadow: 0 0 0 0 rgba(255, 210, 63, .6); }

/* hit bursts */
.game.rhythm .bursts { position: absolute; left: 14%; top: 50%; width: 0; height: 0; z-index: 3; pointer-events: none; }
.game.rhythm .bp { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); animation: rburst .65s ease-out forwards; }
.game.rhythm .bp.ring { background: transparent; border: 3px solid var(--c); width: 18px; height: 18px; }
.game.rhythm .bstar { position: absolute; left: -26px; top: -30px; font-size: 52px; animation: rstar .7s ease-out forwards; }

/* dancers */
.game.rhythm .dancers { display: flex; justify-content: center; align-items: flex-end; gap: clamp(8px, 3vw, 40px); height: clamp(90px, 20vh, 160px); --lean: 4deg; }
.game.rhythm .dancers.hype-1 { --lean: 7deg; }
.game.rhythm .dancers.hype-2 { --lean: 11deg; }
.game.rhythm .dancers.hype-3 { --lean: 15deg; }
.game.rhythm .dancer { transform: rotate(calc(var(--lean) * -1)); transform-origin: bottom center; transition: transform .2s ease-out; }
.game.rhythm .dancers.lean .dancer { transform: rotate(var(--lean)); }
.game.rhythm .dancers.lean .dancer:nth-child(even) { transform: rotate(calc(var(--lean) * -1)); }
.game.rhythm .dancers:not(.lean) .dancer:nth-child(even) { transform: rotate(var(--lean)); }
.game.rhythm .dancer-inner { font-size: clamp(40px, 8vh, 64px); line-height: 1; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .2)); }
.game.rhythm .dancer.me .dancer-inner .avatar-svg { width: clamp(64px, 12vh, 100px); height: clamp(100px, 19vh, 156px); display: block; }
.game.rhythm .dancers.hype-0 .dancer:not(.me) { opacity: .75; }
.game.rhythm .dancer.jelly .dancer-inner { animation: rjelly 2.4s ease-in-out infinite; }

/* word celebration */
.game.rhythm .word-pop { position: absolute; inset: 0; pointer-events: none; z-index: 4; display: grid; place-items: center; }
.game.rhythm .word-zoom { grid-area: 1 / 1; font-size: min(clamp(60px, 13vh, 120px), calc(92vw / ((var(--len, 6) + 2) * .7))); font-weight: 800; color: var(--sun); text-shadow: 0 5px 0 var(--grape), 0 10px 0 var(--ink); letter-spacing: .06em; animation: rzoom 1.25s cubic-bezier(.2, 1.4, .4, 1) forwards; white-space: nowrap; }
.game.rhythm .wz-spark { font-size: .5em; display: inline-block; animation: twinkle .6s ease-in-out infinite; }
.game.rhythm .finale { grid-area: 1 / 1; font-size: 180px; animation: rfinale 1.3s cubic-bezier(.2, 1.4, .4, 1) forwards; }

/* judge + get ready */
.game.rhythm .get-ready { position: absolute; left: 0; right: 0; top: 38%; z-index: 3; pointer-events: none; min-height: 0; text-shadow: 0 3px 0 var(--ink); }
.game.rhythm .dolphin.flip { animation: rflip .6s ease-out; }

/* fever mode (the banner sits low on the right, clear of long sentences up top) */
.game.rhythm .disco { position: absolute; inset: -40%; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .5s;
  background: conic-gradient(from 0deg, rgba(255, 90, 95, .32), rgba(255, 210, 63, .32), rgba(60, 207, 122, .32), rgba(63, 169, 245, .32), rgba(155, 107, 255, .32), rgba(255, 90, 95, .32));
  mix-blend-mode: screen; animation: rspin 6s linear infinite; }
.game.rhythm .disco .beam { position: absolute; top: 40%; left: 50%; width: 22%; height: 90%; transform-origin: top center; background: linear-gradient(rgba(255, 255, 255, .45), transparent); animation: rbeam 2.2s ease-in-out infinite alternate; }
.game.rhythm .disco .beam.b2 { animation-delay: -1.1s; background: linear-gradient(rgba(255, 210, 63, .45), transparent); }
.game.rhythm.fever .disco { opacity: 1; }
.game.rhythm.fever .rhythm-stage { animation: rhue 3s linear infinite; }
.game.rhythm.fever .note:not(.hit):not(.missed) { box-shadow: 0 0 16px 6px rgba(255, 255, 255, .7), 0 0 30px 12px var(--nc); }
.game.rhythm.fever .hit-zone { border-color: #fff; background: rgba(255, 255, 255, .25); box-shadow: 0 0 30px 10px rgba(255, 210, 63, .8); }
.game.rhythm.fever .dancer.jelly .dancer-inner { filter: drop-shadow(0 0 14px #ff9de2); }
.game.rhythm .fever-banner { position: absolute; top: auto; bottom: 14px; right: 3%; left: auto; transform: scale(0) rotate(6deg); z-index: 5; pointer-events: none;
  background: linear-gradient(90deg, var(--coral), var(--sun), var(--mint), #3fa9f5, var(--grape)); color: #fff; font-weight: 800; font-size: 28px;
  padding: 2px 22px; border: 4px solid var(--ink); border-radius: 999px; text-shadow: 0 2px 0 var(--ink); transition: transform .3s cubic-bezier(.2, 1.6, .4, 1); white-space: nowrap; }
.game.rhythm.fever .fever-banner { transform: scale(1) rotate(6deg); animation: rbanner .5s ease-in-out infinite alternate; }

@keyframes rburst { from { transform: translate(0, 0) scale(1); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }
@keyframes rstar { 0% { transform: scale(.3) rotate(0); opacity: 1; } 60% { transform: scale(1.4) rotate(140deg); opacity: 1; } 100% { transform: scale(1.6) rotate(200deg) translateY(-30px); opacity: 0; } }
@keyframes rzoom { 0% { transform: scale(.3) translateY(60px); opacity: 0; } 25% { transform: scale(1.15) translateY(0); opacity: 1; } 70% { transform: scale(1) translateY(-20px); opacity: 1; } 100% { transform: scale(1.1) translateY(-90px); opacity: 0; } }
@keyframes rfinale { 0% { transform: scale(0) rotate(-30deg); } 50% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1) rotate(0); opacity: 0; } }
@keyframes rflip { 0% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-60px) rotate(-200deg); } 100% { transform: translateY(0) rotate(-360deg); } }
@keyframes rspin { to { transform: rotate(360deg); } }
@keyframes rbeam { from { transform: rotate(-35deg); } to { transform: rotate(35deg); } }
@keyframes rhue { to { filter: hue-rotate(360deg); } }
@keyframes rbanner { from { transform: scale(1) rotate(3deg); } to { transform: scale(1.08) rotate(8deg); } }
@keyframes rjelly { 0%, 100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-10px) scaleY(.88); } }
@keyframes rdance { from { transform: rotate(-6deg) translateY(0); } to { transform: rotate(6deg) translateY(-8px); } }

/* short screens (a small laptop, and the taller keyboard from level 6): a slimmer lane, smaller
   notes and dancers, so the word, the lane and the dancers all stay in view */
@media (max-height: 640px) {
  .game.rhythm .word-show { min-height: 0; }
  .game.rhythm .ws-word { font-size: min(44px, calc((100vw - 60px) / (var(--len, 6) * .72))); line-height: 1.25; }
  .game.rhythm .ws-next { font-size: 15px; line-height: 1.2; }
  .game.rhythm .lane { height: 104px; margin: 4px 0; }
  .game.rhythm .note { width: 70px; height: 70px; margin-left: -35px; font-size: 40px; }
  .game.rhythm .note.space { width: 100px; margin-left: -50px; font-size: 20px; }
  .game.rhythm .hit-zone { width: 92px; height: 92px; border-width: 5px; }
  .game.rhythm .clam { font-size: 46px; }
  .game.rhythm .dolphin { top: -48px; font-size: 38px; }
  .game.rhythm .judge { top: -36px; font-size: 30px; }
  .game.rhythm .dancers { height: 58px; }
  .game.rhythm .dancer-inner { font-size: 36px; }
  .game.rhythm .dancer.me .dancer-inner .avatar-svg { width: 38px; height: 60px; }
  .game.rhythm .get-ready { font-size: 26px; }
  .game.rhythm .fever-banner { bottom: 6px; font-size: 20px; padding: 0 14px; border-width: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .game.rhythm .disco, .game.rhythm.fever .rhythm-stage, .game.rhythm .dancer-inner { animation: none !important; }
  .game.rhythm .disco { opacity: 0 !important; }
  .game.rhythm .dancer { transition: none; }
}
