/* Ronda: concurso de preguntas en directo.
   Concepto: fondo índigo profundo; las cuatro fichas de respuesta (triángulo, rombo, círculo, cuadrado)
   son lo único con color saturado y se tratan como botones físicos con relieve inferior. */
:root {
  --ink: #140e36;
  --ink2: #1d1650;
  --ink3: #2a2170;
  --line: #3d3396;
  --paper: #f7f4ff;
  --mute: #b4addf;
  --c0: #e5484d; --c0d: #a92e34;
  --c1: #3e63dd; --c1d: #2c46a0;
  --c2: #f2a900; --c2d: #b07c00;
  --c3: #2fa36b; --c3d: #1e7149;
  --good: #3ddc97;
  --bad: #ff6b72;
  --display: 'Bricolage Grotesque', 'Avenir Next', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1100px 560px at 85% -10%, #2c2080 0%, transparent 60%), var(--ink);
  background-attachment: fixed;
  color: var(--paper);
  font: 500 16px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .display { font-family: var(--display); font-weight: 800; letter-spacing: -0.01em; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--paper); outline-offset: 2px; }
svg { display: block; }
.ico svg { fill: currentColor; width: 100%; height: 100%; }
.eyebrow { font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); font-weight: 700; }
[hidden] { display: none !important; }

