/* ════════════════════════════════════════
   Design tokens — gold luxury, mobile-first
   ════════════════════════════════════════ */
:root {
  --gold: #f5c96b;
  --gold-deep: #c8941f;
  --gold-soft: #ffe7b0;
  --rose: #e58aa0;
  --bg-1: #160d1c;
  --bg-2: #07040b;
  --ink: #fff6e6;

  /* portrait-tuned type scale (vmin keeps it sane on tall phones) */
  --text-big: clamp(2rem, 8.5vmin, 5rem);
  --text-small: clamp(0.95rem, 3.6vmin, 1.7rem);
  --text-sig: clamp(0.95rem, 3.4vmin, 1.5rem);

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --serif: 'Cormorant Garamond', serif;
  --ar-display: 'Reem Kufi', 'Cairo', sans-serif;
  --ar-serif: 'Amiri', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 32%, var(--bg-1), var(--bg-2) 72%);
  color: var(--ink);
  font-family: var(--ar-display);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: block;
}

/* ════════════════════════════════════════
   Caption overlay
   ════════════════════════════════════════ */
#overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  z-index: 5;
  padding: max(env(safe-area-inset-top), 4vmin) 6vw max(env(safe-area-inset-bottom), 4vmin);
}

.caption {
  text-align: center;
  max-width: 90vw;
  opacity: 0;
  transform: translateY(20px);
  will-change: transform, opacity, filter;
}

.caption-big {
  font-family: var(--ar-serif);
  font-weight: 700;
  font-size: var(--text-big);
  line-height: 1.18;
  color: var(--gold-soft);
  text-shadow:
    0 0 14px rgba(245, 201, 107, 0.55),
    0 0 48px rgba(200, 148, 31, 0.4);
}

.caption-small {
  margin-top: 0.7em;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: var(--text-small);
  letter-spacing: 0.06em;
  color: rgba(255, 246, 230, 0.82);
}

.caption-sig {
  margin-top: 1.1em;
  font-family: var(--ar-serif);
  font-weight: 700;
  font-size: var(--text-sig);
  color: var(--rose);
  opacity: 0;
  text-shadow: 0 0 18px rgba(229, 138, 160, 0.5);
}

/* atmosphere */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(4, 2, 8, 0.82) 100%);
}
.grain {
  position: fixed; inset: -50%; pointer-events: none; z-index: 6; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.7s steps(2) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-3%, 2%); }
  100% { transform: translate(2%, -2%); }
}

/* scene flash */
#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 7; opacity: 0;
  background: radial-gradient(circle at center, rgba(255, 231, 176, 0.9), rgba(245, 201, 107, 0.4) 40%, transparent 75%);
}

/* ════════════════════════════════════════
   Start screen
   ════════════════════════════════════════ */
#start-screen {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 38%, #1d1124, #060309 78%);
  transition: opacity 1.1s var(--ease-out-expo), visibility 1.1s;
  padding: env(safe-area-inset-top) 8vw env(safe-area-inset-bottom);
}
#start-screen.hidden { opacity: 0; visibility: hidden; }

.start-card { position: relative; text-align: center; animation: rise 1.1s var(--ease-out-expo) both; }
@keyframes rise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }

.start-ring {
  position: absolute; left: 50%; top: -2.2em; width: 9em; height: 9em;
  transform: translateX(-50%);
  border: 1px solid rgba(245, 201, 107, 0.25);
  border-radius: 50%;
  box-shadow: 0 0 60px rgba(245, 201, 107, 0.15) inset;
  animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: translateX(-50%) scale(1); opacity: 0.6; } 50% { transform: translateX(-50%) scale(1.08); opacity: 1; } }

.start-spark { font-size: 2.2rem; color: var(--gold); text-shadow: 0 0 24px var(--gold-deep); animation: spin 9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.start-title {
  margin-top: 0.4rem;
  font-family: var(--ar-serif); font-weight: 700;
  font-size: clamp(3rem, 18vmin, 6rem);
  color: var(--gold-soft);
  text-shadow: 0 0 34px rgba(245, 201, 107, 0.55);
}
.start-sub {
  margin-top: 0.3rem; font-family: var(--serif); font-style: italic;
  letter-spacing: 0.1em; color: rgba(255, 246, 230, 0.62);
  font-size: clamp(0.9rem, 4vmin, 1.3rem);
}

#start-btn {
  margin-top: 2.4rem;
  padding: 0.95em 2.6em;
  font-family: var(--ar-display); font-weight: 600;
  font-size: clamp(1.05rem, 4.6vmin, 1.35rem);
  color: var(--bg-2);
  background: linear-gradient(135deg, var(--gold-soft), var(--gold), var(--gold-deep));
  border: none; border-radius: 999px; cursor: pointer;
  box-shadow: 0 10px 34px rgba(200, 148, 31, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.3s var(--ease-out-expo), box-shadow 0.3s, filter 0.3s, opacity 0.4s;
}
#start-btn:active { transform: scale(0.97); }
@media (hover: hover) { #start-btn:hover { transform: translateY(-3px) scale(1.03); filter: brightness(1.06); } }
#start-btn.not-ready { opacity: 0.45; pointer-events: none; }

.start-hint { margin-top: 1.6rem; font-size: clamp(0.75rem, 3.2vmin, 0.95rem); color: rgba(255, 246, 230, 0.42); letter-spacing: 0.04em; }
.start-loading { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 1.6rem); left: 0; right: 0; text-align: center; font-size: 0.8rem; color: rgba(255, 246, 230, 0.4); letter-spacing: 0.12em; }
.start-loading.done { display: none; }

/* ════════════════════════════════════════
   Replay button (after the show)
   ════════════════════════════════════════ */
.replay {
  position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 2.4rem);
  z-index: 9; display: grid; place-items: center; pointer-events: none;
}
.replay[hidden] { display: none; }
#replay-btn {
  pointer-events: auto;
  font-family: var(--ar-display); font-size: 0.95rem;
  color: var(--gold-soft); background: rgba(20, 12, 24, 0.6);
  border: 1px solid rgba(245, 201, 107, 0.4); border-radius: 999px;
  padding: 0.6em 1.6em; cursor: pointer; backdrop-filter: blur(8px);
  transition: background 0.3s, transform 0.2s;
  animation: fadeIn 1s ease both;
}
#replay-btn:active { transform: scale(0.96); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ════════════════════════════════════════
   Rotate hint (landscape phones)
   ════════════════════════════════════════ */
#rotate-hint {
  position: fixed; inset: 0; z-index: 30; display: none;
  place-items: center; text-align: center;
  background: radial-gradient(ellipse at center, #1a0f1f, #060309);
  color: var(--gold-soft); font-family: var(--ar-display);
}
.rotate-icon { font-size: 3rem; animation: tilt 2s ease-in-out infinite; }
@keyframes tilt { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }
#rotate-hint p { margin-top: 1rem; line-height: 1.7; }
#rotate-hint span { font-family: var(--serif); font-style: italic; opacity: 0.7; font-size: 0.9rem; }

@media (max-aspect-ratio: 13/9) and (max-height: 480px) {
  /* short + wide → phone in landscape */
  #rotate-hint { display: grid; }
}
