@font-face {
  font-family: "Unbounded";
  src: url("/fonts/unbounded-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --paper: #EFE8FF;      /* papel lila */
  --white: #FFFDF7;      /* sticker */
  --ink: #1A0638;        /* tinta violeta: texto y contornos */
  --ink-soft: #5B4A80;
  --sticker: #FFE53D;
  --pink: #FF5CDB;
  --cyan: #3DF5FF;
  --lime: #C6FF3D;
  --violet: #7B5CFF;
  --good: #00C46A;
  --good-ink: #00804A;
  --bad: #FF2E4D;
  --bad-ink: #D0122F;
  --aura: var(--violet);  /* cambia con el humor del Tribunal */
  --holo: conic-gradient(from 210deg at 50% 50%, var(--pink), var(--violet), var(--cyan), var(--lime), var(--sticker), var(--pink));
  --display: "Unbounded", system-ui, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --line: 3px solid var(--ink);
  --pop: 4px 4px 0 var(--ink);
}
body[data-mood="rebelde"] { --aura: var(--bad); }
body[data-mood="caotico"] { --aura: #00B8A9; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; } /* el orbe y la cinta girada no deben ensanchar la página */
body {
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.09'/%3E%3C/svg%3E"),
    radial-gradient(60% 40% at 85% 0%, #ffd1f4 0%, transparent 70%),
    radial-gradient(50% 35% at 0% 30%, #c9f7ff 0%, transparent 70%),
    var(--paper);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body:has(#screen-game.void) { background: #000; }
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }

.screen { display: none; flex-direction: column; gap: 14px; min-height: calc(100dvh - 28px); }
.screen.active { display: flex; }
[hidden] { display: none !important; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.title { margin: 0; font: 800 1.5rem/1.15 var(--display); }
.lede { margin: 0; font-size: 1.05rem; color: var(--ink-soft); max-width: 34ch; }

/* ---------- Botones: sticker con sombra dura ---------- */
.btn {
  font: 700 1.02rem var(--sans); color: var(--ink); background: var(--white);
  border: var(--line); border-radius: 14px; padding: 14px 18px; box-shadow: var(--pop);
  cursor: pointer; text-align: center; touch-action: manipulation; user-select: none;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, input:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--aura); outline-offset: 3px; }
.btn-primary { background: var(--sticker); font: 800 1.05rem var(--display); }
.btn-ghost { background: transparent; box-shadow: none; border-style: dashed; color: var(--ink-soft); }

/* ---------- Intro ---------- */
#screen-intro { padding-top: 4px; }
.marquee { display: flex; overflow: hidden; margin: 0 -16px; background: var(--ink); color: var(--lime); font: 600 .78rem var(--display); padding: 7px 0; white-space: nowrap; transform: rotate(-1.5deg); }
.marquee span { flex: none; animation: marquee 18s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }

.hero { position: relative; padding: 28px 0 8px; }
.orb { position: absolute; z-index: -1; width: 260px; height: 260px; right: -40px; top: 0; border-radius: 50%; background: var(--holo); filter: blur(28px); opacity: .85; animation: orb 7s ease-in-out infinite alternate; }
@keyframes orb { to { transform: translate(-60px, 40px) rotate(160deg) scale(1.15); } }
.wordmark { margin: 0; font: 900 clamp(3.4rem, 19vw, 5.6rem)/.86 var(--display); letter-spacing: -.04em; color: var(--ink); text-shadow: 4px 4px 0 var(--white), 7px 7px 0 var(--ink); }
.sticker { position: absolute; font: 800 .8rem var(--display); background: var(--white); border: var(--line); border-radius: 8px; padding: 6px 10px; box-shadow: 3px 3px 0 var(--ink); }
/* Stickers en el hueco a la derecha de "aura" y de "battle", sin tapar letras */
.s1 { right: 0; top: 10px; transform: rotate(7deg); background: var(--lime); }
.s2 { right: 18px; top: 66px; transform: rotate(-6deg); font-size: .7rem; background: var(--pink); }
.s3 { right: -6px; top: 128px; font-size: 1.5rem; padding: 2px 7px; transform: rotate(-12deg); border-radius: 50%; }

/* Reto: burbuja de chat del rival */
.chat-msg { align-self: flex-start; max-width: 88%; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) .3s both; }
.chat-head { display: flex; align-items: center; gap: 8px; font-size: .85rem; margin-bottom: 4px; }
.avatar-sm { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--holo); border: 2px solid var(--ink); font: 800 .8rem var(--display); }
.bubble { margin: 0; background: var(--white); border: var(--line); border-radius: 4px 20px 20px 20px; padding: 12px 14px; font-size: 1.05rem; box-shadow: var(--pop); }
.seen { display: block; font-size: .72rem; color: var(--ink-soft); margin: 6px 0 0 4px; }

.intro-form { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.label { font-weight: 700; font-size: .9rem; }
input {
  font: 700 1.2rem var(--sans); color: var(--ink); background: var(--white);
  border: var(--line); border-radius: 14px; padding: 14px; width: 100%; box-shadow: inset 3px 3px 0 #0001;
}
.fineprint { font-size: .74rem; color: var(--ink-soft); margin: auto 0 0; }

/* ---------- Juego: formato story en directo ---------- */
.story { display: grid; gap: 8px; }
.segments { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.segments i { height: 5px; border-radius: 3px; background: #1a063826; overflow: hidden; }
.segments b { display: block; height: 100%; width: 0; background: var(--ink); }
.segments i.done b { width: 100% !important; transition: none !important; }
.story-row { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--white); border: 2px solid var(--ink); outline: 3px solid var(--aura); outline-offset: 1px; }
.handle { font-weight: 800; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.live, .viewers, .avatar, .icon-btn { flex: none; white-space: nowrap; }
.verified { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #3897F0; color: #fff; font-size: .62rem; }
.live { background: var(--bad); color: #fff; font: 800 .62rem var(--display); padding: 3px 6px; border-radius: 5px; animation: blink 1.6s steps(2) infinite; }
.viewers { color: var(--ink-soft); font-weight: 700; margin-left: auto; font-variant-numeric: tabular-nums; }
.icon-btn { background: none; border: 0; font-size: 1.15rem; padding: 4px; cursor: pointer; }
.score-pill { justify-self: start; background: var(--ink); color: var(--white); font: 800 .82rem var(--display); padding: 5px 12px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.score-pill.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.25) rotate(-3deg); background: var(--aura); } }

.stage {
  position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center;
  gap: 14px; text-align: center; padding-bottom: 96px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.test-title { margin: 0; font: 800 1.35rem/1.15 var(--display); }
.test-text { margin: 0; font-size: 1.02rem; }
.muted { color: var(--ink-soft); }
.options { display: grid; gap: 10px; }
.opt { font-weight: 700; }
.opt.on { background: var(--lime); transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

/* Chat en directo */
.chat { position: fixed; left: max(12px, calc(50% - 228px)); bottom: max(12px, env(safe-area-inset-bottom)); width: min(300px, 74vw); margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; pointer-events: none; z-index: 5; }
.chat li { justify-self: start; background: #1a0638d9; color: var(--white); font-size: .78rem; padding: 4px 10px; border-radius: 12px; animation: chatin .25s ease-out; }
.chat li:nth-last-child(n+3) { opacity: .55; }
.chat b { color: var(--lime); font-weight: 700; }
@keyframes chatin { from { transform: translateX(-20px); opacity: 0; } }
#screen-game.void .story, #screen-game.void .chat { visibility: hidden; }

/* ---------- Veredicto: el momento estrella ---------- */
.verdict { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; overflow: hidden; }
.verdict.good.bg-1, .verdict.neutral { background: var(--holo); }
.verdict.good.bg-2 { background: var(--lime); }
.verdict.good.bg-3 { background: var(--sticker); }
.verdict.bad.bg-1 { background: var(--bad); }
.verdict.bad.bg-2 { background: var(--ink); }
.verdict.bad.bg-3 { background: repeating-linear-gradient(-45deg, var(--bad) 0 22px, var(--ink) 22px 44px); }
.verdict.neutral.bg-2 { background: var(--cyan); }
.verdict.neutral.bg-3 { background: var(--pink); }
.verdict-card {
  position: relative; max-width: 380px; width: 100%; background: var(--white); border: var(--line); border-radius: 20px;
  box-shadow: 8px 8px 0 var(--ink); padding: 26px 20px 22px; text-align: center; transform: rotate(var(--tilt, -2deg));
  animation: pop .3s cubic-bezier(.3, 1.6, .5, 1);
}
.caption { position: absolute; top: -16px; left: 50%; transform: translateX(-50%) rotate(-3deg); white-space: nowrap; background: var(--ink); color: var(--lime); font: 800 .78rem var(--display); padding: 6px 12px; border-radius: 8px; }
.caption:empty { display: none; }
.verdict-delta { display: inline-block; font: 900 2.5rem/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.verdict.good .verdict-delta { color: var(--good-ink); }
.verdict.bad .verdict-delta { color: var(--bad-ink); }
.verdict.neutral .verdict-delta { font-size: 1.7rem; }
.verdict-msg { margin: 12px 0 0; font-size: 1.1rem; white-space: pre-line; }

/* Estilos de revelado (se sortea uno por veredicto) */
.reveal-stamp .verdict-delta { border: 5px double currentColor; border-radius: 10px; padding: 6px 12px; transform: rotate(-7deg); animation: stamp .35s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes stamp { from { transform: scale(2.8) rotate(-24deg); opacity: 0; } }
.reveal-glitch .verdict-delta { animation: glitch .5s steps(2) 2; }
@keyframes glitch { 0% { text-shadow: -4px 0 var(--cyan), 4px 0 var(--pink); transform: translate(2px, -1px); } 50% { text-shadow: 4px 0 var(--cyan), -4px 0 var(--pink); transform: translate(-3px, 1px) skewX(-8deg); } 100% { text-shadow: none; transform: none; } }
.reveal-punch .verdict-delta { animation: punch .45s cubic-bezier(.3, 2, .5, 1); }
@keyframes punch { from { transform: scale(.2); } 60% { transform: scale(1.25); } }
.verdict.bad .verdict-card { animation: pop .3s cubic-bezier(.3, 1.6, .5, 1), shake .4s .3s; }

.verdict-stickers { position: absolute; inset: 0; pointer-events: none; }
.rsticker { position: absolute; font-size: calc(2.2rem * var(--s)); filter: drop-shadow(3px 3px 0 var(--ink)); transform: rotate(var(--r)); animation: pop .3s cubic-bezier(.3, 1.8, .5, 1) both; }

/* Partículas */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.particle { position: absolute; font-size: 1.6rem; animation: fly .95s cubic-bezier(.15, .7, .3, 1) both; }
@keyframes fly { from { transform: translate(-50%, -50%) scale(.2); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--r)) scale(var(--s)); opacity: 0; } }
.drop { position: absolute; top: -60px; font-size: calc(1.6rem * var(--s)); animation: fall linear both; }
@keyframes fall { to { transform: translateY(calc(100vh + 120px)) rotate(var(--r)); } }

/* Notificación push */
.notif {
  position: fixed; z-index: 40; top: max(10px, env(safe-area-inset-top)); left: 50%; width: min(440px, calc(100% - 20px));
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px;
  background: #fffdf7f0; border: 2px solid var(--ink); box-shadow: var(--pop); backdrop-filter: blur(8px);
  transform: translate(-50%, -150%); transition: transform .4s cubic-bezier(.3, 1.4, .5, 1); pointer-events: none;
}
.notif.show { transform: translate(-50%, 0); }
.notif-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--holo); font-size: 1.1rem; flex: none; }
.notif-text { display: grid; font-size: .85rem; line-height: 1.3; flex: 1; }
.notif-time { align-self: flex-start; font-size: .72rem; color: var(--ink-soft); }

/* ---------- Pruebas ---------- */
.arena { position: relative; height: 320px; border: 3px dashed var(--ink); border-radius: 18px; background: #fffdf780; }
.runaway { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 190px; transition: left .12s, top .12s; }
.runaway.moved { transform: none; }
.progress { height: 26px; background: var(--white); border: var(--line); border-radius: 13px; overflow: hidden; box-shadow: var(--pop); }
.progress-fill { height: 100%; width: 0; background: var(--holo); }
.progress-pct { font: 900 2.6rem var(--display); }
.inkblot { width: min(240px, 64vw); aspect-ratio: 1; margin: 0 auto; border-radius: 18px; background: var(--white); border: var(--line); box-shadow: var(--pop); }
.fake-alert { position: absolute; inset: 12% 0 auto; margin: auto; max-width: 340px; background: var(--white); border: var(--line); border-radius: 16px; box-shadow: 8px 8px 0 var(--bad); text-align: left; animation: glitch-box 2s infinite; z-index: 2; }
.fake-alert header { background: var(--bad); color: #fff; font: 800 .8rem var(--display); padding: 8px 12px; border-radius: 12px 12px 0 0; }
.fake-alert p { margin: 0; padding: 14px; }
.fake-alert .options { padding: 0 14px 14px; }
.code-display { font: 900 2rem var(--display); letter-spacing: .25em; min-height: 3rem; border-bottom: var(--line); }
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keys .btn { padding: 13px 0; font-family: var(--display); }
.dot { width: 14px; height: 14px; margin: 0 auto; border-radius: 50%; background: #fff; animation: blink 1s steps(2) infinite; }
#screen-game.void .test-text { color: #8d8d8d; }
.bolt { font-size: 6.5rem; line-height: 1; min-height: 6.5rem; }
.mash { width: 200px; height: 200px; margin: 0 auto; border-radius: 50%; font-size: 1.4rem; }
.counter { font: 900 2.8rem var(--display); font-variant-numeric: tabular-nums; }
.counter.big { font-size: 4.6rem; min-height: 5.6rem; }
.core { width: 190px; height: 190px; margin: 0 auto; border-radius: 50%; border: var(--line); background: var(--white); box-shadow: var(--pop); display: grid; place-items: center; position: relative; touch-action: none; cursor: pointer; overflow: hidden; }
.core::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--holo); transform: scale(0); transition: transform .2s; }
.core.hold::before { transform: scale(1); transition: transform 3s linear; }
.core span { position: relative; font: 800 1rem var(--display); }
.core.plain::before { display: none; }
.core.pressed { background: var(--lime); transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.forbidden { width: 200px; height: 200px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 38% 32%, #ff8a9c, var(--bad) 55%, #9d0019); border: 4px solid var(--ink); color: #fff; font: 900 1.15rem var(--display); box-shadow: 0 10px 0 var(--ink); cursor: pointer; }
.forbidden:active { transform: translateY(8px); box-shadow: 0 2px 0 var(--ink); }
.doors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.doors .btn { font-size: 2.6rem; padding: 24px 0; }
.track { position: relative; height: 60px; background: var(--white); border: var(--line); border-radius: 12px; overflow: hidden; touch-action: manipulation; cursor: pointer; box-shadow: var(--pop); }
.zone { position: absolute; top: 0; bottom: 0; background: var(--lime); border-inline: 3px solid var(--ink); }
.needle { position: absolute; top: 0; bottom: 0; width: 5px; margin-left: -2px; background: var(--ink); }
.bomb { margin: 24px auto 0; min-width: 230px; font: 900 1.25rem var(--display); transition: transform .05s; }
.command { font: 900 2.1rem/1.1 var(--display); min-height: 2.6rem; }
.sketch { width: min(290px, 78vw); aspect-ratio: 1; margin: 0 auto; background: var(--white); border: var(--line); border-radius: 18px; box-shadow: var(--pop); touch-action: none; cursor: crosshair; }
.emoji-row { font-size: 3.4rem; letter-spacing: .1em; }
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cell { font-size: 1.7rem; padding: 7px 0; border-width: 2px; box-shadow: 2px 2px 0 var(--ink); border-radius: 10px; }
.stroop-word { font: 900 2.6rem var(--display); background: var(--ink); border-radius: 16px; padding: 18px 8px; }
.rule { font-weight: 800; }
.rule.flip { color: var(--aura); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.swatch { height: 64px; }
.contract { max-height: 170px; overflow-y: auto; text-align: left; font: .82rem/1.5 var(--sans); background: var(--white); border: var(--line); border-radius: 12px; padding: 4px 12px; user-select: text; -webkit-user-select: text; }
.contract p { margin: 8px 0; }
.secret-word { cursor: pointer; }
.spin { animation: spin .25s linear infinite; }
@keyframes spin { to { transform: rotateY(360deg); } }

/* ---------- Foto ---------- */
#screen-media { justify-content: center; }
.scan-frame { position: relative; width: min(280px, 75vw); aspect-ratio: 1; margin: 0 auto; border: var(--line); border-radius: 20px; overflow: hidden; box-shadow: 8px 8px 0 var(--aura); }
.scan-frame img { width: 100%; height: 100%; object-fit: cover; filter: contrast(1.15) saturate(1.3); }
.scan-line { position: absolute; left: 0; right: 0; height: 6px; background: var(--holo); box-shadow: 0 0 18px var(--pink); animation: scan 1.1s ease-in-out infinite alternate; }
.scan-msg { text-align: center; font-weight: 700; }

/* ---------- Resultado ---------- */
#screen-result { text-align: center; justify-content: center; padding-top: 10px; }
.res-name { margin: 0; font-weight: 800; color: var(--ink-soft); }
.res-score { font: 900 clamp(2.4rem, 13vw, 4.2rem)/1 var(--display); /* Unbounded es ancha: -100,000 debe caber en 358px */ letter-spacing: -.03em; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; font-variant-numeric: tabular-nums; }
.res-score.good { color: var(--good); }
.res-score.bad { color: var(--bad); }
.res-unit { margin: -6px 0 0; font: 700 .95rem var(--display); }
.stamp-wrap { padding: 8px 0; }
.stamp { display: inline-block; margin: 0; font: 900 1.35rem/1.15 var(--display); padding: 10px 16px; border: 5px double currentColor; border-radius: 12px; transform: rotate(-4deg); animation: stamp .45s cubic-bezier(.2, 1.8, .4, 1) .5s both; }
.stamp.good { color: var(--good-ink); }
.stamp.bad { color: var(--bad-ink); }
.res-phrase { margin: 0; font-size: 1.05rem; font-style: italic; }
.res-mood { margin: 0; justify-self: center; align-self: center; background: var(--ink); color: var(--white); font-weight: 700; font-size: .85rem; padding: 5px 12px; border-radius: 999px; }
.duel { background: var(--white); border: var(--line); border-radius: 16px; box-shadow: var(--pop); padding: 14px; }
.duel-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font: 800 .85rem var(--display); }
.duel-row span:not(.vs) { flex: 1; overflow-wrap: anywhere; }
.vs { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--sticker); border: var(--line); font-size: .8rem; transform: rotate(-10deg); }
.duel-headline { margin: 10px 0 0; }
.log { list-style: none; padding: 0; margin: 0; text-align: left; font-size: .88rem; display: grid; gap: 6px; }
.log li { display: flex; gap: 10px; background: #fffdf7b3; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 10px; }
.log b { font: 800 .8rem var(--display); min-width: 6.4em; padding-top: 2px; }
.toast { margin: 0; font-weight: 800; color: var(--good-ink); }

/* ---------- Animaciones comunes ---------- */
@keyframes shake { 0%,100% { translate: 0; } 25% { translate: -7px; } 75% { translate: 7px; } }
@keyframes pop { from { scale: .6; opacity: 0; } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes scan { from { top: 0; } to { top: calc(100% - 6px); } }
@keyframes glitch-box { 0%,92%,100% { translate: 0; } 94% { translate: 3px -2px; } 97% { translate: -3px 1px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
