/* =========================================================
   BEAT RUSH — estilos (mobile-first)
   Paleta base: ciruela profunda + rosa, amarillo y menta de neón
   ========================================================= */

:root {
  --bg: #1A0F33;
  --bg-deep: #10081F;
  --surface: #2B1A57;
  --surface-2: #3A2475;
  --ink: #FFF4E6;
  --muted: #B5A6DA;
  --pink: #FF4D8D;
  --yellow: #FFD23F;
  --yellow-dark: #C9900E;
  --mint: #3DF5C2;
  --sky: #7CC8FF;
  --red: #FF5E57;
  --violet: #8F6BFF;

  --font-display: 'Bungee', 'Arial Black', 'Impact', system-ui, sans-serif;
  --font-ui: 'Fredoka', 'Nunito', 'Trebuchet MS', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
}

html {
  background: var(--bg-deep);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 500;
  background:
    radial-gradient(120% 70% at 50% 108%, #3D1C70 0%, rgba(61, 28, 112, 0) 60%),
    radial-gradient(90% 50% at 50% -10%, #2A1650 0%, rgba(42, 22, 80, 0) 70%),
    var(--bg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

h2, h3 { font-weight: 700; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

/* ---------- Pantallas ---------- */
.screen {
  position: absolute;
  top: var(--safe-t);
  bottom: var(--safe-b);
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 560px;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0s linear 0s;
}

.screen--map { max-width: 1100px; }

/* ---------- Botones ---------- */
.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.18);
}

.icon-btn--text {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.icon-btn:focus-visible,
.btn-secondary:focus-visible,
.btn-link:focus-visible,
.btn-danger:focus-visible,
.switch:focus-visible,
.map-node:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 3px;
}

.ico {
  width: 24px;
  height: 24px;
}

.btn-sound .ico-off { display: none; }
.btn-sound[aria-pressed="true"] .ico-on { display: none; }
.btn-sound[aria-pressed="true"] .ico-off { display: block; }
.btn-sound[aria-pressed="true"] { color: var(--pink); }

.btn-primary {
  min-height: 60px;
  min-width: 200px;
  padding: 0 34px;
  border: 0;
  border-radius: 999px;
  background: var(--yellow);
  color: #2A1500;
  font-family: var(--font-display);
  font-size: clamp(20px, 6vw, 28px);
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--yellow-dark), 0 16px 36px rgba(255, 210, 63, 0.2);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn-primary:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--yellow-dark), 0 8px 20px rgba(255, 210, 63, 0.16);
}

.btn-primary:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 5px;
}

.btn-primary:disabled {
  background: #4A3A73;
  color: var(--muted);
  box-shadow: 0 6px 0 #2E2152;
  cursor: not-allowed;
}

.btn-secondary {
  min-height: 52px;
  min-width: 140px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(16px, 4.6vw, 20px);
  cursor: pointer;
  box-shadow: 0 5px 0 #1E1240;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn-secondary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #1E1240;
}

.btn-link {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--mint);
  font-weight: 700;
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.btn-danger {
  min-height: 48px;
  padding: 0 22px;
  border: 2px solid var(--red);
  border-radius: 999px;
  background: transparent;
  color: var(--red);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}

.btn-danger.is-armed {
  background: var(--red);
  color: #2A0606;
}

/* ---------- Pantalla principal ---------- */
.screen--title {
  align-items: center;
  justify-content: center;
  padding-top: 16px;
  padding-bottom: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
}

.corner {
  position: absolute;
  top: 12px;
  right: calc(14px + var(--safe-r));
  z-index: 2;
}

.title-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  width: 100%;
  margin: auto 0;
  padding: 0 20px;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(52px, 17vw, 100px);
  line-height: 0.88;
  color: var(--ink);
  transform: rotate(-4deg);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--violet);
}

.logo span:last-child { margin-left: 0.5em; }

.tagline {
  margin-top: 14px;
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 600;
  color: var(--mint);
}

.title-progress {
  min-height: 22px;
  font-size: 16px;
  font-weight: 700;
  color: var(--yellow);
}

.title-progress .legend-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #7CC8FF, #FF7EDB, #FFD23F);
  color: #24103F;
}

.title-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
}

.title-actions .btn-primary,
.title-actions .btn-secondary { min-width: 220px; }

