* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold: #a78bfa;
  --gold-light: #c4b5fd;
  --gold-dark: #7c3aed;
  --cyan: #22d3ee;
  --cyan-dim: #0891b2;
  --bg: #040308;
  --glass: oklch(1 0 0 / 0.06);
  --glass-border: oklch(1 0 0 / 0.12);
  --font-ar: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-en: "Outfit", "Segoe UI", sans-serif;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg);
  font-family: var(--font-ar);
  -webkit-font-smoothing: antialiased;
}

#wrap { position: relative; width: 100%; height: 100%; }
canvas { display: block; width: 100%; height: 100%; }

/* Cinematic overlays */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background:
    radial-gradient(ellipse 55% 70% at 12% 50%, transparent 0%, rgba(0,0,0,.25) 55%, rgba(0,0,0,.7) 100%),
    radial-gradient(ellipse at center, transparent 32%, rgba(0,0,0,.58) 100%);
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 0.5s steps(2) infinite;
}
@keyframes grainShift {
  0%, 100% { transform: translate(0,0); }
  50% { transform: translate(-2%, -1%); }
}
.letterbox {
  position: fixed; left: 0; right: 0; height: 5.5vh; pointer-events: none; z-index: 7;
  background: linear-gradient(to bottom, #000, transparent);
}
.letterbox-bottom {
  top: auto; bottom: 0;
  background: linear-gradient(to top, #000, transparent);
}

.screen-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 14;
  background: radial-gradient(circle, rgba(255,255,255,.85) 0%, rgba(34,211,238,.35) 40%, transparent 70%);
  opacity: 0; transition: opacity 0.15s ease-out;
}
.screen-flash.on { opacity: 1; }

/* Chrome */
.chrome {
  position: absolute; inset: 0; pointer-events: none; z-index: 10;
  display: flex; flex-direction: column; justify-content: space-between;
}
.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 32px;
  background: linear-gradient(180deg, rgba(3,5,8,.92), transparent);
  pointer-events: auto;
}
.brand {
  display: flex; align-items: center; gap: 14px;
  color: #f0f4fa; font-weight: 700; font-size: 1.05rem;
  font-family: var(--font-en);
  letter-spacing: 0.02em;
}
.brand em { font-style: normal; color: var(--gold); font-weight: 500; font-size: 0.92em; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(145deg, var(--gold-light), var(--gold-dark));
  color: #1a1200; font-weight: 900; font-size: 0.85rem;
  display: grid; place-items: center;
  box-shadow: 0 0 24px rgba(167,139,250,.45), inset 0 1px 0 rgba(255,255,255,.4);
}
.top-actions { display: flex; gap: 10px; }
.btn-icon {
  pointer-events: auto;
  background: var(--glass); border: 1px solid var(--glass-border);
  color: #e8eef7; width: 42px; height: 42px; border-radius: 12px;
  cursor: pointer; font-size: 1rem;
  backdrop-filter: blur(16px) saturate(1.4);
  transition: all 0.25s ease;
}
.btn-icon:hover {
  background: oklch(0.75 0.12 85 / 0.15);
  border-color: var(--gold);
  box-shadow: 0 0 20px oklch(0.75 0.12 85 / 0.25);
}

/* Finale overlay */
.overlay-text {
  text-align: center; padding: 0 28px 120px;
  opacity: 0; transform: scale(0.88) translateY(20px);
  transition: opacity 1.1s ease, transform 1.1s cubic-bezier(.16,1,.3,1);
}
.overlay-text.show { opacity: 1; transform: scale(1) translateY(0); }

.finale-badge {
  display: inline-block; margin-bottom: 18px;
  padding: 6px 20px; border-radius: 999px;
  font-family: var(--font-en); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.22em; color: var(--gold);
  border: 1px solid oklch(0.75 0.12 85 / 0.45);
  background: oklch(0.75 0.12 85 / 0.08);
  backdrop-filter: blur(12px);
  animation: fadeUp 0.8s ease both;
}

.hero-title {
  font-family: var(--font-en);
  font-size: clamp(2.8rem, 8vw, 5rem); font-weight: 900;
  letter-spacing: -0.04em; line-height: 1;
  margin-bottom: 16px;
  animation: titlePulse 3s ease-in-out infinite alternate;
}
.hero-title span {
  background: linear-gradient(135deg, #fff 0%, var(--gold-light) 35%, var(--cyan) 70%, #34d399 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 40px rgba(34,211,238,.5));
}
@keyframes titlePulse {
  from { filter: drop-shadow(0 0 30px rgba(167,139,250,.4)); }
  to { filter: drop-shadow(0 0 60px rgba(34,211,238,.7)); }
}

.tagline {
  color: rgba(255,255,255,.95);
  font-size: clamp(1.25rem, 3.2vw, 1.85rem); font-weight: 600;
  margin-bottom: 12px;
  text-shadow: 0 4px 40px rgba(0,0,0,.9);
  animation: fadeUp 1s ease 0.2s both;
}
.success-msg {
  color: var(--gold-light);
  font-size: clamp(1rem, 2.4vw, 1.3rem); font-weight: 700;
  margin-bottom: 28px;
  animation: fadeUp 1s ease 0.35s both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.cta {
  pointer-events: auto; position: relative; overflow: hidden;
  display: inline-block;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold), var(--gold-light));
  color: #1a1000; padding: 16px 42px; border-radius: 14px;
  font-weight: 800; text-decoration: none; font-size: 1.05rem;
  box-shadow: 0 12px 48px oklch(0.75 0.12 85 / 0.4), inset 0 1px 0 rgba(255,255,255,.35);
  animation: fadeUp 1s ease 0.5s both;
  transition: transform 0.2s, box-shadow 0.2s;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 16px 56px oklch(0.75 0.12 85 / 0.55); }
