@font-face {
  font-family: 'Bungee';
  src: url('/fonts/bungee-latin-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --y: #FFD60A;
  --y-dark: #A88B00;
  --p: #FF3D7F;
  --p-dark: #B0204F;
  --ink: #0F0F14;
  --ink-2: #17171F;
  --coal: #26262F;
  --cream: #FFF8E7;
  --muted: rgba(255, 248, 231, 0.66);
  --line: rgba(255, 248, 231, 0.14);
  --display: 'Bungee', Impact, 'Arial Black', sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--ink); color: var(--cream); font-family: var(--body); -webkit-tap-highlight-color: transparent; }
html, body { overflow-x: hidden; }
body { min-height: 100dvh; overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; }
a { color: var(--y); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--y); outline-offset: 2px; }

#app {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 16px);
}

/* ---------- Cabecera ---------- */
.top { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; }
.logo {
  justify-self: center;
  font-family: var(--display);
  font-size: clamp(28px, 8.4vw, 38px);
  color: var(--y);
  text-decoration: none;
  letter-spacing: 1px;
  text-shadow: 3px 3px 0 var(--p);
  line-height: 1;
}
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--ink-2);
  display: grid; place-items: center;
  font-size: 20px;
  color: var(--cream);
}

/* ---------- Packs ---------- */
.packbar {
  display: flex; gap: 8px;
  overflow-x: auto;
  margin: 12px -16px 0;
  padding: 2px 16px 6px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.packbar::-webkit-scrollbar { display: none; }
.pchip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  border: 2px solid var(--line);
  background: var(--ink-2);
  color: var(--cream);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}
.pchip[aria-pressed="true"] { background: var(--y); color: var(--ink); border-color: var(--y); }
.pchip.add { border-style: dashed; color: var(--muted); }

/* ---------- Turnos ---------- */
.turnbar {
  margin-top: 10px;
  background: var(--ink-2);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
}
.turn-now { font-weight: 800; font-size: 16px; }
.turn-now b { font-family: var(--display); font-weight: 400; color: var(--y); font-size: 20px; letter-spacing: .5px; }
.turn-now span { color: var(--muted); font-size: 13px; }
.turn-scores { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; scrollbar-width: none; }
.turn-scores::-webkit-scrollbar { display: none; }
.tscore { flex: 0 0 auto; background: var(--coal); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 700; }
.tscore.now { background: var(--p); color: var(--ink); }

/* ---------- Ruleta ---------- */
.stage {
  position: relative;
  flex: 1 0 auto;
  display: grid;
  place-items: center;
  padding: 18px 0 10px;
  min-height: min(96vw, 58dvh);
  overflow-x: hidden;
  overflow-x: clip;
  overflow-y: visible;
}
.rays {
  position: absolute; inset: -10% -30%;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 248, 231, 0.045) 0 7.5deg, transparent 7.5deg 15deg);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0 30%, transparent 62%);
  mask-image: radial-gradient(circle at 50% 50%, #000 0 30%, transparent 62%);
  pointer-events: none;
}
body.spinning .rays { animation: rays 6s linear infinite; }
@keyframes rays { to { transform: rotate(360deg); } }

.wheel-wrap {
  position: relative;
  width: min(92vw, 500px, 54dvh);
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.wheel-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wheel-canvas { will-change: transform; }
.wheel-wrap::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55), 0 0 0 4px var(--ink);
  pointer-events: none;
}
.wheel-pointer {
  position: absolute;
  left: 50%; top: -4.5%;
  width: 13%; aspect-ratio: 1 / 1.1;
  transform: translateX(-50%);
  transform-origin: 50% 20%;
  z-index: 3;
  filter: drop-shadow(0 4px 0 var(--ink));
}
.wheel-pointer::before, .wheel-pointer::after {
  content: '';
  position: absolute; inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.wheel-pointer::before { background: var(--ink); }
.wheel-pointer::after { background: var(--p); inset: 9% 11% 16%; }
.wheel-pointer.flick { animation: flick .13s ease-out; }
@keyframes flick { 0% { transform: translateX(-50%) rotate(0); } 35% { transform: translateX(-50%) rotate(-18deg); } 100% { transform: translateX(-50%) rotate(0); } }

.hub {
  position: absolute;
  left: 50%; top: 50%;
  width: 26%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 5px solid var(--ink);
  background: var(--p);
  box-shadow: inset 0 0 0 4px var(--y), 0 6px 0 var(--ink);
  font-family: var(--display);
  font-size: clamp(14px, 4.6vw, 24px);
  color: var(--ink);
  z-index: 4;
  transition: transform .12s;
}
.hub:active { transform: translate(-50%, -46%) scale(.96); }
body.spinning .hub { pointer-events: none; }
.hub.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.07); } }

