:root {
  --bg: #0a1020;
  --bg2: #0e1630;
  --panel: #121b33;
  --panel2: #18234a;
  --line: #243259;
  --text: #e9eefc;
  --muted: #8d9cc5;
  --accent: #22d3ee;
  --accent-ink: #04222a;
  --ok: #22c55e;
  --bad: #ef4444;
  --a0: #e5484d;
  --a1: #3e63dd;
  --a2: #d9920f;
  --a3: #2a9d62;
  --a4: #8e4ec6;
  --a5: #0e9fb3;
  --r: 14px;
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(130, 160, 230, .13) 1px, transparent 0),
    radial-gradient(1200px 600px at 85% -10%, rgba(34, 211, 238, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(62, 99, 221, .14), transparent 60%);
  background-size: 26px 26px, auto, auto;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
code, kbd { font-family: var(--mono); font-size: .9em; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 0 .35em; }
button { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.grow { flex: 1; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 10px; }
.center { justify-content: center; }

/* ---------- Botones e inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-weight: 600; cursor: pointer;
  text-decoration: none; transition: transform .08s, background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { border-color: #3a4c80; background: var(--panel2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: #5ee3f5; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel); }
.btn.sm { padding: 6px 12px; font-size: .875rem; }
.btn.big { padding: 14px 22px; font-size: 1.08rem; }
.btn.full { width: 100%; }
select.btn { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; max-width: 230px; }
select.btn option { background: var(--panel); }

.input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: inherit; outline: none;
}
.input:focus, .q-text:focus, .cfg-input:focus, .title-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .18); }
.input.sm { padding: 7px 10px; width: auto; }
.code-input { font-family: var(--mono); font-size: 1.6rem; letter-spacing: .12em; text-align: center; font-weight: 600; }
.field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.field select option { background: var(--panel); }

.card { background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }

/* ---------- Barra superior ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: rgba(10, 16, 32, .75); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 1.2rem; letter-spacing: -.01em; }
.brand b { color: var(--accent); }
.brand .logo { width: 30px; height: 30px; color: #7f91c4; }
.brand.big { font-size: 2rem; justify-content: center; }
.brand.big .logo { width: 46px; height: 46px; }
.title-input { flex: 1; min-width: 200px; background: transparent; border: 1px solid transparent; border-radius: 10px; color: var(--text); font: inherit; font-size: 1.1rem; font-weight: 600; padding: 8px 12px; outline: none; }
.title-input:hover { border-color: var(--line); }
.tb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: .9rem; }
.pill b { font-family: var(--mono); color: var(--accent); }
.muted-pill { color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mode-banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 10px; background: rgba(217, 146, 15, .12); border: 1px solid rgba(217, 146, 15, .45); color: #f5d38e; font-size: .9rem; }
.resume-banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 10px; background: rgba(34, 211, 238, .08); border: 1px solid rgba(34, 211, 238, .4); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.resume-banner b { font-family: var(--mono); }

.center-msg { min-height: 60vh; display: grid; place-content: center; text-align: center; color: var(--muted); padding: 20px; }
.center-msg.error h2 { color: var(--text); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; background: #1d2a52; border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); transition: .25s; pointer-events: none; z-index: 100; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Landing ---------- */
.hero { max-width: 1120px; margin: 0 auto; padding: 56px 20px 30px; display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center; }
.eyebrow { font-family: var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: .8rem; margin: 0 0 10px; }
.hero h1 { font-size: clamp(2rem, 4.4vw, 3.3rem); line-height: 1.08; margin: 0 0 16px; letter-spacing: -.025em; }
.hl { background: linear-gradient(90deg, var(--accent), #8aa5ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: #c3cdea; font-size: 1.1rem; max-width: 560px; }
.feat { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.feat li { display: flex; align-items: center; gap: 12px; }
.feat li span { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; }
.hero-cards { display: grid; gap: 16px; }
.hero-cards h2 { margin: 0 0 12px; font-size: 1.2rem; }
.join-card-home { display: grid; gap: 12px; }
.create-card p { margin: 0 0 14px; }
.how { max-width: 1120px; margin: 10px auto 40px; padding: 0 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.how > div { border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: rgba(18, 27, 51, .6); }
.how b { font-family: var(--mono); color: var(--accent); }
.how h3 { margin: 6px 0; }
.how p { margin: 0; color: var(--muted); }
.foot { text-align: center; padding: 20px; }

/* ---------- Editor ---------- */
.builder { display: grid; grid-template-columns: 300px 1fr; gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; }
.qlist { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 110px); overflow: auto; position: sticky; top: 76px; align-self: start; padding-right: 4px; }
.qitem { display: grid; grid-template-columns: 30px 1fr auto; grid-template-rows: auto auto; gap: 2px 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.qitem:hover { border-color: #3a4c80; }
.qitem.on { border-color: var(--accent); background: var(--panel2); }
.qnum { grid-row: span 2; width: 30px; height: 30px; border-radius: 8px; background: var(--bg2); display: grid; place-items: center; font-family: var(--mono); font-weight: 600; }
.qitem.on .qnum { background: var(--accent); color: var(--accent-ink); }
.qsnip { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .92rem; }
.qsnip i { color: var(--muted); }
.qmeta { font-family: var(--mono); font-size: .72rem; color: var(--muted); text-align: right; white-space: nowrap; }
.qtools { grid-column: 2 / 4; display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.qitem:hover .qtools, .qitem.on .qtools { opacity: 1; }
.qtools button { border: 1px solid var(--line); background: var(--bg2); color: var(--muted); border-radius: 6px; width: 26px; height: 24px; cursor: pointer; font-size: .8rem; padding: 0; }
.qtools button:hover { color: var(--text); border-color: var(--accent); }
.btn.add { border-style: dashed; background: transparent; color: var(--muted); }
.btn.add:hover { color: var(--text); }

.editor { background: rgba(18, 27, 51, .75); border: 1px solid var(--line); border-radius: 18px; padding: 22px; display: grid; gap: 16px; align-content: start; min-width: 0; }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ed-head h2 { margin: 0; font-size: 1.15rem; }
.q-text { width: 100%; font: inherit; font-size: 1.35rem; font-weight: 600; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); resize: vertical; outline: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; padding: 3px; background: var(--bg2); gap: 3px; flex-wrap: wrap; width: fit-content; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.media-box { display: grid; gap: 10px; }
.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 30px 20px; text-align: center; color: var(--muted); cursor: pointer; background: rgba(14, 22, 48, .6); transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--text); background: rgba(34, 211, 238, .06); }
.dropzone b { color: var(--text); }
.img-prev { background: #fff; border-radius: 12px; padding: 8px; display: grid; place-items: center; max-height: 340px; overflow: hidden; }
.img-prev img { max-width: 100%; max-height: 320px; object-fit: contain; }
.cfg-input { width: 100%; font-family: var(--mono); font-size: .9rem; line-height: 1.55; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: #060b18; color: #d6e2ff; resize: vertical; outline: none; tab-size: 2; }

.opts-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt-edit { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 13px; background: var(--c); }
.opt-edit .opt-ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; color: #fff; }
.opt-edit .opt-ico svg { width: 28px; height: 28px; }
.opt-edit input { flex: 1; min-width: 0; border: 0; border-radius: 9px; padding: 12px; font: inherit; font-weight: 600; background: rgba(255, 255, 255, .95); color: #0d1430; outline: none; }
.opt-edit input::placeholder { color: #7d88a6; font-weight: 500; }
.ok-toggle { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .85); background: transparent; color: transparent; font-size: 1.2rem; font-weight: 700; cursor: pointer; }
.ok-toggle:hover { color: rgba(255, 255, 255, .7); }
.ok-toggle.on { background: #fff; color: #11804a; border-color: #fff; }

/* ---------- Adjuntos ---------- */
.media { margin: 0; }
.media-img { background: #fff; border-radius: 14px; padding: 8px; display: grid; place-items: center; }
.media-img img { max-width: 100%; max-height: 42vh; object-fit: contain; display: block; }
.media-img.mini img { max-height: 22vh; }
.media-img.player img { max-height: 30vh; }
pre.cfg { background: #060b18; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; font-family: var(--mono); font-size: clamp(.8rem, 1.25vw, 1.05rem); line-height: 1.55; color: #d6e2ff; overflow: auto; max-height: 46vh; text-align: left; white-space: pre; }
pre.cfg.mini { max-height: 22vh; font-size: .85rem; }
pre.cfg.player { font-size: .78rem; max-height: 32vh; padding: 12px; }
.c-com { color: #6b7a99; }
.c-kw { color: #7dd3fc; font-weight: 600; }
.c-ip { color: #fbbf24; }
.c-if { color: #a7f3d0; }
.c-prompt { color: #c4b5fd; }

/* ---------- Sala: lobby ---------- */
.lobby { max-width: 1200px; margin: 0 auto; padding: 24px 20px; display: grid; grid-template-columns: 420px 1fr; gap: 24px; align-items: start; }
.join-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; text-align: center; }
.join-card p { margin: 0 0 6px; }
.big-code { font-family: var(--mono); font-weight: 600; font-size: clamp(3rem, 6vw, 4.6rem); letter-spacing: .06em; color: #fff; margin: 4px 0 18px; text-shadow: 0 0 30px rgba(34, 211, 238, .35); }
.qr { background: #fff; padding: 8px; border-radius: 12px; line-height: 0; }
.qr:empty { display: none; }
.join-actions { display: grid; gap: 8px; }
.players-box { min-width: 0; }
.players-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.players-head h2 { margin: 0; font-size: 1.6rem; }
.players-head h2 #pcount { font-family: var(--mono); color: var(--accent); }
.plist { display: flex; flex-wrap: wrap; gap: 10px; min-height: 120px; align-content: flex-start; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(18, 27, 51, .55); }
.pchip { border: 0; background: var(--panel2); color: var(--text); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 1.05rem; cursor: pointer; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); box-shadow: inset 0 0 0 1px var(--line); }
.pchip:hover { background: var(--bad); text-decoration: line-through; }
.waiting { color: var(--muted); margin: auto; font-size: 1.1rem; }
.dots { display: inline-flex; gap: 3px; margin-left: 4px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Sala: pregunta ---------- */
.stage { max-width: 1280px; margin: 0 auto; padding: 18px 20px 24px; display: grid; gap: 18px; }
.stage.narrow { max-width: 760px; }
.timebar { height: 8px; border-radius: 99px; background: var(--panel); overflow: hidden; }
.timebar span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent), #8aa5ff); border-radius: 99px; transition: width .2s linear; }
.q-big { margin: 0; text-align: center; font-size: clamp(1.5rem, 3vw, 2.4rem); line-height: 1.2; letter-spacing: -.015em; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px 24px; }
.q-big.small { font-size: clamp(1.2rem, 2.2vw, 1.7rem); }
.q-body { display: grid; grid-template-columns: 110px 1fr 110px; align-items: center; gap: 18px; min-height: 120px; }
.q-body:not(.with-media) { grid-template-columns: 1fr 1fr; justify-items: center; }
.clock { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); border: 3px solid var(--accent); font-family: var(--mono); font-size: 2.2rem; font-weight: 600; }
.clock.hurry { border-color: var(--bad); color: #fecaca; animation: pulse .6s infinite alternate; }
.clock.sm { width: 52px; height: 52px; font-size: 1.25rem; border-width: 2px; }
@keyframes pulse { to { transform: scale(1.06); } }
.answered { text-align: center; display: grid; }
.answered b { font-family: var(--mono); font-size: 2rem; }
.answered span { color: var(--muted); }
.stage-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stage-foot.wrap { justify-content: flex-end; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { position: relative; display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 14px 18px; border-radius: 14px; background: var(--c); color: #fff; font-weight: 600; font-size: clamp(1rem, 1.8vw, 1.4rem); border: 0; text-align: left; box-shadow: 0 5px 0 rgba(0, 0, 0, .28); transition: opacity .3s, transform .1s, filter .2s; }
.tile-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; }
.tile-ico svg { width: 38px; height: 38px; }
.tile-txt { flex: 1; overflow-wrap: anywhere; }
.tiles.reveal .tile.dim { opacity: .35; filter: saturate(.6); }
.tiles.reveal .tile.ok { box-shadow: 0 0 0 4px #fff, 0 5px 0 rgba(0, 0, 0, .28); }
.tile-count { display: flex; align-items: center; gap: 10px; flex: none; }
.tile-count .bar { width: 10px; height: 46px; border-radius: 6px; background: rgba(255, 255, 255, .22); position: relative; overflow: hidden; }
.tile-count .bar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: var(--h); background: #fff; border-radius: 6px; animation: grow .6s ease-out; }
@keyframes grow { from { height: 0; } }
.tile-count b { font-family: var(--mono); font-size: 1.5rem; min-width: 1.4em; text-align: right; }
.tick { width: 30px; height: 30px; border-radius: 50%; background: #fff; color: #11804a; display: grid; place-items: center; font-weight: 800; }

/* ---------- Ranking / podio ---------- */
.ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ranking li { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; font-size: 1.15rem; animation: slidein .45s backwards; animation-delay: var(--d, 0ms); }
.ranking li:first-child { border-color: var(--accent); }
.ranking li.me { border-color: var(--accent); background: var(--panel2); }
.ranking li.empty { justify-content: center; color: var(--muted); }
.ranking .pos { font-family: var(--mono); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--bg2); font-weight: 600; flex: none; }
.ranking .nm { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .gain { font-family: var(--mono); color: var(--ok); font-size: .95rem; }
.ranking .sc { font-family: var(--mono); font-weight: 600; }
.ranking.compact li { font-size: 1rem; padding: 9px 12px; }
@keyframes slidein { from { opacity: 0; transform: translateX(-20px); } }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 12px; margin-top: 10px; }
.step { text-align: center; animation: rise .7s backwards; animation-delay: var(--d, 0ms); }
.step .who { font-weight: 700; font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .pts { color: var(--muted); font-family: var(--mono); margin-bottom: 8px; }
.step .block { border-radius: 14px 14px 4px 4px; display: grid; place-items: center; font-family: var(--mono); font-size: 2.6rem; font-weight: 700; color: rgba(255, 255, 255, .95); }
.s1 .block { height: 190px; background: linear-gradient(#e2b33a, #a77a0c); }
.s2 .block { height: 140px; background: linear-gradient(#a9b6d6, #6c7a9e); }
.s3 .block { height: 105px; background: linear-gradient(#d28552, #91512a); }
@keyframes rise { from { opacity: 0; transform: translateY(40px); } }

/* ---------- Jugador ---------- */
body.player { min-height: 100dvh; }
.join { max-width: 420px; margin: 0 auto; padding: 48px 18px; display: grid; gap: 26px; }
.join-form { display: grid; gap: 16px; }
.join-form label { display: grid; gap: 6px; color: var(--muted); font-size: .92rem; }
.err { color: #fca5a5; margin: 0; font-weight: 500; }
.phead { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(10, 16, 32, .8); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(8px); }
.pname { font-weight: 700; }
.pscore { font-family: var(--mono); background: var(--panel2); padding: 4px 10px; border-radius: 999px; }
.pscreen { max-width: 760px; margin: 0 auto; padding: 16px; min-height: calc(100dvh - 56px); display: grid; align-content: center; gap: 14px; }
.pscreen.q { align-content: start; }
.pq-top { display: flex; align-items: center; justify-content: space-between; }
.pq-text { margin: 0; font-size: clamp(1.15rem, 4.5vw, 1.6rem); line-height: 1.25; }
.tiles.answer .tile { cursor: pointer; min-height: 92px; font-size: clamp(.95rem, 3.8vw, 1.2rem); }
.tiles.answer .tile:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .28); }
.tiles.answer .tile:disabled { opacity: .45; cursor: default; }
.timeup { text-align: center; font-weight: 700; font-size: 1.2rem; color: #fecaca; }
.big-msg { text-align: center; display: grid; justify-items: center; gap: 8px; }
.big-msg h1 { margin: 4px 0; font-size: clamp(1.8rem, 7vw, 2.6rem); letter-spacing: -.02em; }
.big-msg p { margin: 0; }
.okmark, .res-ico { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 2.4rem; font-weight: 800; background: var(--panel2); border: 2px solid var(--accent); color: var(--accent); animation: pop .4s cubic-bezier(.2, 1.4, .4, 1); }
.sent-tile { width: 110px; height: 110px; border-radius: 22px; background: var(--c); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 0 rgba(0, 0, 0, .28); animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.sent-tile svg { width: 64px; height: 64px; }
.res-sub { font-size: 1.3rem; font-weight: 600; }
.res-rank { font-size: 1.1rem; }
.res-rank b { font-family: var(--mono); font-size: 1.4rem; }
body.result.good { background-color: #0b3b25; }
body.result.bad { background-color: #43121a; }
body.result.good .res-ico { background: #fff; color: #11804a; border-color: #fff; }
body.result.bad .res-ico { background: #fff; color: #c42b36; border-color: #fff; }
.medal { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); font-size: 2.6rem; font-weight: 800; background: var(--panel2); border: 3px solid var(--line); animation: pop .5s cubic-bezier(.2, 1.4, .4, 1); }
.medal.m1 { background: linear-gradient(#f2c94c, #a77a0c); border-color: #f8e3a0; }
.medal.m2 { background: linear-gradient(#cfd8ee, #6c7a9e); border-color: #e3e9f7; }
.medal.m3 { background: linear-gradient(#e19a68, #91512a); border-color: #f0c3a2; }
.big-msg .ranking { width: 100%; max-width: 380px; margin: 12px 0; text-align: left; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .builder { grid-template-columns: 1fr; }
  .qlist { position: static; max-height: none; flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .qitem { min-width: 220px; }
  .lobby { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; padding-top: 34px; }
  .how { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .tb-actions { width: 100%; }
  .tb-actions .btn { flex: 1 1 auto; }
  .editor { padding: 16px; }
  .opts-edit { grid-template-columns: 1fr; }
  .q-body, .q-body:not(.with-media) { grid-template-columns: 1fr 1fr; }
  .q-body .media { grid-column: 1 / -1; grid-row: 1; }
  .tiles { gap: 9px; }
  .tile { padding: 10px 12px; gap: 8px; }
  .tile-ico { width: 32px; height: 32px; }
  .tile-ico svg { width: 28px; height: 28px; }
  .muted-pill { display: none; }
}
@media (max-width: 380px) {
  .tiles.answer { grid-template-columns: 1fr; }
  .tiles.answer .tile { min-height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Interruptor de avance automático ---------- */
.auto-toggle { gap: 8px; }
.auto-toggle .sw { width: 30px; height: 17px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.auto-toggle .sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform .2s; }
.auto-toggle.on .sw { background: var(--accent); }
.auto-toggle.on .sw::after { transform: translateX(13px); }
@media (max-width: 640px) { .auto-toggle { font-size: 0; gap: 0; } }

/* ---------- Avatares ---------- */
.av { display: block; width: 100%; height: 100%; }
.av-pick { display: grid; gap: 10px; }
.av-pick .lbl { color: var(--muted); font-size: .92rem; }
.av-preview { display: flex; align-items: center; gap: 12px; }
.av-big { width: 64px; height: 64px; flex: none; }
.av-info { flex: 1; display: grid; line-height: 1.2; }
.av-info b { font-size: 1.15rem; }
.av-info small { color: var(--muted); }
.av-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.av-opt { aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; opacity: .55; transition: transform .15s, opacity .15s, box-shadow .15s; }
.av-opt:hover { opacity: .9; transform: scale(1.08); }
.av-opt.on { opacity: 1; transform: scale(1.1); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }

.bob { animation: bob 2.6s ease-in-out infinite; animation-delay: var(--bob, 0s); }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(-2deg); } }
.jump { animation: jump .6s cubic-bezier(.3, 1.6, .5, 1) !important; }
@keyframes jump { 0% { transform: scale(1); } 30% { transform: translateY(-16px) scale(1.12) rotate(6deg); } 60% { transform: translateY(0) scale(.95) rotate(-4deg); } 100% { transform: none; } }
.av .av-eyes { animation: blink-eyes 4.5s infinite; transform-origin: center 50%; transform-box: fill-box; }
@keyframes blink-eyes { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

.bubble { position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translate(-50%, 8px) scale(.6); opacity: 0; background: #fff; color: #0d1430; font-weight: 700; font-size: .95rem; padding: 5px 11px; border-radius: 12px; white-space: nowrap; pointer-events: none; z-index: 3; }
.bubble::after { content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; }
.bubble.show { animation: bubble 1.9s ease forwards; }
@keyframes bubble { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.6); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 20% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -6px) scale(1); } }

/* Lobby del anfitrión: tarjetas con avatar */
.plist { gap: 14px; padding: 22px 16px 16px; }
.pcard { position: relative; display: grid; justify-items: center; gap: 6px; width: 104px; padding: 0; border: 0; background: transparent; color: var(--text); cursor: pointer; font: inherit; animation: bob 2.8s ease-in-out infinite; animation-delay: var(--bob, 0s); }
.pcard .pav { position: relative; width: 72px; height: 72px; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); }
.pcard .pnm { font-weight: 600; max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(18, 27, 51, .9); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; font-size: .95rem; }
.pcard:hover .pnm { background: var(--bad); border-color: var(--bad); text-decoration: line-through; }
.pcard.new { animation: arrive .7s cubic-bezier(.2, 1.5, .4, 1); }
.pcard.bye { animation: leave .3s ease forwards; }
@keyframes arrive { 0% { opacity: 0; transform: translateY(-60px) scale(.3); } 100% { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: scale(.3); } }

/* Lobby del jugador */
.lobby-p .big-msg { gap: 12px; }
.me-av { position: relative; width: 132px; height: 132px; cursor: pointer; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .4)); margin-top: 36px; -webkit-tap-highlight-color: transparent; }
#avChange { width: 100%; max-width: 380px; }
.others { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 420px; }
.others .mini { width: 34px; height: 34px; display: block; }
.others .mini.me { box-shadow: 0 0 0 2px var(--accent); border-radius: 50%; }
.others .mini.new { animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); }
.phead .pname { display: inline-flex; align-items: center; gap: 8px; }
.hav { width: 30px; height: 30px; display: inline-block; }

/* Avatares en ranking y podio */
.ranking .rav { width: 34px; height: 34px; flex: none; display: block; }
.ranking.compact .rav { width: 28px; height: 28px; }
.pod-av { width: 84px; height: 84px; margin: 0 auto 6px; animation: bob 2.6s ease-in-out infinite; }
.s1 .pod-av { width: 104px; height: 104px; }

/* ---------- Modo solo ---------- */
.solo-note { text-align: center; color: var(--muted); margin: 4px 0 0; }
.solo-note b { color: var(--text); }
.solo-intro h1 { font-size: clamp(1.5rem, 6vw, 2.1rem); }
.solo-av { width: 104px; height: 104px; margin-top: 4px; }
.solo-card { width: 100%; max-width: 420px; display: grid; gap: 12px; text-align: left; margin-top: 8px; }
.solo-card h2 { margin: 0; font-size: 1.15rem; }
.solo-card .lbl { color: var(--muted); font-size: .9rem; }
.time-seg { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
.time-seg button { padding: 9px 6px; }
.tiles.solo-ans .tile { cursor: pointer; min-height: 92px; font-size: clamp(.95rem, 3.8vw, 1.2rem); }
.tiles.solo-ans .tile:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .28); }
.small-sub { font-size: 1.05rem; max-width: 420px; }
.ranking .tag { font-size: .72rem; font-family: var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
@media (max-width: 380px) { .tiles.solo-ans { grid-template-columns: 1fr; } .tiles.solo-ans .tile { min-height: 64px; } }

/* ---------- Ajustes para celular: nada debe salirse del ancho de la pantalla ---------- */
body { overflow-x: clip; }
.pscreen, .stage, .editor, .big-msg { grid-template-columns: minmax(0, 1fr); }
.pscreen > *, .stage > *, .big-msg > * { min-width: 0; max-width: 100%; }
.media-img { display: block; text-align: center; max-width: 100%; }
.media-img img { width: auto; height: auto; max-width: 100%; margin: 0 auto; }
pre.cfg { max-width: 100%; min-width: 0; }
.clock.sm { width: auto; min-width: 52px; padding: 0 10px; border-radius: 999px; }
.dropzone small { display: block; margin-top: 8px; font-size: .8rem; }

/* ---------- Imagen por enlace ---------- */
.url-box { border: 1px solid rgba(34, 211, 238, .45); background: rgba(34, 211, 238, .06); border-radius: 14px; padding: 14px 16px; display: grid; gap: 8px; }
.url-head { display: flex; align-items: center; gap: 10px; }
.pill-ok { font-size: .72rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 2px 8px; }
.url-box p { margin: 0; }
.url-box .row.nowrap { flex-wrap: nowrap; }
.url-box .row.nowrap .input { flex: 1; min-width: 0; }
.dropzone.small-dz { padding: 14px; }

/* ---------- Guardar sala / salas guardadas ---------- */
.keep-card { display: flex; gap: 14px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.keep-card p { margin: 4px 0 6px; }
.keep-state { font-family: var(--mono); color: var(--accent); font-size: .8rem; }
.auto-toggle.big-sw { padding: 6px; border: 0; background: transparent; flex: none; margin-top: 2px; }
.auto-toggle.big-sw .sw { width: 46px; height: 26px; }
.auto-toggle.big-sw .sw::after { width: 20px; height: 20px; top: 3px; left: 3px; }
.auto-toggle.big-sw.on .sw::after { transform: translateX(20px); }
.saved-panel { margin: 12px 20px 0; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.saved-panel h3 { margin: 0 0 10px; font-size: 1rem; }
.saved-panel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.saved-panel li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.saved-panel .code { font-family: var(--mono); color: var(--accent); }
.saved-panel .t { flex: 1; min-width: 120px; }
.auto-toggle .sw { display: inline-block; }
.auto-toggle.big-sw { display: inline-flex; cursor: pointer; }
.perm-tag { display: inline-block; margin: 0 0 10px !important; }

/* ---------- Menú «Cuestionario» ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: grid; box-shadow: 0 14px 34px rgba(0, 0, 0, .45); }
.menu-pop button { text-align: left; background: transparent; border: 0; color: var(--text); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.menu-pop button:hover { background: var(--panel2); }
@media (max-width: 640px) { .menu-pop { left: 0; right: auto; } }

/* ---------- Selector de idioma (como topologia.app) ---------- */
.lng { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: .8rem; font-weight: 700; flex: none; }
.lng b, .lng a { padding: 6px 9px; line-height: 1; }
.lng b { background: var(--panel2); color: var(--accent); }
.lng a { color: var(--muted); text-decoration: none; }
.lng a:hover { color: var(--text); background: var(--panel); }
.join-top { display: flex; justify-content: flex-end; margin-bottom: -14px; }
.foot a { color: var(--accent); }
.topo-hint { margin: 0; }
.topo-hint a { color: var(--accent); }

/* ---------- Imagen ampliable + visor con zoom ---------- */
.zoomable, .img-prev { position: relative; cursor: zoom-in; }
.zoom-hint { position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; border-radius: 9px; background: rgba(10, 16, 32, .78); color: #fff; display: grid; place-items: center; font-size: 1.05rem; pointer-events: none; }
.zoom-ov { position: fixed; inset: 0; z-index: 200; background: rgba(6, 10, 22, .94); display: flex; flex-direction: column; }
.zoom-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; justify-content: center; flex-wrap: wrap; }
.zoom-bar button { min-width: 42px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 700; font-size: 1.05rem; cursor: pointer; padding: 0 12px; }
.zoom-bar .zoom-x { margin-left: 12px; }
.zoom-pct { font-family: var(--mono); min-width: 60px; text-align: center; color: var(--muted); }
.zoom-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; cursor: grab; }
.zoom-stage:active { cursor: grabbing; }
.zoom-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; border-radius: 6px; max-width: none; user-select: none; }
.start-tip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; border: 1px dashed rgba(34, 211, 238, .5); background: rgba(34, 211, 238, .06); color: var(--muted); font-size: .92rem; }
.start-tip b { color: var(--text); }

/* ---------- Imágenes más grandes (diagramas cuadrados o verticales) ---------- */
.img-prev { max-height: none; }
.img-prev img { max-height: min(68vh, 760px); width: auto; }
.media-img img { max-height: min(56vh, 820px); }
.media-img.big img { max-height: min(58vh, 900px); }
.media-img.mini img { max-height: 30vh; }
.media-img.player img { max-height: 44vh; }
.q-body.with-media { grid-template-columns: 96px minmax(0, 1fr) 96px; gap: 12px; }

/* orden aleatorio (lista de preguntas) */
.shuf-box { margin-bottom: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); display: grid; gap: 6px; flex: none; }
.shuf { display: flex; gap: 8px; align-items: center; font-size: .9rem; cursor: pointer; }
.shuf input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.shuf-box p { margin: 2px 0 0; }
@media (max-width: 980px) { .shuf-box { min-width: 230px; margin-top: 0; } }

/* ---------- varias respuestas correctas / hasta 6 opciones ---------- */
.pick-badge { align-self: center; justify-self: center; margin: 0 auto 10px; width: fit-content; padding: 6px 14px; border-radius: 999px; background: rgba(34, 211, 238, .14); border: 1px solid rgba(34, 211, 238, .45); color: var(--accent); font-weight: 700; text-align: center; }
.tiles.multi .tile, .tiles.solo-ans.multi .tile { padding-right: 52px; }
.tile-chk { position: absolute; right: 14px; top: 50%; width: 28px; height: 28px; margin-top: -14px; border-radius: 8px; border: 3px solid rgba(255, 255, 255, .85); background: rgba(0, 0, 0, .12); }
.tile.on { box-shadow: 0 0 0 4px #fff, 0 5px 0 rgba(0, 0, 0, .28); }
.tile.on .tile-chk { background: #fff; }
.tile.on .tile-chk::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: #0d1430; font-weight: 900; font-size: 18px; }
.send-multi { margin-top: 14px; }
.send-multi:disabled { opacity: .5; cursor: default; }
.sent-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.sent-tile.sm { width: 76px; height: 76px; border-radius: 16px; }
.sent-tile.sm svg { width: 44px; height: 44px; }
.right-ans { display: grid; gap: 8px; justify-items: center; margin: 12px auto 6px; max-width: 520px; }
.right-ans > span { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; font-weight: 700; }
.right-ans b { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border-radius: 12px; background: var(--c); color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .9); text-align: left; font-size: 1.02rem; }
.right-ans b i { width: 26px; height: 26px; flex: none; display: grid; place-items: center; }
.right-ans b i svg { width: 22px; height: 22px; }
.opts-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.opt-rm { flex: none; width: 34px; height: 34px; border-radius: 9px; border: 0; background: rgba(0, 0, 0, .22); color: #fff; font-weight: 700; cursor: pointer; }
.opt-rm:hover { background: rgba(0, 0, 0, .4); }
.multi-mode { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; color: var(--accent); font-weight: 600; }

/* ---------- corrección en la misma pantalla ---------- */
.tiles.review .tile { cursor: default; padding-right: 54px; }
.tiles.review .tile.rv-dim { opacity: .32; filter: saturate(.5); }
.tiles.review .tile.rv-ok { box-shadow: 0 0 0 4px #22c55e, 0 0 0 7px rgba(255, 255, 255, .9), 0 5px 0 rgba(0, 0, 0, .28); }
.tiles.review .tile.rv-bad { opacity: .9; box-shadow: 0 0 0 4px #ef4444, 0 5px 0 rgba(0, 0, 0, .28); background: repeating-linear-gradient(135deg, var(--c) 0 14px, color-mix(in srgb, var(--c) 78%, #000) 14px 28px); }
.tiles.review .tile.rv-bad .tile-txt { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(255, 255, 255, .7); }
.rv-mark { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 20px; background: #fff; }
.rv-ok .rv-mark { color: #16a34a; }
.rv-bad .rv-mark { color: #dc2626; }
.rv-tag { position: absolute; left: 12px; top: -11px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800; letter-spacing: .02em; background: #fff; color: #0d1430; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.rv-ok .rv-tag { background: #22c55e; color: #fff; }
.rv-bad .rv-tag { background: #ef4444; color: #fff; }
.tiles.review { row-gap: 20px; padding-top: 8px; }
.rv-bar { position: sticky; bottom: 10px; margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); z-index: 5; }
.rv-bar.good { border-color: #22c55e; background: color-mix(in srgb, #22c55e 18%, var(--panel)); }
.rv-bar.bad { border-color: #ef4444; background: color-mix(in srgb, #ef4444 16%, var(--panel)); }
.rv-msg { display: grid; gap: 2px; }
.rv-msg b { font-size: 1.15rem; }
.rv-msg span { font-size: .9rem; color: var(--muted); }
.rv-bar .btn { flex: none; }
