/* Bingo musical · Correr X Correr — estilos (sin dependencias ni fuentes externas)
 * Pensado para móviles de 360 px en adelante y para jugadores de 18 a 70 años:
 * letra generosa, contraste AA, objetivos táctiles de 48 px o más y estados que no dependen solo del color. */
:root {
  --blue: #1d4f7c;
  --blue-2: #2f6ea3;
  --sky: #7fb6dd;
  --sky-light: #d4e8f7; /* texto claro sobre el azul (contraste AA) */
  --gold: #7fb032; /* verde del logo del club */
  --gold-ink: #4a7417; /* verde oscuro para texto sobre fondo claro */
  --gold-dark: #5a8020;
  --x-red: #e8321e;
  --red-ink: #c22712; /* rojo para texto sobre fondo claro */
  --cream: #f7f5ee;
  --ink: #17324d;
  --muted: #4f6275;
  --line: #c9d6e2;
  --yellow: #ffd23f;
  --radius: 14px;
  --tap: 48px; /* objetivo táctil mínimo */
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  font-size: 106.25%; /* 17 px de base */
  line-height: 1.4;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: radial-gradient(circle at 20% 0%, var(--blue-2), var(--blue) 60%) fixed;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 720px; margin: 0 auto; padding: 12px; }
.screen {
  background: var(--cream);
  border-radius: 28px;
  padding: 16px 14px 24px;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.25);
}