/* ---------- Estado y accesos ---------- */
.status { display: flex; justify-content: center; gap: 18px; font-size: 15px; color: var(--muted); font-weight: 700; margin-top: 4px; }
.status b { color: var(--cream); font-size: 17px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.qbtn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--ink-2);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px 4px;
  font-weight: 800; font-size: 13px;
}
.qbtn span { font-size: 22px; }

/* ---------- Texto para Google ---------- */
.seo { margin-top: 40px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.seo h2 { font-family: var(--display); font-weight: 400; color: var(--cream); font-size: 20px; line-height: 1.25; }
.seo h3 { color: var(--cream); font-size: 17px; margin: 22px 0 8px; }
.seo ol { padding-left: 20px; }
.seo details { border-top: 1px solid var(--line); padding: 10px 0; }
.seo summary { cursor: pointer; color: var(--cream); font-weight: 700; }
.seo details p { margin: 8px 0 0; }
.foot { margin-top: 28px; font-size: 13px; color: var(--muted); line-height: 1.5; text-align: center; }
.foot b { color: var(--cream); }

.watermark { display: none; }
.rec-exit { display: none; }

/* ---------- Capas a pantalla completa ---------- */
.overlay {
  position: fixed; inset: 0;
  z-index: 50;
  background:
    repeating-linear-gradient(-45deg, rgba(255, 248, 231, .025) 0 14px, transparent 14px 28px),
    var(--ink);
  overflow-y: auto;
  display: flex;
  justify-content: center;
}
.ov-inner {
  width: 100%;
  max-width: 560px;
  min-height: 100%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  padding: calc(env(safe-area-inset-top) + 24px) 18px calc(env(safe-area-inset-bottom) + 20px);
  gap: 12px;
}
.overlay:not([hidden]) .ov-inner { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.res-label {
  display: inline-block;
  background: var(--p);
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(18px, 5.4vw, 26px);
  padding: 6px 16px;
  transform: rotate(-3deg);
  box-shadow: 4px 4px 0 var(--y);
}
.res-pack { color: var(--muted); font-weight: 800; font-size: 15px; letter-spacing: .5px; text-transform: uppercase; }
.res-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  color: var(--y);
  font-size: clamp(40px, 13vw, 76px);
  line-height: 1.02;
  text-shadow: 4px 4px 0 var(--p);
  overflow-wrap: anywhere;
}
.res-title.mid { font-size: clamp(30px, 9vw, 52px); }
.res-title.long { font-size: clamp(24px, 7vw, 38px); }
.res-desc { margin: 0; font-size: clamp(20px, 5.8vw, 28px); font-weight: 800; line-height: 1.3; max-width: 30ch; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { background: var(--coal); border-radius: 999px; padding: 7px 14px; font-weight: 800; font-size: 16px; }
.chip-y { background: var(--y); color: var(--ink); }
.doble-badge { background: var(--p); color: var(--ink); font-weight: 900; padding: 8px 14px; border-radius: 10px; font-size: 15px; animation: wiggle 1s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
.res-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiny { color: var(--muted); font-size: 13px; font-weight: 700; margin: 6px 0 0; letter-spacing: .3px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--coal);
  color: var(--cream);
  font-weight: 800; font-size: 16px;
  text-decoration: none;
  box-shadow: 0 4px 0 #000;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.btn b { background: rgba(0, 0, 0, .35); border-radius: 999px; padding: 0 8px; }
.btn-y { background: var(--y); color: var(--ink); border-color: var(--y); box-shadow: 0 5px 0 var(--y-dark); }
.btn-y:active { box-shadow: 0 2px 0 var(--y-dark); }
.btn-p { background: var(--p); color: var(--ink); border-color: var(--p); box-shadow: 0 5px 0 var(--p-dark); }
.btn-p:active { box-shadow: 0 2px 0 var(--p-dark); }
.btn-p[aria-pressed="true"] { outline: 3px solid var(--y); outline-offset: 2px; }
.btn-big { min-height: 64px; font-family: var(--display); font-weight: 400; font-size: clamp(18px, 5.4vw, 24px); }
.btn-ghost { background: transparent; box-shadow: none; min-height: 44px; }
.btn.off { opacity: .45; }

/* ---------- Temporizador ---------- */
.tm-who { color: var(--p); font-family: var(--display); font-size: 18px; }
.tm-title { margin: 0; font-family: var(--display); font-weight: 400; color: var(--y); font-size: clamp(26px, 8vw, 44px); line-height: 1.05; overflow-wrap: anywhere; }
.tm-desc { margin: 0; font-weight: 700; font-size: 17px; color: var(--muted); max-width: 34ch; }
.tm-clock { position: relative; width: min(74vw, 46dvh, 360px); aspect-ratio: 1; margin: 6px 0; }
.tm-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.tm-track { fill: none; stroke: var(--coal); stroke-width: 8; }
.tm-prog { fill: none; stroke: var(--y); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 282.743; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear, stroke .3s; }
.tm-num {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--display);
  font-size: clamp(54px, 19vw, 110px);
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}
.timer.low .tm-prog { stroke: var(--p); }
.timer.low .tm-num { color: var(--p); animation: beat 1s ease-in-out infinite; }
.timer.done .tm-num { font-size: clamp(36px, 12vw, 64px); color: var(--p); }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.tm-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tm-duel { width: 100%; }
.tm-duel p { font-weight: 800; font-size: 18px; margin: 0 0 10px; }
.duel-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Resultado del reto ---------- */
.oc-title { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(34px, 10.5vw, 84px); line-height: 1; color: var(--y); text-shadow: 5px 5px 0 var(--p); overflow-wrap: anywhere; }
.outcome.fail .oc-title { color: var(--p); text-shadow: 5px 5px 0 var(--ink-2); animation: shake .5s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-14px) rotate(-3deg); } 40% { transform: translateX(12px) rotate(2deg); } 60% { transform: translateX(-8px); } 80% { transform: translateX(6px); } }
.oc-pts { font-family: var(--display); font-size: clamp(26px, 8vw, 40px); }
.oc-reto { color: var(--muted); font-weight: 700; font-size: 17px; margin: 0; }

