/* rhythm ages (ages/rhythm-engine.js): extra styles (loaded after game.css). Everything is scoped to #stage.rhythm so no other type is touched.
   Two looks: .rh-swing (1920s Jazz Age: warm gold and black) and .rh-punk (Punk Garage: hot pink and yellow on black). */

#stage.rh-swing { --rh-panel: linear-gradient(180deg, rgba(44,24,10,.92), rgba(20,10,5,.94)); --rh-edge: #e0b34e; --rh-ink: #fff1c9; --rh-accent: #ffd45e; --rh-dim: #d9c08a;
  --rh-fill: linear-gradient(90deg, #b8631f, #ffb83d 62%, #fff2a8); --rh-lane: rgba(34,16,6,.62); --rh-laneedge: rgba(255,214,120,.55); --rh-glow: 255,200,90; --rh-pa: .5; }
#stage.rh-punk { --rh-panel: linear-gradient(180deg, rgba(18,6,30,.93), rgba(6,4,12,.95)); --rh-edge: #ff3aa8; --rh-ink: #ffffff; --rh-accent: #ffe600; --rh-dim: #ffb3dd;
  --rh-fill: linear-gradient(90deg, #e0242e, #ff7a1a 55%, #ffe600); --rh-lane: rgba(16,4,26,.68); --rh-laneedge: rgba(255,58,168,.72); --rh-glow: 255,58,168; --rh-pa: .8; }

/* ── lanes, rings, the PERFECT band, the beat pulse ── */
#stage.rhythm .rh-lane { background: linear-gradient(rgba(0,0,0,0), var(--rh-lane)); border: 2px solid var(--rh-laneedge); border-radius: 12px; transition: box-shadow .12s; }
#stage.rhythm .rh-lane.hot { box-shadow: inset 0 -70px 46px -34px var(--lc), 0 0 16px var(--lc); }
#stage.rhythm .rh-lane .rh-key { color: #fff; font-size: clamp(12px, 1.6vw, 17px); }
#stage.rhythm .rx.rh-ring { opacity: .62; }
#stage.rhythm .rx.rh-ring.on { opacity: 1; }
.rh-zone { position: absolute; z-index: 1; pointer-events: none; background: rgba(255,255,255,.1); border-top: 1px solid rgba(255,255,255,.4); border-bottom: 1px solid rgba(255,255,255,.4); border-radius: 6px; }
.rh-pulse { position: absolute; z-index: 0; pointer-events: none; border-radius: 16px; }
.rh-pulse.go { animation: rhPulse .5s ease-out; }
@keyframes rhPulse { 0% { box-shadow: 0 0 36px 8px rgba(var(--rh-glow), var(--rh-pa)); } 100% { box-shadow: 0 0 0 0 rgba(var(--rh-glow), 0); } }
#stage.rh-finale .rh-pulse.go { animation-duration: .38s; }
#stage.rh-fire .rh-lane { border-color: #fff; box-shadow: 0 0 20px rgba(var(--rh-glow), .85); animation: rhFire .5s ease-in-out infinite alternate; }
@keyframes rhFire { to { box-shadow: 0 0 34px 4px rgba(var(--rh-glow), 1); } }
#stage.rhythm .rx.deco img { transform-origin: 50% 100%; }
#stage.rhythm .rx.deco.bop img { animation: rhBop .34s ease-out; }
@keyframes rhBop { 0% { transform: scale(1, 1); } 35% { transform: scale(calc(1 + .03 * var(--amp, 1)), calc(1 - .04 * var(--amp, 1))); } 100% { transform: scale(1, 1); } }

/* ── gems ── */
#stage.rhythm .rx.rh-gem.chord { filter: drop-shadow(0 0 5px #fff) drop-shadow(0 0 12px rgba(var(--rh-glow), .95)); }
#stage.rhythm .rx.rh-gem.held { animation: rhHeld .32s ease-in-out infinite alternate; filter: drop-shadow(0 0 12px #fff) drop-shadow(0 0 22px rgba(var(--rh-glow), 1)); }
@keyframes rhHeld { to { transform: translate(-50%, -100%) scale(1.13); } }
#stage.rhythm .rx.rh-gem.miss { opacity: .3; filter: grayscale(1); }
.rh-tail { position: absolute; z-index: 3; transform: translateX(-50%); border-radius: 999px 999px 10px 10px; pointer-events: none; opacity: .92;
  background: linear-gradient(90deg, rgba(255,255,255,.35), var(--lc) 35%, var(--lc) 65%, rgba(255,255,255,.35)); border: 2px solid rgba(255,255,255,.85); box-shadow: 0 0 12px var(--lc); }
.rh-tail.on { animation: rhTailOn .28s ease-in-out infinite alternate; }
@keyframes rhTailOn { from { box-shadow: 0 0 14px 2px var(--lc); } to { box-shadow: 0 0 28px 6px #fff, 0 0 30px var(--lc); } }
.rh-tail.dead { opacity: .22; filter: grayscale(1); box-shadow: none; }
.rh-tail.fin { opacity: 0; transition: opacity .35s; }

/* ── pops, banners, the count-in, confetti ── */
#stage.rhythm .rh-pop.ok { color: #fff; }
#stage.rhythm .rh-pop.miss { color: #ff8a8a; font-size: max(12px, .85em); }
.rh-big { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 8; pointer-events: none; font: 400 clamp(30px, 6vw, 66px)/1 'Lilita One', cursive; color: #ffd45e; white-space: nowrap;
  text-shadow: 0 4px 0 #3a2200, 0 0 26px rgba(0,0,0,.85); animation: rhBig 1.05s ease-out forwards; }
.rh-big.u3 { color: #ff9a3c; } .rh-big.u4, .rh-big.fire { color: #ff4f9a; }
@keyframes rhBig { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.4); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.22); } 70% { opacity: 1; transform: translate(-50%, -60%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -95%) scale(1); } }
.rh-banner { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); z-index: 8; text-align: center; pointer-events: none; white-space: nowrap; animation: rhBanner 2.5s ease-out forwards; }
.rh-banner b { display: block; font: 400 clamp(26px, 5vw, 56px)/1 'Lilita One', cursive; color: var(--rh-accent); text-shadow: 0 4px 0 rgba(0,0,0,.75), 0 0 28px rgba(0,0,0,.8); letter-spacing: 1px; }
.rh-banner span { display: block; margin-top: 4px; font: 900 clamp(13px, 2vw, 22px)/1 'Nunito'; color: #fff; letter-spacing: 5px; text-shadow: 0 2px 6px #000, 0 0 12px #000; }
@keyframes rhBanner { 0% { opacity: 0; transform: translateX(-50%) scale(.5); } 12% { opacity: 1; transform: translateX(-50%) scale(1.12); } 22% { transform: translateX(-50%) scale(1); } 78% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-18px); } }
.rh-count { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); z-index: 8; opacity: 0; pointer-events: none; font: 400 clamp(54px, 11vw, 120px)/1 'Lilita One', cursive; color: #fff; text-shadow: 0 5px 0 #3a2200, 0 0 30px rgba(var(--rh-glow), .9); }
.rh-count.go { animation: rhCount .6s ease-out; }
@keyframes rhCount { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.85); } }
.rh-conf { position: absolute; top: -8%; z-index: 10; pointer-events: none; opacity: 0; animation: rhConf 2.4s ease-in forwards; }
@keyframes rhConf { 0% { opacity: 1; top: -8%; transform: translateX(0) rotate(0); } 100% { opacity: 1; top: 108%; transform: translateX(var(--dx, 0)) rotate(560deg); } }
#stage.rhythm .rx.rh-reward { z-index: 9; }

