@font-face {
  font-family: 'InterBooth';
  src: url('fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'InterBooth';
  src: url('fonts/inter-ext.woff2') format('woff2');
  font-weight: 100 900;
  unicode-range: U+0100-024F, U+1E00-1EFF;
}

:root {
  --bg: #000;
  --surface: #121214;
  --surface-2: #1c1c1e;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --accent: #ff8a3d;
  --accent-soft: rgba(255, 138, 61, 0.16);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'InterBooth', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); overflow: hidden; }
body {
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
  cursor: none;
}
body.pointer { cursor: default; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: inherit; }

/* Mesa de trabajo fija 1920×1080, escalada a la pantalla */
.app {
  position: absolute;
  left: 50%; top: 50%;
  width: 1920px; height: 1080px;
  transform-origin: center;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  background: radial-gradient(1200px 700px at 78% 10%, rgba(255, 138, 61, 0.07), transparent 60%), var(--bg);
  overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  position: absolute; z-index: 20;
  left: 96px; right: 96px; top: 56px;
  display: flex; align-items: center; justify-content: space-between;
  transition: opacity 0.6s var(--ease);
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 24px rgba(255, 138, 61, 0.6); }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.tagline { font-size: 20px; color: var(--text-2); letter-spacing: -0.01em; }
.mode {
  font-size: 14px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 7px 14px; border-radius: 999px;
}
.mode.live { display: none; }
.app[data-screen='countdown'] .topbar { opacity: 0; }

/* ── Cámara ─────────────────────────────────────────── */
.stage {
  position: absolute; z-index: 5;
  left: 96px; top: 150px; width: 1024px; height: 832px;
  border-radius: 36px; overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 40px 120px rgba(0, 0, 0, 0.55);
  transition: all 0.9s var(--ease);
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.6s;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.42), transparent 40%); }
.app[data-screen='countdown'] .stage::after { opacity: 1; }
.app[data-screen='countdown'] .stage { left: 0; top: 0; width: 1920px; height: 1080px; border-radius: 0; }
.app[data-screen='generating'] .stage,
.app[data-screen='result'] .stage { opacity: 0; transform: scale(0.96); pointer-events: none; }

.stage-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-2); font-size: 26px; text-align: center;
}
.stage-empty span { font-size: 18px; color: var(--text-3); }
.stage-empty-icon {
  width: 88px; height: 88px; border-radius: 26px; margin-bottom: 14px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  position: relative;
}
.stage-empty-icon::after {
  content: ''; position: absolute; inset: 26px; border-radius: 50%; border: 3px solid var(--text-3);
}
.cam-on .stage-empty { display: none; }