.hint {
  max-width: 30ch;
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
}

.best {
  font-size: 15px;
  font-weight: 600;
  color: var(--yellow);
}

/* ---------- Barra superior (mapa / opciones) ---------- */
.bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px 6px;
}

.bar-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(20px, 6vw, 26px);
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--pink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-stars {
  flex: none;
  min-width: 46px;
  text-align: right;
  font-weight: 700;
  font-size: 15px;
  color: var(--yellow);
  white-space: nowrap;
}

.bar-spacer { width: 46px; flex: none; }

/* ---------- Mapa ---------- */
.map-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.map-track {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 18px 14px 24px;
}

.map-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.map-path .seg {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
}

.map-path .seg.is-done { stroke: var(--yellow); }
.map-path .seg.is-locked { stroke: rgba(181, 166, 218, 0.35); stroke-dasharray: 2 14; }
.map-path .seg.is-secret.is-locked { stroke: rgba(255, 126, 219, 0.35); }
.map-path .seg.is-secret.is-done { stroke: #FF7EDB; stroke-dasharray: 10 10; }

.map-node {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 82%;
  min-height: 72px;
  padding: 6px;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.map-node.is-left { align-self: flex-start; }
.map-node.is-right { align-self: flex-end; flex-direction: row-reverse; text-align: right; }
.map-node.is-selected { background: rgba(255, 255, 255, 0.07); }
.map-node--goal { cursor: default; }

.map-dot {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 4px solid rgba(255, 244, 230, 0.9);
  background: var(--c, var(--pink));
  color: #1A0F33;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}

.map-node.is-locked .map-dot {
  background: #33275A;
  border: 4px dashed rgba(181, 166, 218, 0.5);
  font-size: 22px;
}

.map-node.is-current .map-dot::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 3px solid var(--c, var(--yellow));
  animation: ring-pulse 1s ease-out infinite;
}

.map-node--goal .map-dot {
  background: var(--ink);
  font-family: var(--font-ui);
  font-size: 28px;
}

.map-node--secret .map-dot {
  background: conic-gradient(from 0deg, #7CC8FF, #FF7EDB, #FFD23F, #3DF5C2, #7CC8FF);
  font-family: var(--font-ui);
  font-size: 26px;
}

.map-node--secret.is-locked .map-dot { background: #2A1D4A; border-color: rgba(255, 126, 219, 0.5); }

@keyframes ring-pulse {
  0% { transform: scale(0.85); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}

.map-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.map-name {
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}

.map-sub {
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-stars {
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--yellow);
  white-space: nowrap;
}

.map-stars .off { color: rgba(181, 166, 218, 0.4); }

.map-node--secret .map-name { color: #FFB8EC; }

/* Panel de detalle */
.map-panel {
  flex: none;
  margin: 0 10px 10px;
  padding: 14px 16px 16px;
  border-radius: 24px;
  background: rgba(43, 26, 87, 0.92);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-head .map-dot {
  width: 46px;
  height: 46px;
  font-size: 18px;
  border-width: 3px;
}

.panel-title {
  font-size: 18px;
  line-height: 1.2;
}

.panel-sub {
  font-size: 14px;
  color: var(--muted);
}

.panel-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
  text-align: center;
}

.panel-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-stats span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.panel-stats b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
}

.panel-lock {
  margin: 12px 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
}

.map-panel .btn-primary { width: 100%; }

/* Mapa horizontal en pantallas grandes */
@media (min-width: 860px) and (min-height: 600px) {
  .map-scroll { display: flex; align-items: center; }
  .map-track {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    max-width: 1060px;
    min-height: 380px;
    padding: 40px 30px;
    gap: 8px;
  }
  .map-node,
  .map-node.is-left,
  .map-node.is-right {
    flex-direction: column;
    align-self: center;
    width: auto;
    max-width: 150px;
    text-align: center;
  }
  .map-node.is-left { transform: translateY(-56px); }
  .map-node.is-right { transform: translateY(56px); }
  .map-label { align-items: center; }
  .map-dot { width: 70px; height: 70px; font-size: 28px; }
  .map-panel {
    width: 100%;
    max-width: 640px;
    margin: 0 auto 18px;
  }
}

/* ---------- Opciones ---------- */
.options-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  padding: 6px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.opt-group {
  padding: 16px;
  border-radius: 20px;
  background: rgba(43, 26, 87, 0.7);
}

.opt-group h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.opt-group p {
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.opt-group p + p { margin-top: 8px; }

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch {
  position: relative;
  flex: none;
  width: 64px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: #4A3A73;
  cursor: pointer;
  transition: background 0.15s ease;
}

.switch span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.15s ease;
}

.switch[aria-checked="true"] { background: var(--mint); }
.switch[aria-checked="true"] span { transform: translateX(26px); }

.sync {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.sync input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  touch-action: pan-x;
}

.sync input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: #4A3A73;
}

.sync input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--yellow);
  border: 0;
}

.sync input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #4A3A73;
}

.sync input[type="range"]::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--yellow);
  border: 0;
}

