#gameScreen[data-cutscene-hud] > :not(#gameCanvas),
#app:has(> #gameScreen[data-cutscene-hud]) > :not(#gameScreen),
body:has(#gameScreen[data-cutscene-hud]) > :is(#toast, #rewardCelebration) {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

:is(dialog.world-cutscene, dialog.professor-field-scene, dialog.starter-arrival-scene) {
  --scene-side: clamp(15px, 6vw, 104px);
  --scene-top: clamp(16px, 7dvh, 100px);
  --scene-bottom: clamp(16px, 8dvh, 108px);
  --scene-pad: clamp(10px, 2vw, 28px);
  --scene-action-bottom: max(calc(var(--scene-bottom) + var(--scene-pad)), calc(env(safe-area-inset-bottom) + 8px));
}

/* The night theme paints ordinary dialogs in this layer. These two overlays
   must let the world canvas show through while their HUD lock is active. */
@layer pokepark-night {
  html[data-game-theme="dark"]:has(#gameScreen[data-cutscene-hud]) dialog:is(.world-cutscene, .starter-arrival-scene) {
    background-color: transparent !important;
  }
}

dialog.world-cutscene {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: transparent;
  color: #f6f9fc;
  font-family: inherit;
}

:is(dialog.world-cutscene, dialog.professor-field-scene, dialog.starter-arrival-scene)::backdrop {
  background: transparent !important;
}

.world-cutscene-frame {
  position: fixed;
  z-index: 0;
  inset: 0;
  border-style: solid;
  border-color: rgb(0 0 0 / 20%);
  border-width: max(var(--scene-top), env(safe-area-inset-top))
    0
    max(var(--scene-bottom), env(safe-area-inset-bottom))
    0;
  pointer-events: none;
}

#starterArrivalScene > .world-cutscene-frame {
  border-color: rgb(0 0 0 / 85%);
}

.world-cutscene-copy {
  position: absolute;
  z-index: 1;
  inset-inline: max(calc(var(--scene-side) + var(--scene-pad)), env(safe-area-inset-left), env(safe-area-inset-right));
  bottom: max(calc(var(--scene-bottom) + var(--scene-pad)), calc(env(safe-area-inset-bottom) + 8px));
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 20px;
  align-items: end;
  width: auto;
  max-width: 780px;
  margin-inline: auto;
  padding: 14px 16px;
  border: 1px solid #ffffff40;
  border-radius: 16px;
  background: #121b26f5;
  box-shadow: 0 6px 28px #0006;
}

.world-cutscene-copy strong {
  display: block;
  margin-bottom: 4px;
  color: #ffdb8b;
  font-size: 14px;
}

.world-cutscene-copy p {
  margin: 0;
  font-size: clamp(15px, 1.35vw, 19px);
  line-height: 1.35;
}

.world-cutscene-copy [data-scene-error] {
  margin-top: 4px;
  color: #ffc3b2;
  font-size: 13px;
}

.world-cutscene-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: end;
}

.world-cutscene button,
:is(dialog.professor-field-scene, dialog.starter-arrival-scene) > button {
  z-index: 2;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.world-cutscene [data-scene-skip] {
  background: transparent;
  color: #d9e2ec;
}

.evolution-world-scene > .world-cutscene-frame {
  border: 0;
  background: radial-gradient(ellipse at 50% 48%, transparent 31%, rgb(9 27 23 / 29%));
}

.evolution-world-scene > [data-scene-skip] {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  padding-inline: 18px;
  border-color: rgb(255 255 255 / 28%);
  border-radius: 999px;
  color: #fff;
  background: rgb(13 36 34 / 87%);
}

.world-cutscene [data-scene-next],
:is(dialog.professor-field-scene, dialog.starter-arrival-scene) > button {
  background: var(--ui-primary, #096caa);
  color: var(--ui-on-accent, #fff);
  border-color: var(--ui-focus, #087db8);
  box-shadow: 0 3px 12px #102d4550;
}

.world-cutscene [data-scene-next]:hover,
:is(dialog.professor-field-scene, dialog.starter-arrival-scene) > button:hover {
  background: var(--ui-primary-hover, #075a8d);
}

@media (min-width: 761px) and (pointer: fine) {
  .world-cutscene [data-scene-next],
  :is(dialog.professor-field-scene, dialog.starter-arrival-scene) > button {
    min-width: 164px;
    min-height: 54px;
    padding-inline: 20px;
    font-size: 16px;
  }
}

.world-cutscene button:focus-visible,
:is(dialog.professor-field-scene, dialog.starter-arrival-scene) > button:focus-visible {
  outline: 2px solid var(--ui-focus, #087db8);
  outline-offset: 2px;
}

.world-cutscene button[aria-disabled="true"] {
  opacity: .6;
  cursor: wait;
}

:is(dialog.professor-field-scene, dialog.starter-arrival-scene) > button {
  position: fixed;
  top: auto;
  right: max(calc(var(--scene-side) + var(--scene-pad)), calc(env(safe-area-inset-right) + 8px));
  bottom: var(--scene-action-bottom);
}

/* Reset the top inset from the legacy starter dialog so auto height follows
   the button content once the control is anchored to the bottom. */
#starterArrivalScene.starter-arrival-scene > .starter-arrival-skip {
  position: fixed;
  top: auto;
  right: max(calc(var(--scene-side) + var(--scene-pad)), calc(env(safe-area-inset-right) + 8px));
}

dialog.starter-arrival-scene #starterArrivalCaption {
  position: fixed;
  z-index: 1;
  top: auto;
  bottom: calc(var(--scene-action-bottom) + 53px);
  left: 50%;
  max-width: min(680px, calc(100% - 2 * (var(--scene-side) + var(--scene-pad))));
}

#starterArrivalScene.starter-arrival-scene > #starterArrivalCaption {
  position: fixed;
  z-index: 1;
  inset-inline: max(calc(var(--scene-side) + var(--scene-pad)), env(safe-area-inset-left), env(safe-area-inset-right));
  bottom: calc(var(--scene-action-bottom) + 53px);
  max-width: 680px;
  margin: 0 auto;
}

@media (max-width: 620px), (max-height: 540px) {
  :is(dialog.world-cutscene, dialog.professor-field-scene, dialog.starter-arrival-scene) {
    --scene-side: clamp(9px, 4vw, 28px);
    --scene-top: clamp(12px, 5dvh, 32px);
    --scene-bottom: clamp(12px, 5dvh, 32px);
    --scene-pad: 8px;
  }

  .world-cutscene-copy {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 11px;
    gap: 6px;
  }
}

@media (orientation: landscape) and (max-height: 420px) {
  .world-cutscene-copy {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .world-cutscene-actions button {
    padding-inline: 8px;
    font-size: 13px;
  }
}
