/* Piano Legend: 3D experience */
.xp { overflow: hidden; height: 100svh; background: #000; touch-action: manipulation; }
.xp-stage { position: fixed; inset: 0; background: radial-gradient(ellipse 80% 60% at 50% 62%, #121418 0%, #050506 55%, #000 100%); }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* glass */
.glass, .panel, .modes, .info, .xp-top {
  background: rgba(28, 28, 30, .62);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid rgba(255, 255, 255, .08);
}

/* top bar */
.xp-top { position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 max(16px, env(safe-area-inset-left)); border-width: 0 0 1px; background: rgba(0, 0, 0, .5); z-index: 20; }
.xp-back { font-size: 14px; color: #2997ff; display: inline-flex; gap: 4px; align-items: center; }
.xp-back span { font-size: 20px; line-height: 1; transform: translateY(-1px); }
.xp-title { display: flex; justify-content: center; padding: 6px 8px; border-radius: 10px; transition: opacity .2s; }
.xp-title:hover { opacity: .8; }
.xp-title img { height: 24px; width: auto; }
.xp-top-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.btn.small.xp-buy { margin-left: 6px; min-height: 32px; padding: 6px 16px; font-size: 14px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #f5f5f7; background: rgba(255,255,255,.08); transition: background .2s, transform .2s; }
.icon-btn:hover { background: rgba(255,255,255,.16); }
.icon-btn:active { transform: scale(.94); }
.icon-btn[hidden] { display: none; }
.icon-btn.small { width: 30px; height: 30px; font-size: 18px; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .spk { fill: currentColor; stroke: none; }
.icon-btn svg .mute { display: none; }
.icon-btn[aria-pressed="false"] svg .wave { display: none; }
.icon-btn[aria-pressed="false"] svg .mute { display: block; }

/* modes segmented control */
.modes { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; display: flex; gap: 2px;
  padding: 4px; border-radius: 999px; }
.modes button { position: relative; z-index: 1; height: 36px; padding: 0 18px; border-radius: 999px; font-size: 14px; font-weight: 500; letter-spacing: -.01em; color: rgba(245,245,247,.72); transition: color .3s; white-space: nowrap; }
.modes button[aria-selected="true"] { color: #000; }
.modes-pill { position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 999px; background: #f5f5f7; transition: transform .45s var(--ease-out), width .45s var(--ease-out); }

/* panels */
.panel { position: fixed; left: 50%; bottom: calc(max(20px, env(safe-area-inset-bottom)) + 56px); transform: translate(-50%, 16px); width: min(760px, calc(100vw - 24px));
  border-radius: 22px; padding: 16px 18px; z-index: 19; opacity: 0; pointer-events: none; transition: opacity .35s var(--ease), transform .5s var(--ease-out); }
body[data-mode="play"] .panel-play, body[data-mode="learn"] .panel-learn, body[data-mode="light"] .panel-light, body[data-mode="inside"] .panel-inside { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* play */
.play-row { display: flex; align-items: center; gap: 16px; }
.octave { flex: none; display: flex; align-items: center; gap: 10px; }
/* overview of the 88 keys: the bright window is the part reachable from the computer keyboard */
.oct-map { position: relative; width: 156px; height: 22px; border-radius: 5px; overflow: hidden; cursor: pointer; touch-action: none; }
.oct-map svg { display: block; width: 100%; height: 100%; }
.oct-win { position: absolute; top: 0; bottom: 0; left: 0; width: 33px; border-radius: 4px; pointer-events: none;
  box-shadow: inset 0 0 0 1.5px #f5f5f7, 0 0 0 160px rgba(16, 16, 18, .8); transition: left .5s var(--ease-out), width .5s var(--ease-out); }
.now-playing { flex: 1; min-width: 0; text-align: center; font-size: 13px; color: var(--on-dark-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-playing { transition: opacity .6s var(--ease); }
.now-playing.played { opacity: 0; }
/* succès: the move being played, step by step (chord names, fingers) */
.now-playing.caption { color: #f5f5f7; font-size: 15px; font-weight: 600; }
.kbd-toggle { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 14px 0 11px; border-radius: 999px; font-size: 13px; font-weight: 500; color: #f5f5f7; background: rgba(255,255,255,.08); transition: background .2s, color .2s; }
.kbd-toggle:hover { background: rgba(255,255,255,.14); }
.kbd-toggle[aria-expanded="true"] { background: #f5f5f7; color: #000; }
.kbd-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.kbd-help { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .5s var(--ease-out), opacity .3s var(--ease); }
.panel-play.keys-open .kbd-help { grid-template-rows: 1fr; opacity: 1; }
.kbd-help-inner { min-height: 0; overflow: hidden; }
.kbd-help-row { display: flex; align-items: center; justify-content: center; gap: 24px; padding-top: 20px; }
.keys-hint { display: flex; gap: 3px; }
.keys-hint .k { width: 22px; height: 26px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: rgba(255,255,255,.1); color: #f5f5f7; text-transform: uppercase; transition: background .1s, transform .1s; }
.keys-hint .k.b { background: rgba(0,0,0,.55); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); transform: translateY(-6px); height: 22px; }
.keys-hint .k.on { background: #2997ff; color: #fff; }
.pedal { font-size: 13px; color: var(--on-dark-2); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.pedal.on { color: #f5f5f7; }
.kbd { display: inline-block; padding: 2px 8px; border-radius: 6px; background: rgba(255,255,255,.1); font-size: 12px; font-weight: 600; color: #f5f5f7; }
.pedal.on .kbd { background: #2997ff; }
@media (hover: none) and (pointer: coarse) { .kbd-toggle, .kbd-help { display: none; } }

/* learn */
.songs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.songs::-webkit-scrollbar { display: none; }
.songs button { flex: none; height: 32px; padding: 0 14px; border-radius: 999px; font-size: 13px; background: rgba(255,255,255,.08); color: #f5f5f7; transition: background .2s; }
.songs button[aria-checked="true"] { background: #f5f5f7; color: #000; }
.learn-body { display: grid; grid-template-columns: 1fr auto; gap: 12px 18px; align-items: center; margin-top: 14px; }
.learn-next { display: flex; gap: 12px; align-items: center; }
.finger-dot { width: 34px; height: 34px; border-radius: 50%; flex: none; background: #2c2c2e; box-shadow: 0 0 0 0 transparent; transition: background .3s, box-shadow .3s; }
.finger-dot.on { background: var(--c); box-shadow: 0 0 22px var(--c); }
.learn-note { font-family: var(--font); font-size: 19px; font-weight: 600; }
.learn-finger { font-size: 13px; color: var(--on-dark-2); }
.learn-progress { grid-column: 1 / -1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; order: 3; }
.learn-progress span { display: block; height: 100%; width: 0; background: var(--brand-gradient); transition: width .3s var(--ease); }
.learn-actions { display: flex; gap: 8px; }
.fingers-legend { display: flex; gap: 14px; justify-content: center; margin-top: 12px; font-size: 12px; color: var(--on-dark-2); flex-wrap: wrap; }
.fingers-legend li { display: flex; align-items: center; gap: 6px; }
.fingers-legend li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }

/* light */
.effects { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.effects button { display: grid; gap: 7px; justify-items: center; font-size: 12px; color: var(--on-dark-2); padding: 4px 0; border-radius: 12px; transition: color .2s; }
.effects button i { width: 100%; max-width: 74px; height: 34px; border-radius: 10px; background: var(--g); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); transition: box-shadow .25s, transform .25s; }
.effects button[aria-checked="true"] { color: #f5f5f7; }
.effects button[aria-checked="true"] i { box-shadow: 0 0 0 2px #000, 0 0 0 4px #f5f5f7; }
.effects button:hover i { transform: translateY(-2px); }
.slider-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; font-size: 13px; color: var(--on-dark-2); }
.slider-row input { flex: 1; }
.panel-note { margin-top: 8px; font-size: 12px; color: var(--on-dark-3); text-align: center; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: rgba(255,255,255,.18); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #f5f5f7; box-shadow: 0 2px 8px rgba(0,0,0,.4); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #f5f5f7; cursor: pointer; }

/* inside */
.explode-row { display: flex; align-items: center; gap: 12px; }
.explode-row input { flex: 1; }
.chip { height: 30px; padding: 0 14px; border-radius: 999px; font-size: 13px; background: rgba(255,255,255,.08); color: #f5f5f7; white-space: nowrap; }
.chip[aria-pressed="true"] { background: #2997ff; }
.parts { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.parts::-webkit-scrollbar { display: none; }
.parts button { flex: none; display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 6px; border-radius: 999px; font-size: 13px; background: rgba(255,255,255,.06); color: #f5f5f7; transition: background .2s; }
.parts button .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.12); }
.parts button[aria-selected="true"] { background: #f5f5f7; color: #000; }
.parts button[aria-selected="true"] .n { background: #000; color: #fff; }

/* hotspots */
.hotspots { position: absolute; inset: 0; pointer-events: none; }
body:not([data-mode="inside"]) .hotspots { display: none; }
.hotspot { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; display: flex; align-items: center; gap: 8px; opacity: 0; transition: opacity .4s; }
.hotspot.vis { opacity: 1; }
.hotspot .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #000; background: rgba(245,245,247,.92); box-shadow: 0 0 0 6px rgba(245,245,247,.16), 0 4px 18px rgba(0,0,0,.5); transition: transform .25s var(--ease-out); }
.hotspot:hover .dot, .hotspot.sel .dot { transform: scale(1.15); background: #2997ff; color: #fff; }
.hotspot .name { font-size: 13px; font-weight: 600; color: #f5f5f7; text-shadow: 0 1px 10px rgba(0,0,0,.9); opacity: 0; transform: translateX(-6px); transition: opacity .25s, transform .3s var(--ease-out); white-space: nowrap; }
.hotspot:hover .name, .hotspot.sel .name { opacity: 1; transform: none; }

/* info card */
.info { position: fixed; right: max(16px, env(safe-area-inset-right)); top: calc(var(--nav-h) + 16px); width: min(360px, calc(100vw - 32px)); border-radius: 22px; padding: 22px 22px 20px; z-index: 21;
  animation: infoIn .5s var(--ease-out); }
@keyframes infoIn { from { opacity: 0; transform: translateY(10px); } }
.info-close { position: absolute; top: 12px; right: 12px; }
.info-kicker { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: #2997ff; text-transform: uppercase; }
.info-title { font-family: var(--font); font-size: 26px; line-height: 1.12; font-weight: 600; margin: 6px 0 10px; letter-spacing: 0; }
.info-text { font-size: 15px; line-height: 1.47; color: #d2d2d7; letter-spacing: -.012em; }
.info-facts { margin-top: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.info-facts div { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.info-facts dt { color: var(--on-dark-2); }
.info-facts dd { text-align: right; color: #f5f5f7; }
.info-badge { margin-top: 12px; font-size: 12px; color: var(--on-dark-2); }
.info-badge:empty { display: none; }
.info-badge::before { content: "ⓘ "; }

/* start screen: loads like the LED strip, then waits for a first gesture like a console */
.xp-loader { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 34px; padding: 0 24px; background: #000;
  transition: opacity .8s var(--ease), visibility .8s; -webkit-tap-highlight-color: transparent; }
.xp-loader img { width: clamp(170px, 18vw, 230px); height: auto; }
.boot-leds { display: grid; grid-template-columns: repeat(88, minmax(0, 1fr)); column-gap: .38%; width: min(792px, calc(100vw - 48px)); }
.boot-leds i { aspect-ratio: 1; border-radius: 50%; background: #2c2c2e; transition: background .3s, box-shadow .3s; }
.boot-leds i.on { background: var(--c); box-shadow: 0 0 10px var(--c); }
/* while it loads, a soft light keeps running along the strip, so a slow network never looks like a frozen page.
   Opacity only: the animation keeps moving even while the page is busy decoding the piano. */
.boot-leds i { position: relative; }
.boot-leds i::after { content: ""; position: absolute; inset: -70%; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, .95) 0 22%, rgba(214, 226, 255, .32) 44%, transparent 70%); }
.xp-loader:not(.ready):not(.failed) .boot-leds i::after { animation: boot-run 2.4s cubic-bezier(.4, 0, .2, 1) calc(.7s + var(--i) * 10ms) infinite; }
@keyframes boot-run { 0% { opacity: 0; } 7% { opacity: .7; } 24%, 100% { opacity: 0; } }
.boot-text { display: grid; justify-items: center; text-align: center; }
.boot-text > * { grid-area: 1 / 1; transition: opacity .5s var(--ease); }
.boot-press { font-family: var(--font); font-size: clamp(19px, 2vw, 22px); font-weight: 600; color: #f5f5f7; opacity: 0; }
.xp-loader.ready { cursor: pointer; }
.xp-loader.ready .boot-press { opacity: 1; animation: press-pulse 1.6s ease-in-out .5s infinite; }
@keyframes press-pulse { 50% { opacity: .35; } }
.xp-loader:focus, .xp-loader:focus-visible { outline: none; }
/* the gesture: a flash runs along the 88 LEDs, then the start screen opens on the piano */
.xp-loader.go .boot-leds i { animation: boot-sweep .55s var(--ease) calc(var(--i) * 3ms) both; }
.xp-loader.go .boot-press { animation: none; opacity: 0; transition-duration: .25s; }
@keyframes boot-sweep { 40% { background: #fff; box-shadow: 0 0 14px #fff, 0 0 26px var(--c); } }
.xp-loader.failed .boot-press { opacity: 1; font-size: 17px; font-weight: 400; color: var(--on-dark-2); }
.xp-loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .xp-loader.ready .boot-press { animation: none; } .xp-loader.go .boot-leds i, .boot-leds i::after { animation: none !important; } }

/* toast */
.toast { position: fixed; left: 50%; top: calc(var(--nav-h) + 18px); transform: translate(-50%, -8px); z-index: 30; padding: 10px 18px; border-radius: 999px;
  background: rgba(245,245,247,.95); color: #000; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .3s, transform .4s var(--ease-out); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast a { color: #0071e3; }
.toast.has-link.on { pointer-events: auto; }
body.practicing .toast { top: calc(var(--nav-h) + 70px); }

/* ============================================================ game layer */
/* succès (Jouer): the piano plays the move; done ones are checked */
.ach-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.ach-count { flex: none; display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--on-dark-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ach-count svg { width: 14px; height: 14px; fill: #b39cff; }
.ach-count b { color: #f5f5f7; font-weight: 600; }
.ach-list { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.ach-list::-webkit-scrollbar { display: none; }
.ach { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px 0 6px; border-radius: 999px; font-size: 13px; background: rgba(255,255,255,.08); color: #f5f5f7; transition: background .2s, box-shadow .3s; }
.ach:last-child { margin-right: 22px; }
.ach:hover { background: rgba(255,255,255,.14); }
.ach .tick { position: relative; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.28); transition: background .3s, box-shadow .3s; }
.ach .tick::after { content: ""; position: absolute; left: 7px; top: 4px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform .35s var(--ease-out); }
.ach.done .tick { background: var(--brand-gradient); box-shadow: 0 0 10px rgba(143,102,255,.55); }
.ach.done .tick::after { transform: rotate(45deg) scale(1); }
.ach.fresh .tick { animation: tick-pop .6s var(--ease-out); }
@keyframes tick-pop { 40% { transform: scale(1.35); } }
.ach.running { background: rgba(255,255,255,.2); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }

.ach-toast { position: fixed; top: calc(var(--nav-h) + 16px); left: 50%; z-index: 31; display: flex; align-items: center; gap: 12px; padding: 8px 20px 8px 8px; border-radius: 999px;
  background: rgba(245,245,247,.97); color: #000; box-shadow: 0 20px 50px rgba(0,0,0,.5); transform: translate(-50%, -14px) scale(.96); opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease), transform .55s var(--ease-out); white-space: nowrap; }
.ach-toast.on { opacity: 1; transform: translate(-50%, 0); }
.ach-toast .medal { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-gradient); }
.ach-toast .medal svg { width: 20px; height: 20px; fill: #fff; }
.ach-toast small { display: block; font-size: 12px; color: #6e6e73; }
.ach-toast b { font-family: var(--font); font-size: 17px; font-weight: 600; }
.ach-toast em { font-style: normal; margin-left: 6px; font-size: 13px; color: #6e6e73; font-variant-numeric: tabular-nums; }

/* rank badge in the top bar */
.rank-badge { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 13px 0 3px; border-radius: 999px; background: rgba(255,255,255,.08); font-size: 13px; font-weight: 500; transition: background .2s; }
.rank-badge:hover { background: rgba(255,255,255,.16); }
.rank-badge[hidden] { display: none; }
.rank-badge img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: 50% 3%; background: radial-gradient(circle at 50% 35%, #1f3b5c, #0c0f16 70%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.rank-badge.pop { animation: badge-pop .7s var(--ease-out); }
@keyframes badge-pop { from { opacity: 0; transform: scale(.6); } 60% { transform: scale(1.08); } }

/* learn: HUD and bursts */
.hud { position: fixed; top: calc(var(--nav-h) + 16px); left: 50%; z-index: 18; display: flex; gap: 10px; transform: translate(-50%, -10px); opacity: 0; pointer-events: none;
  transition: opacity .35s var(--ease), transform .5s var(--ease-out); }
body.practicing .hud { opacity: 1; transform: translate(-50%, 0); }
.hud-chip { height: 40px; display: inline-flex; align-items: center; gap: 12px; padding: 0 18px; border-radius: 999px; background: rgba(28,28,30,.88);
  border: 1px solid rgba(255,255,255,.1); font-size: 15px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-bar { width: 150px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.14); overflow: hidden; }
.hud-bar i { display: block; height: 100%; background: var(--brand-gradient); transform-origin: left; transform: scaleX(0); transition: transform .35s var(--ease-out); }
.hud-streak { transition: background .3s, color .3s, box-shadow .4s; }
.hud-streak b { font-family: var(--font); font-size: 18px; }
.hud-streak.on { color: #000; background: #f5f5f7; border-color: transparent; box-shadow: 0 0 30px rgba(143,102,255,.5); }
.hud-streak.hot { animation: streak-hot .9s var(--ease-out); }
@keyframes streak-hot { 30% { transform: scale(1.12); box-shadow: 0 0 50px rgba(143,102,255,.95), 0 0 0 6px rgba(167,139,250,.35); } }
body.practicing .learn-progress { opacity: 0; }

.bursts { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.burst { position: absolute; width: 0; height: 0; }
.burst .ring { position: absolute; left: -60px; top: -60px; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 90%, #fff) 0 7%, color-mix(in srgb, var(--c) 45%, transparent) 9% 18%, transparent 40%);
  animation: burst-ring .7s var(--ease-out) both; }
.burst .spark { position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--c) 60%, #fff); box-shadow: 0 0 10px var(--c);
  animation: burst-spark .75s var(--ease-out) both; }
.burst b { position: absolute; left: 0; top: -34px; transform: translateX(-50%); font-family: var(--font); font-size: 22px; font-weight: 600; color: color-mix(in srgb, var(--c) 55%, #fff);
  text-shadow: 0 0 18px var(--c); white-space: nowrap; animation: burst-plus .95s var(--ease-out) both; }
@keyframes burst-ring { from { transform: scale(.25); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@keyframes burst-spark { from { transform: rotate(var(--a)) translateX(6px) scale(1); opacity: 1; } to { transform: rotate(var(--a)) translateX(48px) scale(.2); opacity: 0; } }
@keyframes burst-plus { from { transform: translate(-50%, 8px) scale(.8); opacity: 0; } 20% { opacity: 1; transform: translate(-50%, 0) scale(1); } to { transform: translate(-50%, -30px); opacity: 0; } }

/* modals: results and rank */
.xp-modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: calc(var(--nav-h) + 12px) 16px 16px; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .4s var(--ease); }
.xp-modal.on { opacity: 1; }
.xp-modal[hidden] { display: none; }
body.has-modal .panel, body.has-modal .modes { opacity: 0 !important; pointer-events: none !important; }
.res-card { position: relative; width: min(520px, 100%); max-height: 100%; overflow: auto; border-radius: 30px; padding: 40px 40px 30px; text-align: center; background: rgba(28,28,30,.96);
  border: 1px solid rgba(255,255,255,.1); box-shadow: 0 40px 120px rgba(0,0,0,.7);
  transform: translateY(18px) scale(.97); transition: transform .6s var(--ease-out); }
.xp-modal.on .res-card { transform: none; }
.res-close { position: absolute; top: 14px; right: 14px; }
.res-stars { display: flex; justify-content: center; gap: 14px; }
.res-stars svg { width: 54px; height: 54px; fill: #3a3a3c; transform: scale(.4); opacity: 0; transition: transform .6s cubic-bezier(.3, 1.6, .5, 1), opacity .3s, fill .3s, filter .3s; }
.res-stars svg:nth-child(2) { width: 62px; height: 62px; transform-origin: 50% 60%; }
.res-stars svg.on { fill: #b39cff; filter: drop-shadow(0 0 14px rgba(143,102,255,.75)); transform: none; opacity: 1; }
.res-stars svg.on:nth-child(1) { fill: #5fb4fb; } .res-stars svg.on:nth-child(3) { fill: #eea4b1; filter: drop-shadow(0 0 14px rgba(238,164,177,.7)); }
.res-stars svg.off { transform: none; opacity: 1; }
.res-title { font-family: var(--font); font-size: 32px; line-height: 1.12; font-weight: 600; margin-top: 18px; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0 18px; border-top: 1px solid rgba(255,255,255,.1); border-bottom: 1px solid rgba(255,255,255,.1); }
.res-stats div { display: flex; flex-direction: column-reverse; padding: 14px 4px; }
.res-stats dd { font-family: var(--font); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.res-stats dt { font-size: 13px; color: var(--on-dark-2); }
.res-xp { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--on-dark-2); text-align: left; }
.res-xp b { color: #f5f5f7; white-space: nowrap; }
.res-xp .bar { flex: 1; min-width: 60px; height: 6px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; }
.res-xp .bar i { display: block; height: 100%; background: var(--brand-gradient); box-shadow: 0 0 12px rgba(143,102,255,.7); transform-origin: left; transition: transform 1.1s var(--ease-out); }
.res-xp > span:last-child { white-space: nowrap; }
.res-actions { display: grid; gap: 14px; justify-items: center; margin-top: 26px; }
.res-actions .btn { width: 100%; min-height: 54px; font-size: 19px; }
.res-actions .link { display: inline; font-size: 17px; text-align: center; text-wrap: balance; }
.res-quiet { margin-top: 20px; font-size: 13px; color: var(--on-dark-2); }

.rank-modal { background: rgba(0,0,0,.84); }
.rank-in { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); align-items: center; gap: clamp(24px, 4vw, 64px); width: min(1100px, 100%); max-height: 100%; }
.rank-fig { --h: min(58svh, 540px); position: relative; height: var(--h); display: grid; place-items: end center; }
.rank-fig::before { content: ""; position: absolute; left: 50%; top: 50%; width: 90%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(49,161,248,.38), rgba(143,102,255,.18) 45%, transparent 70%); }
.rank-fig img { position: relative; height: calc(var(--h) * var(--fig, 1)); width: auto; max-width: none; transform: translateY(18px) scale(.95); opacity: 0; transition: transform .8s var(--ease-out), opacity .45s var(--ease); }
.xp-modal.on .rank-fig img.in { transform: none; opacity: 1; }
.rank-eyebrow { font-family: var(--font); font-size: clamp(19px, 1.7vw, 24px); font-weight: 600; color: #2997ff; }
.rank-name { font-family: var(--font); font-size: clamp(44px, 6vw, 80px); line-height: 1.05; font-weight: 600; letter-spacing: -.015em; margin-top: 6px; }
.rank-modal.fresh .rank-name { background: linear-gradient(90deg, #f5f5f7 30%, #b39cff 60%, #f5f5f7 90%) 0 0 / 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: rank-shine 2.4s var(--ease) .3s both; }
@keyframes rank-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }
.rank-text { margin-top: 16px; max-width: 26em; font-family: var(--font); font-size: clamp(19px, 1.75vw, 22px); line-height: 1.35; font-weight: 600; color: var(--on-dark-2); }
.rank-text strong { color: #f5f5f7; font-weight: 600; }
.rank-xp { margin-top: 12px; font-size: 14px; color: var(--on-dark-2); font-variant-numeric: tabular-nums; }
.rank-track { position: relative; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); margin-top: 30px; }
.rank-track::before, .rank-track::after { content: ""; position: absolute; left: 5%; right: 5%; top: 6px; height: 2px; background: #2c2c2e; }
.rank-track::after { background: var(--brand-gradient); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 1.2s var(--ease-out) .3s; }
.rank-track li { position: relative; z-index: 1; display: grid; }
/* every rank can be looked at: tap a dot; the one being looked at gets a halo, the player's own progress stays as it is */
.rank-track button { position: relative; padding: 24px 0 4px; text-align: center; font-size: 11px; letter-spacing: -.01em; color: var(--on-dark-2); white-space: nowrap; transition: color .2s; }
.rank-track button::before { content: ""; position: absolute; left: 50%; top: 1px; width: 12px; height: 12px; border-radius: 50%; background: #2c2c2e; transform: translateX(-50%); transition: box-shadow .3s, background .3s; }
.rank-track button:hover { color: #d2d2d7; }
.rank-track button:hover::before { box-shadow: 0 0 0 4px rgba(255,255,255,.08); }
.rank-track button.on { color: #f5f5f7; } .rank-track button.on::before { background: #f5f5f7; }
.rank-track button.now::before { background: #31a1f8; box-shadow: 0 0 14px #31a1f8; width: 16px; height: 16px; top: -1px; }
.rank-track button.goal { color: #eea4b1; font-weight: 700; }
.rank-track button.sel { color: #f5f5f7; }
.rank-track button.sel::before { box-shadow: 0 0 0 4px rgba(255,255,255,.14), 0 0 16px 3px rgba(255,255,255,.35); }
.rank-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 26px; margin-top: 34px; }
.rank-more { font-size: 17px; color: var(--on-dark-2); }

@media (max-width: 1100px) {
  .rank-track { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 22px; }
  .rank-track::before, .rank-track::after { display: none; }
}

/* responsive */
@media (max-width: 734px) {
  .xp-title { display: none; }
  .xp-top { grid-template-columns: 1fr 1fr; }
  .modes button { padding: 0 12px; font-size: 13px; }
  .panel { padding: 14px; border-radius: 18px; }
  .kbd-toggle, .kbd-help { display: none; }
  .play-row { flex-wrap: wrap; justify-content: center; gap: 10px; }
  .now-playing { flex-basis: 100%; }
  .effects { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .learn-body { grid-template-columns: 1fr; }
  .learn-actions { justify-content: stretch; }
  .learn-actions .btn { flex: 1; }
  .info { top: auto; bottom: calc(max(20px, env(safe-area-inset-bottom)) + 56px); right: 12px; left: 12px; width: auto; max-height: 46svh; overflow: auto; }
  .ach-row { margin-top: 10px; padding-top: 10px; gap: 10px; }
  .rank-badge { padding: 0 3px; }
  .rank-badge span { display: none; }
  .hud { gap: 6px; }
  .hud-chip { height: 36px; padding: 0 14px; gap: 10px; font-size: 14px; }
  .hud-title { display: none; }
  .hud-bar { width: 72px; }
  .ach-toast { padding-right: 16px; }
  .ach-toast em { display: none; }
  .res-card { padding: 32px 22px 22px; border-radius: 26px; }
  .res-stars svg { width: 44px; height: 44px; } .res-stars svg:nth-child(2) { width: 50px; height: 50px; }
  .res-title { font-size: 26px; }
  .res-stats dd { font-size: 22px; }
  .res-xp { flex-wrap: wrap; } .res-xp .bar { order: 3; flex-basis: 100%; }
  .rank-in { grid-template-columns: 1fr; text-align: center; gap: 10px; }
  .rank-fig { --h: min(34svh, 300px); }
  .rank-text { margin-inline: auto; }
  .rank-track { grid-template-columns: repeat(5, 1fr); row-gap: 22px; margin-top: 22px; }
  .rank-track::before, .rank-track::after { display: none; }
  .rank-cta { justify-content: center; margin-top: 24px; }
  body[data-mode="inside"].has-info .panel-inside { opacity: 0; pointer-events: none; }
  .hotspot .name { display: none; }
}
