/* Title screen, brand pass (owner chose the carved fire/ice banner look): full-bleed painted 9:16 key art,
   painted logo over the storm sky, tagline + actions on the dark ground. No duplicate "NINE REALMS" line (it is on
   the logo plate), no eyebrow, no rune glyph over the art. Loaded last. */
#game #screen-title .title-art > div { background-size: cover !important; background-position: 50% 42% !important; }
#game #screen-title .title-art > div, #game #screen-title .title-art video { animation: titleDrift 26s ease-in-out infinite alternate; }
@keyframes titleDrift { from { transform: scale(1.02); } to { transform: scale(1.07) translateY(-0.6%); } }
#game #screen-title .title-vignette { background:
  linear-gradient(180deg, #05080acc 0%, #05080a40 18%, transparent 32%, transparent 58%, #05080a99 76%, #05080af2 100%) !important; }
#game #screen-title .title-rune { display: none !important; }
#game #screen-title .title-heading.brand { position: absolute; left: 50%; top: max(4.5%, 34px); transform: translateX(-50%); width: min(88%, 520px); margin: 0; padding: 0; text-align: center; z-index: 3; }
#game #screen-title .title-heading.brand::before, #game #screen-title .title-heading.brand::after { content: none !important; }
#game #screen-title .title-heading.brand .title-main { margin: 0; padding: 0; line-height: 0; font-size: 0; background: none; }
#game #screen-title .title-logo { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 14px #000c) drop-shadow(0 0 18px #ff8a3a2e);
  animation: logoIn .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes logoIn { from { opacity: 0; transform: translateY(-8px) scale(.97); } }
#game #screen-title .title-tag { text-shadow: 0 2px 6px #000, 0 0 2px #000; }
@media (prefers-reduced-motion: reduce) {
  #game #screen-title .title-art > div, #game #screen-title .title-art video, #game #screen-title .title-logo { animation: none; } }
#game #screen-title .title-heading.brand .title-tag { position: static !important; inset: auto !important; transform: none !important; width: auto; max-width: 30ch;
  margin: 6px auto 0; padding: 0; text-wrap: balance; opacity: .92; }

/* motion layer: canvas FX (js/title-fx.js) between the art and the logo, drifting mist, logo light sweep */
#game #screen-title .title-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
#game #screen-title .title-vignette { z-index: 1; }
#game #screen-title::before { content: ''; position: absolute; left: -20%; right: -20%; bottom: 0; height: 34%; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 40% 60% at 25% 80%, #9fb3c21f, transparent 70%), radial-gradient(ellipse 45% 55% at 75% 90%, #9fb3c219, transparent 70%);
  animation: titleMist 18s ease-in-out infinite alternate; }
@keyframes titleMist { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
#game #screen-title .title-heading.brand .title-main { position: relative; }
#game #screen-title .title-heading.brand .title-main::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, #fff6dd99 48%, #ffffffcc 50%, #fff6dd99 52%, transparent 62%) no-repeat;
  background-size: 260% 100%; background-position: 140% 0; mix-blend-mode: overlay;
  -webkit-mask: var(--logo-mask) center / 100% 100% no-repeat; mask: var(--logo-mask) center / 100% 100% no-repeat;
  animation: logoSheen 7.5s ease-in-out 1.4s infinite; }
@keyframes logoSheen { 0%, 70% { background-position: 140% 0; } 92%, 100% { background-position: -40% 0; } }
#game #screen-title .title-logo { animation: logoIn .9s cubic-bezier(.2,.8,.2,1) both, logoBreath 4.8s ease-in-out .9s infinite; }
@keyframes logoBreath { 50% { filter: drop-shadow(0 6px 14px #000c) drop-shadow(-10px 0 22px #ff8a3a4d) drop-shadow(10px 0 22px #6cc4ff40); } }
@media (prefers-reduced-motion: reduce) { #game #screen-title::before, #game #screen-title .title-heading.brand .title-main::after { animation: none; } }

/* map header realm subtitle: wrap (max 2 lines) instead of cutting it with "…" (game-ui-craft: never truncate titles) */
#game .map-header .realm span { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; text-wrap: balance; line-height: 1.2; }

#game #screen-title .title-art video { width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; }

/* Shorter screens (exact 9:16 desktop frame, tablets): the logo scales with width, the painting with height, so
   keep the heading short enough that the tagline clears the god's head (~31% of the height). */
@media (min-aspect-ratio: 52/100) {
  #game #screen-title .title-heading.brand { width: min(74%, 440px); top: max(3.5%, 26px); }
  #game #screen-title .title-heading.brand .title-tag { margin-top: 2px; font-size: .92em; }
}

/* ---- perf pass (owner: "đầu game hơi giật"): only compositor-friendly animation on the title.
   The logo breath animated `filter` (a full repaint of a 1200 px image every frame) → now a separate glow layer
   whose opacity animates. Art layers are promoted once. Logo is WebP (108 KB instead of a 1.08 MB PNG). */
#game #screen-title .title-art > div, #game #screen-title .title-art video { will-change: transform; backface-visibility: hidden; }
#game #screen-title .title-logo { animation: logoIn .9s cubic-bezier(.2,.8,.2,1) both !important; filter: drop-shadow(0 6px 12px #000c); }
#game #screen-title .title-heading.brand .title-main::before { content: ''; position: absolute; inset: -6% -4%; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 34% 50% at 24% 46%, #ff8a3a40, transparent 70%), radial-gradient(ellipse 34% 50% at 78% 44%, #6cc4ff38, transparent 70%);
  opacity: .35; will-change: opacity; animation: logoGlow 4.8s ease-in-out 1s infinite; }
@keyframes logoGlow { 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #game #screen-title .title-heading.brand .title-main::before { animation: none; } }

/* ---- no CSS drift on the video (owner: "khung hình giật giật kiểu lag"): a 24 fps video re-scaled by a 60 fps
   transform shows each frame at a slightly different scale, which reads as judder. The loop already moves; the
   slow push-in stays only on the still-image fallback. */
#game #screen-title .title-art video { animation: none !important; transform: none !important; will-change: auto; }

/* intro gate: nothing animates until app.js adds .title-ready (page loaded + idle). Logo waits hidden, then reveals. */
#game #screen-title:not(.title-ready) .title-logo { opacity: 0; animation: none !important; }
#game #screen-title:not(.title-ready) .title-heading.brand .title-tag { opacity: 0; }
#game #screen-title .title-heading.brand .title-tag { transition: opacity .6s ease .45s; }
#game #screen-title:not(.title-ready) .title-heading.brand .title-main::before,
#game #screen-title:not(.title-ready) .title-heading.brand .title-main::after,
#game #screen-title:not(.title-ready)::before { animation-play-state: paused; }
