/* ETAPA 14 — Immersive fullscreen demo (scoped under .jdemo-body only) */

/* ===== Root / stage: kill letterboxed 1280×16:9 box ===== */
html:has(.jdemo-body) {
  height: 100%;
}
.jdemo-body.jv2-body {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
.jdemo-body .jdemo-app.jv2-app {
  display: block;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
  place-items: unset;
}
.jdemo-body .jdemo-stage.jv2-stage {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
  box-shadow: none;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(26, 59, 109, 0.45), transparent 55%),
    linear-gradient(180deg, #0b1a33 0%, #07101f 100%);
}

/* Ultrawide: soft side atmosphere without deforming game art */
@media (min-aspect-ratio: 21/9) {
  .jdemo-body .jdemo-stage.jv2-stage {
    background:
      radial-gradient(ellipse at 50% 40%, rgba(22, 50, 90, 0.9) 0%, transparent 70%),
      linear-gradient(90deg, #050b16 0%, #0b1a33 18%, #0b1a33 82%, #050b16 100%);
  }
}

/* ===== Immersive HUD ===== */
.jdemo-body .jdemo-topbar.jv2-topbar {
  position: relative;
  z-index: 40;
  gap: 8px;
  padding: 6px 10px;
  min-height: 48px;
  background: rgba(7, 16, 31, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(230, 195, 106, 0.22);
}
.jdemo-topbar__tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.jdemo-brand { min-width: 0; }
.jdemo-brand__text { min-width: 0; }
.jdemo-body .jv2-brand__eyebrow {
  font-size: clamp(0.72rem, 1.15vw, 0.82rem);
  letter-spacing: 0.03em;
  opacity: 0.85;
}
.jdemo-body .jv2-brand__title {
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(48vw, 360px);
  line-height: 1.2;
}
.jdemo-age select {
  min-width: 6.75rem;
  min-height: 44px;
  font-size: clamp(0.88rem, 1.3vw, 0.98rem);
}
.jdemo-body .jdemo-topbar .jv2-btn {
  min-height: 44px;
  padding: 0 12px;
  font-size: clamp(0.88rem, 1.35vw, 0.98rem);
}
.jdemo-fs-btn { font-size: 1.1rem; line-height: 1; }
.jdemo-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}
.jdemo-sr-only-focus {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.jdemo-sr-only-focus:focus {
  left: 12px;
  top: 56px;
  width: auto;
  height: auto;
  z-index: 50;
  padding: 8px 12px;
  background: rgba(7, 16, 31, 0.95);
}

/* ===== Main ===== */
.jdemo-body .jdemo-main.jv2-main {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.jdemo-body .jv2-view {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.jdemo-finale[hidden],
.jv2-view[hidden],
.jv2-step[hidden] {
  display: none !important;
}

/* ===== Map: hero fill ===== */
.jdemo-view--map {
  position: relative;
}
.jdemo-map {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  border-radius: 0;
  overflow: hidden;
  background: #071428;
}
.jdemo-map__bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  min-height: 0;
}
.jdemo-map__char {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}
.jdemo-map__char--andelka { left: 8%; bottom: 14%; height: 34%; width: auto; }
.jdemo-map__char--hvezdulka { left: 22%; bottom: 16%; height: 14%; width: auto; }
.jdemo-map__props {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.jdemo-map__prop {
  position: absolute;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center bottom;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.jdemo-map__prop.is-on {
  opacity: 1;
  filter: drop-shadow(0 0 12px rgba(255, 210, 120, 0.55));
}
.jdemo-map__prop.is-off { opacity: 0; }
.jdemo-map__stops { position: absolute; inset: 0; z-index: 5; }
.jdemo-stop {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(230, 195, 106, 0.75);
  background: rgba(10, 24, 48, 0.88);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.jdemo-stop.is-completed {
  background: rgba(230, 195, 106, 0.92);
  color: #1a1208;
  border-color: #fff3c4;
}
.jdemo-stop.is-locked { opacity: 0.45; cursor: not-allowed; }
.jdemo-stop.is-available {
  box-shadow: 0 0 0 3px rgba(230, 195, 106, 0.35);
  animation: jdemo-pulse 2s ease-in-out infinite;
}
.jdemo-map__info {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 4;
  max-width: min(520px, calc(100% - 20px));
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(7, 16, 31, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(230, 195, 106, 0.22);
  /* Don't steal taps from map hotspots under the strip */
  pointer-events: none;
}
.jdemo-map__info a,
.jdemo-map__info button {
  pointer-events: auto;
}
.jdemo-lead {
  margin: 0 0 6px;
  font-size: clamp(0.8rem, 1.25vw, 0.92rem);
  color: var(--jv2-muted, #9eb6d8);
  text-align: left;
  line-height: 1.35;
  pointer-events: none;
}
.jdemo-map__info-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.jdemo-body .jv2-progress {
  margin: 0;
  font-size: clamp(0.88rem, 1.35vw, 1rem);
  color: var(--jv2-gold-soft, #ffe9a8);
  font-weight: 600;
  pointer-events: none;
}
.jdemo-cta-soft {
  text-decoration: none;
  font-size: clamp(0.8rem, 1.2vw, 0.9rem);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

/* ===== Day screens ===== */
.jdemo-view--day {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.jdemo-body .jdemo-day.jv2-day {
  flex: 1;
  height: 100%;
  min-height: 0;
}
.jdemo-body .jv2-day__panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Internal panel scroll only — never the whole page */
  overflow: hidden;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}
.jdemo-body .jv2-day__eyebrow {
  flex: 0 0 auto;
  font-size: clamp(0.78rem, 1.2vw, 0.88rem);
}
.jdemo-body .jv2-day__title {
  flex: 0 0 auto;
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  margin: 4px 0 10px;
  line-height: 1.25;
}
.jdemo-body .jv2-day__steps {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.jdemo-body .jv2-step {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* Story step: scroll content, sticky CTA row (Hrát + Poslechnout) */
.jdemo-body .jv2-step[data-step="story"] {
  overflow: hidden;
}
.jdemo-body .jv2-step[data-step="story"] .jdemo-story-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 2px;
  padding-bottom: 8px;
}
.jdemo-body .jv2-step[data-step="story"] .jdemo-story-actions {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 4px;
  padding-top: 8px;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(7, 16, 31, 0) 0%, rgba(7, 16, 31, 0.92) 28%, rgba(7, 16, 31, 0.96) 100%);
}
.jdemo-body .jv2-step[data-step="story"] #jdemoToGame {
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 0;
  min-height: 48px;
  padding: 0 22px;
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(255, 233, 168, 0.25), 0 6px 18px rgba(0, 0, 0, 0.35);
}
.jdemo-body .jdemo-day--baked-chars .jv2-char-stage {
  display: none !important;
}
.jdemo-body .jdemo-day--baked-chars .jv2-day__scene img {
  /* Keep Andělka + Hvězdulka (lower-left) visible under cover scaling */
  object-position: 18% 72%;
}
.jdemo-body .jv2-day.is-playing .jv2-day__panel {
  padding: 6px 8px 8px;
  background: rgba(7, 16, 31, 0.55);
}
.jdemo-body .jv2-day.is-playing .jdemo-game-title {
  margin: 0 0 4px;
  font-size: 0.85rem;
  color: var(--jv2-gold-soft, #ffe9a8);
}
.jdemo-body #jdemoGameMount {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.jdemo-story {
  margin: 0 0 10px;
  font-size: clamp(0.88rem, 1.35vw, 1rem);
  line-height: 1.45;
  color: rgba(238, 245, 255, 0.82);
}
.jdemo-instruction {
  margin: 0 0 4px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: clamp(0.95rem, 1.55vw, 1.08rem);
  font-weight: 600;
  line-height: 1.4;
  color: var(--jv2-gold-soft, #ffe9a8);
  background: rgba(230, 195, 106, 0.12);
  border: 1px solid rgba(230, 195, 106, 0.28);
}
.jdemo-dialog {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.jdemo-dialog__line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(8, 20, 40, 0.55);
  border: 1px solid rgba(230, 195, 106, 0.18);
}
.jdemo-dialog__speaker {
  grid-column: 1;
  color: var(--jv2-gold, #e6c36a);
  font-size: clamp(0.82rem, 1.2vw, 0.92rem);
  font-weight: 700;
}
.jdemo-dialog__text {
  grid-column: 1;
  margin: 0;
  font-size: clamp(0.98rem, 1.55vw, 1.12rem);
  line-height: 1.45;
}
.jdemo-dialog__play { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

/* Completion — scroll body + sticky footer (audio CTA + nav always reachable) */
.jdemo-step--done {
  align-items: stretch;
  justify-content: flex-start;
  text-align: center;
  gap: 0;
  padding: 8px 10px 0 !important;
  overflow: hidden;
}
.jdemo-done-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 12px;
}
.jdemo-done-footer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 4px max(10px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(7, 16, 31, 0) 0%, rgba(7, 16, 31, 0.94) 22%, rgba(7, 16, 31, 0.98) 100%);
  border-top: 1px solid rgba(230, 195, 106, 0.14);
}
.jdemo-body .jv2-reward {
  margin: 6px auto 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.jdemo-body .jv2-reward img {
  width: min(200px, 36vw);
  max-width: min(42vh, 180px);
  height: auto;
  filter: drop-shadow(0 0 22px rgba(255, 233, 168, 0.5));
  animation: jdemo-reward-reveal 0.85s ease-out both;
}
.jdemo-reward-label {
  margin: 0;
  font-size: clamp(1rem, 1.7vw, 1.2rem);
  font-weight: 700;
  color: var(--jv2-gold-soft, #ffe9a8);
  animation: jdemo-reward-label-in 0.6s ease-out 0.25s both;
}
@keyframes jdemo-reward-reveal {
  from { opacity: 0; transform: scale(0.82); filter: drop-shadow(0 0 0 rgba(255, 233, 168, 0)); }
  60% { opacity: 1; transform: scale(1.04); }
  to { opacity: 1; transform: scale(1); filter: drop-shadow(0 0 22px rgba(255, 233, 168, 0.5)); }
}
@keyframes jdemo-reward-label-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .jdemo-body .jv2-reward img,
  .jdemo-reward-label {
    animation: none;
  }
}
.jdemo-done-listen {
  margin: 0 auto;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}
.jdemo-story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 0;
}
.jdemo-story-listen {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}
/* Baked day-1 scene: soft glow while Andělka speaks (no lip-sync / no new engine). */
.jdemo-day.is-andelka-voice .jdemo-scene-img,
.jdemo-day.is-andelka-voice #jdemoSceneImg {
  filter: drop-shadow(0 0 18px rgba(255, 233, 168, 0.35));
  transition: filter 0.35s ease;
}
.jdemo-day.is-andelka-voice .jv2-char--hvezdulka {
  filter: drop-shadow(0 0 10px rgba(255, 220, 140, 0.45));
}
@media (prefers-reduced-motion: reduce) {
  .jdemo-day.is-andelka-voice .jdemo-scene-img,
  .jdemo-day.is-andelka-voice #jdemoSceneImg,
  .jdemo-day.is-andelka-voice .jv2-char--hvezdulka {
    filter: none;
    outline: 2px solid rgba(230, 195, 106, 0.55);
    outline-offset: 2px;
  }
}
.jdemo-done-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}
.jdemo-done-actions .jv2-btn {
  min-height: 44px;
}
.jdemo-finale {
  text-align: center;
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jdemo-finale__card {
  max-width: 36rem;
  padding: 28px 22px;
  border-radius: 16px;
  background: rgba(7, 16, 31, 0.82);
  border: 1px solid rgba(230, 195, 106, 0.28);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.jdemo-cta { text-decoration: none; display: inline-flex; align-items: center; }

/* ===== Day 1 starlight immersive ===== */
.jdemo-day .jv2-starlight {
  min-height: 0;
  height: 100%;
  gap: 4px;
}
.jdemo-day .jv2-starlight.has-scene {
  background: transparent;
}
.jdemo-day .jv2-starlight.has-scene .jv2-starlight__hud { z-index: 2; }
.jdemo-day .jv2-starlight.has-scene .jv2-starlight__hud .jv2-starlight__score {
  font-size: clamp(0.98rem, 1.6vw, 1.18rem);
  font-weight: 700;
}
.jdemo-day .jv2-starlight.has-scene .jv2-starlight__intro {
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(6, 16, 34, 0.55);
  backdrop-filter: blur(4px);
  font-size: clamp(0.9rem, 1.45vw, 1.05rem);
  line-height: 1.35;
  z-index: 2;
}
.jdemo-day .jv2-starlight.has-scene .jv2-starlight__chars {
  display: none !important;
}
.jdemo-day .jv2-starlight__sky {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.jdemo-day .jv2-starlight.has-scene .jv2-starlight__sky {
  /* Fill available game area — no nested max-height box */
  min-height: 0;
  max-height: none;
  aspect-ratio: auto;
  height: 100%;
  border-radius: 12px;
  border: 1px solid rgba(230, 195, 106, 0.22);
  box-shadow: inset 0 0 40px rgba(0, 10, 30, 0.25);
  background-color: #061228;
  background-size: cover;
  background-position: center center;
}
.jdemo-day .jv2-starlight.has-scene.is-glow .jv2-starlight__sky {
  box-shadow: inset 0 0 50px rgba(255, 220, 120, 0.22);
}
.jdemo-day .jv2-starlight__star.has-art {
  overflow: visible;
  max-width: min(16%, 110px);
}
.jdemo-day .jv2-starlight__star.has-art.is-main {
  max-width: min(20%, 140px);
}
.jdemo-day .jv2-starlight__star-fill.has-art {
  clip-path: none;
  background: transparent;
  opacity: 1;
  filter: none;
  display: grid;
  place-items: center;
  transition: filter 0.35s ease, opacity 0.35s ease, transform 0.35s ease;
}
/*
 * ETAPA 18B catch states:
 * inactive = soft dormant glow (no pulse)
 * active   = bright gold-white slow pulse
 * lit      = permanent steady glow
 */
.jdemo-day .jv2-starlight.is-catch .jv2-starlight__star.is-inactive .jv2-starlight__star-fill.has-art {
  filter: brightness(0.78) saturate(0.85) drop-shadow(0 0 4px rgba(255, 220, 120, 0.22));
  opacity: 0.72;
  animation: none;
}
.jdemo-day .jv2-starlight.is-catch .jv2-starlight__star.is-active .jv2-starlight__star-fill.has-art {
  filter: brightness(1.45) saturate(1.25) drop-shadow(0 0 16px rgba(255, 240, 180, 0.9));
  opacity: 1;
  animation: jdemo-star-active-pulse 1.5s ease-in-out infinite;
}
.jdemo-day .jv2-starlight.is-catch.is-generous .jv2-starlight__star.is-active .jv2-starlight__star-fill.has-art {
  animation-duration: 1.8s;
  filter: brightness(1.55) saturate(1.3) drop-shadow(0 0 20px rgba(255, 245, 190, 0.95));
}
.jdemo-day .jv2-starlight.is-catch .jv2-starlight__star.is-lit .jv2-starlight__star-fill.has-art {
  opacity: 1;
  filter: drop-shadow(0 0 11px rgba(255, 233, 168, 0.7));
  background: transparent;
  animation: none;
}
.jdemo-day .jv2-starlight.is-catch .jv2-starlight__star.is-hint .jv2-starlight__star-fill.has-art,
.jdemo-day .jv2-starlight.is-catch .jv2-starlight__star.is-active.is-hint .jv2-starlight__star-fill.has-art {
  outline: 2px solid var(--jv2-gold, #e6c36a);
  outline-offset: 3px;
  border-radius: 50%;
}
.jdemo-day .jv2-starlight.is-catch.is-glow .jv2-starlight__sky {
  box-shadow: inset 0 0 70px rgba(255, 220, 120, 0.32);
  transition: box-shadow 0.8s ease;
}
@keyframes jdemo-star-active-pulse {
  0%, 100% { transform: scale(1); filter: brightness(1.35) saturate(1.2) drop-shadow(0 0 12px rgba(255, 240, 180, 0.75)); }
  50% { transform: scale(1.08); filter: brightness(1.55) saturate(1.35) drop-shadow(0 0 20px rgba(255, 250, 210, 1)); }
}
@media (prefers-reduced-motion: reduce) {
  .jdemo-day .jv2-starlight.is-catch .jv2-starlight__star.is-active .jv2-starlight__star-fill.has-art,
  .jdemo-day .jv2-starlight.is-catch.is-generous .jv2-starlight__star.is-active .jv2-starlight__star-fill.has-art {
    animation: none;
    transform: none;
  }
}
.jdemo-day .jv2-starlight.is-reduced-motion .jv2-starlight__star-fill.has-art {
  animation: none !important;
}
.jdemo-day .jv2-starlight__star-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  transform-origin: center center;
}
/* Legacy warming path (unused in catch mode) */
.jdemo-day .jv2-starlight__star.is-warming .jv2-starlight__star-fill.has-art {
  filter: brightness(1.18) saturate(1.15) drop-shadow(0 0 10px rgba(255, 220, 120, 0.55));
}
.jdemo-day .jv2-starlight__star.is-warming .jv2-starlight__star-img { transform: scale(1.04); }
.jdemo-day .jv2-starlight:not(.is-catch) .jv2-starlight__star.has-art:not(.is-lit):not(.is-warming) .jv2-starlight__star-fill.has-art {
  filter: brightness(1.2) saturate(1.1) drop-shadow(0 0 7px rgba(255, 220, 120, 0.4));
  animation: jdemo-star-idle-pulse 2.8s ease-in-out infinite;
}
.jdemo-day .jv2-starlight:not(.is-catch) .jv2-starlight__star.is-lit .jv2-starlight__star-fill.has-art {
  opacity: 1;
  filter: drop-shadow(0 0 12px rgba(255, 233, 168, 0.75));
  background: transparent;
  animation: jdemo-star-pulse 1.6s ease-in-out infinite;
}
.jdemo-day .jv2-starlight:not(.is-catch) .jv2-starlight__star.is-hint .jv2-starlight__star-fill.has-art {
  outline: 2px solid var(--jv2-gold, #e6c36a);
  outline-offset: 2px;
  border-radius: 50%;
}

/* ===== Day 2 / 3 fill ===== */
.jdemo-day .jv2-spot {
  flex: 1;
  min-height: 0;
  height: 100%;
  background: rgba(7, 18, 36, 0.35);
  border-radius: 10px;
}

/*
 * ETAPA 16A — Compact centered pexeso grid (demo-only overrides).
 * Fit strategy: HUD row + 1fr stage; board uses aspect-ratio cols/rows and
 * min(width%, height-fit) so every card stays square, visible, no H-scroll.
 * Future art: /pics/journey_demo/pexeso/pexeso-bg.webp (1920×1080), quieter center.
 */
.jdemo-day .jv2-pexeso {
  --jdemo-pex-gap: clamp(4px, 0.85vw, 10px);
  --jdemo-pex-pad-x: clamp(8px, 2vw, 28px);
  --jdemo-pex-pad-y: clamp(6px, 1.4vh, 16px);
  /* ETAPA 16C.1: larger desktop cards; age variants override below */
  --jdemo-pex-max-card: 160px;
  --jdemo-pex-min-card: 44px;
  --jdemo-pex-cols: var(--jv2-pex-cols, 4);
  --jdemo-pex-rows: 3;
  --jdemo-pex-hud: 2.5rem;

  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 4px;
  border-radius: 12px;
  overflow: hidden;
  isolation: isolate;
  container-type: size;
  container-name: jdemo-pex;
  /* Technical underlay = fallback if art missing / load fails */
  --jdemo-pex-bg: url('/pics/journey_demo/pexeso/pexeso-bg.webp?v=97eaa43c');
  --jdemo-pex-bg-pos: center center;
  background-color: #0a1628;
  background-image:
    radial-gradient(ellipse 62% 58% at 50% 52%, rgba(36, 62, 102, 0.55) 0%, transparent 72%),
    linear-gradient(180deg, rgba(14, 28, 52, 0.92) 0%, rgba(7, 14, 28, 0.96) 100%);
  background-size: cover;
  background-position: var(--jdemo-pex-bg-pos);
  background-repeat: no-repeat;
}

/* ETAPA 16B — fairy-tale workshop art (stacked over technical fallback) */
.jdemo-day .jv2-pexeso.is-bg-ready {
  background-image:
    var(--jdemo-pex-bg),
    radial-gradient(ellipse 62% 58% at 50% 52%, rgba(36, 62, 102, 0.35) 0%, transparent 72%),
    linear-gradient(180deg, rgba(14, 28, 52, 0.55) 0%, rgba(7, 14, 28, 0.7) 100%);
  background-size: cover, cover, cover;
  background-position: var(--jdemo-pex-bg-pos), center, center;
  background-repeat: no-repeat;
}

/*
 * Short landscape: with HUD 18G.1 3-col + shell::before full-bleed (18G.1a/1b),
 * do NOT re-bias/paint workshop art on .jv2-pexeso — that creates a second crop.
 * Desktop / tall viewports keep .is-bg-ready art on .jv2-pexeso unchanged.
 */
@media (orientation: landscape) and (max-height: 480px) {
  .jdemo-hud17c .jdemo-pex-shell[data-mode="pexeso"] .jv2-pexeso.is-bg-ready {
    --jdemo-pex-bg: none;
    background-image: none;
  }
}
@media (orientation: landscape) and (max-height: 430px) and (max-width: 960px) {
  .jdemo-hud17c .jdemo-pex-shell[data-mode="pexeso"] .jv2-pexeso.is-bg-ready {
    --jdemo-pex-bg: none;
    background-image: none;
  }
}

.jdemo-day .jv2-pexeso > * {
  position: relative;
  z-index: 1;
}

.jdemo-day .jv2-pexeso__hud {
  flex: unset;
  min-height: 0;
  padding: 4px var(--jdemo-pex-pad-x);
  border-radius: 10px;
  background: rgba(7, 16, 31, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.jdemo-day .jv2-pexeso.is-bg-ready .jv2-pexeso__hud {
  background: rgba(7, 16, 31, 0.55);
}
/* Keep cards readable over workshop art */
.jdemo-day .jv2-pexeso.is-bg-ready .jv2-pexeso__card {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* Rows from card count (architecture: 4×2 / 4×3 / 5×4) */
.jdemo-day .jv2-pexeso:has(.jv2-pexeso__card:nth-child(8)):not(:has(.jv2-pexeso__card:nth-child(9))) {
  --jdemo-pex-rows: 2;
  --jdemo-pex-max-card: 220px; /* 3–6: most room in safe zone */
}
.jdemo-day .jv2-pexeso:has(.jv2-pexeso__card:nth-child(12)):not(:has(.jv2-pexeso__card:nth-child(13))) {
  --jdemo-pex-rows: 3;
  --jdemo-pex-max-card: 188px; /* 6–9 */
}
.jdemo-day .jv2-pexeso:has(.jv2-pexeso__card:nth-child(20)) {
  --jdemo-pex-rows: 4;
  --jdemo-pex-max-card: 148px; /* 9+: denser grid, still clearly > former 112 */
}

.jdemo-day .jv2-pexeso__board {
  --jdemo-pex-cols: var(--jv2-pex-cols, 4);
  --jdemo-pex-rows: inherit;
  /* cqi/cqh → .jv2-pexeso container (verified = mount box) */
  --jdemo-pex-cell-w: calc(
    (100cqi - 2 * var(--jdemo-pex-pad-x) - (var(--jdemo-pex-cols) - 1) * var(--jdemo-pex-gap))
    / var(--jdemo-pex-cols)
  );
  --jdemo-pex-cell-h: calc(
    (
      100cqh
      - var(--jdemo-pex-hud)
      - 4px
      - 2 * var(--jdemo-pex-pad-y)
      - (var(--jdemo-pex-rows) - 1) * var(--jdemo-pex-gap)
    ) / var(--jdemo-pex-rows)
  );
  --jdemo-pex-cell: clamp(
    var(--jdemo-pex-min-card),
    min(var(--jdemo-pex-cell-w), var(--jdemo-pex-cell-h), var(--jdemo-pex-max-card)),
    var(--jdemo-pex-max-card)
  );

  box-sizing: border-box;
  width: max-content;
  max-width: 100%;
  height: max-content;
  max-height: 100%;
  justify-self: center;
  align-self: center;
  margin: 0;
  padding: var(--jdemo-pex-pad-y) var(--jdemo-pex-pad-x);
  display: grid;
  grid-template-columns: repeat(var(--jdemo-pex-cols), var(--jdemo-pex-cell));
  grid-template-rows: repeat(var(--jdemo-pex-rows), var(--jdemo-pex-cell));
  gap: var(--jdemo-pex-gap);
  overflow: hidden;
}

.jdemo-day .jv2-pexeso__card {
  width: var(--jdemo-pex-cell);
  height: var(--jdemo-pex-cell);
  max-width: none;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  border-radius: clamp(8px, 1.2vw, 12px);
}

.jdemo-day .jv2-pexeso__inner,
.jdemo-day .jv2-pexeso__face {
  border-radius: inherit;
}

.jdemo-day .jv2-pexeso__label {
  font-size: clamp(0.5rem, 1.1vw, 0.72rem);
  padding: 1px 3px;
}

.jdemo-day .jv2-pexeso__finale {
  margin: 0 var(--jdemo-pex-pad-x) var(--jdemo-pex-pad-y);
  max-height: 42%;
  overflow: auto;
}

/* Short mobile landscape: tighter chrome, prefer full grid */
@media (orientation: landscape) and (max-height: 430px) {
  .jdemo-day .jv2-pexeso {
    --jdemo-pex-hud: 2.15rem;
    --jdemo-pex-gap: 3px;
    --jdemo-pex-pad-x: 4px;
    --jdemo-pex-pad-y: 3px;
    --jdemo-pex-max-card: 88px;
    gap: 2px;
  }
  .jdemo-day .jv2-pexeso__hud .jv2-btn {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.8rem;
  }
  .jdemo-day .jv2-pexeso__label { display: none; }
  .jdemo-body .jv2-day.is-playing .jdemo-game-title { display: none; }
}

/*
 * Fallback (documented): ultra-short landscape — prefer full grid with 40px floor
 * over clipping. Vertical scroll only if min-size still overflows.
 */
@media (orientation: landscape) and (max-height: 340px) {
  .jdemo-day .jv2-pexeso {
    --jdemo-pex-min-card: 40px; /* touch compromise vs. crop */
  }
  .jdemo-day .jv2-pexeso__board {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Spot exception: allow light vertical scroll on very short landscape for readability */
@media (orientation: landscape) and (max-height: 420px) {
  .jdemo-day .jv2-spot {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ===== Portrait orientation gate (mobile-like only; CSS assist) ===== */
.jdemo-rotate.jv2-rotate {
  background:
    radial-gradient(ellipse at 50% 20%, rgba(40, 70, 120, 0.55), transparent 55%),
    rgba(5, 12, 28, 0.96);
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}
.jdemo-rotate__card {
  max-width: 22rem;
  padding: 28px 20px;
  border-radius: 18px;
  border: 1px solid rgba(230, 195, 106, 0.35);
  background: rgba(12, 24, 48, 0.88);
  display: grid;
  gap: 14px;
  justify-items: center;
}
.jdemo-rotate__icon {
  position: relative;
  width: 72px;
  height: 72px;
}
.jdemo-rotate__phone {
  position: absolute;
  inset: 10px 22px;
  border: 3px solid var(--jv2-gold-soft, #ffe9a8);
  border-radius: 10px;
  transform: rotate(-28deg);
  box-shadow: 0 0 16px rgba(230, 195, 106, 0.35);
  animation: jdemo-phone-tilt 1.8s ease-in-out infinite;
}
.jdemo-rotate__arrow {
  position: absolute;
  right: 4px;
  top: 8px;
  width: 22px;
  height: 22px;
  border-top: 3px solid var(--jv2-gold, #e6c36a);
  border-right: 3px solid var(--jv2-gold, #e6c36a);
  transform: rotate(45deg);
  opacity: 0.9;
}
.jdemo-rotate__hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--jv2-muted, #9eb6d8);
  line-height: 1.4;
}
.jdemo-body.jdemo-portrait-locked .jdemo-app {
  pointer-events: none;
  user-select: none;
}
.jdemo-body.jdemo-portrait-locked .jdemo-rotate {
  pointer-events: auto;
}
@keyframes jdemo-phone-tilt {
  0%, 100% { transform: rotate(-28deg); }
  50% { transform: rotate(18deg); }
}
@keyframes jdemo-star-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes jdemo-star-idle-pulse {
  0%, 100% { filter: brightness(1.18) saturate(1.08) drop-shadow(0 0 6px rgba(255, 220, 120, 0.32)); }
  50% { filter: brightness(1.28) saturate(1.14) drop-shadow(0 0 11px rgba(255, 220, 120, 0.5)); }
}
@keyframes jdemo-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.06); }
}

/* ===== Short landscape polish ===== */
@media (orientation: landscape) and (max-height: 480px) {
  .jdemo-body .jdemo-topbar.jv2-topbar { padding: 4px 8px; min-height: 44px; }
  .jdemo-body .jv2-brand__eyebrow { display: none; }
  .jdemo-map__info { padding: 6px 10px; bottom: 6px; left: 6px; right: 6px; }
  .jdemo-lead { display: none; } /* keep progress + CTA only on short landscape */
  .jdemo-map__char--andelka { height: 40%; bottom: 18%; }
  .jdemo-stop { width: 44px; height: 44px; }
  .jdemo-day .jv2-starlight__star.has-art {
    max-width: min(14%, 88px);
    min-width: 48px !important;
    min-height: 48px !important;
  }
  .jdemo-day .jv2-starlight__star.has-art.is-main { max-width: min(18%, 112px); }
  .jdemo-day .jv2-starlight.has-scene .jv2-starlight__intro {
    font-size: 0.8rem;
    max-height: 2.8em;
    overflow: hidden;
  }
  .jdemo-body .jv2-day.is-playing .jdemo-game-title { display: none; }
  .jdemo-body .jv2-day.is-playing .jv2-day__panel { padding: 2px 4px 4px; }
  .jdemo-body .jv2-day__panel {
    padding-top: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
  .jdemo-body .jv2-day__title { font-size: 1.05rem; margin-bottom: 4px; }
  .jdemo-body .jv2-reward img {
    width: min(120px, 28vw);
    max-width: 28vh;
  }
  .jdemo-body .jv2-step[data-step="story"] #jdemoToGame {
    min-height: 44px;
    font-size: 0.95rem;
    margin-top: 0;
  }
  .jdemo-body .jv2-step[data-step="story"] .jdemo-story-actions,
  .jdemo-done-footer {
    padding-top: 6px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }
  .jdemo-done-actions {
    gap: 6px;
  }
  .jdemo-done-actions .jv2-btn,
  .jdemo-done-listen,
  .jdemo-story-listen,
  .jdemo-body .jv2-step[data-step="story"] #jdemoToGame {
    min-height: 40px;
    font-size: 0.9rem;
    padding-left: 12px;
    padding-right: 12px;
  }
  .jdemo-map__info { max-width: min(420px, calc(100% - 12px)); }
}

@media (prefers-reduced-motion: reduce) {
  .jdemo-stop.is-available,
  .jdemo-rotate__phone,
  .jdemo-day .jv2-starlight__star.is-lit .jv2-starlight__star-fill.has-art,
  .jdemo-day .jv2-starlight__star.has-art:not(.is-lit) .jv2-starlight__star-fill.has-art {
    animation: none;
  }
  .jdemo-day .jv2-starlight__star.is-warming .jv2-starlight__star-img { transform: none; }
}

/* Record mode */
.jdemo-body.is-record .jdemo-lead,
.jdemo-body.is-record .jdemo-map__info,
.jdemo-body.is-record .jdemo-age,
.jdemo-body.is-record #jdemoMute,
.jdemo-body.is-record #jdemoFullscreen { display: none !important; }
.jdemo-body.is-record .jv2-topbar { opacity: 0.92; }

/* ===== ETAPA 17B — UI asset pack hooks (no live layout rewrite) ===== */
.jdemo-body {
  --jdemo-ui-title-ribbon: url('/pics/journey_demo/ui/title-ribbon.webp?v=06cbbccd');
  --jdemo-ui-parchment: url('/pics/journey_demo/ui/parchment-panel.webp?v=7b83b96d');
  --jdemo-ui-btn-back: url('/pics/journey_demo/ui/button-back.webp?v=9da9849d');
  --jdemo-ui-btn-audio: url('/pics/journey_demo/ui/button-audio.webp?v=13bb4228');
  --jdemo-ui-btn-settings: url('/pics/journey_demo/ui/button-settings.webp?v=a974338e');
  --jdemo-ui-btn-hint: url('/pics/journey_demo/ui/button-hint.webp?v=03471af2');
  --jdemo-ui-progress-star: url('/pics/journey_demo/ui/progress-star.webp?v=e11f4f92');
  /* map-star-pin: MISSING source in 17B — hook reserved for 17C drop */
  --jdemo-ui-map-pin: none;
}

.jdemo-ui-title-ribbon,
.jdemo-ui-parchment,
.jdemo-ui-btn-back,
.jdemo-ui-btn-audio,
.jdemo-ui-btn-settings,
.jdemo-ui-btn-hint,
.jdemo-ui-progress-star,
.jdemo-ui-map-pin {
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.jdemo-ui-title-ribbon { background-image: var(--jdemo-ui-title-ribbon); }
.jdemo-ui-parchment { background-image: var(--jdemo-ui-parchment); }
.jdemo-ui-btn-back { background-image: var(--jdemo-ui-btn-back); }
.jdemo-ui-btn-audio { background-image: var(--jdemo-ui-btn-audio); }
.jdemo-ui-btn-settings { background-image: var(--jdemo-ui-btn-settings); }
.jdemo-ui-btn-hint { background-image: var(--jdemo-ui-btn-hint); }
.jdemo-ui-progress-star { background-image: var(--jdemo-ui-progress-star); }
.jdemo-ui-map-pin { background-image: var(--jdemo-ui-map-pin); }

/* Optional QA strip — only when body has .jdemo-ui-preview */
.jdemo-body.jdemo-ui-preview .jdemo-ui-preview-strip {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 80;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 12px;
  background: rgba(7, 16, 31, 0.88);
  border: 1px solid rgba(230, 195, 106, 0.28);
  pointer-events: none;
}
.jdemo-body.jdemo-ui-preview .jdemo-ui-preview-strip > span {
  width: 56px;
  height: 56px;
  display: inline-block;
}
.jdemo-body.jdemo-ui-preview .jdemo-ui-preview-strip > span.jdemo-ui-title-ribbon,
.jdemo-body.jdemo-ui-preview .jdemo-ui-preview-strip > span.jdemo-ui-parchment {
  width: 120px;
  height: 48px;
}
