/* ============================================================
   MUSIC LAB — STYLES
   ============================================================ */

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

/* ── PAGE TRANSITION OVERLAY ─────────────────────────────── */
.page-transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: var(--t);
  opacity: 1;
}
/* Hide elements initially for entrance animation */
.gsap-hidden { opacity: 0; visibility: hidden; }

/* SVG logos: fill hereda de color para que sea controlable vía CSS/JS */
#logoSvg, .mlab-svg { fill: currentColor; }
.svg-defs { position: absolute; }

:root {
  --t:  #2CC1C7;   /* teal  */
  --p:  #F194A8;   /* pink  */
  --y:  #F9F28B;   /* yellow */
  --w:  #ffffff;
  --dk: #111111;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', sans-serif;
}

/* ── GAME SHELL ─────────────────────────────────────────── */
#game {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  background: var(--t);
}

/* ── SCREENS ─────────────────────────────────────────────── */
.sc {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--t);
}

/* ── FONT HELPERS ────────────────────────────────────────── */
.kalam { font-family: 'Kalam', cursive; }
.dm    { font-family: 'DM Sans', sans-serif; }

/* ── S0: STANDBY ─────────────────────────────────────────── */
#s0 { padding: 0; overflow: hidden; background: var(--bounce-bg, var(--t)); }
#isdin0 { position: absolute; top: 4.5%; left: 50%; transform: translateX(-50%); z-index: 10; color: var(--bounce-isdin, var(--dk)); }
#dvd { position: absolute; width: min(82%, 480px); pointer-events: none; }
#logoSvg { width: 100%; height: auto; display: block; color: var(--bounce-logo, var(--y)); }
#tocameBtn { position: absolute; bottom: 8%; left: 50%; transform: translateX(-50%); width: min(58%, 320px); cursor: pointer; z-index: 20; }

/* ── S1: PLAYER SELECT ───────────────────────────────────── */
#s1 { padding: 0 6%; justify-content: center; }
.s1-cj { position: absolute; top: 3%; right: 4%; z-index: 5; }
.s1-content { width: 100%; display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 3.5vw, 34px); }
.s1-header { text-align: center; width: 100%; display: flex; flex-direction: column; align-items: center; gap: clamp(4px, 1vw, 10px); }
.s1-pcards { display: flex; gap: 3.5%; width: 100%; }
.s1-siguiente { width: min(62%, 280px); cursor: pointer; position: relative; margin-top: clamp(20px, 3vw, 30px); }

/* ── ISDIN / ACNIBEN LOGO ────────────────────────────────── */
.isdin-logo { text-align: center; line-height: 1; }
.isdin-logo .l1 { font-family: 'DM Sans', sans-serif; font-weight: 900; letter-spacing: .14em; font-size: clamp(24px, 5.5vw, 52px); }
.isdin-logo .l2 { font-family: 'DM Sans', sans-serif; font-weight: 400; letter-spacing: .2em;  margin-top: 2px; font-size: clamp(9px, 2vw, 18px); }
.isdin-logo .l3 { font-family: 'DM Sans', sans-serif; font-weight: 800; letter-spacing: .02em; margin-top: 2px; font-size: clamp(26px, 6vw, 58px); }
.isdin-logo .l3 sup { font-size: 50%; vertical-align: super; }
.isdin-logo-ranking { text-align: center; line-height: 1; margin-top: 50px; color: var(--dk); flex-shrink: 0; }
.isdin-logo-ranking .l1 { font-family: 'DM Sans', sans-serif; font-weight: 900; letter-spacing: .14em; font-size: clamp(24px, 5.5vw, 52px); }
.isdin-logo-ranking .l2 { font-family: 'DM Sans', sans-serif; font-weight: 400; letter-spacing: .2em; margin-top: 2px; font-size: clamp(9px, 2vw, 18px); }
.isdin-logo-ranking .l3 { font-family: 'DM Sans', sans-serif; font-weight: 800; letter-spacing: .02em; margin-top: 2px; font-size: clamp(26px, 6vw, 58px); }
.isdin-logo-ranking .l3 sup { font-size: 50%; vertical-align: super; }

/* ── MUSIC LAB SVG SIZES ─────────────────────────────────── */
.mlab-svg       { display: block; width: auto; height: 1em; }
.ml-title-small { height: clamp(70px,  9vw, 86px);  color: var(--w); }
.ml-title-big   { width: min(94%, 500px); height: auto; color: var(--w); }
.ml-title-xl    { height: clamp(80px, 20vw, 190px); color: var(--w); }