.pd-list { list-style: none; padding: 0; margin: 6px 0; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.pd-list li { display: flex; justify-content: space-between; align-items: center; background: var(--ink-2); border: 2px solid var(--line); border-radius: 14px; padding: 12px 16px; font-weight: 800; font-size: 18px; }
.pd-list li:first-child { background: var(--y); color: var(--ink); border-color: var(--y); font-family: var(--display); font-weight: 400; font-size: 22px; }

/* ---------- Hojas inferiores ---------- */
.sheet { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .62); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--ink-2);
  border: 2px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 22px);
  animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-card h2 { margin: 0; font-family: var(--display); font-weight: 400; color: var(--y); font-size: 22px; }
.sheet-card h3 { font-size: 16px; margin: 18px 0 8px; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 6px 0; }
.field-error { color: var(--p); font-weight: 700; font-size: 14px; margin: 6px 0 0; }

.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-list > button, .menu-list > a, .menu-list > label {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--ink);
  color: var(--cream);
  text-decoration: none;
  font-weight: 800; font-size: 16px;
  text-align: left;
}
.toggle input { width: 22px; height: 22px; accent-color: var(--y); }

.pack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pack-card {
  position: relative;
  text-align: left;
  background: var(--ink);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 4px;
  color: var(--cream);
}
.pack-card .em { font-size: 28px; }
.pack-card b { font-size: 16px; }
.pack-card small { color: var(--muted); font-size: 13px; line-height: 1.35; }
.pack-card .count { font-size: 12px; font-weight: 800; color: var(--y); }
.pack-card[aria-pressed="true"] { border-color: var(--y); }
.pack-card.pro { opacity: .8; border-style: dashed; }
.pack-card.pro::after { content: '🔒 Próximamente'; position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 900; background: var(--p); color: var(--ink); padding: 3px 7px; border-radius: 999px; }
.pro-h { display: flex; align-items: center; gap: 8px; margin-top: 22px !important; }
.soon { background: var(--p); color: var(--ink); font-size: 12px; padding: 3px 8px; border-radius: 999px; font-weight: 900; }