.cta-shine {
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.45) 50%, transparent 60%);
  animation: ctaShine 3s ease-in-out infinite;
}
@keyframes ctaShine {
  0%, 100% { transform: translateX(-120%); }
  50% { transform: translateX(120%); }
}

/* Bottom bar */
.bottom-bar {
  padding: 18px 32px 28px;
  background: linear-gradient(0deg, rgba(3,5,8,.95), transparent);
  pointer-events: auto;
}
.progress-wrap { display: flex; align-items: center; gap: 16px; }
.play-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--glass-border);
  cursor: pointer; flex-shrink: 0;
  background: linear-gradient(145deg, oklch(0.75 0.12 85 / 0.25), oklch(0.55 0.08 85 / 0.15));
  color: var(--gold-light); font-size: 1.15rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.progress-track {
  flex: 1; height: 4px; background: rgba(255,255,255,.1);
  border-radius: 4px; cursor: pointer; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--cyan), #34d399);
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(34,211,238,.6);
  transition: width 0.1s linear;
}
.time {
  color: rgba(255,255,255,.55); font-size: 0.82rem;
  min-width: 96px; text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-en);
}

/* Left rail — sequential premium steps */
.cinema-rail {
  position: absolute;
  top: 50%;
  left: clamp(16px, 3vw, 40px);
  transform: translateY(-50%);
  width: min(300px, 28vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  transition: opacity 0.8s ease;
}
body.playing .cinema-rail { opacity: 1; }

.rail-head {
  margin-bottom: 6px;
  padding-inline-start: 4px;
}
.rail-badge {
  display: block;
  font-family: var(--font-en);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.26em;
  color: var(--gold);
  opacity: 0.9;
  margin-bottom: 6px;
}
.rail-title {
  display: block;
  color: rgba(255,255,255,.92);
  font-size: 1.05rem;
  font-weight: 700;
}

.cinema-step {
  display: flex;
  align-items: stretch;
  gap: 12px;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  filter: blur(6px);
  transition:
    opacity 0.85s cubic-bezier(.16,1,.3,1),
    transform 0.95s cubic-bezier(.16,1,.3,1),
    filter 0.7s ease;
}
.cinema-step.in {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}
.cinema-step.active .step-card {
  border-color: oklch(0.75 0.12 85 / 0.65);
  box-shadow:
    0 0 0 1px oklch(0.75 0.12 85 / 0.2),
    0 12px 40px rgba(0,0,0,.45),
    0 0 32px oklch(0.75 0.12 85 / 0.22),
    inset 0 1px 0 rgba(255,255,255,.08);
}
.cinema-step.done .step-card {
  border-color: oklch(0.72 0.14 165 / 0.5);
  background: oklch(0.22 0.04 200 / 0.55);
}
.cinema-step.done .step-state::after {
  content: '✓';
  color: #34d399;
  font-weight: 900;
  font-size: 1.1rem;
  text-shadow: 0 0 16px rgba(52,211,153,.8);
}
.cinema-step.active .step-state::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 14px var(--cyan);
  animation: stepPulse 1.2s ease-in-out infinite;
}
@keyframes stepPulse {
  50% { transform: scale(1.35); opacity: 0.65; }
}

.step-num {
  flex-shrink: 0;
  width: 36px;
  font-family: var(--font-en);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: oklch(0.75 0.12 85 / 0.55);
  padding-top: 16px;
  transition: color 0.4s, text-shadow 0.4s;
}
.cinema-step.in .step-num { color: var(--gold); text-shadow: 0 0 20px oklch(0.75 0.12 85 / 0.45); }
.cinema-step.done .step-num { color: #34d399; }

.step-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: oklch(0.1 0.02 250 / 0.62);
  border: 1px solid oklch(1 0 0 / 0.1);
  backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: 0 8px 32px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
  transition: border-color 0.45s, box-shadow 0.45s, background 0.45s;
}
.step-flag { font-size: 1.65rem; line-height: 1; }
.step-copy { flex: 1; min-width: 0; }
.step-copy strong {
  display: block;
  color: #f4f8ff;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 3px;
}
.step-ip {
  display: block;
  font-family: Consolas, monospace;
  font-size: 0.78rem;
  color: var(--cyan);
  letter-spacing: 0.04em;
}
.step-state {
  flex-shrink: 0;
  width: 22px;
  display: grid;
  place-items: center;
}
.step-state::after { display: block; }