/* colour tokens per answer slot */
.c0 { --c: var(--c0); --cd: var(--c0d); --on: #fff; }
.c1 { --c: var(--c1); --cd: var(--c1d); --on: #fff; }
.c2 { --c: var(--c2); --cd: var(--c2d); --on: #1b1300; }
.c3 { --c: var(--c3); --cd: var(--c3d); --on: #fff; }

/* buttons */
.btn {
  border: 2px solid var(--line);
  background: transparent;
  border-radius: 12px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--ink3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--paper); color: var(--ink); border-color: var(--paper); box-shadow: 0 4px 0 #a79fd6; }
.btn.primary:hover { background: #fff; }
.btn.primary:active { box-shadow: 0 2px 0 #a79fd6; transform: translateY(2px); }
.btn.big { font-size: 1.25rem; padding: 0.8rem 1.6rem; border-radius: 14px; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 0.35rem 0.7rem; font-size: 0.9rem; border-radius: 10px; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

input[type='text'], input[type='url'], input:not([type]), input[type='search'], textarea, select {
  background: var(--ink2);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  width: 100%;
  min-width: 0;
}
input::placeholder, textarea::placeholder { color: #8a82c4; }
label { font-weight: 700; font-size: 0.9rem; color: var(--mute); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--paper); color: var(--ink); padding: 0.7rem 1.1rem; border-radius: 12px;
  font-weight: 700; z-index: 50; max-width: 90vw; box-shadow: 0 8px 30px #0008;
}

/* answer tiles (shared by host and phone) */
.opts { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.opts.n3 .opt:last-child { grid-column: 1 / -1; }
.opt {
  display: flex; align-items: center; gap: 0.9rem;
  background: var(--c, var(--ink3)); color: var(--on, #fff);
  border: 0; border-radius: 14px; padding: 1rem 1.1rem;
  box-shadow: 0 6px 0 var(--cd, var(--line));
  text-align: left; font-weight: 800; font-family: var(--display); font-size: 1.25rem; line-height: 1.15;
  min-width: 0; position: relative;
}
.opt .ico { flex: none; width: 2rem; height: 2rem; }
.opt .otxt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
button.opt:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--cd, var(--line)); }
.opt .ocount { flex: none; font-size: 1.6rem; background: #0003; border-radius: 10px; padding: 0.1rem 0.6rem; }
.opt.dim { opacity: 0.32; }
.opt.right { outline: 4px solid var(--paper); outline-offset: 3px; }
.opt .tick { flex: none; width: 1.8rem; height: 1.8rem; }
.timerbar { flex: 1; height: 12px; background: var(--ink3); border-radius: 99px; overflow: hidden; }
.timerbar i { display: block; height: 100%; width: 100%; background: var(--paper); transform-origin: left; border-radius: 99px; }

/* ====================== HOST ====================== */
.shell { max-width: 1200px; margin: 0 auto; padding: 24px max(20px, env(safe-area-inset-left)); }
.top { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 28px; }
.brand { font-family: var(--display); font-weight: 800; font-size: 2rem; letter-spacing: -0.02em; }
.brand small { font-family: var(--body); font-size: 0.85rem; font-weight: 700; color: var(--mute); margin-left: 0.5rem; letter-spacing: 0.1em; text-transform: uppercase; }

.qgrid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.qcard { background: var(--ink2); border: 2px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.qcard h3 { font-size: 1.35rem; overflow-wrap: anywhere; }
.qcard .meta { color: var(--mute); font-size: 0.92rem; }
.empty { text-align: center; padding: 70px 20px; border: 2px dashed var(--line); border-radius: 20px; display: grid; gap: 14px; justify-items: center; }
.empty h2 { font-size: 1.8rem; }
.empty p { color: var(--mute); max-width: 46ch; }

.editor .top { margin-bottom: 20px; }
.titleinput { flex: 1; min-width: 200px; font-family: var(--display); font-weight: 800; font-size: 1.3rem; }
.savestat { color: var(--mute); font-size: 0.9rem; min-width: 6.5em; }
.ed-body { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
.qlist { position: sticky; top: 12px; display: grid; gap: 12px; min-width: 0; }
.qlist li { min-width: 0; }
.qlist ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 60vh; overflow: auto; }
.qitem { width: 100%; min-width: 0; display: flex; gap: 0.7rem; align-items: center; text-align: left; background: var(--ink2); border: 2px solid var(--line); border-radius: 12px; padding: 0.6rem 0.7rem; }
.qitem.on { border-color: var(--paper); background: var(--ink3); }
.qitem .n { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 8px; background: var(--ink3); display: grid; place-items: center; font-weight: 800; font-family: var(--display); }
.qitem.on .n { background: var(--paper); color: var(--ink); }
.qitem .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qitem .hasimg { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mute); border: 1px solid var(--line); border-radius: 6px; padding: 0 0.35rem; }
.addrow { display: grid; gap: 8px; }
.qedit { background: var(--ink2); border: 2px solid var(--line); border-radius: 20px; padding: 22px; display: grid; gap: 16px; min-width: 0; }
.qe-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
.qe-head h2 { font-size: 1.4rem; }
.qedit textarea { resize: vertical; font-size: 1.15rem; font-weight: 700; }
.imgbox { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.drop { display: grid; place-items: center; text-align: center; width: 100%; min-height: 84px; border: 2px dashed var(--line); border-radius: 14px; color: var(--mute); cursor: pointer; padding: 12px; }
.drop:hover { border-color: var(--paper); color: var(--paper); }
.thumb { max-height: 160px; max-width: 100%; border-radius: 12px; border: 2px solid var(--line); }
.optgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.optrow { display: flex; align-items: center; gap: 8px; background: var(--c); color: var(--on); border-radius: 14px; padding: 8px; box-shadow: 0 5px 0 var(--cd); min-width: 0; }
.optrow .ico { flex: none; width: 1.7rem; height: 1.7rem; margin-left: 4px; }
.optrow input { flex: 1; background: #fffffff0; color: #140e36; border: 0; border-radius: 10px; font-weight: 700; padding: 0.6rem 0.7rem; }
.optrow input::placeholder { color: #7d76a8; }
.okbtn, .optrow .x { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 3px solid #fff9; background: #0002; color: #fff; font-weight: 800; font-size: 1.1rem; }
.c2 .okbtn, .c2 .x { color: #1b1300; border-color: #1b130066; }
.okbtn.on { background: #fff; color: var(--cd); border-color: #fff; }
.settings { display: flex; gap: 18px; flex-wrap: wrap; }
.settings label { display: grid; gap: 6px; min-width: 180px; }

/* host stages (projector) */
.stage { min-height: 100dvh; padding: clamp(16px, 3vw, 40px); max-width: 1500px; margin: 0 auto; display: flex; flex-direction: column; gap: clamp(14px, 2.4vw, 28px); }
.lobby { flex-direction: row; align-items: stretch; gap: clamp(24px, 4vw, 60px); }
.lobby-join { flex: 0 0 min(430px, 38%); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.joinurl { font-family: var(--display); font-weight: 800; font-size: clamp(1.4rem, 2.6vw, 2.2rem); background: var(--ink2); border: 2px solid var(--line); border-radius: 14px; padding: 0.4rem 0.9rem; overflow-wrap: anywhere; }
.pin { font-family: var(--display); font-weight: 800; font-size: clamp(2.8rem, 5.6vw, 5.2rem); line-height: 1; letter-spacing: 0.03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.qr { width: min(300px, 100%); background: #fff; border-radius: 18px; padding: 10px; margin-top: 8px; }
.qr svg { width: 100%; height: auto; }
.basebox { margin-top: 10px; color: var(--mute); font-size: 0.92rem; display: grid; gap: 8px; width: 100%; }
.basebox summary { cursor: pointer; font-weight: 700; }
.basebox[open] { padding: 12px; border: 2px solid var(--line); border-radius: 14px; background: var(--ink2); }
.lobby-players { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.lp-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.lp-head h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; }
.chip { display: inline-flex; align-items: center; gap: 0.5rem; background: var(--ink3); border: 2px solid var(--line); border-radius: 999px; padding: 0.35rem 0.5rem 0.35rem 1rem; font-family: var(--display); font-weight: 800; font-size: 1.25rem; animation: pop 0.25s ease-out; }
.chip button { border: 0; background: #0003; color: var(--mute); width: 1.7rem; height: 1.7rem; border-radius: 50%; line-height: 1; }
.chip button:hover { background: var(--bad); color: #fff; }
.hint { color: var(--mute); font-size: 1.2rem; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }

.qbar { display: flex; align-items: center; gap: 16px; }
.qcount { font-family: var(--display); font-weight: 800; font-size: 1.3rem; white-space: nowrap; }
.tnum { font-family: var(--display); font-weight: 800; font-size: 2.2rem; width: 2.2ch; text-align: right; font-variant-numeric: tabular-nums; }
.answered { color: var(--mute); font-weight: 700; white-space: nowrap; }
.qbody { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; min-height: 0; }
.qtext { font-size: clamp(1.7rem, 4.2vw, 3.6rem); line-height: 1.1; max-width: 26ch; }
.qimg { max-height: 30vh; max-width: min(100%, 780px); border-radius: 18px; object-fit: contain; border: 3px solid var(--line); background: var(--ink2); }
.stage .opts .opt { font-size: clamp(1.1rem, 2.4vw, 2rem); padding: clamp(0.8rem, 2vw, 1.4rem); }
.stage .opts .opt .ico { width: clamp(1.6rem, 3vw, 2.6rem); height: clamp(1.6rem, 3vw, 2.6rem); }
.qfoot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.qfoot .summary { color: var(--mute); font-weight: 700; font-size: 1.1rem; }

.board h1, .final h1 { font-size: clamp(2rem, 5vw, 3.6rem); text-align: center; }
.rows { list-style: none; margin: 0 auto; padding: 0; width: min(900px, 100%); display: grid; gap: 12px; }
.rows li { display: grid; grid-template-columns: 2.4rem minmax(6ch, 14ch) 1fr auto auto; gap: 14px; align-items: center; background: var(--ink2); border: 2px solid var(--line); border-radius: 16px; padding: 12px 18px; font-family: var(--display); font-weight: 800; font-size: clamp(1.1rem, 2.4vw, 1.8rem); }
.rows .rk { color: var(--mute); }
.rows .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .bar { height: 16px; background: var(--ink3); border-radius: 99px; overflow: hidden; }
.rows .bar i { display: block; height: 100%; width: 100%; background: var(--paper); border-radius: 99px; transform-origin: left; transform: scaleX(var(--w, 0)); animation: grow 0.9s cubic-bezier(.2,.8,.2,1) both; }
.rows .sc { font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }
.rows .gn { color: var(--good); font-size: 0.8em; min-width: 4.5ch; text-align: right; }
@keyframes grow { from { transform: scaleX(0); } }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: clamp(8px, 2vw, 24px); margin-top: 10px; }
.pcol { width: clamp(100px, 22vw, 240px); display: grid; gap: 8px; justify-items: center; text-align: center; min-width: 0; }
.pcol .nm { font-family: var(--display); font-weight: 800; font-size: clamp(1.1rem, 2.4vw, 2rem); max-width: 100%; overflow-wrap: anywhere; }
.pcol .sc { color: var(--mute); font-weight: 700; }
.pcol .blk { width: 100%; border-radius: 16px 16px 0 0; display: grid; place-items: start center; padding-top: 12px; font-family: var(--display); font-weight: 800; font-size: clamp(2rem, 5vw, 4rem); color: var(--ink); animation: rise 0.8s cubic-bezier(.2,.8,.2,1) both; transform-origin: bottom; }
.pcol.p1 .blk { height: clamp(150px, 26vh, 260px); background: var(--c2); }
.pcol.p2 .blk { height: clamp(110px, 19vh, 190px); background: #d7d3f2; animation-delay: 0.15s; }
.pcol.p3 .blk { height: clamp(80px, 14vh, 140px); background: #d98c5a; animation-delay: 0.3s; }
@keyframes rise { from { transform: scaleY(0); } }
.rest { list-style: none; margin: 10px auto 0; padding: 0; width: min(560px, 100%); display: grid; gap: 8px; }
.rest li { display: flex; justify-content: space-between; gap: 1rem; padding: 8px 14px; background: var(--ink2); border-radius: 12px; font-weight: 700; }
.finalfoot { display: flex; justify-content: center; margin-top: 10px; }

/* ====================== PLAYER (phone) ====================== */
body.player #app {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-width: 560px; margin: 0 auto;
}
.join { margin: auto 0; display: grid; gap: 22px; }
.join .brand { font-size: 3rem; text-align: center; }
.card { background: var(--ink2); border: 2px solid var(--line); border-radius: 20px; padding: 20px; display: grid; gap: 10px; }
.card input { font-size: 1.4rem; font-weight: 800; text-align: center; font-family: var(--display); }
.card #pin { letter-spacing: 0.25em; font-variant-numeric: tabular-nums; }
.card .btn { width: 100%; margin-top: 8px; }
.err { color: var(--bad); font-weight: 700; min-height: 1.4em; text-align: center; }
.center { margin: auto 0; display: grid; gap: 14px; text-align: center; justify-items: center; }
.center h1 { font-size: 2.4rem; }
.center .sub, .sub { color: var(--mute); font-size: 1.1rem; }
.namebadge { background: var(--ink3); border: 2px solid var(--line); border-radius: 999px; padding: 0.4rem 1.2rem; font-family: var(--display); font-weight: 800; font-size: 1.6rem; max-width: 100%; overflow-wrap: anywhere; }
.pq { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.pbar { display: flex; align-items: center; gap: 12px; font-weight: 800; font-family: var(--display); }
.pbar b { width: 2.2ch; text-align: right; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.ptext { font-size: 1.5rem; line-height: 1.15; text-align: center; }
.pimg { max-height: 24vh; max-width: 100%; margin: 0 auto; border-radius: 14px; object-fit: contain; }
body.player .opts { flex: 1; grid-auto-rows: 1fr; min-height: 220px; }
body.player .opts.n2 { grid-template-columns: 1fr; }
body.player .opt { font-size: 1.15rem; padding: 0.8rem; }
.picked { flex: 1; display: grid; place-items: center; align-content: center; gap: 18px; text-align: center; }
.picked .opt { width: 100%; max-width: 360px; pointer-events: none; }
.pres { flex: 1; display: grid; align-content: center; justify-items: center; gap: 12px; text-align: center; }
.pres .mark { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; background: var(--good); color: var(--ink); animation: pop 0.35s ease-out; }
.pres.bad .mark { background: var(--bad); }
.pres .mark svg { width: 60%; height: 60%; }
.pres h1 { font-size: 2.3rem; }
.gain { font-family: var(--display); font-weight: 800; font-size: 3rem; color: var(--good); }
.me { display: flex; gap: 12px; margin-top: 12px; }
.me span { background: var(--ink3); border-radius: 12px; padding: 0.4rem 0.9rem; font-family: var(--display); font-weight: 800; font-size: 1.2rem; }
.bigrank { font-family: var(--display); font-weight: 800; font-size: 6rem; line-height: 1; }

/* ====================== RESPONSIVE ====================== */
@media (max-width: 900px) {
  .ed-body { grid-template-columns: 1fr; }
  .qlist { position: static; }
  .qlist ol { max-height: 220px; }
  .lobby { flex-direction: column; }
  .lobby-join { flex: none; width: 100%; }
}
@media (max-width: 640px) {
  .optgrid, .opts { grid-template-columns: 1fr; }
  .opts.n3 .opt:last-child { grid-column: auto; }
  .rows li { grid-template-columns: 2rem minmax(0, 1fr) auto auto; }
  .rows .bar { display: none; }
  body.player .opts { grid-template-columns: 1fr 1fr; }
  body.player .opts.n2 { grid-template-columns: 1fr; }
  body.player .opts.n3 .opt:last-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.join .create-link { text-align: center; font-size: .95rem; }
.join .create-link a { color: inherit; opacity: .85; text-decoration: underline; text-underline-offset: 3px; }

.vidbox { display: grid; gap: 6px; }
.vidbox input { width: 100%; }
.vidnote { color: var(--mute); }
.qvid { aspect-ratio: 16 / 9; border: 3px solid var(--line); border-radius: 18px; background: #000; }
.pvid { width: min(100%, calc(26vh * 16 / 9)); aspect-ratio: 16 / 9; margin: 0 auto; border: 0; border-radius: 14px; background: #000; display: block; }

/* ====================== MÓVIL: EDITOR Y LISTAS ====================== */
@media (max-width: 900px) {
  /* Cabecera del editor: [← Mis quizzes] [estado] [Jugar] y el título a todo el ancho debajo */
  .editor .top { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
  .editor .top > .btn:first-child { grid-column: 1; grid-row: 1; }
  .editor .top .savestat { grid-column: 2; grid-row: 1; text-align: right; min-width: 0; }
  .editor .top > .btn.primary { grid-column: 3; grid-row: 1; }
  .editor .titleinput { grid-column: 1 / -1; grid-row: 2; min-width: 0; width: 100%; }

  /* Lista de preguntas: tira horizontal para llegar antes a editar */
  .qlist ol { display: flex; gap: 8px; max-height: none; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .qlist li { flex: none; width: 168px; scroll-snap-align: start; }
  .qlist .addrow { display: flex; gap: 8px; }
  .qlist .addrow .btn { flex: 1; padding-inline: 0.6rem; font-size: 0.92rem; }
}
@media (max-width: 640px) {
  .shell { padding-top: 16px; }
  .brand { font-size: 1.7rem; }
  /* Tarjeta de quiz: Jugar a todo el ancho y el resto debajo en una fila */
  .qcard .row { display: flex; flex-wrap: wrap; gap: 8px; }
  .qcard .row .btn.primary { flex: 1 1 100%; }
  .qcard .row .btn:not(.primary) { flex: 1; padding-inline: 0.5rem; }
  .qe-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .qe-head .row { display: flex; gap: 6px; }
  .qe-head .row .btn { flex: 1; padding-inline: 0.4rem; }
  /* Áreas táctiles cómodas */
  .btn, select, input[type='text'], input[type='url'] { min-height: 46px; }
  .okbtn, .optrow .x { min-width: 46px; min-height: 46px; }
}

/* ====================== JUGADOR: FICHAS DE RESPUESTA ====================== */
/* Forma arriba y texto centrado y grande: se lee de un vistazo con el pulgar encima. */
body.player .opts .opt { flex-direction: column; justify-content: center; text-align: center; gap: 0.7rem; font-size: clamp(1.2rem, 5.6vw, 1.8rem); line-height: 1.15; padding: 0.8rem 0.6rem; -webkit-tap-highlight-color: transparent; }
body.player .opts .opt .otxt { flex: 0 1 auto; }
body.player .opts .opt .ico { width: 2.6rem; height: 2.6rem; }
body.player .opts .opt:active { transform: translateY(3px); }
/* Con foto o vídeo la pregunta pierde altura: fichas más compactas para que todo quepa sin scroll */
body.player .pq:has(.pimg, .pvid) .opts .opt .ico { width: 1.8rem; height: 1.8rem; }
body.player .pq:has(.pimg, .pvid) .opts .opt { font-size: clamp(1.05rem, 4.8vw, 1.4rem); gap: 0.4rem; }

/* Pensado para proyector: nombres y contador legibles desde el fondo de la sala */
@media (min-width: 900px) {
  .chip { font-size: clamp(1.25rem, 2.1vw, 2rem); padding: 0.45rem 0.6rem 0.45rem 1.2rem; }
  .chip button { width: 1.9rem; height: 1.9rem; }
  .lobby-players h2 { font-size: clamp(1.6rem, 2.8vw, 2.6rem); }
  .answered { font-size: clamp(1rem, 1.6vw, 1.5rem); }
}

.maxrow { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--mute); font-weight: 700; font-size: 0.95rem; margin-top: 4px; }
.maxrow select { width: auto; min-width: 5.5rem; }

/* ====================== MEDIA DE LA PREGUNTA (host) ======================
   La pantalla de pregunta mide exactamente la ventana; la zona de media se queda con el hueco
   libre entre el título y las respuestas, y foto/vídeo se reparten ese hueco (container query),
   así nada empuja las respuestas ni el botón fuera de pantalla. */
.stage.q { height: 100dvh; min-height: 0; }
.stage.q .qbody { min-height: 0; }
.qmedia { container-type: size; flex: 1 1 0; min-height: 0; width: 100%; display: grid; gap: 14px; place-items: center; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.qmedia > * { min-width: 0; min-height: 0; }
.qmedia.m2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.qmedia.m3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qmedia.m4 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.qmedia.m5 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.qmedia .qvid { width: min(100%, calc(100cqh * 16 / 9)); height: auto; max-height: 100%; aspect-ratio: 16 / 9; justify-self: center; }
.qmedia .qimg { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; border: 0; border-radius: 14px; background: transparent; }
@media (max-width: 700px) {
  .stage.q { height: auto; min-height: 100dvh; }
  .qmedia { container-type: normal; flex: none; }
  .qmedia .qvid { width: 100%; height: auto; }
  .qmedia .qimg { height: auto; max-height: 28vh; }
}

/* Móvil del jugador: una foto grande o una rejilla de fotos */
.pimgs { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.pimgs.n1 { grid-template-columns: 1fr; }
.pimgs .pimg { width: 100%; height: 100%; max-height: 24vh; object-fit: cover; border-radius: 12px; margin: 0; }
.pimgs.n1 .pimg { object-fit: contain; }
.pimgs.n2 .pimg { max-height: 17vh; }
.pimgs.n3 .pimg, .pimgs.n4 .pimg { max-height: 11vh; }

/* Editor: galería de fotos de la pregunta */
.imgbox { align-items: stretch; }
.thumbfig { position: relative; margin: 0; }
.thumbfig .thumb { display: block; height: 110px; width: auto; max-width: 100%; object-fit: cover; }
.thumbfig .x { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: #000b; color: #fff; font-size: 1.1rem; line-height: 1; }
.thumbfig .x:hover { background: var(--bad); }
.drop.small { width: auto; min-width: 110px; min-height: 110px; }
.chk { display: flex; align-items: center; gap: 0.6rem; color: var(--mute); font-size: 0.95rem; }
.chk input { width: 1.2rem; height: 1.2rem; accent-color: var(--paper); }

/* Pantallas bajas (portátil, proyector 16:9 de poca altura): más sitio para la foto/vídeo */
@media (min-width: 701px) and (max-height: 860px) {
  .stage.q { padding-block: 14px; gap: 10px; }
  .stage.q .qbody { gap: 10px; }
  .stage.q .qtext { font-size: clamp(1.4rem, 3.2vw, 2.6rem); }
  .stage.q .opts { gap: 8px; }
  .stage.q .opts .opt { padding: 0.55rem 1rem; }
  .stage.q .qfoot .btn.big { padding: 0.55rem 1.3rem; font-size: 1.1rem; }
}

.lightbox { position: fixed; inset: 0; z-index: 50; background: #000d; display: grid; place-items: center; padding: 12px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }

/* ====================== TIPOS DE PREGUNTA, FOTOS DE RESPUESTA, AVATARES, SONIDO ====================== */
.em { font-style: normal; }
.em.big { font-size: clamp(2.2rem, 4.5vw, 3.8rem); line-height: 1; }
.chip .em { margin-right: 0.15rem; }

/* Editor */
.seg { display: inline-flex; align-self: flex-start; background: var(--ink2); border: 2px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.segbtn { border: 0; background: transparent; color: var(--mute); padding: 0.5rem 1rem; border-radius: 9px; font-weight: 700; cursor: pointer; }
.segbtn.on { background: var(--paper); color: var(--ink); }
.optimg { flex: none; width: 2.6rem; height: 2.6rem; border-radius: 10px; border: 2px dashed #fffa; background: #0002; display: grid; place-items: center; cursor: pointer; overflow: hidden; font-size: 1.2rem; }
.optimg.has { border-style: solid; }
.optimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.accbox { display: grid; gap: 10px; }
.accbox .hint { font-size: 0.95rem; }
.accrow { display: flex; gap: 8px; }
.accrow input { flex: 1; min-width: 0; }
.accrow .x { flex: none; width: 46px; border-radius: 10px; border: 2px solid var(--line); background: var(--ink2); color: var(--paper); font-size: 1.1rem; cursor: pointer; }

/* Respuestas con foto (host y móvil): la forma queda como insignia en la esquina para no depender solo del color */
.opts.hasimg .opt { position: relative; flex-direction: column; justify-content: flex-start; text-align: center; gap: 0.5rem; padding: 0.5rem; }
.opts.hasimg .opt .ico { position: absolute; top: 8px; left: 8px; width: 1.7rem; height: 1.7rem; padding: 3px; background: #0007; border-radius: 8px; z-index: 1; }
.opts.hasimg .opt .ico svg { fill: #fff; }
.oimg { width: 100%; object-fit: cover; border-radius: 10px; display: block; background: #0003; }
.stage .opts.hasimg .oimg { height: clamp(70px, 15vh, 190px); }
body.player .opts.hasimg .opt { padding: 0.4rem; }
body.player .opts .oimg { flex: 1 1 auto; min-height: 0; height: auto; max-height: 18vh; }
.picked .opt .oimg { max-height: 22vh; }

/* Pregunta de escribir */
.typebox { flex: none; display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; padding: clamp(14px, 3vh, 30px); border: 3px dashed var(--line); border-radius: 18px; color: var(--mute); font-size: clamp(1.1rem, 2.2vw, 1.8rem); font-weight: 700; }
.typebox.done { border-style: solid; border-color: var(--good); color: var(--paper); }
.typeicon { font-size: clamp(2rem, 5vh, 3rem); line-height: 1; }
.acc { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.accchip { background: var(--good); color: #06281b; border-radius: 999px; padding: 0.3rem 1.1rem; font-family: var(--display); font-weight: 800; font-size: clamp(1.3rem, 3vw, 2.4rem); }
.typeform { display: grid; gap: 12px; margin-top: 18px; }
.typeform input { font-size: 1.4rem; text-align: center; font-weight: 700; padding: 0.9rem; min-height: 58px; }
.typed { background: var(--ink3); border: 2px solid var(--line); border-radius: 16px; padding: 1rem 1.4rem; font-family: var(--display); font-weight: 800; font-size: 1.6rem; overflow-wrap: anywhere; max-width: 100%; }

/* Entrada del jugador: nombre aleatorio y avatar */
.nickrow { display: flex; gap: 8px; }
.nickrow input { flex: 1; min-width: 0; }
.dice { flex: none; width: 56px; font-size: 1.5rem; padding: 0; }
.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.av { font-size: 1.8rem; min-height: 54px; border-radius: 14px; border: 2px solid var(--line); background: var(--ink2); cursor: pointer; line-height: 1; }
.av.on { border-color: var(--paper); background: var(--ink3); transform: translateY(-2px); }

/* Interruptor de sonido */
.sndbtn { position: fixed; left: 14px; bottom: 14px; z-index: 40; width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--line); background: var(--ink2); color: var(--paper); font-size: 1.3rem; display: grid; place-items: center; cursor: pointer; opacity: 0.85; }
.sndbtn:hover { opacity: 1; background: var(--ink3); }
.sndbtn.inline { position: static; margin-top: 18px; width: auto; height: 44px; padding: 0 1.1rem; border-radius: 999px; font-size: 1.1rem; }

@media (max-width: 640px) {
  .optrow { flex-wrap: wrap; row-gap: 8px; }
  .optrow input { flex: 1 1 calc(100% - 3rem); }
  .optrow .optimg { margin-left: auto; }
  .seg { width: 100%; }
  .segbtn { flex: 1; padding-inline: 0.4rem; }
}
@media (max-width: 640px) { .segbtn { white-space: nowrap; font-size: 0.9rem; } }

.optwrap { position: relative; flex: none; display: inline-flex; }
.imgx { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: #1d1650; color: #fff; font-size: 0.8rem; line-height: 1; padding: 0; display: grid; place-items: center; cursor: pointer; }
.imgx:hover { background: var(--bad); }
@media (max-width: 640px) { .optrow .optwrap { margin-left: auto; } .optrow .optimg { margin-left: 0; } }
.card .nickrow .dice { width: 56px; margin-top: 0; }
/* El interruptor de sonido (abajo a la izquierda) no debe tapar el texto del pie */
body.host .qfoot .summary { margin-left: 58px; }
/* Proyector: con 3-4 respuestas con foto, todas en una fila (fotos más cuadradas) */
@media (min-width: 900px) {
  .stage .opts.hasimg.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stage .opts.hasimg.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stage .opts.hasimg.n3 .opt:last-child { grid-column: auto; }
  .stage .opts.hasimg .oimg { height: clamp(90px, 19vh, 230px); }
}

/* ====================== MODO EQUIPOS ====================== */
.lp-head .btn.sm { margin: 6px 0 2px; }
.teamgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; align-content: start; }
.teamcard { background: var(--ink2); border: 3px solid var(--tc); border-radius: 16px; overflow: hidden; display: grid; align-content: start; }
.teamcard header { background: var(--tc); color: var(--on); font-family: var(--display); font-weight: 800; font-size: clamp(1.1rem, 1.8vw, 1.5rem); padding: 0.5rem 0.9rem; display: flex; align-items: center; gap: 0.5rem; }
.teamcard header b { margin-left: auto; background: #0003; border-radius: 999px; padding: 0 0.65rem; }
.teamcard .chips { padding: 10px; min-height: 56px; }
.teamcard .chip { font-size: clamp(1rem, 1.5vw, 1.3rem); }
.rows.teams li { border-color: var(--tc); }
.rows.teams .bar i { background: var(--tc); }
.rows.teams .nm small { opacity: 0.6; font-size: 0.6em; margin-left: 0.3rem; }
.teamnote { text-align: center; color: var(--mute); margin: 0; font-size: clamp(0.95rem, 1.4vw, 1.2rem); }
.mvpline { text-align: center; margin: 0; font-size: clamp(1rem, 1.6vw, 1.4rem); }
.mvpline b { color: var(--good); }
.pcol[style*='--tc'] .blk { background: var(--tc); }
h2.mvp { text-align: center; margin: 8px 0 0; font-size: 1.2rem; color: var(--mute); }

/* Móvil */
.teambadge { background: var(--tc); color: var(--on); border-radius: 999px; padding: 0.45rem 1.2rem; font-family: var(--display); font-weight: 800; font-size: 1.2rem; }
.teamline { background: var(--tc); color: var(--on); border-radius: 14px; padding: 0.55rem 1rem; font-weight: 800; text-align: center; margin-top: 4px; }
.teampick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 360px; }
.tp { border: 2px solid var(--tc); background: var(--ink2); color: var(--paper); border-radius: 999px; padding: 0.5rem 1rem; font-weight: 800; font-size: 1rem; cursor: pointer; min-height: 44px; }
.tp small { opacity: 0.7; margin-left: 0.2rem; }
.tp.on { background: var(--tc); color: var(--on); }
.teamrest li { border-left: 6px solid var(--tc); }

/* Panel "Otro dispositivo" */
.modal { position: fixed; inset: 0; z-index: 60; background: #0009; display: grid; place-items: center; padding: 16px; overflow: auto; }
.modalbox { background: var(--ink2); border: 2px solid var(--line); border-radius: 20px; padding: 22px; width: min(520px, 100%); display: grid; gap: 10px; }
.modalbox h2 { margin: 0; font-size: 1.5rem; }
.modalbox h3 { margin: 10px 0 0; font-size: 1.05rem; color: var(--mute); }
.modalbox input { flex: 1; min-width: 0; }
.linkres { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qr.small { width: 150px; flex: none; }
.linkcode { font-family: var(--display); font-weight: 800; font-size: 2.2rem; letter-spacing: 0.08em; margin: 4px 0; }
/* Pantallas estrechas: el interruptor de sonido va al borde derecho, discreto, para no tapar botones */
@media (max-width: 900px) {
  body.host .sndbtn:not(.inline) { left: auto; right: 8px; bottom: auto; top: 8px; width: 36px; height: 36px; font-size: 1rem; opacity: 0.45; }
  body.host .qfoot .summary { margin-left: 0; }
}

/* Ayudas */
.help { margin: 0; color: var(--mute); font-size: 0.92rem; line-height: 1.4; max-width: 62ch; }
.help b { color: var(--paper); }
.lp-head .help { margin: 4px 0 6px; max-width: 44ch; }
.helpbox { margin-top: 1.4rem; display: grid; gap: 8px; max-width: 70ch; }
.helpbox p { margin: 0; color: var(--mute); }
.helpbox b { color: var(--paper); }
.modalbox .meta { margin: 0; line-height: 1.4; }
.modalbox h3 { color: var(--paper); font-size: 1.05rem; }

/* Notas de ayuda de los botones: visibles solo donde no hay ratón (móvil/tablet) o la pantalla es estrecha; el proyector queda limpio */
.foothelp { display: none; text-align: center; margin: 0 auto; }
@media (hover: none), (max-width: 900px) { .foothelp { display: block; } }

/* Táctil: sin retardo de doble toque ni zoom accidental al responder rápido */
button, .btn, .opt, .av, .tp, .segbtn, .okbtn, label.drop, label.optimg { touch-action: manipulation; }
