/* ============================================================
   Trivial de Espinosa de Henares — estilo "cartel de fiestas"
   Papel crema, tinta azul marino, cuatro colores de verbena.
   ============================================================ */
:root {
  --paper: #f3e7ce;
  --paper-2: #e8d7b0;
  --cream: #fff9ea;
  --ink: #1d2433;
  --ink-soft: #4b5468;
  --c0: #c93d20;   /* terracota  ▲ */
  --c1: #2b6c99;   /* azul Henares ◆ */
  --c2: #edb125;   /* mostaza    ● */
  --c3: #4f7b2f;   /* verde olivo ■ */
  --ok: #2f8f5b;
  --bad: #c0392b;
  --radius: 18px;
  --shadow: 5px 5px 0 var(--ink);
  --display: "Alfa Slab One", "Rockwell", Georgia, serif;
  --body: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.35;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(29, 36, 51, .10) 1.1px, transparent 1.6px),
    radial-gradient(1200px 600px at 85% -10%, rgba(237, 177, 37, .35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(43, 108, 153, .18), transparent 60%);
  background-size: 15px 15px, auto, auto;
  background-attachment: fixed;
  overflow-x: hidden;
}

h1, h2, h3, .display { font-family: var(--display); font-weight: 400; letter-spacing: .01em; margin: 0; }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- banderines ---------- */
.bunting {
  position: fixed; inset: 0 0 auto 0; height: 58px; z-index: 5;
  display: flex; pointer-events: none; overflow: hidden;
}
.bunting::before {   /* la cuerda */
  content: ""; position: absolute; left: -2%; right: -2%; top: 6px; height: 3px;
  background: var(--ink); border-radius: 3px;
}
.bunting i {
  flex: 0 0 44px; height: 46px; margin: 7px 3px 0; background: var(--c);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0; animation: sway 3.4s ease-in-out var(--d) infinite alternate;
}
@keyframes sway { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

/* ---------- piezas ---------- */
.card {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.sticker {
  display: inline-block; font-family: var(--display); background: var(--c0); color: var(--cream);
  border: 3px solid var(--ink); border-radius: 12px; box-shadow: 4px 4px 0 var(--ink);
  padding: .15em .55em; transform: rotate(-3deg); line-height: 1.05;
}
.btn {
  appearance: none; cursor: pointer; font-weight: 800; font-size: 1.05rem;
  background: var(--c2); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--ink);
  padding: .8em 1.3em; transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { font-size: 1.3rem; padding: .85em 1.4em; width: 100%; }
.btn.ghost { background: var(--cream); }
.btn.green { background: var(--c3); color: #fff; }
.btn.small { font-size: .9rem; padding: .5em .9em; box-shadow: 3px 3px 0 var(--ink); }

.field { display: block; margin: 0 0 1rem; }
.field > span { display: block; font-weight: 800; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .35rem; }
.field input, .field select {
  width: 100%; background: #fff; border: 3px solid var(--ink); border-radius: 14px;
  padding: .75em .9em; font-size: 1.25rem; font-weight: 700; outline: none;
}
.field input:focus, .field select:focus { box-shadow: 0 0 0 4px var(--c2); }
.pin-input { font-family: var(--display); font-size: 2rem !important; letter-spacing: .3em; text-align: center; }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 600; margin: 0 0 1.1rem; cursor: pointer; }
.check input { width: 1.3rem; height: 1.3rem; accent-color: var(--c3); }
.error { min-height: 1.4em; margin: 0 0 .8rem; color: var(--bad); font-weight: 800; }
.hint { color: var(--ink-soft); font-weight: 600; }

/* formas de respuesta: accesibles aunque no se distingan los colores */
.shape { display: inline-block; width: 1em; height: 1em; background: currentColor; flex: 0 0 auto; }
.shape.s0 { clip-path: polygon(50% 6%, 98% 94%, 2% 94%); }
.shape.s1 { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.shape.s2 { border-radius: 50%; }
.shape.s3 { transform: scale(.86); border-radius: 2px; }

/* ---------- vistas ---------- */
.view { animation: rise .38s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }

.opt {
  --bg: var(--c0); --fg: #fff;
  position: relative; display: flex; align-items: center; gap: .9rem; overflow: hidden; text-align: left; width: 100%;
  background: var(--bg); color: var(--fg); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--ink);
  padding: .9rem 1rem; font-weight: 800; font-size: 1.15rem; line-height: 1.2;
  transition: transform .12s, opacity .25s, filter .25s, box-shadow .12s;
}
.opt.o0 { --bg: var(--c0); } .opt.o1 { --bg: var(--c1); }
.opt.o2 { --bg: var(--c2); --fg: var(--ink); } .opt.o3 { --bg: var(--c3); }
.opt .shape { font-size: 1.5em; z-index: 1; }
.opt .txt { flex: 1; z-index: 1; overflow-wrap: anywhere; }
.opt .bar { position: absolute; inset: 0 auto 0 0; width: calc(var(--p, 0) * 1%); background: rgba(0, 0, 0, .22); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.opt.o2 .bar { background: rgba(0, 0, 0, .14); }
.opt .cnt { z-index: 1; font-family: var(--display); font-size: 1.3em; min-width: 1.4em; text-align: right; }
.opt.dim { opacity: .38; filter: saturate(.5); box-shadow: 2px 2px 0 var(--ink); }
.opt.right { animation: pop .5s ease-out both; outline: 5px solid var(--ok); outline-offset: 3px; }
.opt.right::after { content: "✔"; z-index: 1; font-size: 1.5em; margin-left: .3rem; }
.opt.mine { outline: 4px dashed var(--ink); outline-offset: 3px; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }

.timer-bar { height: 14px; background: rgba(29, 36, 51, .14); border: 3px solid var(--ink); border-radius: 99px; overflow: hidden; }
.timer-bar > i { display: block; height: 100%; width: 100%; background: var(--c3); transform-origin: left; will-change: transform; }
.timer-bar.low > i { background: var(--c0); }
.timer-num { font-family: var(--display); font-size: 1.8rem; min-width: 2ch; text-align: center; }

.slam { animation: slam .55s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes slam { 0% { transform: scale(2.4); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1); } }
@keyframes blink { 50% { opacity: .25; } }
.dots span { animation: blink 1.2s infinite; } .dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }

.conn-flag {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--cream); font-weight: 800; padding: .5em 1em; border-radius: 99px;
}

/* ============================================================
   JUGADOR (móvil)
   ============================================================ */
.player main { max-width: 520px; margin: 0 auto; padding: 78px 18px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 1.1rem; min-height: 100dvh; }
.brand { text-align: center; margin: .3rem 0 .4rem; }
.brand .sticker { font-size: clamp(2.6rem, 14vw, 3.6rem); }
.brand p { margin: .7rem 0 0; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: .9rem; }
.big-center { text-align: center; }
.big-center h2 { font-size: 2rem; }
.big-center .num { font-family: var(--display); font-size: clamp(6rem, 38vw, 11rem); line-height: 1; }
.p-q { display: grid; gap: .9rem; }
.p-q h2 { font-size: 1.45rem; line-height: 1.2; }
.p-head { display: flex; align-items: center; gap: .8rem; }
.p-head .timer-bar { flex: 1; }
.p-head .k { font-weight: 800; white-space: nowrap; }
.p-opts { display: grid; gap: .8rem; }
.p-opts .opt { font-size: 1.2rem; padding: 1.05rem 1rem; cursor: pointer; }
.p-opts .opt:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.p-opts .opt:disabled { cursor: default; }
.wait-note { text-align: center; font-weight: 800; }
.result { text-align: center; }
.result .mark { font-family: var(--display); font-size: 5.5rem; line-height: 1; }
.result.ok .mark { color: var(--ok); } .result.ko .mark { color: var(--bad); } .result.none .mark { color: var(--ink-soft); }
.result .pts { font-family: var(--display); font-size: 3rem; }
.result .rank { font-weight: 800; font-size: 1.15rem; }
.fact { margin-top: 1rem; background: var(--paper-2); border: 3px dashed var(--ink); border-radius: 14px; padding: .8rem 1rem; text-align: left; font-weight: 600; }
.fact b { font-family: var(--display); font-weight: 400; display: block; margin-bottom: .2rem; }
.podium-mini { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .5rem; text-align: left; counter-reset: p; }
.podium-mini li { display: flex; gap: .7rem; align-items: center; background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; padding: .5rem .8rem; font-weight: 800; }
.podium-mini li::before { counter-increment: p; content: counter(p); font-family: var(--display); width: 1.6em; height: 1.6em; display: grid; place-items: center; background: var(--c2); border: 2px solid var(--ink); border-radius: 50%; }
.podium-mini li span:nth-child(1) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   ANFITRIÓN (pantalla grande)
   ============================================================ */
.host { --u: clamp(14px, 1.45vw, 28px); font-size: calc(var(--u) * 1.15); }
.host main { padding: 72px calc(var(--u) * 2) 110px; min-height: 100dvh; }
.h-login { max-width: 560px; margin: 4vh auto 0; }
.h-login h1 { font-size: 2.6rem; margin-bottom: .3rem; }

.h-lobby { display: grid; grid-template-columns: minmax(300px, 34%) 1fr; gap: calc(var(--u) * 2); align-items: start; }
.h-join { text-align: center; }
.h-join .lbl { font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: .8em; }
.h-join .url { font-weight: 800; font-size: 1.05em; word-break: break-all; }
.h-pin { font-family: var(--display); font-size: clamp(2.6rem, min(6.5vw, 10vh), 7rem); line-height: 1.05; letter-spacing: .06em; margin: .1em 0 .25em; color: var(--c0); text-shadow: 3px 3px 0 var(--ink); }
.qr { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 12px; width: min(100%, 360px, 40vh); margin: 0 auto .6rem; line-height: 0; }
.h-join { padding: 1rem 1.25rem; }
.qr svg { width: 100%; height: auto; }
.h-who h2 { font-size: clamp(1.8rem, 3.2vw, 3.4rem); margin-bottom: .6em; }
.chips { display: flex; flex-wrap: wrap; gap: .6em; }
.chip {
  display: inline-flex; align-items: center; gap: .4em; background: var(--c2); color: var(--ink); font-weight: 800;
  border: 3px solid var(--ink); border-radius: 99px; padding: .25em .9em; box-shadow: 3px 3px 0 var(--ink);
  animation: pop-in .45s cubic-bezier(.2, 1.5, .4, 1) both; font-size: 1.05em;
}
.chip:nth-child(4n+1) { background: var(--c2); } .chip:nth-child(4n+2) { background: #f5a38d; }
.chip:nth-child(4n+3) { background: #9cc4dd; } .chip:nth-child(4n) { background: #b9d49a; }
.chip button { all: unset; cursor: pointer; font-weight: 800; opacity: .35; padding: 0 .1em; }
.chip:hover button { opacity: 1; }
@keyframes pop-in { from { transform: scale(.2) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.empty-note { font-size: 1.2em; font-weight: 700; color: var(--ink-soft); }

.h-count { text-align: center; padding-top: 6vh; }
.h-count .k { font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.h-count .num { font-family: var(--display); font-size: clamp(10rem, 36vh, 26rem); line-height: 1; color: var(--c0); text-shadow: 6px 6px 0 var(--ink); }
.h-count h2 { font-size: clamp(1.8rem, 3.4vw, 3.6rem); }

.h-top { display: flex; align-items: center; gap: calc(var(--u) * 1.2); margin-bottom: calc(var(--u) * 1.2); }
.h-top .k { font-weight: 800; white-space: nowrap; font-size: 1.1em; }
.h-top .timer-bar { flex: 1; height: 22px; }
.h-top .timer-num { font-size: 2.6em; }
.h-top .answered { font-weight: 800; white-space: nowrap; background: var(--cream); border: 3px solid var(--ink); border-radius: 99px; padding: .2em .9em; }
.h-qtext { font-size: clamp(1.8rem, 3.6vw, 4rem); line-height: 1.12; margin: 0 0 calc(var(--u) * 1.4); max-width: 26em; }
.h-opts { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 1); }
.h-opts .opt { font-size: clamp(1.2rem, 2.3vw, 2.5rem); padding: calc(var(--u) * 1.1) calc(var(--u) * 1.2); min-height: 4.2em; border-radius: 22px; box-shadow: 6px 6px 0 var(--ink); }
.h-reveal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 34%); gap: calc(var(--u) * 1.6); align-items: start; }
.h-side h3 { font-size: 1.7em; margin-bottom: .5em; }
.h-side .hint { margin: .6em 0 0; }
.lb { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .5em; }
.lb li { min-width: 0; display: flex; align-items: center; gap: .6em; background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: .35em .8em; font-weight: 800; animation: rise .4s both; }
.lb li .pos { font-family: var(--display); width: 1.7em; height: 1.7em; display: grid; place-items: center; border-radius: 50%; background: var(--c2); border: 2px solid var(--ink); flex: 0 0 auto; }
.lb li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb li .sc { font-family: var(--display); }
.lb li .gain { color: var(--ok); font-size: .8em; }
.lb li:nth-child(1) .pos { background: #f4c542; } .lb li:nth-child(2) .pos { background: #cfd4da; } .lb li:nth-child(3) .pos { background: #d79a63; }
.h-fact { margin-top: calc(var(--u) * 1.2); max-width: 46em; }

.h-final { text-align: center; }
.h-final h1 { font-size: clamp(2.4rem, 5vw, 5.5rem); margin-bottom: .2em; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: calc(var(--u) * 1.2); margin: calc(var(--u) * 1.5) 0; min-height: 40vh; }
.podium .step { width: min(26%, 340px); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.podium .who { font-weight: 800; font-size: 1.4em; margin-bottom: .2em; max-width: 100%; text-align: center; line-height: 1.1; overflow-wrap: anywhere; }
.podium .pts { font-family: var(--display); margin-bottom: .3em; }
.podium .block {
  width: 100%; border: 3px solid var(--ink); border-radius: 16px 16px 0 0; box-shadow: 5px 5px 0 var(--ink);
  display: grid; place-items: start center; padding-top: .3em; font-family: var(--display); font-size: 3.4em; background: var(--c2);
  transform-origin: bottom; animation: grow 1s cubic-bezier(.2, .9, .3, 1) both;
}
.podium .p1 .block { height: 30vh; background: #f4c542; animation-delay: 1.4s; }
.podium .p2 .block { height: 21vh; background: #cfd4da; animation-delay: .7s; }
.podium .p3 .block { height: 14vh; background: #d79a63; animation-delay: 0s; }
.podium .step > .who, .podium .step > .pts { animation: rise .6s both; }
.podium .p1 > .who, .podium .p1 > .pts { animation-delay: 2.2s; }
.podium .p2 > .who, .podium .p2 > .pts { animation-delay: 1.5s; }
.podium .p3 > .who, .podium .p3 > .pts { animation-delay: .8s; }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.h-final .lb { max-width: 640px; margin: 0 auto; text-align: left; }

.h-bar {
  position: fixed; inset: auto 0 0 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  padding: .8rem calc(var(--u) * 2); background: var(--ink); color: var(--cream);
}
.h-bar .meta { flex: 1; font-weight: 700; font-size: .85em; opacity: .9; }
.h-bar .meta b { font-family: var(--display); font-weight: 400; letter-spacing: .08em; }
.h-bar .btn { box-shadow: 4px 4px 0 var(--c0); }
.h-bar .btn.ghost { background: transparent; color: var(--cream); border-color: var(--cream); box-shadow: none; }

@media (max-width: 860px) {
  .h-lobby, .h-reveal { grid-template-columns: 1fr; }
  .h-opts { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
