
/* Layout: escenario a pantalla completa sin desplazamiento. Fila 1 cabecera, fila 2 marcador, fila 3 tres columnas: ruleta | tarjeta | Stradi. En pantallas estrechas se apila y sí se desplaza. Un solo tema oscuro a propósito (sala con luces bajas, pensado para proyector). */
:root {
  color-scheme: dark;
  --stage: #1b1420;
  --stage-2: #261c2c;
  --stage-3: #33263a;
  --ink: #fbf3e6;
  --muted: #c9b8c4;
  --varnish: #d9822b;
  --varnish-dark: #7a3d12;
  --rosin: #f2c14e;
  --good: #5cc98a;
  --bad: #ef6a5b;
  --display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
  --wheel: 420px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(242,193,78,.16), transparent 70%),
    var(--stage);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.4;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--rosin); outline-offset: 3px; }
.wrap {
  height: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}

/* Cabecera */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1 {
  font-family: var(--display); font-weight: 400; margin: 0; line-height: 1;
  font-size: clamp(24px, 4.2vh, 38px); color: var(--rosin); text-shadow: 0 3px 0 var(--varnish-dark);
}
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.ghost {
  background: transparent; border: 1.5px solid var(--stage-3); border-radius: 999px;
  padding: 6px 14px; font-weight: 600; font-size: 14px; color: var(--muted);
}
.ghost:hover { border-color: var(--muted); color: var(--ink); }

/* Marcador */
.scores { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 10px; }
.player {
  background: var(--stage-2); border: 3px solid transparent; border-radius: 14px;
  padding: 8px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 10px;
  transition: border-color .25s, box-shadow .25s;
}
.player.active { border-color: var(--c); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 18%, transparent); }
.player .name { font-family: var(--display); font-size: clamp(18px, 3vh, 28px); color: var(--c); line-height: 1.05; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.player .turn { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.player.active .turn { color: var(--c); }
.jokers { display: flex; gap: 3px; }
.jokers i {
  width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center;
  font-style: normal; font-size: 11px; font-weight: 800; background: var(--rosin); color: #2a1406;
}
.jokers i.used { background: var(--stage-3); color: var(--stage-3); }
.player .pts {
  grid-row: 1 / span 2; grid-column: 2; font-family: var(--display); font-size: clamp(34px, 6vh, 56px);
  line-height: 1; font-variant-numeric: tabular-nums; min-width: 1.3ch; text-align: right;
}
.player .pts.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--rosin); } }
.player .adj { display: flex; gap: 4px; }
.player .adj button { background: var(--stage-3); border: 0; border-radius: 6px; width: 26px; height: 20px; font-size: 12px; font-weight: 800; color: var(--muted); line-height: 1; padding: 0; }
.player .adj button:hover { color: var(--ink); }