/* ── TEXT STYLES ─────────────────────────────────────────── */
.ml-sm {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: clamp(18px, 4vw, 36px);
  color: var(--w);
  text-align: center;
}
.ml-sm-grettings{
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: clamp(35px, 4vw, 36px);
  color: var(--w);
  text-align: center;
}
.qtext {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-style: italic;
  font-size: clamp(24px, 5.5vw, 54px);
  color: var(--w);
  text-align: center;
  line-height: 1;
}
.vamos {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-style: italic;
  font-size: clamp(24px, 6vw, 52px);
  color: var(--w);
  text-align: center;
  transform: rotate(-3deg);
  line-height: 1.05;
}

/* ── NAV ELEMENTS ────────────────────────────────────────── */
.help-btn-svg {
  width:  clamp(44px, 8.5vw, 76px);
  height: clamp(44px, 8.5vw, 76px);
  cursor: pointer;
  flex-shrink: 0;
  display: block;
}
.back-link {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-style: italic;
  font-size: clamp(18px, 4vw, 34px);
  color: var(--w);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: rotate(-3deg);
}
.back-arrow { width: clamp(18px, 3.5vw, 30px); height: auto; flex-shrink: 0; }
.back-link-underline { text-decoration: underline; }
.cj-wrap  { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.cj-label {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: clamp(18px, 2.2vw, 18px);
  color: var(--w);
  display: inline-block;
  transform: rotate(-3deg);
}

/* ── BTN: SVG WRAPPER ────────────────────────────────────── */
.btn-svg { display: block; width: 100%; height: auto; cursor: pointer; transition: transform .1s; }
.btn-svg:active { transform: scale(.97); }

/* ── BTN: LABEL OVERLAY ──────────────────────────────────── */
.btn-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Kalam', cursive;
  font-weight: 700;
  color: #fff;
  font-size: clamp(25px, 4.5vw, 42px);
  letter-spacing: .04em;
  pointer-events: none;
}

/* ── BTN: GREY / DISABLED ────────────────────────────────── */
.pill-grey {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  background: #d8d8d8;
  color: #999;
  border: none;
  border-radius: 100px;
  padding: 0 10%;
  height: clamp(52px, 9.5vw, 88px);
  font-size: clamp(22px, 4.5vw, 42px);
  letter-spacing: .06em;
  cursor: not-allowed;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  box-shadow: 0 clamp(4px, 1vw, 8px) 0 #bbb;
}

/* ── COMENZAR: disabled state ─────────────────────────────── */
.comenzar-disabled { pointer-events: none; opacity: .4; }
.pill-grey.full-w { width: 100%; }

/* ── OTRA BTN: visible state (handled in .otra-btn block) ── */

/* ── MONO ICON (inline in badges) ────────────────────────── */
.team-mono-ic { width: clamp(10px, 2vw, 18px); height: auto; display: inline-block; vertical-align: middle; margin-right: 2px; }


/* ── BADGE (team + song counter) ─────────────────────────── */
.badge {
  background: var(--y);
  border-radius: clamp(14px, 3vw, 24px);
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: clamp(14px, 2.8vw, 26px);
  color: var(--dk);
  padding: clamp(8px,1.5vw,14px) clamp(18px,3.5vw,30px);
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.2vw, 10px);
  white-space: nowrap;
  position: relative;
  z-index: 1;
  transform: rotate(-2deg);
}
.badge.italic { font-style: italic; }
.badge-wrap   { position: relative; display: inline-block; }
.badge-wrap::after {
  content: "";
  position: absolute;
  top:    clamp(5px, 1vw, 9px);
  left:   clamp(5px, 1vw, 9px);
  right:  calc(-1 * clamp(5px, 1vw, 9px));
  bottom: calc(-1 * clamp(5px, 1vw, 9px));
  background: var(--p);
  border-radius: clamp(14px, 3vw, 24px);
  z-index: 0;
}
.badge .mono-ic {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  color: #111;
}