.sync-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.sync-foot output {
  font-family: var(--font-display);
  font-size: 18px;
}

.legend {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 10px 0;
  font-size: 15px;
  color: var(--ink);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: none;
}

.dot--beat { background: var(--pink); }
.dot--half { background: var(--mint); }
.dot--third { background: var(--sky); }
.dot--quarter { background: var(--yellow); }

/* ---------- Personajes ---------- */
.buddy-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.b-body {
  transform-box: view-box;
  transform-origin: 60px 133px;
}

.b-arm {
  transform-box: view-box;
  transform-origin: 94px 94px;
  transform: rotate(-8deg);
  transition: transform 0.1s ease-out;
}

.b-eyes-happy path,
.b-eyes-dizzy path,
.b-mouth {
  fill: none;
  stroke: var(--line, #1A0F33);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.b-mouth-open { fill: var(--line, #1A0F33); }

.b-eyes-happy,
.b-eyes-dizzy,
.b-mouth-open,
.b-mouth-sad,
.b-crown {
  display: none;
}

.buddy.has-crown .b-crown { display: inline; }
.buddy.has-crown .b-antenna-group { display: none; }

.buddy.is-swing .b-arm {
  transform: rotate(30deg);
  transition-duration: 0.035s;
}

.buddy.is-perfect .b-eyes-normal,
.buddy.is-miss .b-eyes-normal,
.buddy.is-victory .b-eyes-normal,
.buddy.is-defeat .b-eyes-normal,
.buddy.is-perfect .b-mouth-normal,
.buddy.is-good .b-mouth-normal,
.buddy.is-miss .b-mouth-normal,
.buddy.is-victory .b-mouth-normal,
.buddy.is-defeat .b-mouth-normal {
  display: none;
}

.buddy.is-perfect .b-eyes-happy,
.buddy.is-perfect .b-mouth-open,
.buddy.is-good .b-mouth-open,
.buddy.is-victory .b-eyes-happy,
.buddy.is-victory .b-mouth-open,
.buddy.is-miss .b-eyes-dizzy,
.buddy.is-miss .b-mouth-sad,
.buddy.is-defeat .b-eyes-dizzy,
.buddy.is-defeat .b-mouth-sad {
  display: inline;
}

.buddy-inner { transform-origin: 50% 100%; }

.buddy.is-perfect .buddy-inner { animation: buddy-hop 0.36s ease-out; }
.buddy.is-miss .buddy-inner { animation: buddy-wobble 0.36s ease-in-out; }
.buddy.is-victory .buddy-inner { animation: buddy-victory 0.42s ease-in-out infinite alternate; }
.buddy.is-defeat .buddy-inner { animation: buddy-sway 1.3s ease-in-out infinite; }
.buddy.is-victory .b-arm { transform: rotate(-55deg); }
.buddy.is-defeat .b-arm { transform: rotate(40deg); }

@keyframes buddy-hop {
  0% { transform: translateY(0); }
  40% { transform: translateY(-14%) rotate(-3deg); }
  100% { transform: translateY(0); }
}

@keyframes buddy-wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg) translateX(-4%); }
  60% { transform: rotate(8deg); }
}

@keyframes buddy-victory {
  from { transform: translateY(0) scale(1.03, 0.97); }
  to { transform: translateY(-16%) rotate(4deg); }
}

@keyframes buddy-sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg) translateY(3%); }
}