.rail-glow {
  position: absolute;
  inset: -20% auto -20% -40%;
  width: 120%;
  background: radial-gradient(ellipse at left center, oklch(0.75 0.12 85 / 0.12), transparent 68%);
  pointer-events: none;
  z-index: -1;
  animation: railGlow 4s ease-in-out infinite alternate;
}
@keyframes railGlow {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

@media (max-width: 720px) {
  .cinema-rail {
    width: min(240px, 42vw);
    left: 10px;
    gap: 10px;
  }
  .step-card { padding: 10px 12px; }
  .step-copy strong { font-size: 0.82rem; }
  .rail-title { font-size: 0.9rem; }
}

.subtitle {
  position: absolute; bottom: 108px; left: 50%; transform: translateX(-50%);
  padding: 14px 32px; border-radius: 14px;
  background: oklch(0.08 0.02 250 / 0.72);
  backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid oklch(1 0 0 / 0.1);
  box-shadow: 0 8px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.06);
  color: var(--gold-light); font-size: 1.02rem; font-weight: 600;
  white-space: nowrap; opacity: 0; transition: opacity 0.5s;
  z-index: 11; pointer-events: none;
}
.subtitle.show { opacity: 1; }

.flash-msg {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-family: var(--font-ar);
  font-size: clamp(2rem, 6vw, 3.5rem); font-weight: 900;
  color: #fff; white-space: nowrap;
  text-shadow: 0 0 60px var(--cyan), 0 0 120px var(--gold);
  opacity: 0; pointer-events: none; z-index: 15;
  transition: opacity 0.35s, transform 0.7s cubic-bezier(.16,1.4,.3,1);
}
.flash-msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* Start screen — luxury */
#startScreen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, oklch(0.75 0.12 85 / 0.08), transparent),
    radial-gradient(ellipse at center, oklch(0.65 0.15 200 / 0.12), var(--bg) 72%);
  cursor: pointer; transition: opacity 0.7s;
}
#startScreen.hidden { opacity: 0; pointer-events: none; visibility: hidden; display: none; }

.start-badge {
  font-family: var(--font-en); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.28em; color: var(--gold);
  margin-bottom: 32px; opacity: 0.85;
}
.play-ring {
  position: relative; width: 130px; height: 130px;
  margin-bottom: 32px;
}
.play-ring-inner {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid oklch(0.75 0.12 85 / 0.35);
  animation: ringSpin 8s linear infinite;
}
.play-ring-inner::before {
  content: ''; position: absolute; inset: -8px; border-radius: 50%;
  border: 1px solid oklch(0.65 0.15 200 / 0.25);
  animation: ringSpin 12s linear infinite reverse;
}
@keyframes ringSpin { to { transform: rotate(360deg); } }

.play-big {
  position: absolute; inset: 12px; border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-light), var(--gold-dark));
  display: grid; place-items: center;
  font-size: 2.6rem; color: #1a1000;
  box-shadow: 0 0 80px oklch(0.75 0.12 85 / 0.5), inset 0 2px 0 rgba(255,255,255,.35);
  animation: playPulse 2.5s ease-in-out infinite;
}
@keyframes playPulse {
  50% { box-shadow: 0 0 100px oklch(0.75 0.12 85 / 0.7); transform: scale(1.04); }
}

#startScreen h2 {
  color: #fff; font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 700;
  text-align: center; padding: 0 24px; margin-bottom: 12px;
  line-height: 1.45;
}
#startScreen h2 .gold {
  font-family: var(--font-en); font-weight: 900;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.start-sub { color: rgba(255,255,255,.55); font-size: 1rem; margin-bottom: 20px; }
.start-hint {
  color: var(--gold); font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.08em; opacity: 0.7;
  animation: hintBlink 2s ease-in-out infinite;
}
@keyframes hintBlink { 50% { opacity: 0.35; } }

body.embedded .cinema-rail { left: clamp(14px, 3vw, 30px); width: min(258px, 44vw); }
body.embedded .step-card { padding: 12px 13px; }
body.embedded .step-copy strong { font-size: 0.84rem; }
body.embedded .rail-title { font-size: 0.98rem; }
body.embedded .bottom-bar { padding-bottom: 14px; }
body.embedded .subtitle { bottom: 80px; }
body.embedded .letterbox { height: 4vh; }
body.cinema .progress-fill { background: linear-gradient(90deg, #b91c1c, #e50914, #fca5a5); }
body.cinema .cta { background: #e50914; color: #fff; border-radius: 6px; box-shadow: none; }
body.cinema .cta-shine { display: none; }
body.chrome-hidden .bottom-bar, body.chrome-hidden .subtitle { opacity: 0; pointer-events: none; transition: opacity 0.45s; }