.live-pill {
  position: absolute; left: 28px; top: 28px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px 10px 16px; border-radius: 999px;
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  background: rgba(0, 0, 0, 0.38); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  transition: opacity 0.4s;
}
.live-pill i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.8s ease-in-out infinite; }
.app[data-screen='countdown'] .live-pill { opacity: 0; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* Silueta del personaje durante la cuenta */
.ghost {
  position: absolute; right: 140px; bottom: 0; width: 520px; height: 960px;
  opacity: 0; transform: translateY(40px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  pointer-events: none;
}
.ghost-shape { position: absolute; left: 50%; bottom: -10px; width: 420px; height: 945px; transform: translateX(-50%); overflow: visible; }
.ghost-shape path {
  fill: rgba(255, 138, 61, 0.10); stroke: var(--accent); stroke-width: 3; stroke-dasharray: 2 12; stroke-linecap: round;
  filter: drop-shadow(0 0 18px rgba(255, 138, 61, 0.55));
  animation: ghostPulse 1.6s ease-in-out infinite;
}
@keyframes ghostPulse { 50% { fill: rgba(255, 138, 61, 0.2); } }
.ghost img {
  position: absolute; left: 50%; top: 99px; transform: translateX(-50%);
  width: 132px; height: 132px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 3px var(--accent), 0 16px 40px rgba(0, 0, 0, 0.5);
}
.ghost span {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); white-space: nowrap;
  font-size: 22px; font-weight: 500; color: var(--text); padding: 12px 22px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.app[data-screen='countdown'] .ghost { opacity: 1; transform: none; }

.count {
  position: absolute; left: 0; top: 0; width: 640px; height: 1080px; display: flex; align-items: center; justify-content: center;
  font-size: 340px; font-weight: 200; letter-spacing: -0.06em; font-variant-numeric: tabular-nums;
  text-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
  pointer-events: none; opacity: 0;
}
.count.tick { animation: tick 1s var(--ease-out) forwards; }
@keyframes tick {
  0% { opacity: 0; transform: scale(1.25); filter: blur(12px); }
  25% { opacity: 1; transform: scale(1); filter: blur(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(0.92); }
}
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash 0.7s ease-out; }
@keyframes flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }

/* ── Pantallas ──────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  opacity: 0; pointer-events: none;
  transition: opacity 0.6s var(--ease);
}
.app[data-screen='select'] .screen-select,
.app[data-screen='generating'] .screen-gen,
.app[data-screen='result'] .screen-result { opacity: 1; pointer-events: auto; }

.eyebrow { font-size: 20px; font-weight: 600; color: var(--accent); letter-spacing: -0.005em; margin-bottom: 14px; }
h1 { font-size: 76px; line-height: 0.98; font-weight: 700; letter-spacing: -0.045em; }
h2 { font-size: 52px; line-height: 1.05; font-weight: 700; letter-spacing: -0.035em; }
.sub { font-size: 24px; color: var(--text-2); letter-spacing: -0.01em; margin-top: 16px; }
.hint { font-size: 18px; color: var(--text-3); margin-top: 18px; font-variant-numeric: tabular-nums; }
kbd {
  font-family: inherit; font-size: 13px; font-weight: 650; letter-spacing: 0.04em;
  padding: 5px 9px; border-radius: 8px; background: rgba(0, 0, 0, 0.14); color: inherit; opacity: 0.75;
}

/* 1 · Selección */
.select-panel { position: absolute; left: 1192px; top: 150px; width: 632px; height: 832px; display: flex; flex-direction: column; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 36px; }
.card {
  position: relative; aspect-ratio: 1 / 1; border-radius: 26px; overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--line);
  transition: transform 0.5s var(--ease), box-shadow 0.35s var(--ease), opacity 0.35s;
  opacity: 0.62;
}
.card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); transition: transform 0.7s var(--ease); }
.card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 52%, rgba(0, 0, 0, 0.82)); }
.card span {
  position: absolute; z-index: 1; left: 16px; bottom: 14px; right: 16px;
  font-size: 19px; font-weight: 600; letter-spacing: -0.015em;
}
.card.on { opacity: 1; transform: scale(1.035); box-shadow: 0 0 0 3px var(--accent), 0 24px 60px rgba(255, 138, 61, 0.22); }
.card.on img { transform: scale(1.1); }
.card.on::before {
  content: ''; position: absolute; z-index: 2; right: 14px; top: 14px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px no-repeat;
}

.cta {
  margin-top: auto; height: 92px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  background: var(--accent); color: #000;
  font-size: 28px; font-weight: 650; letter-spacing: -0.02em;
  box-shadow: 0 18px 50px rgba(255, 138, 61, 0.28);
  transition: transform 0.25s var(--ease), filter 0.25s;
}
.cta:active, .cta.press { transform: scale(0.97); filter: brightness(0.92); }
.cta.small { height: 76px; padding: 0 34px; font-size: 24px; margin-top: 0; flex: 1; }

/* 3 · Generando */
.gen-backdrop {
  position: absolute; inset: -80px; background-size: cover; background-position: center;
  filter: blur(70px) saturate(1.3) brightness(0.45); transform: scale(1.1);
}
.gen-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.gen-photo {
  position: relative; width: 760px; height: 428px; border-radius: 30px; overflow: hidden; margin-bottom: 56px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 50px 120px rgba(0, 0, 0, 0.6);
  animation: breathe 3.2s ease-in-out infinite;
}
.gen-photo img { width: 100%; height: 100%; object-fit: cover; }
.shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 180, 120, 0.28) 48%, rgba(255, 255, 255, 0.18) 50%, transparent 68%);
  background-size: 250% 100%; animation: sweep 2.4s var(--ease) infinite; mix-blend-mode: screen;
}
@keyframes sweep { from { background-position: 130% 0; } to { background-position: -30% 0; } }
@keyframes breathe { 50% { transform: scale(1.012); } }
#genLine { min-height: 34px; transition: opacity 0.4s; }
.progress { width: 420px; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); margin-top: 40px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width 1s linear; }