.b-sparkle,
.b-halo {
  transform-box: fill-box;
  transform-origin: center;
  animation: twinkle 1.1s ease-in-out infinite alternate;
}

.b-halo { animation-duration: 0.9s; }

.buddy--hero {
  width: clamp(110px, 34vw, 160px);
  margin: 14px 0 6px;
}

.buddy--hero .b-body { animation: hero-bob 0.5s ease-in-out infinite alternate; }
.buddy--hero .b-arm { animation: hero-drum 0.5s ease-in infinite; }

@keyframes hero-bob {
  from { transform: translateY(0) scale(1.04, 0.95); }
  to { transform: translateY(-5px) scale(0.98, 1.03); }
}

@keyframes hero-drum {
  0%, 60%, 100% { transform: rotate(-8deg); }
  12% { transform: rotate(26deg); }
}

/* ---------- Pantalla de juego ---------- */
.screen--game { overflow: hidden; }

.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.scene svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(16, 8, 31, 0.55) 0%, rgba(16, 8, 31, 0.25) 45%, rgba(16, 8, 31, 0.35) 100%);
}

.scene * {
  transform-box: fill-box;
  transform-origin: center;
}

.sc-tw { animation: twinkle 1.6s ease-in-out infinite alternate; }
.sc-ff { animation: firefly 3s ease-in-out infinite alternate; }
.sc-spot { transform-origin: 50% 0%; animation: spot 3.2s ease-in-out infinite alternate; }
.sc-crowd { animation: crowd 0.45s ease-in-out infinite alternate; }
.sc-streak { animation: streak 2.6s linear infinite; }
.sc-aurora { animation: aurora 7s ease-in-out infinite alternate; }
.sc-float { animation: floaty 3.4s ease-in-out infinite alternate; }
.sc-blink { animation: blink 1s steps(2, end) infinite; }

@keyframes twinkle { from { opacity: 0.25; } to { opacity: 1; } }
@keyframes firefly { from { transform: translate(0, 0); opacity: 0.3; } to { transform: translate(10px, -16px); opacity: 1; } }
@keyframes spot { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
@keyframes crowd { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@keyframes streak { from { transform: translateX(-160%); } to { transform: translateX(520%); } }
@keyframes aurora { from { transform: translateX(-6%) scaleY(1); } to { transform: translateX(6%) scaleY(1.15); } }
@keyframes floaty { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-14px) rotate(8deg); } }
@keyframes blink { 50% { opacity: 0.35; } }

.hud {
  position: relative;
  z-index: 1;
  flex: none;
  padding: 8px 14px 4px;
}

.hud-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: clamp(14px, 4.4vw, 18px);
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--pink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-actions {
  display: flex;
  gap: 8px;
}

.stats {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  align-items: end;
  margin-top: 6px;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat--combo { align-items: center; }
.stat--acc { align-items: flex-end; }

.stat-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(19px, 6vw, 28px);
  line-height: 1.15;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.stat--combo .stat-value {
  display: inline-block;
  color: var(--mint);
}

.stat--combo .stat-value.is-bump { animation: bump 0.18s ease-out; }
.stat--combo .stat-value.is-milestone { animation: milestone 0.45s ease-out; }
.stat--combo .stat-value.is-break { color: var(--red); }

.mult {
  margin-left: 4px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  color: var(--yellow);
  vertical-align: middle;
}

@keyframes bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

@keyframes milestone {
  0% { transform: scale(1); color: var(--yellow); }
  35% { transform: scale(1.5) rotate(-6deg); color: var(--yellow); }
  100% { transform: scale(1); }
}

.stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
  outline: none;
}

.stage.is-shake { animation: shake 0.24s linear; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(5px); }
  70% { transform: translateX(-3px); }
}

#lane {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.buddy--game {
  position: absolute;
  left: var(--bx, 8px);
  top: var(--by, 60%);
  width: var(--bw, 90px);
  pointer-events: none;
}

.callout {
  position: absolute;
  left: 0;
  right: 0;
  top: 28%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.c-main {
  font-family: var(--font-display);
  font-size: clamp(30px, 9.5vw, 52px);
  line-height: 1.05;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--pink), 0 0 30px rgba(255, 77, 141, 0.45);
}