h2, h3 { margin: 18px 4px 8px; color: var(--blue); line-height: 1.2; }
h3 small { font-weight: 500; color: var(--muted); font-size: 0.8em; }
.hint { color: var(--muted); font-size: 0.95rem; margin: 6px 4px; }
.center { text-align: center; }
.error { color: var(--red-ink); font-weight: 700; margin: 4px; }
.error::before { content: "⚠️ "; }
code { background: #e8eef4; padding: 1px 5px; border-radius: 5px; }

/* ---------- Portada ---------- */
.logo { text-align: center; padding: 6px 0 4px; }
.club-logo { display: block; margin: 0 auto 6px; width: 140px; height: 140px; filter: drop-shadow(0 6px 14px rgb(0 0 0 / 0.25)); }
.logo h1 {
  margin: 0;
  font-size: clamp(3.2rem, 17vw, 5.2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--blue);
  transform: rotate(-3deg);
  line-height: 1;
}
.logo .sub { margin: -2px 0 0; font-size: 1.9rem; color: var(--gold-ink); font-weight: 800; transform: rotate(-3deg); }
.club { margin: 8px 0 0; color: var(--ink); font-size: 1rem; }
.x { color: var(--x-red); font-style: normal; font-weight: 900; }

.card-box {
  background: #fff;
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-box h2 { margin: 0; }
.card-box.flat { border-width: 0; padding: 4px 14px; gap: 8px; }
summary {
  font-weight: 800;
  color: var(--blue);
  cursor: pointer;
  font-size: 1.05rem;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "▾"; margin-left: auto; font-size: 1.1rem; transition: transform 0.2s; }
details[open] > summary::after { transform: rotate(180deg); }
summary small { color: var(--muted); font-weight: 500; }
details[open] > summary { margin-bottom: 4px; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 1rem; }
input, textarea, select {
  font: inherit;
  font-size: 1.1rem; /* ≥16 px: iPhone no hace zoom al enfocar */
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue-2); box-shadow: 0 0 0 3px rgb(47 110 163 / 0.25); }
input::placeholder { color: #7a8a99; }
label > small.hint { margin: -4px 0 0; font-weight: 500; }
#joinCode { text-transform: uppercase; letter-spacing: 0.4em; font-size: 1.8rem; font-weight: 900; text-align: center; padding-left: calc(14px + 0.4em); }
textarea { font-size: 1rem; font-family: ui-monospace, monospace; }

.resume { background: #eaf4ff; text-align: center; }
.resume p { margin: 0; font-size: 1.05rem; }
.howto ol { margin: 0; padding-left: 22px; line-height: 1.55; font-size: 1rem; }
.howto li + li { margin-top: 6px; }

/* ---------- Botones ---------- */
.btn {
  font: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1.2;
  border: 0;
  border-radius: 999px;
  min-height: var(--tap);
  padding: 12px 20px;
  cursor: pointer;
  background: #e3ebf3;
  color: var(--blue);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  touch-action: manipulation;
  transition: transform 0.08s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 4px 0 #123757; }
.btn.secondary { background: var(--gold); color: #10230a; box-shadow: 0 4px 0 var(--gold-dark); }
.btn.big { font-size: 1.25rem; min-height: 60px; padding: 16px 22px; }
.btn.small { font-size: 1rem; padding: 10px 16px; }
.btn.link { background: none; color: var(--muted); font-weight: 700; width: 100%; margin-top: 12px; text-decoration: underline; text-underline-offset: 3px; }
.btn.link.inline { width: auto; margin: 0; padding: 0 8px; font-size: 1rem; }
.btn.spotify { background: #1db954; color: #04230f; margin-top: 8px; }
.btn.danger { background: #fff; color: var(--red-ink); border: 2px solid var(--red-ink); margin-top: 10px; }
.btn.round { width: 60px; height: 60px; padding: 0; font-size: 1.5rem; flex: none; }
.btn.round.active { background: var(--gold); color: #10230a; box-shadow: 0 4px 0 var(--gold-dark); }
.row { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.row.tight { margin-top: 0; flex-wrap: nowrap; }
.row.tight label { min-width: 0; }
.row.tight input { width: 100%; }
.grow { flex: 1; }
.switch { flex-direction: row; align-items: center; gap: 12px; font-size: 1rem; min-height: var(--tap); cursor: pointer; }
.switch input { width: 26px; height: 26px; min-height: 0; flex: none; accent-color: var(--blue); margin: 0; }

/* ---------- Barra superior ---------- */
.topbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mini-logo { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.pill { background: #e3ebf3; color: var(--blue); border-radius: 999px; padding: 8px 12px; font-size: 0.95rem; line-height: 1.2; }
a.pill { text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; font-weight: 700; }
.btn-pill { border: 0; font: inherit; font-weight: 800; cursor: pointer; min-height: var(--tap); min-width: var(--tap); }
.pill.warn { background: var(--x-red); color: #fff; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar .ellipsis { max-width: 40vw; }
.topbar b.grow { color: var(--blue); font-size: 1.15rem; }
/* Conexión: punto verde, o aviso con texto cuando se pierde (no solo color) */
.conn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 6px 10px;
  background: #fff3f0;
  color: var(--red-ink);
}
.conn::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--x-red); flex: none; }
.conn::after { content: "Conectando…"; }
.conn.ok { background: none; padding: 6px; }
.conn.ok::before { background: #2dbb5d; width: 12px; height: 12px; }
.conn.ok::after { content: none; }

/* ---------- Canción que suena ---------- */
.now {
  margin-top: 12px;
  background: var(--blue);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}
.now small { color: var(--sky-light); font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; }
.now b { font-size: 1.4rem; line-height: 1.2; }
.now span { color: #e6f0f8; font-size: 1.05rem; }
.now .fast { margin-top: 8px; font-size: 1rem; font-weight: 800; color: #c9ef8f; }
.now .fast.open { color: var(--sky-light); font-weight: 700; }
.now.pulse { animation: pulse 0.9s ease-out; }
@keyframes pulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgb(127 176 50 / 0.8); } 30% { transform: scale(1.03); } 100% { transform: scale(1); box-shadow: 0 0 0 18px rgb(127 176 50 / 0); } }
.cover { width: 96px; height: 96px; border-radius: 10px; object-fit: cover; margin-bottom: 8px; box-shadow: 0 4px 14px rgb(0 0 0 / 0.3); }
.link-light { color: var(--sky-light); font-size: 0.95rem; margin-top: 8px; min-height: 32px; display: inline-flex; align-items: center; }
.status { margin: 10px 4px 0; font-size: 1.05rem; text-align: center; }

/* ---------- Jugador: marcador ---------- */
.scorebar { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.scorebar .status { margin: 0; flex: 1; text-align: left; }
.score {
  flex: none;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  background: #fff;
  border: 2px solid var(--blue);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  color: var(--blue);
  font-weight: 900;
  position: relative;
}
.score-ico { font-size: 1.1rem; }
.score-num { font-size: 1.6rem; line-height: 1; min-width: 1ch; text-align: center; font-variant-numeric: tabular-nums; }
.score small { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.score.neg .score-num { color: var(--red-ink); }
.score.up { animation: score-up 0.7s cubic-bezier(.2, 1.6, .4, 1); }
.score.up { background: #fff6cc; border-color: var(--gold); }
.score.down { animation: score-down 0.5s; border-color: var(--red-ink); }
@keyframes score-up { 0% { transform: scale(1); } 35% { transform: scale(1.35) rotate(-4deg); box-shadow: 0 0 0 10px rgb(255 210 63 / 0.5); } 100% { transform: scale(1); box-shadow: 0 0 0 18px rgb(255 210 63 / 0); } }
@keyframes score-down { 25%, 75% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }

/* Chip «+1» que vuela de la celda al marcador */
.fly {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 13;
  pointer-events: none;
  font-weight: 900;
  font-size: 1.6rem;
  color: #3a2a00;
  background: var(--yellow);
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 2px 12px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.3);
  white-space: nowrap;
}
.fly.neg { background: #fff; color: var(--red-ink); border-color: var(--red-ink); font-size: 1.3rem; }

/* ---------- Cartón ---------- */
.board-wrap {
  margin-top: 12px;
  background: #fff;
  border: 3px solid var(--blue);
  border-radius: 20px;
  padding: 8px 6px 8px;
}
.board-head { display: flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 6px 6px; text-align: center; }
.board-tip { margin: 0; color: var(--muted); font-weight: 700; font-size: 0.95rem; }
.nudge { margin: 0; font-weight: 900; color: var(--red-ink); font-size: 1.05rem; animation: nudge 0.5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes nudge { from { transform: scale(0.6); opacity: 0; } }
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 4px;
  row-gap: 8px; /* las filas se separan más: una fila = una línea */
}
.cell {
  font: inherit;
  position: relative;
  isolation: isolate;
  min-height: 92px;
  padding: 8px 3px 6px;
  border: 2px solid #8fa6bc;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  -webkit-hyphens: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.cell:active { transform: scale(0.95); }
.cell .t, .cell .a { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; position: relative; z-index: 1; }
.cell .t { font-weight: 800; font-size: clamp(0.8rem, 3.5vw, 1.05rem); line-height: 1.12; letter-spacing: -0.01em; -webkit-line-clamp: 4; line-clamp: 4; }
.cell .a { font-size: clamp(0.72rem, 2.9vw, 0.88rem); color: var(--muted); line-height: 1.1; -webkit-line-clamp: 2; line-clamp: 2; }
.cell.long .t { font-size: clamp(0.74rem, 3.15vw, 0.98rem); }
.cell.xlong .t { font-size: clamp(0.7rem, 2.95vw, 0.92rem); -webkit-line-clamp: 5; line-clamp: 5; }
.big-text .cell { min-height: 110px; }
.big-text .cell .t { font-size: clamp(0.92rem, 4.1vw, 1.25rem); -webkit-line-clamp: 5; line-clamp: 5; }
.big-text .cell.long .t, .big-text .cell.xlong .t { font-size: clamp(0.85rem, 3.7vw, 1.15rem); -webkit-line-clamp: 6; line-clamp: 6; }
.big-text .cell .a { font-size: clamp(0.8rem, 3.3vw, 1rem); }

/* Tachada: borrón de rotulador de bingo detrás del texto + insignia ✓ (no depende solo del color) */
.cell::before {
  content: "";
  position: absolute;
  inset: 6% 4%;
  z-index: 0;
  border-radius: 48% 52% 44% 56% / 56% 44% 56% 44%;
  background: radial-gradient(circle at 42% 40%, rgb(127 176 50 / 0.5), rgb(127 176 50 / 0.34) 58%, rgb(127 176 50 / 0.12) 72%, transparent 74%);
  transform: scale(0) rotate(-20deg);
  opacity: 0;
  pointer-events: none;
}
.cell::after {
  content: "✓";
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold-ink);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 20px;
  text-align: center;
  transform: scale(0);
  pointer-events: none;
}
.cell.marked { background: #f1f8e6; border-color: var(--gold-ink); border-width: 3px; }
.cell.marked::before { transform: scale(1) rotate(-8deg); opacity: 1; animation: dab 0.38s cubic-bezier(.3, 1.5, .5, 1); }
.cell.marked::after { transform: scale(1); animation: tick 0.4s 0.12s cubic-bezier(.3, 1.8, .5, 1) backwards; }
.cell.marked .t { color: #10263b; }
@keyframes dab {
  0% { transform: scale(1.9) rotate(-30deg); opacity: 0; }
  55% { transform: scale(0.88) rotate(-6deg); opacity: 1; }
  100% { transform: scale(1) rotate(-8deg); opacity: 1; }
}
@keyframes tick { from { transform: scale(0); } }
.cell.press { animation: press 0.28s ease-out; }
@keyframes press { 0% { transform: scale(0.9); } 60% { transform: scale(1.05); } 100% { transform: scale(1); } }
.board.instant .cell::before, .board.instant .cell::after, .board.instant .cell { animation: none !important; }

/* Celda con punto de rapidez: insignia ⚡ dorada */
.cell.star { border-color: #c99a00; background: #fff8d9; }
.cell.star::after { content: "⚡"; background: var(--yellow); color: #3a2a00; width: 24px; height: 24px; line-height: 24px; font-size: 0.85rem; }
.cell.star::before { background: radial-gradient(circle at 42% 40%, rgb(255 210 63 / 0.7), rgb(255 210 63 / 0.45) 58%, rgb(255 210 63 / 0.15) 72%, transparent 74%); }
.cell.hit { animation: hit 0.75s cubic-bezier(.2, 1.6, .4, 1); z-index: 3; }
@keyframes hit {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgb(255 210 63 / 0.9); }
  25% { transform: scale(1.22) rotate(-3deg); background: #fff1a8; }
  60% { transform: scale(0.97); box-shadow: 0 0 0 16px rgb(255 210 63 / 0); }
  100% { transform: scale(1); }
}

/* Fallo: tiembla y se marca en rojo un momento, con ✕ */
.cell.wrong { animation: shake 0.5s; background: #ffece8; border-color: var(--red-ink); border-width: 3px; }
.cell.wrong::after { content: "✕"; background: var(--red-ink); transform: scale(1); animation: tick 0.3s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* Suena ahora (solo si el presentador muestra los títulos) */
.cell .live {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: var(--blue);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  font-style: normal;
  letter-spacing: 0.04em;
  line-height: 1.5;
  text-transform: uppercase;
}
.cell.live { border-color: var(--blue); border-width: 3px; padding-top: 18px; animation: live 1.4s ease-in-out 6; }
.cell.live .live { display: block; }
@keyframes live { 50% { box-shadow: 0 0 0 4px rgb(47 110 163 / 0.35); } }

/* Línea ganada: la fila brilla en dorado */
.cell.line { border-color: #c99a00; background: #fff4c2; box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--yellow); }
.cell.line.glow { animation: linewin 1.1s var(--d, 0s) cubic-bezier(.2, 1.4, .4, 1) 2; }
@keyframes linewin {
  0% { transform: scale(1); }
  30% { transform: scale(1.12) translateY(-4px); background: #ffe680; box-shadow: 0 0 0 5px var(--yellow), 0 0 24px 6px rgb(255 210 63 / 0.8); }
  100% { transform: scale(1); }
}
/* Bingo: todo el cartón en oro, con un barrido de brillo */
.board-wrap.won { border-color: #c99a00; box-shadow: 0 0 0 4px var(--yellow), 0 0 30px rgb(255 210 63 / 0.6); }
.board.won .cell { border-color: #c99a00; }
.board-wrap.won .board-tip { color: var(--gold-ink); }
.board.won.glow .cell { animation: linewin 1.1s var(--d, 0s) cubic-bezier(.2, 1.4, .4, 1) 2; }

/* ---------- Listas ---------- */
.players, .songlist, .history { list-style: none; margin: 0; padding: 0; }
.players li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 6px;
  font-weight: 700;
  border: 1px solid #e3ebf3;
}
.players li.off { opacity: 0.6; }
.players li.off .pl-top > span:first-child::after { content: " · desconectado"; font-weight: 500; font-size: 0.85rem; color: var(--muted); }
.players li.empty { color: var(--muted); font-weight: 500; }
.pl-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badges { display: flex; align-items: center; gap: 6px; flex: none; }
.badges small { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.badge { font-size: 0.75rem; padding: 3px 8px; border-radius: 999px; color: #fff; font-weight: 900; }
.badge.l { background: var(--blue-2); }
.badge.b { background: var(--yellow); color: #3a2a00; }
.pts { font-weight: 900; color: var(--blue); font-size: 0.95rem; }
.pts.neg { color: var(--red-ink); }
.bar { height: 8px; background: #e3ebf3; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width 0.4s; }

.songlist { max-height: 360px; overflow-y: auto; border-radius: 10px; }
.songlist button {
  font: inherit;
  width: 100%;
  min-height: 52px;
  text-align: left;
  border: 0;
  background: #fff;
  border-bottom: 1px solid #e3ebf3;
  padding: 10px 12px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.songlist button small { color: var(--muted); }
.songlist button i { margin-left: auto; color: var(--blue); font-style: normal; font-weight: 900; font-size: 1.2rem; }
.history li { padding: 8px 10px; font-size: 1rem; border-bottom: 1px solid #edf1f5; }
.history a { color: var(--blue); font-weight: 700; }
.history small { color: var(--muted); }

/* ---------- Crear sala ---------- */
.step { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 1.15rem; }
.step span { background: var(--blue); color: #fff; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 1rem; flex: none; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 30%; flex-direction: row; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 52px;
  padding: 8px 6px;
  border-radius: 12px;
  border: 2px solid var(--line);
  font-size: 1rem;
  cursor: pointer;
}
.seg input:checked + span { border-color: var(--blue); background: var(--blue); color: #fff; }
.seg input:checked + span::before { content: "✓ "; white-space: pre; }
.seg input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 2px; }
#songCount.bad { color: var(--red-ink); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips small { font-weight: 500; color: var(--muted); margin-left: 4px; }
.sp-user { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-height: var(--tap); }

/* ---------- Presentador ---------- */
.big-code { font-size: 3.4rem; font-weight: 900; letter-spacing: 0.25em; color: var(--blue); margin: 2px 0 6px; padding-left: 0.25em; }
.admin-now b { font-size: 1.6rem; }
.invite { text-align: center; align-items: center; }
.invite .big-code { margin: 0; }
.qr { width: min(220px, 60vw); aspect-ratio: 1; background: #fff; border-radius: 12px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.controls { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.progress { height: 8px; background: #d6e2ee; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 1s linear; }
.alert { margin-top: 10px; background: #fff3f0; border: 2px solid var(--x-red); border-radius: var(--radius); padding: 12px; }
.alert p { margin: 0 0 6px; font-weight: 700; }
.alert .row { margin-top: 4px; }
#songFilter { width: 100%; }

.modal { position: fixed; inset: 0; background: rgb(15 40 65 / 0.75); display: grid; place-items: center; z-index: 9; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.modal-inner { background: var(--cream); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(360px, 100%); }
.modal-inner .qr { width: min(260px, 70vw); }

/* ---------- Opciones del jugador ---------- */
.prefs { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 14px 4px 0; }

/* ---------- Aviso (toast) ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  background: var(--ink);
  color: #fff;
  padding: 14px 20px;
  border-radius: 18px;
  z-index: 14;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.3);
  animation: toast-in 0.25s ease-out;
}
.toast.bad { background: #fff; color: var(--red-ink); border: 3px solid var(--red-ink); }
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } }

/* ---------- Premio ---------- */
.prize {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 45%, rgb(47 110 163 / 0.92), rgb(12 32 54 / 0.95) 70%);
  animation: fade 0.25s;
}
.prize.mine { background: radial-gradient(circle at 50% 45%, rgb(255 222 110 / 0.95), rgb(127 176 50 / 0.95) 45%, rgb(29 79 124 / 0.97) 85%); }
/* Rayos de sol girando detrás */
.prize-rays {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 180vmax;
  height: 180vmax;
  margin: -90vmax 0 0 -90vmax;
  background: repeating-conic-gradient(rgb(255 255 255 / 0.13) 0 10deg, transparent 10deg 20deg);
  border-radius: 50%;
  mask-image: radial-gradient(circle, #000 15%, transparent 60%);
  -webkit-mask-image: radial-gradient(circle, #000 15%, transparent 60%);
  animation: spin 24s linear infinite;
  pointer-events: none;
}
.prize.big .prize-rays { animation-duration: 12s; background: repeating-conic-gradient(rgb(255 236 150 / 0.2) 0 8deg, transparent 8deg 16deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.prize-inner {
  position: relative;
  background: var(--cream);
  border: 5px solid var(--blue);
  border-radius: 28px;
  padding: 22px 22px 18px;
  text-align: center;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.45);
  animation: bounce 0.7s cubic-bezier(.2, 1.6, .4, 1);
}
.prize.mine .prize-inner { border-color: #fff; background: linear-gradient(160deg, #fffbe6, #fff3c4); box-shadow: 0 0 0 6px var(--yellow), 0 20px 60px rgb(0 0 0 / 0.45); }
.prize-emoji { font-size: 4.2rem; line-height: 1; animation: wobble 1.2s 0.3s ease-in-out 2; }
.prize.big.mine .prize-emoji { font-size: 5.4rem; }
.prize-kicker {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.prize.mine .prize-kicker { background: var(--blue); color: #fff; padding: 6px 16px; border-radius: 999px; font-size: 1.15rem; animation: bounce 0.6s 0.25s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.prize-title { margin: 0; font-size: clamp(2.8rem, 15vw, 4.4rem); font-weight: 900; color: var(--blue); line-height: 1; letter-spacing: 0.02em; display: flex; justify-content: center; }
.prize.big .prize-title { color: var(--x-red); font-size: clamp(3.2rem, 18vw, 5.4rem); text-shadow: 0 4px 0 #ffd23f; }
.prize-title span { display: inline-block; animation: letter 0.55s cubic-bezier(.2, 1.8, .4, 1) backwards; animation-delay: calc(0.15s + var(--i) * 0.06s); }
@keyframes letter { from { transform: translateY(-60%) scale(0.2); opacity: 0; } }
.prize-name { font-size: clamp(1.6rem, 8vw, 2.3rem); font-weight: 900; color: var(--gold-ink); line-height: 1.15; overflow-wrap: anywhere; }
.prize:not(.mine) .prize-name { font-size: clamp(2rem, 10vw, 2.8rem); }
.prize-next { margin: 4px 0 6px; font-size: 1.05rem; color: var(--ink); font-weight: 600; }
.prize .btn { width: 100%; margin-top: 6px; }
@keyframes fade { from { opacity: 0; } }
@keyframes bounce { from { transform: scale(0.3); opacity: 0; } }
@keyframes wobble { 25% { transform: rotate(-12deg) scale(1.1); } 75% { transform: rotate(12deg) scale(1.1); } }

/* Destello blanco al cantar premio */
.flash { position: fixed; inset: 0; z-index: 12; background: #fff; pointer-events: none; animation: flash 0.6s ease-out forwards; }
.flash.gold { background: radial-gradient(circle, #fff 0%, #ffe680 60%, #ffd23f 100%); }
@keyframes flash { 0% { opacity: 0.9; } 100% { opacity: 0; } }

/* Lienzo de confeti y chispas */
.fx { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 11; pointer-events: none; }

/* ---------- Modo remoto ---------- */
.sound-gate {
  display: block;
  width: 100%;
  margin: 12px 0 0;
  padding: 16px;
  min-height: 64px;
  border: 0;
  border-radius: 16px;
  background: var(--gold);
  color: #10230a;
  font: inherit;
  font-weight: 900;
  font-size: 1.2rem;
  cursor: pointer;
  animation: gate 1.6s ease-in-out 12;
}
.sound-gate small { display: block; font-weight: 600; font-size: 0.95rem; margin-top: 4px; }
@keyframes gate { 50% { transform: scale(1.02); box-shadow: 0 0 0 6px rgba(127, 176, 50, 0.35); } }

/* ---------- Pantallas pequeñas: más sitio para el cartón ---------- */
@media (max-width: 480px) {
  #app { padding: 6px; }
  .screen { padding: 12px 8px 20px; border-radius: 22px; }
  .board-wrap { padding: 6px 4px; border-width: 2px; border-radius: 16px; }
  .board { column-gap: 3px; }
  .cell { padding-left: 2px; padding-right: 2px; border-radius: 10px; }
  .topbar .ellipsis { max-width: 34vw; }
}
@media (max-width: 370px) {
  .pill { padding: 6px 9px; font-size: 0.9rem; }
  .score-num { font-size: 1.4rem; }
  .score small { display: none; }
}

/* ---------- Reducir movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .prize-rays { display: none; }
  .flash { display: none; }
}

/* ---------- modo oscuro (por defecto; cada jugador puede pasar a claro) ----------
 * Fondos casi negros (en pantallas OLED los píxeles oscuros apenas gastan), texto claro con contraste AA
 * y los mismos colores del club para los estados. La pantalla de premio se queda clara: es el momento
 * de fiesta y así destaca más. */
html[data-theme="dark"] {
  color-scheme: dark;
  --cream: #0f1b28; /* fondo de pantalla */
  --surface: #172636; /* tarjetas, celdas, listas */
  --surface-2: #213549; /* botones, píldoras, barras */
  --ink: #e6edf5;
  --muted: #a7b6c6;
  --line: #3a5068;
  --gold-ink: #a8d861;
  --red-ink: #ff7b67;
  --blue-text: #8fc6f0;
}
html[data-theme="dark"] body { background: #070e16; }
html[data-theme="dark"] .card-box,
html[data-theme="dark"] .board-wrap,
html[data-theme="dark"] .players li,
html[data-theme="dark"] .songlist button,
html[data-theme="dark"] .score,
html[data-theme="dark"] .fly.neg,
html[data-theme="dark"] .toast.bad { background: var(--surface); }
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select { background: #0b1520; color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] input::placeholder { color: #7f91a3; }
html[data-theme="dark"] .btn:not(.primary):not(.secondary):not(.spotify):not(.danger):not(.link):not(.round.active),
html[data-theme="dark"] .pill { background: var(--surface-2); color: #d6e8f7; }
html[data-theme="dark"] .pill.warn { background: var(--x-red); color: #fff; }
html[data-theme="dark"] .btn.primary { box-shadow: 0 4px 0 #061a2b; }
html[data-theme="dark"] .btn.danger { background: transparent; }
html[data-theme="dark"] .bar,
html[data-theme="dark"] .progress { background: var(--surface-2); }
html[data-theme="dark"] .players li { border-color: var(--line); }
html[data-theme="dark"] .songlist button { border-bottom-color: var(--line); }
html[data-theme="dark"] .history li { border-bottom-color: var(--line); }
html[data-theme="dark"] code { background: var(--surface-2); }
html[data-theme="dark"] .resume { background: #13304b; }
html[data-theme="dark"] .alert,
html[data-theme="dark"] .conn { background: #3a1b16; }
html[data-theme="dark"] .toast { background: #e6edf5; color: #0b1622; }
/* Textos que en claro usan el azul del club: un azul claro legible sobre fondo oscuro. */
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] summary,
html[data-theme="dark"] .logo h1,
html[data-theme="dark"] .topbar b.grow,
html[data-theme="dark"] .score,
html[data-theme="dark"] .pts,
html[data-theme="dark"] .big-code,
html[data-theme="dark"] .history a,
html[data-theme="dark"] .songlist button i { color: var(--blue-text); }
html[data-theme="dark"] .score,
html[data-theme="dark"] .board-wrap { border-color: #2f6ea3; }
html[data-theme="dark"] .seg input:checked + span { background: #2f6ea3; border-color: #2f6ea3; }
/* Cartón */
html[data-theme="dark"] .cell { background: var(--surface); border-color: #4d6884; color: var(--ink); }
html[data-theme="dark"] .cell.marked { background: #1f3317; border-color: var(--gold); }
html[data-theme="dark"] .cell.marked .t { color: #eef7e2; }
html[data-theme="dark"] .cell.star { background: #3a3110; border-color: #e0b400; }
html[data-theme="dark"] .cell.line { background: #3b3312; border-color: #e0b400; box-shadow: inset 0 0 0 2px #0f1b28, 0 0 0 2px var(--yellow); }
html[data-theme="dark"] .cell.wrong { background: #3a1b16; }
html[data-theme="dark"] .cell.live { border-color: var(--blue-text); }
html[data-theme="dark"] .score.up { background: #3a3110; }
/* La pantalla de premio (y el QR) se quedan en claro. */
html[data-theme="dark"] .prize-inner {
  color-scheme: light;
  --cream: #f7f5ee;
  --ink: #17324d;
  --muted: #4f6275;
  --gold-ink: #4a7417;
  --red-ink: #c22712;
  color: var(--ink);
}
html[data-theme="dark"] .prize-inner .btn.primary { background: var(--blue); color: #fff; }

/* Lista del presentador: en cuántos cartones (de jugadores conectados) está cada canción */
.oncards { margin-left: auto; flex: none; font-weight: 800; font-size: 0.85rem; color: var(--gold-ink); white-space: nowrap; }
.oncards.none { color: var(--muted); font-weight: 600; }
.oncards + i { margin-left: 8px !important; }
.songlist .list-sep { padding: 12px 10px 6px; font-weight: 800; font-size: 0.9rem; color: var(--muted); }