/* ── NAME BOX ────────────────────────────────────────────── */
.namebox {
  width: 100%;
  background: rgba(255,255,255,.25);
  border-radius: 16px;
  padding: clamp(16px,3.5vw,30px) 5%;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(33px, 6.2vw, 58px);
  color: var(--dk);
  text-align: center;
  cursor: pointer;
  min-height: clamp(66px, 13vw, 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .01em;
  transition: background .15s;
}
.namebox:hover { background: rgba(255,255,255,.32); }
.namebox.err   { background: #e53935; color: var(--w); animation: errShake .45s ease-out; }

.err-msg {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-style: italic;
  font-size: clamp(18px, 4vw, 34px);
  color: var(--w);
  text-align: center;
  display: none;
  line-height: 1.25;
}
.err-msg.on {
  display: block;
  animation: errShake .45s ease-out;
}
@keyframes errShake {
  0%   { opacity: 0; transform: translateX(-12px); }
  20%  { opacity: 1; transform: translateX(10px); }
  40%  { transform: translateX(-8px); }
  60%  { transform: translateX(6px); }
  80%  { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

/* ── PLAYER CARDS ────────────────────────────────────────── */
.pcard {
  flex: 1;
  background: rgba(255,255,255,.22);
  border-radius: clamp(14px, 3vw, 24px);
  padding: 6% 4% 6%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .18s, transform .12s;
  aspect-ratio: 1 / 1;
}
.pcard:active  { transform: scale(.96); }
.pcard.sel     { background: var(--y); border-color: transparent; }

.pcard-label {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(10px, 2vw, 17px);
  font-weight: 800;
  color: var(--w);
  letter-spacing: .04em;
  text-align: center;
  line-height: 1.1;
}
.pcard.sel .pcard-label { color: var(--dk); }

.pcard .monos {
  display: flex;
  gap: clamp(2px, .6vw, 5px);
  justify-content: center;
  align-items: flex-end;
  flex: 1;
  width: 100%;
}
.pcard .mono { flex: 1; max-width: clamp(22px, 5.5vw, 48px); color: var(--w); display: block; }
.pcard.sel .mono { color: #111; }
.pcard .mono svg { width: 100%; height: auto; display: block; }

/* ── ANSWER OPTIONS ──────────────────────────────────────── */
.ans {
  width: 100%;
  background: var(--w);
  border-radius: clamp(16px, 3.5vw, 28px);
  border: 2.5px solid var(--p);
  padding: clamp(12px, 2.5vw, 22px) 5%;
  display: flex;
  align-items: center;
  gap: 3%;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  position: relative;
  z-index: 1;
}
.ans-wrap {
  position: relative;
  width: 100%;
  opacity: 0;
  animation: ansIn .35s ease forwards;
}
.ans-wrap:nth-child(1) { animation-delay: .05s; }
.ans-wrap:nth-child(2) { animation-delay: .12s; }
.ans-wrap:nth-child(3) { animation-delay: .19s; }
.ans-wrap:nth-child(4) { animation-delay: .26s; }

@keyframes ansIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ans-wrap::after {
  content: "";
  position: absolute;
  top:    clamp(5px, 1vw, 9px);
  left:   clamp(5px, 1vw, 9px);
  right:  calc(-1 * clamp(5px, 1vw, 9px));
  bottom: calc(-1 * clamp(5px, 1vw, 9px));
  background: var(--p);
  border-radius: clamp(16px, 3.5vw, 28px);
  z-index: 0;
}
.ans.sel     { background: var(--y); }
.ans.correct {
  background: linear-gradient(135deg, #a8ffa8, #7eff7e);
  border-color: var(--y);
}
.ans.correct .ans-txt,
.ans.correct .ans-txt b,
.ans.correct .ans-txt span { color: var(--dk); }
.ans-wrap:has(.ans.correct)::after { background: var(--y); }
.ans.wrong {
  background: var(--p);
  border-color: var(--y);
}
.ans.wrong .ans-letter { color: var(--dk); }
.ans.wrong .ans-txt,
.ans.wrong .ans-txt b,
.ans.wrong .ans-txt span { color: var(--dk); }
.ans-wrap:has(.ans.wrong)::after { background: var(--y); }

/* Highlight the correct answer's letter when another was picked wrong */
.ans.correct-hint .ans-letter {
  background: #7eff7e;
  border-radius: 50%;
  min-width: clamp(52px, 11vw, 90px);
  min-height: clamp(52px, 11vw, 90px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ans-letter {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Chewy', cursive;
  font-weight: 400;
  font-size: clamp(18px, 3.5vw, 32px);
  color: var(--dk);
  padding-left: 2%;
}
.ans.correct .ans-letter,
.ans.wrong   .ans-letter { color: var(--dk); }

.ans-txt {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(12px, 2.4vw, 22px);
  font-weight: 700;
  color: var(--dk);
  text-align: left;
  line-height: 1.15;
}
.ans-txt span { font-weight: 400; color: #333; }

/* ── KEYBOARD OVERLAY ────────────────────────────────────── */
.kb-overlay {
  position: fixed;
  inset: 0;
  background: var(--t);
  z-index: 50;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  transform: translateY(5%);
  transition: opacity .3s ease, transform .3s ease, visibility 0s .3s;
}
.kb-overlay.on {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .3s ease, transform .3s ease, visibility 0s 0s;
}

/* ── KEYBOARD ────────────────────────────────────────────── */
.kb-outer     { background: var(--y); border-radius: 18px; padding: 3% 2.5% 2.5%; width: 100%; flex-shrink: 0; }
.kb-close-row { display: flex; justify-content: flex-end; margin-bottom: 1.5%; }
.kb-close {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  transform: rotate(-4deg);
}
.cerrar-svg {
  height: clamp(22px, 4.5vw, 40px);
  width: auto;
  display: block;
}
.kb-close .close-x {
  font-family: 'DM Sans', sans-serif;
  font-weight: 900;
  font-size: 1.6em;
  line-height: 1;
}
.krow { display: flex; justify-content: center; gap: 1.8%; margin-bottom: 1.8%; }
.k {
  background: var(--t);
  color: var(--w);
  font-size: clamp(10px, 2vw, 18px);
  font-weight: 700;
  border: none;
  border-radius: 7px;
  height: clamp(28px, 5.5vw, 50px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Sans', sans-serif;
  flex: 1;
  transition: opacity .1s;
}
.k:active { opacity: .7; }
.k.kp  { background: var(--p); }
.k.kd  { background: #1A9BA0; }
.k.kw  { flex: 1.6; }
.k.ksp { flex: 4; }

/* ── WAVEFORM / CANVAS ───────────────────────────────────── */
.wave-wrap {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wave-wrap canvas { display: block; width: 100%; }

.cd-circle {
  position: absolute;
  z-index: 2;
  background: var(--w);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width:  clamp(72px, 17vw, 150px);
  height: clamp(72px, 17vw, 150px);
  transition: opacity .3s ease, transform .3s ease;
}
.cd-circle.hidden {
  opacity: 0;
  transform: scale(.5);
  pointer-events: none;
}
.cd-num {
  font-family: 'DM Sans', sans-serif;
  font-weight: 900;
  font-size: clamp(34px, 8vw, 74px);
  color: var(--t);
}

.play-circle {
  position: absolute;
  z-index: 2;
  background: var(--w);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width:  clamp(72px, 17vw, 150px);
  height: clamp(72px, 17vw, 150px);
  cursor: pointer;
  border: none;
  animation: heartbeat 1.4s ease-in-out infinite;
}
.play-circle:active { animation: none; transform: scale(.94); }
.play-circle svg    { width: 70%; position: relative; z-index: 2; }

/* Heartbeat animation */
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.08); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.05); }
  56%      { transform: scale(1); }
}

/* Pulse rings radiating outward */
.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--w);
  animation: pulseRing 2s ease-out infinite;
  pointer-events: none;
}
.pulse-ring--2 {
  animation-delay: 0.7s;
}
@keyframes pulseRing {
  0%   { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* "Otra oportunidad" — same spot as qtext */
.otra-btn {
  display: none;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.5vw, 20px);
  cursor: pointer;
}
.otra-btn.visible {
  display: flex;
  animation: slideUp .4s ease-out;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.otra-text {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: clamp(20px, 4.5vw, 42px);
  color: var(--w);
  font-style: italic;
  white-space: nowrap;
}
.otra-pill-wrap {
  position: relative;
}
.otra-pill-wrap::after {
  content: "";
  position: absolute;
  top:    clamp(3px, .7vw, 6px);
  left:   clamp(3px, .7vw, 6px);
  right:  calc(-1 * clamp(3px, .7vw, 6px));
  bottom: calc(-1 * clamp(3px, .7vw, 6px));
  background: var(--y);
  border-radius: clamp(10px, 2vw, 16px);
  z-index: 0;
}
.otra-pill {
  position: relative;
  z-index: 1;
  font-family: 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: clamp(11px, 2.2vw, 20px);
  color: var(--w);
  background: var(--p);
  border-radius: clamp(10px, 2vw, 16px);
  padding: clamp(8px, 1.5vw, 14px) clamp(14px, 2.5vw, 24px);
  white-space: nowrap;
  letter-spacing: .04em;
  text-transform: uppercase;
  display: inline-block;
}

/* ── RANKING ─────────────────────────────────────────────── */
.rank-row {
  background: var(--w);
  border-radius: clamp(14px, 3vw, 24px);
  padding: clamp(5px, 2vw, 18px) 5%;
  display: flex;
  align-items: center;
  gap: 3%;
}
.rank-row { transform: rotate(-1.2deg); }
.rank-row.me { background: var(--y); }

.rank-pos {
  font-family: 'Chewy', cursive;
  font-size: clamp(30px, 4.2vw, 40px);
  font-weight: 400;
  color: var(--dk);
  min-width: 6%;
  white-space: nowrap;
}
.rank-name {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(18px, 2.6vw, 24px);
  font-weight: 500;
  color: var(--dk);
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rank-name .rank-monos       { display: flex; gap: 2px; }
.rank-name .rank-monos svg   { width: clamp(5px, 1.8vw, 16px); height: auto; color: #111; }
.rank-stats {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: clamp(18px, 2.2vw, 20px);
  color: #444;
  text-align: center;
  line-height: 1.2;
}
.rank-row.me .rank-stats { color: #222; }

/* ── QR BOX ──────────────────────────────────────────────── */
.qr-grid img { border-radius: 0 !important; }
.qr-grid {
  width:  clamp(60px, 12vw, 100px);
  height: clamp(60px, 12vw, 100px);
  background: repeating-conic-gradient(#000 0% 25%, #fff 0% 50%) 0 0 / 9px 9px;
  border-radius: clamp(8px, 1.8vw, 14px);
  border: clamp(6px, 1.2vw, 10px) solid var(--y);
  overflow: hidden;
}
.qr-box {
  background: var(--t);
  border-radius: clamp(12px, 2.5vw, 20px);
  padding: clamp(8px, 1.5vw, 14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 0.8vw, 8px);
}
.qr-box-label {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(9px, 1.6vw, 14px);
  font-weight: 700;
  color: var(--w);
}

/* ── INSTRUCCIONES MODAL ─────────────────────────────────── */
@keyframes instrIn {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes instrOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(.95); }
}
.instr-overlay {
  position: fixed;
  inset: 0;
  background: var(--y);
  z-index: 100;
  display: none;
}
.instr-overlay.on {
  display: flex;
  flex-direction: column;
  animation: instrIn .3s ease-out both;
}
.instr-overlay.closing {
  animation: instrOut .2s ease-in both;
}
.instr-close {
  position: absolute;
  top: 3.5%;
  right: 5%;
  z-index: 30;
  cursor: pointer;
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: clamp(14px, 3vw, 24px);
  color: var(--dk);
  display: flex;
  align-items: center;
  gap: .25em;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transform: rotate(-4deg);
  transition: opacity .15s ease;
  letter-spacing: .04em;
}
.instr-close:active { opacity: .6; }
.instr-close .close-x {
  font-family: 'DM Sans', sans-serif;
  font-weight: 900;
  font-size: 1.6em;
  line-height: 1;
}
.instr-card-wrap { position: absolute; top: 8%; bottom: 4%; left: 5%; right: 5%; }
.instr-card-shadow {
  position: absolute;
  inset: 0;
  background: var(--p);
  border-radius: 28px;
}
.instr-card {
  position: absolute;
  inset: 0;
  background: var(--t);
  border-radius: 28px;
  border: 3px solid rgba(255,255,255,.35);
  padding: 7% 8%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.2vw, 22px);
  overflow-y: auto;
  transform: rotate(-1.5deg);
}
.instr-title {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-style: italic;
  font-size: clamp(48px, 11vw, 100px);
  color: var(--w);
  text-align: center;
  transform: rotate(-5deg);
}
.instr-title.objetivo {
  font-size: clamp(42px, 9.5vw, 88px);
  margin-top: 4%;
  transform: rotate(-5deg);
}
.instr-text {
  font-family: 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: clamp(18px, 3.2vw, 28px);
  color: rgba(255,255,255,.85);
  text-align: center;
  line-height: 1.5;
}
.instr-text b {
  font-weight: 800;
  color: var(--y);
}

/* ── SHARED SCREEN LAYOUTS ──────────────────────────────── */
#s3 { padding: 4% 6%; }
#s4 { padding: 4% 5% 4%; display: flex; flex-direction: column; align-items: center; }
#s5 { padding: 4% 5%; }
#s6 { padding: 4% 5%; }
#s7 { padding: 4% 5%; }
#s8 { padding: 4% 5%; justify-content: space-between; background: var(--t); }

/* topbar: flex row with space-between */
.sc-topbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sc-topbar-start { align-items: flex-start; }

/* body: centered flex column filling remaining space */
.sc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.sc-body--s3  { gap: clamp(18px, 4vw, 40px); }
.sc-body--s5  { gap: clamp(20px, 5vw, 50px); }
.sc-body--s6  { gap: clamp(12px, 3vw, 28px); }
.sc-body--s7  { gap: clamp(14px, 3.5vw, 32px); }

/* header: centered text column */
.sc-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1vw, 10px);
}

/* badge row between song and team badges */
.sc-badges {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8%;
  gap: 3%;
}
#b5teamName, #b6teamName, #b7teamName{
  font-weight: 800;
  font-size:45px;
}
#teamN8{
  font-size: 60px;
  font-weight: 500;
}

/* small top-margin for logo svg */
.ml-title-mt { margin-top: 1%; }

/* wave height modifier */
.wave-wrap--play { height: clamp(200px, 24vw, 220px); }

/* canvas fills parent height */
.wave-wrap canvas { height: 100%; }

/* ── S3: NOMBRE ─────────────────────────────────────────── */
#comenzarWrap {
  width: min(58%, 260px);
  cursor: pointer;
  position: relative;
  margin-top: clamp(20px, 3vw, 30px);
}

/* ── S4: TECLADO ────────────────────────────────────────── */
.kb-top {
  width: 100%;
  display: flex;
  flex-direction: column;
}
.kb-header {
  text-align: center;
  margin-top: 2%;
  margin-bottom: clamp(40px, 8vw, 80px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1vw, 10px);
}
.ml-sm--mt { margin-top: 2%; }
#nameBox4 { margin-top: 2%; }
.k-spacer { flex: .5; }
.krow-last { margin-bottom: 0; }
.k-sm { font-size: clamp(8px, 1.6vw, 13px); }

/* ── S6: PLAYING ────────────────────────────────────────── */
#ansCont {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.2vw, 20px);
}

/* ── S7: FEEDBACK ───────────────────────────────────────── */
#s7 .vamos {
  animation: fbMsgIn .5s ease-out both;
}
@keyframes fbMsgIn {
  from { opacity: 0; transform: rotate(-3deg) scale(.7); }
  to   { opacity: 1; transform: rotate(-3deg) scale(1); }
}
#ansResult {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.2vw, 20px);
}
#ansResult .ans-wrap {
  animation: ansIn .35s ease-out both;
}
#ansResult .ans-wrap:nth-child(1) { animation-delay: .15s; }
#ansResult .ans-wrap:nth-child(2) { animation-delay: .25s; }
#ansResult .ans-wrap:nth-child(3) { animation-delay: .35s; }
#ansResult .ans-wrap:nth-child(4) { animation-delay: .45s; }

/* ── S8: RESULTADOS ─────────────────────────────────────── */
.res-badges {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 4%;
  margin-top: 1.5%;
}
.badge-wrap--full { flex: 1; }
.badge-lg {
  width: 100%;
  font-size: clamp(18px, 4.2vw, 40px);
  padding: clamp(12px, 2.5vw, 22px) 5%;
}
.mono-ic-inline { display: inline-flex; gap: 2px; }
.res-stats {
  display: flex;
  align-items: baseline;
  gap: clamp(6px, 1.5vw, 14px);
  flex-wrap: wrap;
  margin-top: 3%;
}
.res-label {
  font-size: clamp(14px, 3vw, 28px);
  color: var(--w);
  font-weight: 700;
}
.res-value + .res-label {
  margin-left: clamp(16px, 5vw, 40px);
}
.res-value {
  font-size: clamp(28px, 6.5vw, 60px);
  color: var(--w);
  font-weight: 700;
  font-style: italic;
}
.res-ranking-title {
  padding-top: 10px;
  font-size: clamp(26px, 6vw, 58px);
  color: var(--w);
  font-weight: 700;
  font-style: italic;
  text-align: center;
  margin-top: 0;
}
.res-ranking-list {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 1.3vw, 12px);
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px;
}
@keyframes rankFadeIn {
  from { opacity: 0; transform: translateY(16px) rotate(-1.2deg); }
  to   { opacity: 1; transform: translateY(0)   rotate(-1.2deg); }
}
.rank-row {
  opacity: 0;
  animation: rankFadeIn .4s ease forwards;
}