.c-sub {
  max-width: 26ch;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.c-sub:empty { display: none; }

.callout.mode-count .c-main {
  font-size: clamp(80px, 28vw, 150px);
  color: var(--yellow);
  text-shadow: 5px 5px 0 var(--pink);
}

.callout.mode-end .c-main {
  color: var(--mint);
  text-shadow: 4px 4px 0 var(--violet);
}

.callout.is-hold {
  opacity: 1;
  animation: breathe 0.5s ease-in-out infinite alternate;
}

.callout.is-flash { animation: count-pop 0.46s ease-out forwards; }
.callout.mode-end.is-flash { animation: end-pop 1.2s ease-out forwards; }

@keyframes breathe {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

@keyframes count-pop {
  0% { opacity: 0; transform: scale(1.6); }
  25% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(0.92); }
}

@keyframes end-pop {
  0% { opacity: 0; transform: scale(1.6); }
  15% { opacity: 1; transform: scale(1); }
  100% { opacity: 1; transform: scale(1); }
}

.tag {
  position: absolute;
  top: 12px;
  left: 50%;
  max-width: calc(100% - 24px);
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--yellow);
  color: #2A1500;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%);
  box-shadow: 0 4px 0 var(--yellow-dark);
}

.tag.is-on { animation: tag-in 1.9s ease forwards; }

@keyframes tag-in {
  0% { opacity: 0; transform: translate(-50%, -16px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

.judgment {
  position: absolute;
  left: 50%;
  top: var(--judge-y, 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
}

.j-main {
  font-family: var(--font-display);
  font-size: clamp(30px, 9.5vw, 48px);
  line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.j-sub {
  margin-top: 2px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.9;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.j-sub:empty { display: none; }

.judgment[data-r="perfect"] .j-main { color: var(--yellow); }
.judgment[data-r="good"] .j-main { color: var(--sky); }
.judgment[data-r="miss"] .j-main { color: var(--red); }

.judgment.is-on { animation: judge-pop 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) forwards; }
.judgment.is-on[data-r="miss"] { animation: judge-drop 0.5s ease-out forwards; }

@keyframes judge-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.55); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.14); }
  38% { transform: translate(-50%, -50%) scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

@keyframes judge-drop {
  0% { opacity: 0; transform: translate(-50%, -80%); }
  20% { opacity: 1; transform: translate(-50%, -50%) rotate(-4deg); }
  70% { opacity: 1; transform: translate(-50%, -42%) rotate(3deg); }
  100% { opacity: 0; transform: translate(-50%, -30%) rotate(3deg); }
}

/* ---------- Resultado ---------- */
.screen--result {
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
}

.result-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 100%;
  justify-content: center;
  padding: 18px 18px 26px;
  text-align: center;
}

.res-level {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

.res-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(22px, 6.6vw, 30px);
  line-height: 1.1;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--violet);
}

.res-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3vw, 20px);
  width: 100%;
}

.buddy--result {
  width: clamp(70px, 22vw, 110px);
  flex: none;
}

.res-score-block,
.rating-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rating-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.res-score {
  font-family: var(--font-display);
  font-size: clamp(38px, 12vw, 58px);
  line-height: 1;
  white-space: nowrap;
}

.res-score small {
  margin-left: 2px;
  font-size: 0.36em;
  color: var(--muted);
}

.stars {
  margin-top: 4px;
  font-size: clamp(18px, 5.4vw, 24px);
  letter-spacing: 2px;
  color: var(--yellow);
  white-space: nowrap;
}

.stars .off { color: rgba(181, 166, 218, 0.35); }

.rating {
  font-family: var(--font-display);
  font-size: clamp(60px, 19vw, 96px);
  line-height: 0.95;
  color: var(--pink);
  text-shadow: 5px 5px 0 var(--violet);
}

.rating[data-rating="S"] { color: var(--yellow); text-shadow: 5px 5px 0 var(--pink); }
.rating[data-rating="A"] { color: var(--pink); }
.rating[data-rating="B"] { color: var(--mint); }
.rating[data-rating="C"] { color: var(--sky); }
.rating[data-rating="D"] { color: var(--muted); text-shadow: 5px 5px 0 var(--surface); }

.screen--result.is-active .rating { animation: rating-in 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) 0.15s both; }

