/* Opt-in only: load after styles.css and region-game.css.
   The cinematic panel fills the stage, so container queries also work inside
   the desktop portrait player. No ordinary-choice or other-QTE selectors. */
.qte-panel--guided.qte-panel--cinematic {
  --qte-guided-safe-top: calc(57px + env(safe-area-inset-top, 0px));
  --qte-guided-safe-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  --qte-guided-retry: #ffc083;
  container: guided-qte / size;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  animation: none;
  pointer-events: none;
}

/* India also shows a provenance line below the HUD; keep it readable. */
.qte-panel--guided.qte-panel--cinematic:lang(hi) {
  --qte-guided-safe-top: calc(81px + env(safe-area-inset-top, 0px));
}

/* A small, persistent card below the HUD, never a touch-blocking overlay. */
.qte-panel--guided .qte-guide {
  --qte-guide-accent: var(--cyan);
  position: absolute;
  z-index: 6;
  top: calc(var(--qte-guided-safe-top) + 8px);
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  max-width: 420px;
  margin-inline: auto;
  padding: 10px 12px;
  border: 1px solid rgba(242, 246, 244, .22);
  border-left: 3px solid var(--qte-guide-accent);
  border-radius: 10px;
  background: linear-gradient(115deg, rgba(5, 8, 11, .9), rgba(9, 16, 21, .78));
  box-shadow: 0 3px 12px rgba(0, 0, 0, .24);
  color: var(--paper);
  font-size: 12px;
  line-height: 1.45;
  text-align: start;
  text-transform: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .65);
}

.qte-panel--guided .qte-guide,
.qte-panel--guided .qte-guide * {
  pointer-events: none;
}

.qte-panel--guided .qte-guide :is(strong, p, small, span) {
  min-width: 0;
  margin: 0;
  font: inherit;
  letter-spacing: normal;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
  hyphens: none;
}

.qte-panel--guided .qte-guide-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  min-width: 0;
  color: rgba(242, 246, 244, .82);
  font-size: 11px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.qte-panel--guided #qteGuideStatus {
  color: var(--qte-guide-accent);
  font-weight: 800;
}

.qte-panel--guided #qteGuideAction {
  display: block;
  color: var(--paper);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.4;
  text-shadow: 0 1px 3px #000;
}

.qte-panel--guided #qteGuideHint {
  color: rgba(242, 246, 244, .88);
  font-size: 12px;
  line-height: 1.45;
}

.qte-panel--guided #qteGuideNext {
  display: block;
  padding-top: 5px;
  border-top: 1px solid rgba(242, 246, 244, .2);
  color: var(--paper);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.qte-panel--guided .qte-guide:is(.is-ready, .is-waiting) {
  --qte-guide-accent: var(--cyan);
  border-top-style: dashed;
}

.qte-panel--guided .qte-guide.is-active {
  --qte-guide-accent: var(--acid);
}

.qte-panel--guided:is(.is-complete, .is-ordinary) .qte-guide,
.qte-panel--guided .qte-guide.is-complete {
  --qte-guide-accent: var(--cyan);
}

.qte-panel--guided.is-perfect .qte-guide {
  --qte-guide-accent: var(--acid);
}

.qte-panel--guided.is-retry .qte-guide,
.qte-panel--guided .qte-guide.is-retry {
  --qte-guide-accent: var(--qte-guided-retry);
}

.qte-panel--guided .qte-guide[hidden],
.qte-panel--guided #qteGuideNext:empty {
  display: none;
}

/* Freeze geometry, not feedback: the existing hit animation still fades and
   brightens the cue. !important prevents its scale expansion, and any inline
   countdown transform, from moving the target into the subtitle safe band. */