/* Zona de juego */
.arena {
  min-height: 0;
  display: grid;
  grid-template-columns: var(--wheel) minmax(0, 1fr) clamp(180px, 19vw, 260px);
  gap: 18px;
}
.wheel-box { display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 0; }
.wheel-holder { position: relative; width: var(--wheel); height: var(--wheel); flex: none; }
#wheel { width: 100%; height: 100%; display: block; }
.pointer {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%); z-index: 2;
  border-left: 18px solid transparent; border-right: 18px solid transparent; border-top: 34px solid var(--rosin);
  filter: drop-shadow(0 3px 0 var(--varnish-dark));
}
.spin {
  font-family: var(--display); font-size: clamp(22px, 3.4vh, 28px);
  background: var(--varnish); color: #2a1406; border: 0; border-radius: 999px;
  padding: 10px 40px; box-shadow: 0 5px 0 var(--varnish-dark); transition: transform .1s, box-shadow .1s, opacity .2s;
}
.spin:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--varnish-dark); }
.spin:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.card {
  background: var(--stage-2); border-radius: var(--radius);
  padding: clamp(14px, 2.6vh, 26px);
  display: flex; flex-direction: column; gap: clamp(10px, 1.8vh, 16px);
  min-width: 0; min-height: 0; overflow: auto;
}
.card .kind {
  align-self: flex-start; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px; background: var(--k, var(--stage-3)); color: #1b1420;
}
.card .who { color: var(--muted); font-weight: 600; margin: 0; }
.card .who b { color: var(--pc); }
.card h2 { font-family: var(--display); font-weight: 400; font-size: clamp(22px, 4.2vh, 38px); line-height: 1.12; margin: 0; text-wrap: balance; }
.card .desc { margin: 0; font-size: clamp(16px, 2.4vh, 20px); }
.card .hint { color: var(--muted); margin: 0; font-size: 15px; }
.opts { display: grid; gap: clamp(6px, 1.1vh, 10px); }
.opt {
  text-align: left; background: var(--stage-3); border: 2px solid transparent; border-radius: 12px;
  padding: clamp(8px, 1.5vh, 14px) 14px; font-size: clamp(16px, 2.5vh, 20px); font-weight: 600;
  display: flex; gap: 12px; align-items: center;
}
.opt:hover:not(:disabled) { border-color: var(--muted); }
.opt .l { font-family: var(--display); font-weight: 400; color: var(--rosin); width: 1.2em; flex: none; }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 22%, var(--stage-3)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 22%, var(--stage-3)); }
.opt:disabled { cursor: default; }
.vf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vf .opt { justify-content: center; font-family: var(--display); font-weight: 400; font-size: clamp(20px, 3.4vh, 28px); }
.explain { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--stage); font-size: 16px; }
.explain b { color: var(--rosin); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.btn { border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800; font-size: 16px; background: var(--stage-3); }
.btn.ok { background: var(--good); color: #0f2a1a; }
.btn.no { background: var(--bad); color: #2e0d08; }
.btn.pl { background: var(--c); color: #1b1420; }
.btn.next { background: var(--rosin); color: #2a1406; }
.btn.small { padding: 8px 12px; font-size: 14px; font-weight: 600; background: transparent; border: 1.5px solid var(--stage-3); color: var(--muted); }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.timer { display: flex; align-items: center; gap: 12px; }
.timer .t { font-family: var(--display); font-size: clamp(28px, 4.5vh, 40px); font-variant-numeric: tabular-nums; min-width: 2.2ch; }
.timer.low .t { color: var(--bad); }
.bar { flex: 1; height: 10px; background: var(--stage); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--rosin); width: 100%; transition: width 1s linear; }
.idle { display: grid; place-content: center; text-align: center; gap: 10px; flex: 1; color: var(--muted); }
.idle .big { font-family: var(--display); font-size: clamp(28px, 5vh, 44px); color: var(--ink); line-height: 1.1; }
.idle .big b { font-weight: 400; color: var(--pc); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-size: 14px; }
.legend b { color: var(--ink); font-weight: 600; }

/* Stradi */
.buddy { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; min-height: 0; }
.bubble {
  position: relative; width: 100%; background: var(--ink); color: #1b1420; border-radius: 16px;
  padding: 12px 14px; font-weight: 600; font-size: clamp(14px, 2.2vh, 17px); line-height: 1.35;
  min-height: 3.6em; overflow: auto; flex: 0 1 auto; max-height: 40%;
}
.bubble::after {
  content: ""; position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%);
  border-left: 12px solid transparent; border-right: 12px solid transparent; border-top: 14px solid var(--ink);
}
.bubble .from { display: block; font-family: var(--display); font-weight: 400; color: var(--varnish); font-size: 15px; margin-bottom: 2px; }
.stradi-btn { background: none; border: 0; padding: 0; flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; width: 100%; }
#stradi { height: 100%; max-height: 42vh; width: auto; max-width: 100%; overflow: visible; }
#stradi .bob { animation: bob 2.6s ease-in-out infinite; transform-origin: 100px 320px; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
#stradi .eyes { animation: blink 4.5s infinite; transform-origin: 100px 152px; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
#stradi.talk .arm-r { animation: wave .5s ease-in-out infinite alternate; transform-origin: 166px 236px; }
@keyframes wave { to { transform: rotate(-22deg); } }
#stradi.jump .bob { animation: jump .5s ease-out 2; }
@keyframes jump { 40% { transform: translateY(-22px) rotate(4deg); } }
#stradi.sad .bob { animation: droop 1s ease-in-out; }
@keyframes droop { 50% { transform: translateY(6px) rotate(3deg); } }
#stradi [data-mouth] { display: none; }
#stradi[data-face="smile"] [data-mouth="smile"],
#stradi[data-face="open"] [data-mouth="open"],
#stradi[data-face="sad"] [data-mouth="sad"],
#stradi[data-face="wow"] [data-mouth="wow"] { display: inline; }
.joker-btn {
  width: 100%; font-family: var(--display); font-size: clamp(16px, 2.4vh, 19px); font-weight: 400;
  background: var(--rosin); color: #2a1406; border: 0; border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 4px 0 var(--varnish-dark);
}
.joker-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.joker-btn small { display: block; font-family: var(--body); font-size: 12px; font-weight: 600; }

/* Menú inicial y pantalla final */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow: auto;
  background: color-mix(in srgb, var(--stage) 96%, transparent);
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
}
.menu { width: min(560px, 100%); display: grid; gap: 18px; }
.menu h2 { font-family: var(--display); font-weight: 400; font-size: clamp(34px, 6vw, 56px); line-height: 1; margin: 0; color: var(--rosin); text-shadow: 0 3px 0 var(--varnish-dark); }
.menu p { margin: 0; color: var(--muted); }
.menu label.lbl { font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.count { display: flex; gap: 8px; flex-wrap: wrap; }
.count button {
  width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--stage-3); background: var(--stage-2);
  font-family: var(--display); font-size: 24px;
}
.count button[aria-pressed="true"] { background: var(--rosin); color: #2a1406; border-color: var(--rosin); }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.names input {
  width: 100%; min-width: 0; background: var(--stage-2); border: 2px solid var(--stage-3); border-radius: 12px;
  padding: 10px 12px; font: 600 18px var(--body); color: var(--c);
}
.names input:focus { border-color: var(--c); outline: none; }
.lvl { font-family: var(--body); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--stage); background: var(--muted); border-radius: 999px; padding: 4px 10px; vertical-align: middle; text-shadow: none; }
.levels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.levels button { border: 2px solid var(--stage-3); background: var(--stage-2); border-radius: 12px; padding: 10px 6px; display: grid; gap: 2px; text-align: center; }
.levels button b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.levels button span { font-size: 12px; color: var(--muted); }
.levels button[aria-pressed="true"] { background: var(--rosin); border-color: var(--rosin); color: #2a1406; }
.levels button[aria-pressed="true"] span { color: #5b3a10; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--varnish); }
@media (max-width: 480px) { .levels { grid-template-columns: 1fr 1fr; } }
.go { font-family: var(--display); font-size: 26px; background: var(--varnish); color: #2a1406; border: 0; border-radius: 999px; padding: 12px; box-shadow: 0 5px 0 var(--varnish-dark); }
.final-box { display: grid; gap: 14px; justify-items: center; text-align: center; }
.final-box .crown { font-family: var(--display); font-size: clamp(22px, 3vw, 30px); color: var(--muted); }
.final-box .name { font-family: var(--display); font-size: clamp(54px, 10vw, 120px); line-height: 1; color: var(--pc, var(--rosin)); }
.final-box .sub { font-size: 20px; }
.final-box ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 18px; color: var(--muted); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; width: 100%; height: 100%; }

/* Pantallas estrechas o bajas: se apila y se permite desplazar */
@media (max-width: 899px), (max-height: 520px) {
  body { overflow: auto; }
  .wrap { height: auto; grid-template-rows: none; }
  .scores { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .arena { grid-template-columns: minmax(0, 1fr); }
  .buddy { flex-direction: row; align-items: center; }
  .buddy .stradi-btn { flex: 0 0 110px; }
  #stradi { height: 170px; max-height: none; }
  .bubble { max-height: none; }
  .bubble::after { display: none; }
  .buddy .joker-btn { width: auto; }
  .buddy-side { display: grid; gap: 8px; flex: 1; min-width: 0; }
}
@media (min-width: 900px) and (min-height: 521px) { .buddy-side { display: contents; } }
@media (max-width: 480px) { .vf, .names { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

a.ghost { text-decoration: none; display: inline-flex; align-items: center; }