@keyframes rating-in {
  0% { opacity: 0; transform: scale(2.2) rotate(-12deg); }
  100% { opacity: 1; transform: scale(1) rotate(-4deg); }
}

.phrase {
  font-size: clamp(19px, 5.4vw, 23px);
  font-weight: 700;
  color: var(--ink);
}

.record {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--mint);
  color: #062B22;
  font-weight: 700;
  font-size: 15px;
}

.unlock {
  max-width: 34ch;
  padding: 8px 16px;
  border-radius: 16px;
  background: rgba(255, 210, 63, 0.14);
  color: var(--yellow);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.35;
}

.unlock.is-hint {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
}

.unlock.is-secret {
  background: linear-gradient(90deg, #7CC8FF, #FF7EDB, #FFD23F);
  color: #24103F;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(15px, 4.4vw, 19px);
  animation: secret-glow 1.2s ease-in-out infinite alternate;
}

@keyframes secret-glow {
  from { box-shadow: 0 0 0 rgba(255, 126, 219, 0); }
  to { box-shadow: 0 0 26px rgba(255, 126, 219, 0.8); }
}

.screen--result.is-legend .res-title {
  background: linear-gradient(90deg, #7CC8FF, #FF7EDB, #FFD23F, #3DF5C2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.res-stats {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
}

.res-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 4px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.14);
}

.res-row dt {
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
}

.res-row dd {
  font-family: var(--font-display);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.breakdown {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.bd b { font-weight: 700; color: var(--ink); }
.bd--perfect { color: var(--yellow); }
.bd--good { color: var(--sky); }
.bd--miss { color: var(--red); }

.res-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
  width: 100%;
}

.res-actions .btn-primary { min-width: 240px; max-width: 100%; }

.res-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.res-actions-row .btn-secondary { min-width: 130px; }

/* Confeti */
.confetti {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- Pantallas bajitas ---------- */
@media (max-height: 600px) {
  .logo { font-size: 46px; }
  .buddy--hero { width: 92px; margin: 4px 0; }
  .tagline { margin-top: 6px; }
  .hint { display: none; }
  .hud { padding-top: 4px; }
  .stat-value { font-size: 19px; }
  .result-inner { gap: 7px; }
  .map-node { min-height: 64px; }
  .map-dot { width: 54px; height: 54px; font-size: 21px; }
}

@media (max-height: 700px) {
  .map-panel { padding: 10px 14px 12px; }
  .panel-head .map-dot { display: none; }
  .panel-title { font-size: 17px; }
  .panel-sub { font-size: 13px; margin-top: 2px; }
  .panel-stats { margin: 8px 0; }
  .panel-stats b { font-size: 16px; }
  .panel-lock { margin: 8px 0; }
  .map-panel .btn-primary { min-height: 52px; }
}

@media (max-width: 350px) {
  .map-node { width: 92%; gap: 10px; }
  .map-name { font-size: 16px; }
  .btn-primary { min-width: 180px; }
  .title-actions .btn-primary,
  .title-actions .btn-secondary { min-width: 200px; }
  .panel-stats b { font-size: 16px; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .buddy--hero .b-body,
  .buddy--hero .b-arm,
  .buddy .buddy-inner,
  .b-sparkle,
  .b-halo,
  .stage.is-shake,
  .callout.is-hold,
  .stat--combo .stat-value.is-bump,
  .stat--combo .stat-value.is-milestone,
  .map-node.is-current .map-dot::after,
  .unlock.is-secret,
  .scene *,
  .confetti i {
    animation: none !important;
  }

  .confetti { display: none; }
  .judgment.is-on,
  .judgment.is-on[data-r="miss"] { animation: judge-fade 0.5s linear forwards; }
  .callout.is-flash { animation: judge-fade-plain 0.46s linear forwards; }
  .callout.mode-end.is-flash { animation: none; opacity: 1; }
  .screen--result.is-active .rating { animation: none; transform: rotate(-4deg); }
  .tag.is-on { animation: tag-fade 1.9s linear forwards; }

  @keyframes judge-fade {
    0%, 70% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -50%); }
  }
  @keyframes judge-fade-plain {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
  }
  @keyframes tag-fade {
    0%, 85% { opacity: 1; transform: translateX(-50%); }
    100% { opacity: 0; transform: translateX(-50%); }
  }
}