/* «أنا الدافور» opening show: game_intro (title) + welcome (contestants, crown, rules).
   Everything is scoped to .dafour-intro. Content is laid out on a 1600×900 canvas that
   intro-show.js scales to the screen (--di-fit); the background layers fill the whole viewport. */

body[data-phase="welcome"] .topbar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-18px);
}
body[data-phase="welcome"] .stage { width: 100%; padding: 0; }

.dafour-intro {
  --di-ink: #111117;
  --di-paper: #fffaf0;
  --di-sun: #ffd348;
  --di-violet: #6846ed;
  --di-coral: #ff5b70;
  --di-mint: #3fe0b0;
  --di-lilac: #b79cff;
  --di-snap: cubic-bezier(.16, 1.28, .3, 1);
  --di-enter: cubic-bezier(.18, .82, .22, 1);
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  isolation: isolate;
  background: #07060c;
  color: var(--di-paper);
  font-family: var(--display-font);
  font-weight: 900;
  direction: rtl;
  animation: none !important;
}
.dafour-intro *, .dafour-intro *::before, .dafour-intro *::after { box-sizing: border-box; }

/* ---------- full-viewport background layers ---------- */
.di-wash { position: absolute; inset: 0; z-index: -5; opacity: 0; transition: opacity .25s, background 1s;
  background: radial-gradient(60% 70% at 70% 30%, #6846ed 0, transparent 70%), radial-gradient(55% 60% at 20% 85%, #ff5b70 0, transparent 70%), #171227; }
.di-wash.on { opacity: 1; }
.di-wash.crown { background: radial-gradient(60% 70% at 50% 35%, #8a5cff 0, transparent 70%), radial-gradient(50% 50% at 50% 100%, #ffb23f 0, transparent 70%), #1a1030; }
.di-rays { position: absolute; left: 50%; top: 50%; width: 180vmax; height: 180vmax; margin: -90vmax 0 0 -90vmax; z-index: -4; opacity: 0;
  background: repeating-conic-gradient(from 4deg, rgba(255,255,255,.12) 0 4deg, transparent 4deg 18deg);
  -webkit-mask-image: radial-gradient(circle, transparent 0 8%, #000 10% 40%, transparent 62%);
  mask-image: radial-gradient(circle, transparent 0 8%, #000 10% 40%, transparent 62%);
  animation: di-spin 22s linear infinite; transition: opacity .4s; }
.di-rays.on { opacity: .55; }
.di-spot { position: absolute; left: 50%; top: 50%; width: 100vmin; height: 100vmin; margin: -50vmin 0 0 -50vmin; z-index: -3; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(255,240,200,.22), transparent 60%); transition: opacity .5s; }
.di-spot.on { opacity: 1; }
.di-vignette { position: absolute; inset: 0; z-index: 19; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55)); }
.di-grain { position: absolute; inset: 0; z-index: 20; pointer-events: none; opacity: .13; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
.di-flash { position: absolute; inset: 0; z-index: 18; background: #fff; opacity: 0; pointer-events: none; }
.di-flash.go { animation: di-flash .45s ease-out; }

/* ---------- 1600×900 content canvas ---------- */
.di-canvas { position: absolute; left: 50%; top: 50%; width: 1600px; height: 900px; margin: -450px 0 0 -800px; transform: scale(var(--di-fit, 1)); transform-origin: 50% 50%; }
.di-canvas.shake { animation: di-shake .42s cubic-bezier(.36,.07,.19,.97); }
.di-n { font-family: "Segoe UI", Tahoma, Arial, sans-serif; font-weight: 900; direction: ltr; unicode-bidi: isolate; }

/* ---------- act 1: title ---------- */
.di-line { position: absolute; top: 450px; right: 50%; height: 3px; width: 0; background: var(--di-sun); box-shadow: 0 0 18px var(--di-sun); transform: translateX(50%); }
.di-line.draw { animation: di-line-draw .5s var(--di-enter) forwards; }
.di-line.gone { opacity: 0; transition: opacity .3s; }
.di-lockup { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; transition: transform .8s var(--di-enter), opacity .4s; }
.di-lockup.docked { transform: translateY(-345px) scale(.34); }
.di-lockup.hide { opacity: 0; }
.di-ana { position: relative; z-index: 3; margin-bottom: -46px; padding: 2px 26px 12px; color: var(--di-ink); background: var(--di-paper); border: 5px solid var(--di-ink); border-radius: 16px;
  font-size: 62px; line-height: 1.2; box-shadow: 7px 8px 0 rgba(17,17,23,.45); opacity: 0; translate: 300px 0; rotate: -9deg; }
.di-ana::before { content: ""; position: absolute; top: -14px; left: 50%; width: 46px; height: 22px; margin-left: -23px; background: rgba(255,244,218,.55); rotate: 4deg; box-shadow: 0 1px 0 rgba(0,0,0,.1); }
.di-ana.on { animation: di-pop .4s var(--di-snap) forwards; }
.di-slot { position: relative; height: 320px; min-width: 900px; display: grid; place-items: center; }
.di-word { position: absolute; font-size: 210px; line-height: 1; white-space: nowrap; color: var(--di-word, #fff);
  text-shadow: 1px 1px 0 rgba(17,17,23,.55), 2px 2px 0 rgba(17,17,23,.55), 3px 3px 0 rgba(17,17,23,.55), 4px 4px 0 rgba(17,17,23,.55), 5px 5px 0 rgba(17,17,23,.55), 6px 6px 0 rgba(17,17,23,.55), 7px 7px 0 rgba(17,17,23,.55), 8px 8px 0 rgba(17,17,23,.55);
  animation: di-slot-tick var(--di-d, .3s) linear forwards; }
.di-halftone { position: absolute; width: 900px; height: 900px; border-radius: 50%; z-index: -2; opacity: 0;
  background: radial-gradient(circle, rgba(255,211,72,.7) 2.2px, transparent 2.8px) 0 0 / 20px 20px;
  -webkit-mask-image: radial-gradient(circle, #000 0 22%, rgba(0,0,0,.5) 40%, transparent 66%);
  mask-image: radial-gradient(circle, #000 0 22%, rgba(0,0,0,.5) 40%, transparent 66%); }
.di-halftone.on { animation: di-halftone-in .9s var(--di-enter) forwards, di-spin 60s linear .9s infinite; }
.di-ring { position: absolute; width: 300px; height: 300px; border-radius: 50%; border: 10px solid var(--di-sun); opacity: 0; z-index: -1; }
.di-ring.r2 { border-color: var(--di-coral); border-width: 6px; }
.di-ring.on { animation: di-ring 1s cubic-bezier(.1,.7,.3,1) forwards; }
.di-ring.r2.on { animation-delay: .1s; }
.di-shards { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.di-shard { position: absolute; left: 50%; top: 50%; width: var(--w); height: var(--h); background: var(--c); border: 3px solid var(--di-ink); border-radius: 3px;
  box-shadow: 3px 4px 0 rgba(17,17,23,.35); opacity: 0;
  animation: di-shard-out .8s cubic-bezier(.12,.8,.25,1) forwards, di-shard-float var(--fl) ease-in-out .8s infinite alternate; }
.di-shard.tri { border: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); box-shadow: none; }
.di-shard.dot { border-radius: 50%; }
.di-title { position: relative; margin: 0; display: grid; place-items: center; font-size: 270px; font-weight: 900; line-height: .95; white-space: nowrap; opacity: 0; }
.di-title > * { grid-area: 1 / 1; }
.di-t-ext { color: #6b2a10; -webkit-text-stroke: 12px var(--di-ink);
  text-shadow: 1px 1px 0 #5a2410, 2px 2px 0 #62280f, 3px 3px 0 #5a2410, 4px 4px 0 #62280f, 5px 5px 0 #5a2410, 6px 6px 0 #62280f, 7px 7px 0 #5a2410, 8px 8px 0 #62280f, 9px 9px 0 #5a2410, 10px 10px 0 #62280f, 11px 11px 0 #5a2410, 12px 12px 0 #62280f, 13px 13px 0 #5a2410, 14px 14px 0 #62280f, 22px 26px 0 rgba(17,17,23,.5), 0 0 90px rgba(255,170,40,.45); }
.di-t-ghost { opacity: 0; mix-blend-mode: screen; }
.di-t-ghost.g1 { color: var(--di-coral); }
.di-t-ghost.g2 { color: var(--di-mint); }
.di-t-face { color: transparent; -webkit-background-clip: text; background-clip: text;
  background-image: linear-gradient(112deg, transparent 38%, rgba(255,255,255,.95) 48%, transparent 58%),
    radial-gradient(circle, rgba(190,70,0,.38) 1.6px, transparent 2.1px),
    linear-gradient(180deg, #fff7c9 0%, #ffe066 34%, #ffc23a 62%, #ff9420 100%);
  background-size: 320% 100%, 11px 11px, 100% 100%; background-position: 140% 0, 0 0, 0 0; }
.di-title.stamp { animation: di-stamp .62s var(--di-snap) forwards; }
.di-title.stamp .di-t-ghost { animation: di-ghost .55s ease-out forwards; }
.di-title.stamp .di-t-ghost.g2 { --gx: 18px; --gy: 10px; }
.di-title.shine .di-t-face { animation: di-shine 1.1s ease-in-out forwards; }
.di-swoosh { position: absolute; left: 50%; bottom: -54px; width: 620px; height: 70px; margin-left: -310px; overflow: visible; }
.di-swoosh path { fill: none; stroke-linecap: round; stroke-dasharray: 700; stroke-dashoffset: 700; }
.di-swoosh .sw-ink { stroke: var(--di-ink); stroke-width: 20; transform: translate(6px, 7px); opacity: .55; }
.di-swoosh .sw-paint { stroke: var(--di-coral); stroke-width: 18; }
.di-swoosh .sw-hi { stroke: rgba(255,255,255,.5); stroke-width: 4; transform: translate(-3px, -4px); }
.di-title.ruled .di-swoosh path { animation: di-draw .5s var(--di-enter) forwards; }
.di-title.ruled .di-swoosh .sw-hi { animation-delay: .12s; }
.di-kicker { margin-top: 44px; padding: 10px 26px 14px; font-size: 38px; color: var(--di-paper); background: var(--di-ink); opacity: 0; clip-path: polygon(2% 3%, 100% 9%, 96% 100%, 0 92%); }
.di-kicker.on { animation: di-kicker-in .45s var(--di-snap) forwards; }
.di-tease { margin-top: 18px; min-height: 70px; font-size: 52px; color: var(--di-paper); white-space: pre; }
.di-tease span { display: inline-block; opacity: 0; transform: translateY(20px); }
.di-tease span.on { animation: di-char-in .28s var(--di-snap) forwards; }

/* ---------- act 2: contestants ---------- */
.di-label { position: absolute; top: 150px; left: 0; right: 0; z-index: 6; text-align: center; font-size: 44px; opacity: 0; transition: opacity .3s; }
.di-label span { display: inline-block; padding: 6px 26px 12px; background: var(--di-ink); transform: rotate(-1.5deg); box-shadow: 6px 6px 0 var(--di-sun); }
.di-label.on { animation: di-kicker-in .45s var(--di-snap) forwards; }
.di-label.off { opacity: 0 !important; animation: none; }
.di-cards { position: absolute; top: 330px; left: 0; right: 0; z-index: 6; display: flex; justify-content: center; gap: 24px; transition: transform .8s var(--di-enter); }
.di-cards.many { gap: 14px; }
.di-cards.low { transform: translateY(120px) scale(.86); }
.di-card { --c: var(--di-violet); position: relative; width: 160px; padding: 14px 10px 16px; display: grid; justify-items: center; gap: 8px;
  color: var(--di-ink); background: var(--di-paper); border: 5px solid var(--di-ink); border-radius: 22px; box-shadow: 8px 10px 0 rgba(0,0,0,.35);
  opacity: 0; transition: box-shadow .12s, transform .12s; }
.di-card.in { animation: di-card-fly .62s var(--di-snap) forwards; }
.di-card.landed { opacity: 1; transform: rotate(var(--r)); }
.di-card .player-avatar { width: 116px; height: 116px; min-width: 116px; border: 6px solid var(--c); box-shadow: none; font-size: 3rem; }
.di-card .di-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; font-size: 30px; line-height: 1.15; white-space: nowrap; }
.di-card .di-no { padding: 2px 12px 5px; color: #fff; background: var(--c); border-radius: 999px; font-size: 18px; }
.di-card.lit { box-shadow: 0 0 0 8px var(--di-sun), 0 0 60px 10px rgba(255,211,72,.7); transform: translateY(-18px) rotate(0deg) !important; }
.di-count { position: absolute; top: 650px; left: 0; right: 0; z-index: 6; text-align: center; font-size: 64px; opacity: 0; text-shadow: 6px 7px 0 rgba(0,0,0,.4); transition: opacity .3s; }
.di-count b { color: var(--di-sun); }
.di-count.on { animation: di-pop .5s var(--di-snap) forwards; }
.di-count.off { opacity: 0 !important; animation: none; }

/* ---------- act 3: crown + rules ---------- */
.di-crown-wrap { position: absolute; top: 40px; left: 50%; z-index: 7; width: 420px; margin-left: -210px; display: grid; justify-items: center; transform: translateY(-460px); }
.di-crown-wrap.drop { animation: di-crown-drop 1s var(--di-snap) forwards; }
.di-crown-wrap.landed { transform: none; }
.di-crown { width: 300px; filter: drop-shadow(10px 12px 0 rgba(0,0,0,.35)); }
.di-crown .q { transform-origin: 150px 120px; transform-box: view-box; }
.di-crown.glow { animation: di-crown-glow .9s ease-out; }
.di-crown.glow .q { animation: di-q-spin .9s var(--di-snap); }
.di-crown-cap { margin-top: 2px; padding: 6px 24px 12px; font-size: 46px; white-space: nowrap; background: var(--di-ink); transform: rotate(-2deg); box-shadow: 6px 6px 0 var(--di-coral); opacity: 0; }
.di-crown-cap.on { animation: di-kicker-in .45s var(--di-snap) forwards; }
.di-rules { position: absolute; left: 0; right: 0; bottom: 100px; z-index: 8; display: flex; justify-content: center; gap: 18px; }
.di-rule { display: flex; align-items: center; gap: 12px; padding: 10px 22px 14px 18px; font-size: 30px; white-space: nowrap; background: var(--di-ink); border: 3px solid rgba(255,255,255,.18); border-radius: 16px; opacity: 0; transform: translateY(60px); }
.di-rule i { width: 46px; height: 46px; display: grid; place-items: center; color: var(--di-ink); background: var(--di-icon, var(--di-sun)); border-radius: 12px; font-size: 30px; font-style: normal; }
.di-rule.on { animation: di-rule-in .5s var(--di-snap) forwards; }

/* Reduced motion: show each state without movement. */
@media (prefers-reduced-motion: reduce) {
  .dafour-intro *, .dafour-intro *::before, .dafour-intro *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

@keyframes di-spin { to { transform: rotate(1turn); } }
@keyframes di-flash { from { opacity: .85; } to { opacity: 0; } }
@keyframes di-shake { 0%, 100% { translate: 0 0; } 15% { translate: -16px 8px; } 30% { translate: 14px -10px; } 45% { translate: -10px 6px; } 60% { translate: 8px -4px; } 80% { translate: -3px 2px; } }
@keyframes di-line-draw { to { width: 1100px; } }
@keyframes di-pop { from { opacity: 0; transform: scale(.5) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes di-slot-tick { 0% { opacity: 0; transform: translateY(70%) scaleY(1.3); filter: blur(6px); } 22% { opacity: 1; transform: none; filter: blur(0); } 78% { opacity: 1; transform: none; filter: blur(0); } 100% { opacity: 0; transform: translateY(-70%) scaleY(1.3); filter: blur(6px); } }
@keyframes di-halftone-in { from { opacity: 0; transform: scale(.4); } to { opacity: .55; transform: scale(1); } }
@keyframes di-ring { 0% { opacity: 1; transform: scale(.4); } 100% { opacity: 0; transform: scale(4.2); } }
@keyframes di-shard-out { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(0) scale(.3); } 25% { opacity: 1; } 100% { opacity: 1; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); } }
@keyframes di-shard-float { from { translate: 0 0; } to { translate: 0 -14px; } }
@keyframes di-ghost { 0% { opacity: .9; transform: translate(calc(var(--gx, -18px) * 1.8), calc(var(--gy, -8px) * 1.8)); } 100% { opacity: 0; transform: translate(0, 0); } }
@keyframes di-shine { from { background-position: 140% 0, 0 0, 0 0; } to { background-position: -40% 0, 0 0, 0 0; } }
@keyframes di-draw { to { stroke-dashoffset: 0; } }
@keyframes di-stamp { 0% { opacity: 0; transform: scale(2.8) rotate(-16deg); } 55% { opacity: 1; transform: scale(.9) rotate(-2deg); } 78% { transform: scale(1.05) rotate(-4deg); } 100% { opacity: 1; transform: scale(1) rotate(-3deg); } }
@keyframes di-kicker-in { from { opacity: 0; transform: translateY(-18px) rotate(-5deg) scale(.8); } to { opacity: 1; transform: rotate(-1deg); } }
@keyframes di-char-in { to { opacity: 1; transform: none; } }
@keyframes di-card-fly { 0% { opacity: 0; transform: translate(var(--fx), var(--fy)) rotate(var(--fr)) scale(.6); } 70% { opacity: 1; transform: translate(0, 0) rotate(calc(var(--r) * -1.6)) scale(1.06); } 100% { opacity: 1; transform: rotate(var(--r)); } }
@keyframes di-crown-drop { 0% { transform: translateY(-460px) rotate(-8deg); } 70% { transform: translateY(12px) rotate(3deg); } 100% { transform: translateY(0) rotate(0); } }
@keyframes di-crown-glow { 0% { filter: drop-shadow(10px 12px 0 rgba(0,0,0,.35)) brightness(1.8); } 100% { filter: drop-shadow(10px 12px 0 rgba(0,0,0,.35)); } }
@keyframes di-q-spin { from { transform: rotateY(-360deg) scale(.4); } to { transform: none; } }
@keyframes di-rule-in { to { opacity: 1; transform: none; } }

/* Freeze the show while the game is paused (the pause overlay sits above it). */
body:has(#paused:not([hidden])) .dafour-intro *,
body:has(#paused:not([hidden])) .dafour-intro *::before,
body:has(#paused:not([hidden])) .dafour-intro *::after { animation-play-state: paused !important; }
