/* Capa del juego 3D sobre el kit de UI (tokens + ui.css + screens.css). */
#app, .ui-root { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
#app { background: var(--paper); }
.game-canvas {
  position: absolute; inset: 0; width: 100% !important; height: 100% !important;
  display: block; z-index: 0; touch-action: none;
}
.ui-root { z-index: 1; pointer-events: none; }
.ui-root > * { pointer-events: none; }
.ui-root .hud > *,
.ui-root .dim,
.ui-root .card,
.ui-root .kit-screen,
.ui-root .kit-screen *,
.ui-root .a11y-panel, .ui-root .a11y-panel *,
.ui-root .pause-panel, .ui-root .pause-panel *,
.ui-root .toast,
.ui-root .btn, .ui-root .rbtn, .ui-root .dpad { pointer-events: auto; }

/* Durante el juego 3D el fondo ilustrado se oculta (el canvas es el mundo). */
.ui-root[data-screen="play"] .kit-screen { display: none; }
.ui-root[data-screen="play"] .hud { display: block; }
.ui-root:not([data-screen="play"]) .hud { display: none; }
.ui-root[data-screen="play"] .game-underlay { display: none; }

/* Pantallas 2D del kit cubren el canvas */
.kit-screen {
  position: absolute; inset: 0; z-index: 50;
  pointer-events: auto;
}
.kit-screen.is-hidden, .hud.is-hidden, .a11y-panel.is-hidden, .pause-panel.is-hidden, .toast.is-hidden { display: none !important; }

/* HUD: no mostrar el pie de «ilustración» sobre el mundo 3D */
.ui-root[data-screen="play"] .caption { display: none; }

/* Controles del kit visibles en juego; el joystick viejo ya no se usa */
.touch-ui { display: none !important; }

/* Candado de 3 s en Continuar */
.btn.is-locked { opacity: .55; pointer-events: none; }

/* Toast de evolución (z 70) */
.toast {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  z-index: 70; font-family: var(--font-display); font-weight: 800;
  font-size: calc(var(--fs-stage-title) * 1.15); color: var(--cream);
  background: var(--teal-deep); padding: 8px 28px; border-radius: var(--r-pill);
  box-shadow: 0 0 0 3px var(--cream), 0 0 0 5.5px var(--teal-deep), 0 8px 0 0 var(--ink);
  animation: fadein var(--fade) both;
}

/* Panel de accesibilidad (z 80) y de pausa */
.a11y-panel, .pause-panel {
  position: absolute; z-index: 80; right: calc(var(--pad) + var(--safe-r));
  top: calc(var(--pad) + var(--safe-t) + 64px);
  width: min(320px, calc(100% - 2 * var(--pad)));
  background: var(--paper); color: var(--ink);
  border-radius: var(--r-card); padding: 16px 18px;
  box-shadow: 0 0 0 3px var(--cream), 0 0 0 5.5px var(--teal-deep), 0 8px 0 0 var(--teal-deep);
}
.pause-panel { left: 50%; right: auto; top: 50%; transform: translate(-50%, -50%); width: min(420px, 90%); text-align: center; }
.pause-panel h2, .a11y-panel h2 { font-family: var(--font-display); font-weight: 800; margin: 0 0 10px; color: var(--teal-deep); font-size: var(--fs-stage-title); }
.a11y-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--touch-min); font-weight: 800; }
.a11y-row button { min-width: 88px; }
.dim { position: absolute; inset: 0; z-index: 50; background: var(--overlay-ink); }
.dim.is-hidden { display: none !important; }

/* Puntos flotantes (ya definidos en ui.css); asegurar posición de juego */
.float-points { pointer-events: none; }

/* Velo para tarjetas sobre el 3D cuando no hay fondo de kit a pantalla completa */
.ui-root[data-screen="card"] .kit-screen { display: block; }

html.ui-reduce-motion *, html.ui-reduce-motion *::before, html.ui-reduce-motion *::after {
  animation: none !important; transition: none !important;
}

/* Fuentes (pantalla completa, no la tarjeta compacta anterior) */
.sources-card { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(760px, 94%); max-height: min(90vh, 900px); display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; }
.sources-card .src-wrap { flex: 1; min-height: 0; }
.qr-placeholder { display: flex; gap: 14px; align-items: center; background: var(--paper); border-radius: var(--r-panel); padding: 10px 12px; box-shadow: inset 0 0 0 2.5px var(--teal); }
.qr-placeholder .qrbox { width: 72px; height: 72px; border: 3px dashed var(--teal); border-radius: 8px; display: grid; place-items: center; font-weight: 900; color: var(--teal); font-size: 14px; letter-spacing: .04em; flex: none; }
.qr-placeholder p { margin: 0; font-size: var(--fs-source); }
.qr-placeholder .ph { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--orange-pressed); font-weight: 900; }

/* Tarjeta genérica (cameo, muerte, escape) centrada cuando no es stagecard */
.card.simple { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(620px, 92%); display: flex; flex-direction: column; gap: 14px; }

.hud-timer.is-pulse { animation: kitpulse 1.2s ease-in-out infinite; }
@keyframes kitpulse { 50% { transform: scale(1.06); } }

.threat.is-hidden { display: none !important; }
body:not([data-screen="play"]) .game-canvas { visibility: hidden; }
.hud-top .rbtn--a11y { margin-left: 8px; flex: none; }