/* ── the HUD: section + progress, score + pace, multiplier + streak, groove / mosh-pit meter ── */
#stage.rhythm .rh-hud { position: absolute; inset: 0; z-index: 7; pointer-events: none; color: var(--rh-ink); font: 800 clamp(12px, 1.5vw, 17px)/1.15 'Nunito', sans-serif; }
#stage.rhythm .rh-card { position: absolute; box-sizing: border-box; background: var(--rh-panel); border: 2px solid var(--rh-edge); border-radius: 14px; padding: .55em .8em .6em; box-shadow: 0 5px 16px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.08); }
#stage.rh-swing .rh-card { box-shadow: 0 5px 16px rgba(0,0,0,.5), 0 0 0 3px rgba(20,10,5,.9), 0 0 0 4px rgba(224,179,78,.55); }
#stage.rh-punk .rh-card { border-radius: 6px; }
#stage.rh-punk .rh-sec { transform: rotate(-1.6deg); } #stage.rh-punk .rh-scorebox { transform: rotate(1.1deg); } #stage.rh-punk .rh-multbox { transform: rotate(1.6deg); } #stage.rh-punk .rh-meterbox { transform: rotate(-1deg); }
.rh-sec { left: 2.5%; top: 13%; width: 21%; }
.rh-scorebox { left: 2.5%; top: 31%; width: 21%; }
.rh-multbox { right: 2.5%; top: 13%; width: 21%; text-align: center; }
.rh-meterbox { right: 2.5%; top: 37%; width: 21%; }
.rh-round { display: block; font: 400 1.4em/1 'Lilita One', cursive; color: var(--rh-accent); letter-spacing: .5px; }
.rh-secname { display: block; margin-top: .15em; font-size: max(12px, .9em); color: var(--rh-ink); letter-spacing: 1px; text-transform: uppercase; }
.rh-prog { display: flex; gap: 3px; margin-top: .5em; height: .6em; }
.rh-prog i { display: block; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.rh-prog u { display: block; width: 0; height: 100%; background: var(--rh-accent); }
.rh-scorebox small { display: block; font-size: max(.7em, 12px); letter-spacing: 3px; color: var(--rh-dim); }
.rh-score { display: block; font: 400 2.3em/1.05 'Lilita One', cursive; color: var(--rh-accent); text-shadow: 0 2px 0 rgba(0,0,0,.6); }
.rh-pace { display: block; min-height: 1em; margin-top: .1em; font-size: max(12px, .78em); color: var(--rh-dim); }
.rh-pace.g { color: #ffd45e; } .rh-pace.s { color: #e5eef7; } .rh-pace.b { color: #e0a070; }
.rh-mult { display: block; font: 400 3.3em/1 'Lilita One', cursive; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.65); }
.rh-mult.m2 { color: #ffd45e; } .rh-mult.m3 { color: #ff9a3c; } .rh-mult.m4 { color: #ff4f9a; text-shadow: 0 3px 0 rgba(0,0,0,.65), 0 0 18px #ff4f9a; }
.rh-streak { display: block; font-size: max(.78em, 12px); letter-spacing: 2px; color: var(--rh-dim); }
.rh-multbox.pop { animation: rhMultPop .55s cubic-bezier(.2,1.6,.4,1); }
.rh-multbox.hit { animation: rhMultHit .35s ease; }
@keyframes rhMultPop { 0% { transform: scale(1); } 35% { transform: scale(1.22); box-shadow: 0 0 24px var(--rh-edge); } 100% { transform: scale(1); } }
@keyframes rhMultHit { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.rh-mname { display: block; font: 400 max(12px, 1.05em)/1 'Lilita One', cursive; letter-spacing: 3px; color: var(--rh-accent); margin-bottom: .35em; }
.rh-meter { position: relative; height: 1em; border-radius: 99px; background: rgba(0,0,0,.55); border: 2px solid rgba(255,255,255,.55); overflow: hidden; }
.rh-meter i { display: block; width: 60%; height: 100%; border-radius: 99px; background: var(--rh-fill); transition: width .25s ease-out; }
.rh-meterbox.hot { border-color: #fff; box-shadow: 0 0 22px rgba(var(--rh-glow), .95); }
.rh-meterbox.hot .rh-meter i { filter: brightness(1.25); }
.rh-meterbox.low { border-color: #ff4d4d; animation: rhLow .45s ease-in-out infinite alternate; }
.rh-meterbox.low .rh-meter i { background: linear-gradient(90deg, #8a0f1a, #ff4d4d); }
@keyframes rhLow { to { box-shadow: 0 0 22px 3px #ff4d4d; } }
.rh-crowd { display: none; }
#stage.rh-punk .rh-crowd { display: flex; justify-content: space-between; margin-top: .45em; font-size: 1.55em; line-height: 1; }
#stage.rh-punk .rh-meter { height: .5em; }
.rh-crowd span { display: block; opacity: .22; filter: grayscale(1); transition: opacity .2s; }
.rh-crowd span.on { opacity: 1; filter: none; animation: rhJump .44s ease-in-out infinite alternate; animation-delay: calc(var(--i) * 70ms); }
@keyframes rhJump { to { transform: translateY(calc(-.4em * var(--amp, 1))); } }

/* the coaching strip at the bottom (the scene kit's clue bar), in each age's colours */
#stage.rhythm .sr-clue { width: min(92%, 640px); bottom: 6px; padding: 5px 12px; border-radius: 14px; font-size: clamp(12px, 1.6vw, 15px); }
#stage.rh-swing .sr-clue { background: rgba(26,13,6,.9); border-color: #e0b34e; color: #fff1c9; }
#stage.rh-punk .sr-clue { background: rgba(10,4,18,.92); border-color: #ff3aa8; color: #fff; }
#stage.rhythm .sr-clue b { color: var(--rh-accent); }
#stage.rhythm .sr-clue .sr-p { color: var(--rh-dim); font-size: max(12px, .8em); }
#stage.rhythm .speech { top: 2.5%; width: max-content; max-width: min(80%, 620px); }

/* ── upright phone: a tall stage, so the HUD becomes two rows over the lanes ── */
#stage.rhythm.tall .rh-hud { font-size: clamp(12px, 3.2vw, 15px); }
#stage.rhythm.tall .rh-card { padding: .28em .5em .3em; border-radius: 10px; }
#stage.rhythm.tall .rh-sec { left: 2%; top: 1.2%; width: 34%; }
#stage.rhythm.tall .rh-scorebox { left: 37.3%; top: 1.2%; width: 32.4%; text-align: center; }
#stage.rhythm.tall .rh-multbox { right: 2%; top: 1.2%; width: 27.3%; text-align: center; }
#stage.rhythm.tall .rh-meterbox { left: 2%; right: auto; top: 15.6%; width: 96%; display: flex; align-items: center; gap: .6em; padding: .3em .6em; }
#stage.rhythm.tall .rh-mname { margin: 0; font-size: max(12px, .9em); letter-spacing: 1px; white-space: nowrap; }
#stage.rhythm.tall .rh-meter { flex: 1; height: .8em; }
#stage.rhythm.tall.rh-punk .rh-meter { display: none; }
#stage.rhythm.tall.rh-punk .rh-crowd { flex: 1; margin: 0; font-size: 1.35em; }
#stage.rhythm.tall .rh-round { font-size: 1.15em; } #stage.rhythm.tall .rh-secname { font-size: max(12px, .78em); letter-spacing: .5px; }
#stage.rhythm.tall .rh-prog { margin-top: .25em; } #stage.rhythm.tall .rh-secname { margin-top: 0; }
#stage.rhythm.tall .rh-score { font-size: 1.6em; } #stage.rhythm.tall .rh-scorebox small { letter-spacing: 2px; }
#stage.rhythm.tall .rh-pace { font-size: max(12px, .72em); }
#stage.rhythm.tall .rh-mult { font-size: 2.3em; } #stage.rhythm.tall .rh-streak { font-size: max(12px, .72em); letter-spacing: .3px; }
#stage.rhythm.tall.rh-punk .rh-sec, #stage.rhythm.tall.rh-punk .rh-scorebox, #stage.rhythm.tall.rh-punk .rh-multbox, #stage.rhythm.tall.rh-punk .rh-meterbox { transform: none; }
#stage.rhythm.tall .speech { top: 78%; max-width: 94%; padding: 5px 11px; font-size: 12px; border-radius: 12px; }
#stage.rhythm.tall .rh-banner { top: 28%; } #stage.rhythm.tall .rh-count { top: 42%; }
#stage.rhythm.tall .sr-clue { width: 96%; }

/* a landscape phone (a short, wide window): the stage is only ~570px wide, so the cards are ~120px; keep the round title on one line and the cards tight */
.rh-round { white-space: nowrap; }
@media (max-height: 460px) and (min-aspect-ratio: 1/1) {
  #stage.rhythm:not(.tall) .rh-round { font-size: 1.1em; }
  #stage.rhythm:not(.tall) .rh-card { padding: .4em .6em .45em; }
  #stage.rhythm:not(.tall) .rh-sec { top: 12%; }
}

@media (prefers-reduced-motion: reduce) {
  .rh-pulse.go, #stage.rh-fire .rh-lane, .rh-crowd span.on, #stage.rhythm .rx.deco.bop img { animation: none; }
}