.score-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.score-list li { display: flex; justify-content: space-between; gap: 10px; background: var(--ink); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; font-weight: 800; }
.score-list li.now { border-color: var(--p); }
.score-list small { color: var(--muted); font-weight: 700; }
.add-player { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input, select, textarea {
  width: 100%;
  background: var(--ink);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  color: var(--cream);
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--y); outline: none; }
.player-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.player-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--coal); border-radius: 999px; padding: 6px 6px 6px 12px; font-weight: 800; }
.player-chip button { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--ink); color: var(--cream); }
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rules label, .custom-form > label { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; }
.rules label:nth-child(3):last-child { grid-column: 1 / -1; }
.custom-form { display: flex; flex-direction: column; gap: 12px; }
#btnStartGame { width: 100%; margin-top: 14px; }

.custom-list { display: flex; flex-direction: column; gap: 8px; }
.cw { background: var(--ink); border: 2px solid var(--line); border-radius: 14px; padding: 12px; }
.cw-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cw-head b { font-size: 17px; overflow-wrap: anywhere; }
.cw-head small { color: var(--muted); white-space: nowrap; }
.cw-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.cw-btns .btn { min-height: 42px; font-size: 13px; padding: 6px; box-shadow: none; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

.imp-name { font-family: var(--display); color: var(--cream); font-size: 20px; margin: 4px 0; }
.imp-list { color: var(--muted); padding-left: 20px; max-height: 34dvh; overflow-y: auto; line-height: 1.5; }
.share-prev { display: grid; place-items: center; background: var(--ink); border-radius: 14px; padding: 10px; margin-bottom: 12px; }
.share-prev img { max-height: 52dvh; max-width: 100%; border-radius: 10px; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; display: none; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translate(-50%, 30px);
  background: var(--cream); color: var(--ink);
  font-weight: 800;
  padding: 12px 18px;
  border-radius: 14px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { text-align: center; padding: 20px; }

/* ---------- Modo grabación (9:16 limpio) ---------- */
body.rec .packbar, body.rec .quick, body.rec .seo, body.rec .foot, body.rec #btnMenu, body.rec #btnSound { visibility: hidden; }
body.rec .packbar, body.rec .quick, body.rec .seo, body.rec .foot { display: none; }
body.rec #app {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding-top: calc(env(safe-area-inset-top) + 7dvh);
  padding-bottom: calc(env(safe-area-inset-bottom) + 11dvh);
}
body.rec .logo { font-size: clamp(34px, 10vw, 48px); }
body.rec .stage { min-height: 0; flex: 1 1 auto; }
body.rec .wheel-wrap { width: min(94vw, 56dvh, 600px); }
body.rec .watermark {
  display: block;
  align-self: center;
  margin-top: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 15, 20, .7);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .4px;
}
body.rec .watermark b { font-family: var(--display); font-weight: 400; color: var(--y); }
body.rec .rec-exit {
  display: grid; place-items: center;
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px); right: 10px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(15, 15, 20, .6);
  color: var(--cream);
  opacity: .25;
  z-index: 95;
}
body.rec .rec-exit:hover, body.rec .rec-exit:focus-visible { opacity: 1; }

@media (min-aspect-ratio: 3/4) {
  body.rec { background: #050507; }
  body.rec #app {
    width: calc(100dvh * 9 / 16);
    max-width: 100vw;
    background: var(--ink);
    box-shadow: 0 0 0 1px var(--line);
  }
  body.rec .overlay { left: 50%; right: auto; width: min(100vw, calc(100dvh * 9 / 16)); transform: translateX(-50%); }
  body.rec .wheel-wrap { width: min(calc(100dvh * 9 / 16 - 32px), 56dvh); }
}

@media (min-width: 720px) {
  .seo, .foot { max-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  body.spinning .rays, .hub.pulse, .doble-badge, .timer.low .tm-num { animation: none; }
  .overlay:not([hidden]) .ov-inner, .sheet-card { animation: none; }
}