/* 4 · Resultado */
.result-photo {
  position: absolute; left: 96px; top: 150px; width: 1060px; height: 832px;
  display: flex; align-items: center; justify-content: center;
}
.result-photo canvas {
  max-width: 100%; max-height: 100%; border-radius: 30px;
  box-shadow: 0 0 0 1px var(--line), 0 50px 120px rgba(0, 0, 0, 0.6);
  opacity: 0; transform: scale(0.97); transition: opacity 0.8s var(--ease), transform 0.9s var(--ease);
}
.app[data-screen='result'] .result-photo canvas.ready { opacity: 1; transform: none; }
.result-panel { position: absolute; left: 1256px; top: 150px; width: 568px; height: 832px; display: flex; flex-direction: column; }
.qr-row { display: flex; align-items: center; gap: 36px; margin-top: 48px; }
.qr {
  width: 236px; height: 236px; flex: none; padding: 22px; border-radius: 30px; background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr-loading { width: 100%; height: 100%; border-radius: 14px; background: linear-gradient(90deg, #eee, #f8f8f8, #eee); background-size: 200% 100%; animation: sweep 1.4s linear infinite; }
.code-block { display: flex; flex-direction: column; gap: 8px; }
.code-label { font-size: 18px; color: var(--text-2); }
.code { font-size: 54px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.steps { list-style: none; margin-top: 44px; display: flex; flex-direction: column; gap: 18px; counter-reset: s; }
.steps li { counter-increment: s; display: flex; align-items: baseline; gap: 16px; font-size: 24px; color: var(--text); letter-spacing: -0.01em; }
.steps li::before {
  content: counter(s); flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 17px; font-weight: 700; transform: translateY(-2px);
}
.actions { margin-top: auto; display: flex; gap: 14px; }
.ghost-btn {
  height: 76px; padding: 0 30px; border-radius: 999px; display: flex; align-items: center; gap: 14px;
  font-size: 22px; font-weight: 600; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  transition: opacity 0.3s, transform 0.25s var(--ease);
}
.ghost-btn kbd { background: rgba(255, 255, 255, 0.1); }
.ghost-btn[hidden] { display: none; }
.result-panel .hint { margin-top: 16px; text-align: right; }

/* Toast */
.toast {
  position: absolute; z-index: 50; left: 50%; bottom: 56px; transform: translate(-50%, 30px);
  padding: 16px 26px; border-radius: 999px; font-size: 20px; font-weight: 500;
  background: rgba(28, 28, 30, 0.86); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: inset 0 0 0 1px var(--line); opacity: 0; transition: all 0.5s var(--ease); pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ── Modo TV (lo maneja el operador) ───────────────── */
.app.tv .screen-select { display: none; }
.app.tv[data-screen='select'] .stage { left: 0; top: 0; width: 1920px; height: 1080px; border-radius: 0; }
.app.tv[data-screen='select'] .topbar { z-index: 6; }
.next-chip, .queue-pill { position: absolute; z-index: 7; display: none; align-items: center; gap: 18px;
  background: rgba(18, 18, 20, 0.72); backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0, 0, 0, 0.45); border-radius: 999px; }
.app.tv[data-screen='select'] .next-chip { display: flex; }
.next-chip { left: 64px; bottom: 64px; padding: 12px 34px 12px 12px; }
.next-chip img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; }
.next-chip small { display: block; font-size: 18px; color: var(--text-2); }
.next-chip b { display: block; font-size: 32px; font-weight: 650; letter-spacing: -0.02em; }
.queue-pill { right: 64px; bottom: 64px; padding: 18px 28px; font-size: 22px; color: var(--text-2); }
.queue-pill i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.8s ease-in-out infinite; }
.app.tv.has-queue[data-screen='select'] .queue-pill { display: flex; }
.app.tv .actions, .app.tv .result-panel kbd { display: none; }

/* ── Ruleta ─────────────────────────────────────────── */
.roulette { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(30px) saturate(1.3); -webkit-backdrop-filter: blur(30px) saturate(1.3);
  opacity: 0; pointer-events: none; transition: opacity 0.5s var(--ease); }
.app.spinning .roulette { opacity: 1; }
.roulette-eyebrow { font-size: 24px; font-weight: 600; color: var(--accent); }
.roulette-card { width: 440px; height: 440px; border-radius: 48px; overflow: hidden; background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 40px 120px rgba(0, 0, 0, 0.6); }
.roulette-card img { width: 100%; height: 100%; object-fit: cover; }
.roulette-card.tick { animation: rtick 0.18s var(--ease-out); }
@keyframes rtick { from { transform: translateY(-14px) scale(0.98); opacity: 0.6; } }
.roulette-card.win { animation: rwin 0.9s var(--ease-out) forwards; box-shadow: 0 0 0 6px var(--accent), 0 0 120px rgba(255, 138, 61, 0.45); }
@keyframes rwin { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1.03); } }
.roulette b { font-size: 64px; font-weight: 700; letter-spacing: -0.04em; }