.qte-panel--guided.qte-panel--cinematic .qte-cue-ring,
.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-visible,
.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-pressed {
  transform: translate(-50%, -50%) scale(1) !important;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring {
  --qte-guided-cue-width: 148px;
  --qte-guided-cue-height: 148px;
  width: min(var(--qte-guided-cue-width), calc(100% - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  height: var(--qte-guided-cue-height);
  grid-template: repeat(4, auto) / minmax(0, 1fr);
  align-content: center;
  gap: 2px;
  padding: 11px;
  background:
    radial-gradient(closest-side, rgba(5, 10, 12, .9) 0 92%, transparent 93%),
    conic-gradient(var(--acid) 0deg var(--qte-window-angle), rgba(255, 255, 255, .14) var(--qte-window-angle) 360deg);
  box-shadow: 0 0 0 4px rgba(220, 255, 63, .08), 0 0 18px rgba(220, 255, 63, .2);
  transition: opacity 100ms linear, filter 100ms linear, border-color 100ms linear;
  will-change: opacity;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring strong {
  min-width: 0;
  margin: 0;
  color: var(--acid);
  font-size: 40px;
  line-height: 1;
  text-shadow: 0 1px 5px #000;
}

/* Early input is accepted once, but the next cue stays on the video's beat. */
.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-armed {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(98, 221, 255, .12), 0 0 18px rgba(98, 221, 255, .28);
  background: rgba(5, 20, 26, .88);
}
.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-armed strong {
  color: var(--cyan);
}

/* Explicit :lang(hi) specificity beats region-game.css's 9px overrides.
   Keep Devanagari marks intact; wrap words rather than clipping/ellipsizing. */
.qte-panel--guided.qte-panel--cinematic .qte-cue-ring span,
.qte-panel--guided.qte-panel--cinematic:lang(hi) .qte-cue-ring span {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: var(--paper);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: normal;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring small,
.qte-panel--guided.qte-panel--cinematic:lang(hi) .qte-cue-ring small {
  display: block;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: rgba(242, 246, 244, .9);
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: normal;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring em,
.qte-panel--guided.qte-panel--cinematic:lang(hi) .qte-cue-ring em {
  min-width: 0;
  max-width: 100%;
  justify-self: center;
  margin: 0;
  padding: 2px 5px;
  font-size: 10px;
  line-height: 1.35;
  letter-spacing: normal;
  white-space: normal;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-swipe-cue {
  --qte-guided-cue-width: 226px;
  --qte-guided-cue-height: 100px;
  grid-template: auto auto / 40px minmax(0, 1fr) auto;
  gap: 2px 6px;
  padding: 9px 10px;
  border-radius: 22px;
  background: linear-gradient(110deg, rgba(4, 12, 15, .92), rgba(20, 31, 24, .82));
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-swipe-cue strong {
  font-size: 40px;
}

/* Main strong arrow remains crisp; decorative arrows no longer oscillate. */
.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-swipe-cue::after {
  animation: none;
  transform: none;
  opacity: .12;
  text-shadow: none;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.qte-direction-up, .qte-direction-down) {
  --qte-guided-cue-width: 152px;
  --qte-guided-cue-height: 178px;
  grid-template: repeat(4, auto) / minmax(0, 1fr);
  gap: 2px;
  padding: 12px 10px;
  border-radius: 26px;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.qte-direction-up, .qte-direction-down) > :is(strong, span, small, em) {
  grid-area: auto / 1;
  align-self: center;
  max-width: 100%;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-rapid-cue {
  --qte-guided-cue-width: 166px;
  --qte-guided-cue-height: 166px;
  grid-template-rows: repeat(4, auto);
  background:
    radial-gradient(closest-side, rgba(5, 10, 12, .92) 0 92%, transparent 93%),
    conic-gradient(var(--acid) 0deg var(--qte-tap-angle), rgba(255, 255, 255, .14) var(--qte-tap-angle) 360deg);
}

/* Preview is visual preparation, not an active hit target. The :has rule
   also disables the inherited full-stage gesture surface during preview. */
.qte-panel--guided.qte-panel--cinematic .qte-gesture-surface:has(.qte-cue-ring.is-preview) {
  pointer-events: none;
  cursor: default;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-preview {
  pointer-events: none;
  cursor: default;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-preview:not(.is-hit) {
  border-color: var(--cyan);
  border-style: dashed;
  background: rgba(5, 10, 12, .74);
  box-shadow: none;
  opacity: .62;
  filter: none;
  animation: none;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-preview::before,
.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-preview::after {
  animation: none;
  transform: none;
  opacity: .1;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-preview :is(strong, em) {
  color: var(--cyan);
  border-color: currentColor;
  text-shadow: none;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-retry:not(.is-hit):not(.is-lethal) {
  border-color: var(--qte-guided-retry);
  background: rgba(34, 23, 15, .85);
  box-shadow: 0 0 0 3px rgba(255, 192, 131, .12);
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-retry:not(.is-lethal) :is(strong, em) {
  color: var(--qte-guided-retry);
  border-color: currentColor;
  text-shadow: none;
}

/* Keep legacy terminal classes and local feedback, not the full-screen red
   failure mask. Retry is deliberately distinct from an actual lethal miss. */
.qte-panel--guided.qte-panel--cinematic.is-failure::after {
  content: none;
  animation: none;
}

.qte-panel--guided.is-failure .qte-guide {
  --qte-guide-accent: var(--danger);
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-lethal {
  border-color: var(--danger);
  background: rgba(35, 8, 13, .88);
  box-shadow: 0 0 0 3px rgba(255, 60, 79, .16);
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-lethal :is(strong, em) {
  color: var(--danger);
  border-color: currentColor;
}

.qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-hit {
  animation: qteCueHit 280ms ease-out forwards;
  pointer-events: none;
}

/* Short portrait / short desktop stage: move toward 60%, but cap the entire
   cue 20px above subtitles at 72.5% and above the bottom HUD. top overrides
   JS's inline 52%; the fixed transform never changes the JS hit rectangle. */
@container guided-qte (max-height: 680px) {
  .qte-panel--guided .qte-guide {
    top: calc(var(--qte-guided-safe-top) + 6px);
    gap: 3px;
    padding: 7px 10px;
  }

  .qte-panel--guided #qteGuideAction { font-size: 15px; }
  .qte-panel--guided #qteGuideHint,
  .qte-panel--guided #qteGuideNext { font-size: 11px; }
  .qte-panel--guided .qte-guide-meta { font-size: 10px; }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring {
    --qte-guided-cue-width: 132px;
    --qte-guided-cue-height: 132px;
    top: min(60%, calc(72.5% - var(--qte-guided-cue-height) / 2 - 20px), calc(100% - var(--qte-guided-safe-bottom) - var(--qte-guided-cue-height) / 2 - 10px)) !important;
    gap: 1px;
    padding: 9px;
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring strong { font-size: 32px; }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-swipe-cue {
    --qte-guided-cue-width: 226px;
    --qte-guided-cue-height: 100px;
    gap: 2px 6px;
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.qte-direction-up, .qte-direction-down) {
    --qte-guided-cue-width: 148px;
    --qte-guided-cue-height: 148px;
    gap: 1px;
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-rapid-cue {
    --qte-guided-cue-width: 136px;
    --qte-guided-cue-height: 136px;
  }
}

/* Landscape / very short stages: a two-row guide and shallow, readable cues
   preserve the center target while leaving both HUDs and subtitles clear. */
@container guided-qte (max-height: 440px) {
  .qte-panel--guided .qte-guide {
    top: calc(var(--qte-guided-safe-top) + 4px);
    max-width: 640px;
    grid-template-columns: minmax(0, 1fr) minmax(0, .7fr);
    align-items: start;
    gap: 3px 10px;
    padding: 5px 8px;
  }

  .qte-panel--guided .qte-guide-meta {
    grid-area: 1 / 2;
    justify-content: flex-end;
    gap: 2px 8px;
  }

  .qte-panel--guided #qteGuideAction { grid-area: 1 / 1; }
  .qte-panel--guided #qteGuideHint { grid-area: 2 / 1; }
  .qte-panel--guided #qteGuideNext {
    grid-area: 2 / 2;
    padding: 0 0 0 8px;
    border-top: 0;
    border-left: 1px solid rgba(242, 246, 244, .24);
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.is-swipe-cue, .is-rapid-cue) {
    --qte-guided-cue-width: 226px;
    --qte-guided-cue-height: 88px;
    grid-template: auto auto / 34px minmax(0, 1fr) auto;
    gap: 2px 6px;
    padding: 7px 9px;
    border-radius: 20px;
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring > strong,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.is-swipe-cue, .is-rapid-cue) > strong {
    grid-area: 1 / 1 / 3 / 2;
    align-self: center;
    font-size: 32px;
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring > span,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.is-swipe-cue, .is-rapid-cue) > span {
    grid-area: 1 / 2;
    align-self: end;
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring > small,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.is-swipe-cue, .is-rapid-cue) > small {
    grid-area: 2 / 2;
    align-self: start;
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring > em,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.is-swipe-cue, .is-rapid-cue) > em {
    grid-area: 1 / 3 / 3 / 4;
    align-self: center;
  }
}

@container guided-qte (max-height: 360px) {
  .qte-panel--guided .qte-guide {
    gap: 2px 8px;
    padding: 4px 8px;
  }

  .qte-panel--guided #qteGuideAction,
  .qte-panel--guided #qteGuideHint,
  .qte-panel--guided #qteGuideNext { line-height: 1.35; }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.is-swipe-cue, .is-rapid-cue) {
    --qte-guided-cue-height: 72px;
  }

  /* Only the duplicate in-cue explanation is omitted at this height.
     The permanent guide retains the full current hint and next step. */
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring small,
  .qte-panel--guided.qte-panel--cinematic:lang(hi) .qte-cue-ring small { display: none; }
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring > span,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring:is(.is-swipe-cue, .is-rapid-cue) > span {
    grid-row: 1 / 3;
    align-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qte-panel--guided.qte-panel--cinematic,
  .qte-panel--guided .qte-guide,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring::before,
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring::after {
    animation: none !important;
    transition: none !important;
  }

  /* Static success feedback replaces the hit flash; don't silently lose it. */
  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-hit {
    opacity: 1;
    filter: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(98, 221, 255, .24);
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-rapid-hit:not(.is-hit) {
    filter: none;
    border-color: var(--cyan);
  }

  .qte-panel--guided.qte-panel--cinematic .qte-cue-ring.is-hit:not(.is-visible) {
    opacity: 0;
  }
}
