/* A painted, widescreen opening. The 3D world lives on the game's canvas below it. */
.opening {
  --op-accent: #edcf97;
  --op-ink: #faf0db;
  --op-black: #040812;
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  color: var(--op-ink);
}
.opening[hidden] { display: none; }
.opening p { margin: 0; }
.op-black, .op-nebula, .op-pantheon, .op-vignette, .op-flash, .op-letterbox { position: absolute; inset: 0; pointer-events: none; }
.op-black { background: var(--op-black); opacity: 0; transition: opacity 1s; }
.at-presents .op-black, .is-flat .op-black { opacity: 1; }
.op-nebula {
  background: radial-gradient(ellipse at 24% 26%, #bb813813, transparent 50%), radial-gradient(ellipse at 78% 70%, #355c9122, transparent 55%);
  opacity: 0.75;
}
.op-vignette { background: radial-gradient(ellipse at center, transparent 30%, #02050d99 100%), linear-gradient(0deg, #02050d 0%, transparent 25%, transparent 75%, #02050d66 100%); }
.op-letterbox { border-top: 6vh solid #03060c; border-bottom: 6vh solid #03060c; z-index: 8; }
.op-eyebrow { font: 500 clamp(10px, 0.95vw, 14px)/1.6 var(--sans); letter-spacing: 0.25em; text-transform: uppercase; color: #e5c38c; }

/* A brief studio signature, preserving the supplied name and optional mark. */
.op-presents { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 20px; opacity: 0; text-align: center; visibility: hidden; }
.op-studio { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.2em 0.5em; max-width: 86vw; font: 400 clamp(19px, 3.1vw, 42px)/1.35 var(--serif); letter-spacing: 0.06em; }
.op-logo { height: 1.25em; width: auto; }
.op-logo[hidden] { display: none; }
.op-word { font: 400 10px/1.4 var(--sans); letter-spacing: 0.5em; text-transform: uppercase; color: #c4b99f; }
.at-presents .op-presents { visibility: visible; animation: op-studio 3s ease both; }
@keyframes op-studio { 0%, 100% { opacity: 0; } 24%, 76% { opacity: 1; } }


/* Each painting fills the frame, with its edge lost in the sky. No portrait cards. */
.op-god { position: absolute; inset: 0; opacity: 0; visibility: hidden; overflow: hidden; }
.op-god img { position: absolute; height: 112%; width: 68%; object-fit: cover; object-position: center 35%; top: -5%; left: -2%; filter: saturate(0.83) brightness(0.82); }
.op-god::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 25%, #04081235 42%, #040812 67%), linear-gradient(0deg, #040812 3%, transparent 40%); }
.op-god:nth-child(even) img { left: auto; right: -2%; }
.op-god:nth-child(even)::after { background: linear-gradient(270deg, transparent 25%, #04081235 42%, #040812 67%), linear-gradient(0deg, #040812 3%, transparent 40%); }
.op-god span { display: none; }
.is-flat.at-gods .op-god.active { opacity: 1; visibility: visible; animation: op-cut 0.45s ease-out both; }
.is-flat.at-gods .op-god.active img { animation: op-portrait 3.1s cubic-bezier(0.16, 0.7, 0.3, 1) both; }
@keyframes op-cut { from { opacity: 0; } to { opacity: 1; } }
@keyframes op-portrait { from { transform: scale(1.1) translateX(-2%); filter: saturate(0.65) brightness(1.1); } to { transform: scale(1.02) translateX(0); filter: saturate(0.85) brightness(0.82); } }
.op-god-copy { position: absolute; left: 56%; right: 5%; top: 35%; visibility: hidden; opacity: 0; text-shadow: 0 4px 35px #0008; }
[data-god='1'] .op-god-copy, [data-god='3'] .op-god-copy { left: 9%; right: 51%; }
.op-god-copy .op-eyebrow { color: var(--op-accent); }
.op-god-copy .op-god-name { margin: 12px 0 18px; font: 400 clamp(64px, 8.5vw, 140px)/0.95 var(--serif); letter-spacing: -0.045em; }
.op-god-copy::before { content: ''; display: block; width: 46px; height: 2px; margin-bottom: 28px; background: var(--op-accent); box-shadow: 0 0 24px var(--op-accent); }
.at-gods .op-god-copy { visibility: visible; }
.at-gods .op-god-copy.arrive { animation: op-copy var(--op-god-duration, 6.4s) ease both; }
@keyframes op-copy { 0% { opacity: 0; transform: translateX(24px); } 14%, 88% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(-6px); } }

/* Illustrated fallback: the same story on machines without WebGL. */
.is-flat.at-claim .op-pantheon, .is-flat.at-title .op-pantheon { mask-image: radial-gradient(ellipse at 50% 67%, transparent 12%, #0008 42%, #000 70%); -webkit-mask-image: radial-gradient(ellipse at 50% 67%, transparent 12%, #0008 42%, #000 70%); }
.is-flat.at-claim .op-god, .is-flat.at-title .op-god { width: 25%; top: 6%; bottom: 7%; opacity: 0.55; visibility: visible; animation: op-assembly 0.9s ease-out both; }
.is-flat.at-claim .op-god:nth-child(1), .is-flat.at-title .op-god:nth-child(1) { left: 0; }
.is-flat.at-claim .op-god:nth-child(2), .is-flat.at-title .op-god:nth-child(2) { left: 25%; }
.is-flat.at-claim .op-god:nth-child(3), .is-flat.at-title .op-god:nth-child(3) { left: 50%; }
.is-flat.at-claim .op-god:nth-child(4), .is-flat.at-title .op-god:nth-child(4) { left: 75%; }
.is-flat.at-claim .op-god img, .is-flat.at-title .op-god img { width: 100%; height: 100%; inset: 0; object-position: 50% 32%; filter: saturate(0.7) brightness(0.6); }
.is-flat.at-claim .op-god::after, .is-flat.at-title .op-god::after { background: linear-gradient(0deg, #040812 4%, transparent 65%), linear-gradient(90deg, #04081299, transparent 30%, transparent 70%, #04081299); }
.is-flat.at-claim .op-god span { display: block; position: absolute; top: 6%; width: 100%; text-align: center; font: 400 clamp(11px, 1.1vw, 17px)/1 var(--serif); letter-spacing: 0.22em; text-transform: uppercase; color: #f3dfb5; }
@keyframes op-assembly { from { opacity: 0; transform: scale(1.08); } to { opacity: 0.55; transform: scale(1); } }
.op-caption { position: absolute; left: 8%; right: 8%; bottom: 13%; text-align: center; font: italic 400 clamp(17px, 2vw, 26px)/1.4 var(--serif); color: #f6e9cc; text-shadow: 0 2px 20px #000, 0 2px 4px #000; opacity: 0; transition: opacity 0.45s ease; }
.op-caption.on { opacity: 1; }
.is-flat.at-claim .op-caption { font-style: normal; font-size: clamp(21px, 2.7vw, 40px); }

/* The poster's wordmark is shared with the main menu, including its transparent edges. */
.op-title { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; visibility: hidden; pointer-events: none; }
.op-name { width: min(86vw, 1200px, 220vh); }
.at-title .op-title { visibility: visible; animation: op-title 4.8s cubic-bezier(0.16, 0.8, 0.2, 1) both; }
.is-flat.at-title .op-god { animation: none; opacity: 0.28; }
@keyframes op-title { 0% { opacity: 0; transform: scale(1.14); } 14%, 92% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.01); } }
.op-flash { z-index: 6; background: #ebcba1; opacity: 0; }
.op-flash.go { animation: op-flash 0.8s ease-out both; }
@keyframes op-flash { from { opacity: 0.34; } to { opacity: 0; } }

/* Controls remain legible within the lower cinema bar and usable without a pointer. */
.op-controls { position: absolute; z-index: 10; bottom: max(5px, env(safe-area-inset-bottom)); left: max(24px, env(safe-area-inset-left)); right: max(24px, env(safe-area-inset-right)); height: 5vh; min-height: 36px; display: flex; align-items: center; justify-content: space-between; }
.op-controls button { background: none; border: 0; color: #c8bdab; padding: 8px 2px; font: 500 10px/1.5 var(--sans); text-transform: uppercase; letter-spacing: 0.17em; cursor: pointer; min-height: 36px; }
.op-controls button:hover { color: #fff3d4; }
.op-controls button:focus-visible { outline: 1px solid #e9d39d; outline-offset: 5px; }
.op-skip span { display: inline-block; margin-left: 14px; font-size: 17px; }
.op-progress { position: absolute; z-index: 11; bottom: 0; left: 0; width: 100%; height: 1px; background: #c9ac70; opacity: 0.5; transform-origin: left; transform: scaleX(var(--op-progress, 0)); }
.at-out { pointer-events: none; opacity: 0; transition: opacity 0.6s ease; }

/* Reduced motion keeps every story beat as a still composition, including the reset. */
.op-flat-world { position: absolute; display: none; width: min(58vw, 76vh); height: auto; left: 22%; top: 15%; filter: drop-shadow(0 0 24px #488bac44); }
.is-flat .op-flat-world { display: block; }
.is-flat.at-presents .op-flat-world { display: none; }
.is-flat.at-world .op-flat-world, .is-flat.at-ascension .op-flat-world, .is-flat.at-battle .op-flat-world { left: 4%; }
.is-flat.at-ascension .op-flat-world { animation: op-world-glory 5s ease both; }
@keyframes op-world-glory {
  0%, 100% { filter: drop-shadow(0 0 24px #488bac44); }
  35%, 65% { filter: drop-shadow(0 0 28px #edcc7777); }
}
.is-flat.at-gods .op-flat-world { width: 28vw; top: 55%; left: 62%; opacity: 0.5; }
.is-flat.at-gods[data-god='1'] .op-flat-world, .is-flat.at-gods[data-god='3'] .op-flat-world { left: 10%; }
.is-flat.at-title .op-flat-world { top: 42%; opacity: 0.5; }
.is-calm *, .is-calm *::before, .is-calm *::after { animation: none !important; transition: none !important; }
.is-calm.at-presents .op-presents, .is-calm.at-title .op-title { opacity: 1; }
.is-calm .op-flash { display: none; }

@media (max-aspect-ratio: 4/5) {
  .op-letterbox { border-top-width: 5vh; border-bottom-width: 7vh; }
  .at-world .op-caption { bottom: 11%; font-size: 16px; }
  .op-god img, .op-god:nth-child(even) img { width: 120%; height: 79%; top: 2%; left: -10%; right: auto; object-position: center 28%; }
  .op-god::after, .op-god:nth-child(even)::after { background: linear-gradient(0deg, #040812 19%, #040812cc 29%, transparent 60%); }
  .op-god-copy, [data-god='1'] .op-god-copy, [data-god='3'] .op-god-copy { left: 9%; right: 9%; top: 64%; text-align: center; }
  .op-god-copy::before { margin: 0 auto 18px; width: 28px; }
  .op-god-copy .op-god-name { font-size: clamp(60px, 15vw, 100px); margin: 12px 0; }
  .op-god-title { font-size: 10px; letter-spacing: 0.18em; }
  .is-flat.at-claim .op-god, .is-flat.at-title .op-god { width: 50%; height: 43%; }
  .is-flat.at-claim .op-god:nth-child(1), .is-flat.at-title .op-god:nth-child(1) { left: 0; top: 5%; }
  .is-flat.at-claim .op-god:nth-child(2), .is-flat.at-title .op-god:nth-child(2) { left: 50%; top: 5%; }
  .is-flat.at-claim .op-god:nth-child(3), .is-flat.at-title .op-god:nth-child(3) { left: 0; top: 48%; }
  .is-flat.at-claim .op-god:nth-child(4), .is-flat.at-title .op-god:nth-child(4) { left: 50%; top: 48%; }
  .is-flat.at-claim .op-god img, .is-flat.at-title .op-god img { height: 100%; width: 100%; inset: 0; }
  .is-flat.at-claim .op-god span { top: 8%; font-size: 11px; }
  .is-flat.at-claim .op-pantheon, .is-flat.at-title .op-pantheon { mask-image: radial-gradient(ellipse at 50% 50%, transparent 8%, #0008 44%, #000 80%); -webkit-mask-image: radial-gradient(ellipse at 50% 50%, transparent 8%, #0008 44%, #000 80%); }
  .op-caption { left: 8%; right: 8%; bottom: 12%; }
  .op-flat-world { width: 90vw; left: 5%; top: 22%; }
  .is-flat.at-world .op-flat-world, .is-flat.at-ascension .op-flat-world, .is-flat.at-battle .op-flat-world { width: 92vw; left: 4%; top: 12%; }
  .is-flat.at-gods .op-flat-world { display: none; }
}
@media (max-height: 500px) and (min-aspect-ratio: 4/5) {
  .op-god-copy { top: 28%; }
  .op-god-copy::before { margin-bottom: 12px; }
  .op-god-copy .op-god-name { font-size: 65px; margin: 8px 0 12px; }
  .op-controls { bottom: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .opening *, .opening *::before, .opening *::after { animation: none !important; transition: none !important; }
  .opening.at-presents .op-presents, .opening.at-title .op-title { opacity: 1; }
  .op-flash { display: none; }
}

/* The 3D actors are the main picture. Captions and names are its only overlay. */
/* Keep the exposure steady while the names alternate sides. Flipping a directional
   gradient at each reveal caused a full-screen flick before the next painting arrived. */
.at-gods:not(.is-flat) .op-vignette { background: radial-gradient(ellipse at 50% 40%, transparent 28%, #04081288 100%), linear-gradient(0deg, #040812 0%, transparent 28%); }
.at-battle .op-caption { max-width: 750px; margin: 0 auto; }
.at-claim .op-caption { font-style: normal; font-size: clamp(22px, 2.7vw, 40px); }
.op-shores { display: none; position: absolute; inset: 0; background: #040812; pointer-events: none; }
.op-shore-ash, .op-shore-dawn { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; }
.op-shores .shore { display: block; width: min(110vw, 130vh); max-width: none; height: auto; }
.is-flat.at-ash .op-shores, .is-flat.at-reset .op-shores { display: block; }
.at-ash .op-shore-ash { opacity: 1; }
.at-reset .op-shore-ash { animation: op-ash-out 4s ease both; }
.at-reset .op-shore-dawn { animation: op-dawn-in 4s ease both; }
@keyframes op-ash-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes op-dawn-in { from { opacity: 0; } to { opacity: 1; } }
.is-flat.at-battle .op-flat-world { animation: op-world-burn 9s ease both; }
@keyframes op-world-burn { 0% { filter: brightness(1); } 40% { filter: brightness(2) sepia(.7); } 65%, 100% { filter: brightness(.25) saturate(.15); } }
.is-flat.at-ash .op-flat-world, .is-flat.at-reset .op-flat-world { display: none; }
.is-calm.at-reset .op-shore-ash { opacity: 0; }
.is-calm.at-reset .op-shore-dawn, .is-calm.at-gods .op-god-copy { opacity: 1; }
.is-calm.at-battle .op-flat-world { filter: brightness(.4) saturate(.3); }
@media (max-aspect-ratio: 4/5) {
  .at-gods:not(.is-flat) .op-god-copy { top: 67%; }
  .at-gods:not(.is-flat) .op-god-copy .op-god-name { font-size: 13vw; }
  .at-gods:not(.is-flat) .op-vignette { background: linear-gradient(0deg, #040812 5%, #040812dd 23%, transparent 52%); }
  .op-shores .shore { width: 145vw; }
  .at-battle .op-caption { font-size: 18px; }
}