/* Custom scrollbar for ranking list — pink circle thumb */
.res-ranking-list::-webkit-scrollbar {
  display: block;
  width: 16px;
}
.res-ranking-list::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.3);
  border-radius: 100px;
  margin: 8px 0;
  background-clip: content-box;
  border: 6px solid transparent;
}
.res-ranking-list::-webkit-scrollbar-thumb {
  background: var(--p);
  border-radius: 50%;
  background-clip: content-box;
  border: 2px solid transparent;
}

/* Firefox scrollbar for ranking list */
.res-ranking-list {
  scrollbar-width: thin;
  scrollbar-color: var(--p) rgba(255,255,255,0.3);
}
.rank-pos-me { font-style: italic; }
.res-replay {
  width: min(55%, 240px);
  cursor: pointer;
  margin: 0 auto;
  position: relative;
}
#restartWrap {
  width: min(75%, 420px);
  cursor: pointer;
  position: relative;
  margin: clamp(20px, 4vw, 40px) auto 0;
}
.isdin-logo--light { color: var(--w); margin-bottom: 1%; }
.isdin-logo .l1-sm { font-size: clamp(22px, 5vw, 48px); }
.isdin-logo .l2-sm { font-size: clamp(8px, 1.8vw, 16px); }
.isdin-logo .l3-sm { font-size: clamp(24px, 5.5vw, 52px); }

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { display: none; }

/* ============================================================
   KIOSK / TABLET OVERRIDES — 1080x1920 (9:16 portrait)
   Targets screens >= 900px wide to scale up elements that
   were capped at mobile maximums. Does NOT break mobile.
   ============================================================ */
@media (min-width: 900px) {

  /* ── S0: STANDBY ─────────────────────────────────────── */
  #dvd           { width: min(72%, 680px); }
  #tocameBtn     { width: min(52%, 480px); bottom: 10%; }
  #isdin0 .l1    { font-size: 62px; }
  #isdin0 .l2    { font-size: 22px; }
  #isdin0 .l3    { font-size: 68px; }

  /* ── ISDIN / ACNIBEN LOGO ────────────────────────────── */
  .isdin-logo .l1         { font-size: 62px; }
  .isdin-logo .l2         { font-size: 22px; }
  .isdin-logo .l3         { font-size: 68px; }
  .isdin-logo-ranking .l1 { font-size: 52px; }
  .isdin-logo-ranking .l2 { font-size: 18px; }
  .isdin-logo-ranking .l3 { font-size: 58px; }
  .isdin-logo .l1-sm      { font-size: 52px; }
  .isdin-logo .l2-sm      { font-size: 18px; }
  .isdin-logo .l3-sm      { font-size: 58px; }

  /* ── MUSIC LAB SVG SIZES ─────────────────────────────── */
  .ml-title-small { height: 110px; }
  .ml-title-big   { width: min(80%, 640px); }
  .ml-title-xl    { height: 220px; }

  /* ── TEXT STYLES ──────────────────────────────────────── */
  .ml-sm            { font-size: 42px; }
  .ml-sm-grettings  { font-size: 60px; }
  .qtext            { font-size: 58px; }
  .vamos            { font-size: 90px; }

  /* ── NAV ELEMENTS ────────────────────────────────────── */
  .help-btn-svg { width: 120px; height: 120px; }
  .back-link    { font-size: 38px; }
  .back-arrow   { width: 36px; }
  .cj-label     { font-size: 35px; }

  /* ── BTN LABEL OVERLAY ───────────────────────────────── */
  .btn-label { font-size: 48px; }

  /* ── BTN GREY / DISABLED ─────────────────────────────── */
  .pill-grey {
    height: 100px;
    font-size: 48px;
    box-shadow: 0 10px 0 #bbb;
  }

  /* ── S1: PLAYER SELECT ───────────────────────────────── */
  #s1               { padding: 0 5%; }
  .s1-content       { gap: 42px; }
  .s1-header        { gap: 14px; }
  .s1-siguiente     { width: min(56%, 380px); margin-top: 40px; }
  .s1-pcards        { gap: 4%; }

  .pcard            { border-radius: 28px; padding: 5% 3% 5%; }
  .pcard-label      { font-size: 22px; }
  .pcard .mono      { max-width: 60px; }
  .pcard .monos     { gap: 6px; }

  /* ── BADGES ──────────────────────────────────────────── */
  .badge {
    font-size: 40px;
    padding: 16px 36px;
    border-radius: 28px;
    gap: 12px;
  }
  .badge-wrap::after {
    top: 10px; left: 10px;
    right: -10px; bottom: 5px;
    border-radius: 28px;
    transform: rotate(2deg);
  }
  .badge-lg {
    font-size: 44px;
    padding: 24px 5%;
  }

  /* ── NAME BOX ────────────────────────────────────────── */
  .namebox {
    font-size: 64px;
    padding: 34px 5%;
    min-height: 130px;
    border-radius: 22px;
  }

  .err-msg { font-size: 38px; line-height: 1.3; }

  /* ── S3: NOMBRE ──────────────────────────────────────── */
  #s3 { padding: 3% 5%; }
  .sc-body--s3 { gap: 52px; justify-content: center; }
  .sc-body--s3 .sc-header { gap: 18px; width: 100%; }
  .sc-body--s3 .ml-sm-grettings { font-size: 60px; }
  .sc-body--s3 .ml-title-big { width: 640px; max-width: 90%; }
  .sc-body--s3 .ml-sm { font-size: 44px; }
  #comenzarWrap { width: min(52%, 420px); margin-top: 48px; }
  #comenzarWrap .btn-label { font-size: 52px; }

  /* ── ANSWER OPTIONS ──────────────────────────────────── */
  .ans {
    padding: 22px 2%;
    border-radius: 32px;
    gap: 4%;
  }
  .ans-wrap::after {
    top: 9px; 
    left: 9px;
    right: -9px; 
    bottom: 9px;
    border-radius: 32px;
    transform: rotate(2deg);
  }
  .ans-letter {
    font-size: 65px;
    border-radius: 12px;
  }
  .ans-txt { font-size: 40px; }
  #ansCont { gap: 42px; padding-top: 30px;}
  #ansResult { gap: 42px; }

  /* ── COUNTDOWN / PLAY CIRCLE ─────────────────────────── */
  .cd-circle, .play-circle { width: 170px; height: 170px; }
  .cd-num    { font-size: 82px; }

  /* ── WAVEFORM ────────────────────────────────────────── */
  .wave-wrap--play { height: 260px; }

  /* ── OTRA OPORTUNIDAD ────────────────────────────────── */
  .otra-text { font-size: 68px; }
  .otra-pill { font-size: 30px; padding: 40px 28px; border-radius: 20px; }
  .otra-pill-wrap::after {
    top: 7px; 
    left: 7px;
    right: -7px; 
    bottom: 7x;
    border-radius: 18px;
    transform: rotate(5deg);
  }

  /* ── SCREEN BODY GAPS ────────────────────────────────── */
  .sc-body--s5 { gap: 56px; }
  .sc-body--s6 { gap: 32px; }
  .sc-body--s7 { gap: 36px; }
  .sc-header   { gap: 14px; }
  .sc-badges   { margin-top: 6%; }

  /* ── KEYBOARD OVERLAY ────────────────────────────────── */
  #s4 { padding: 3% 4% 3%; }
  .kb-top { gap: 0; }
  .kb-header { margin-top: 1%; margin-bottom: 40px; gap: 14px; }
  .kb-header .ml-title-big { width: min(70%, 560px); }
  .kb-header .ml-sm { font-size: 38px; }
  .kb-header .ml-sm--mt { margin-top: 3%; }
  #nameBox4 {
    font-size: 58px;
    padding: 28px 5%;
    min-height: 120px;
    border-radius: 20px;
    margin-top: 3%;
  }
  .kb-outer  { border-radius: 28px; padding: 2.5% 2.5% 2.5%; }
  .kb-close-row { margin-bottom: 2%; }
  .cerrar-svg { height: 44px; }

  .k {
    font-size: 24px;
    height: 65px;
    border-radius: 12px;
  }
  .k-sm { font-size: 17px; }
  .krow { gap: 1.4%; margin-bottom: 1.4%; }
  .krow-last { margin-bottom: 0; }

  /* ── INSTRUCCIONES MODAL ─────────────────────────────── */
  .instr-close    { font-size: 28px; }
  .instr-card     { gap: 26px; padding: 6% 7%; border-radius: 36px; }
  .instr-card-shadow { border-radius: 36px; }
  .instr-title    { font-size: 110px; }
  .instr-title.objetivo { font-size: 96px; }
  .instr-text     { font-size: 32px; }

  /* ── RANKING ─────────────────────────────────────────── */
  .rank-row {
    padding: 18px 5%;
    border-radius: 28px;
  }
  .rank-pos  { font-size: 70px; }
  .rank-name { font-size: 50px; gap: 25px; }
  .rank-name .rank-monos svg { width: 18px; }
  .rank-stats { font-size: 35px; }
  .res-ranking-list { gap: 14px; padding-top: 20px;}
  .res-ranking-title { font-size: 75px; padding-top: 18px; }

  /* ── RESULTS STATS ───────────────────────────────────── */
  .res-label { font-size: 45px; }
  .res-value { font-size: 86px; }
  .res-stats { gap: 16px; margin-top: 2%; }
  .res-replay { width: min(48%, 340px); }
  .res-badges { gap: 4%; margin-top: 1%; }

  /* ── QR BOX ──────────────────────────────────────────── */
  .qr-grid {
    width: 160px; height: 160px;
    background-size: 12px 12px;
    border-radius: 16px;
    border-width: 15px;
  }
  .qr-box { border-radius: 22px; padding: 16px; gap: 8px; }
  .qr-box-label { font-size: 25px; }

  /* ── MONO ICON (inline in badges) ────────────────────── */
  .team-mono-ic { width: 15px; }
}
