:root {
  --bg-void: #08051a;
  --bg-nebula-1: #1c0a3e;
  --bg-nebula-2: #3a1568;
  --violet: #7c3aed;
  --violet-glow: #b794f6;
  --gold: #e8b84b;
  --gold-dim: #a8863a;
  --text: #f5f3ff;
  --text-muted: #9c8fc4;
  --card-bg: #170b31;
  --card-border: rgba(183, 148, 246, 0.18);
}

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

body {
  background:
    radial-gradient(ellipse 900px 600px at 50% -10%, var(--bg-nebula-2) 0%, transparent 60%),
    radial-gradient(ellipse 700px 500px at 85% 90%, rgba(124, 58, 237, 0.15) 0%, transparent 60%),
    var(--bg-void);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
}

.grain-source { position: absolute; width: 0; height: 0; }
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.035;
  filter: url(#grain);
  background: #fff;
  mix-blend-mode: overlay;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 480px;
  padding: 2rem 1.5rem;
  position: relative;
  z-index: 1;
}
.screen.active { display: flex; }

/* --- Login --- */
.spotlight {
  position: absolute;
  top: -120px;
  left: 50%;
  width: 500px;
  height: 400px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at top, rgba(232, 184, 75, 0.12) 0%, rgba(124, 58, 237, 0.1) 40%, transparent 70%);
  pointer-events: none;
  animation: spotlight-breathe 6s ease-in-out infinite;
}
@keyframes spotlight-breathe {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 3rem;
  letter-spacing: 0.03em;
  color: var(--text);
  text-shadow: 0 0 30px rgba(183, 148, 246, 0.5), 0 0 60px rgba(124, 58, 237, 0.3);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: -1rem;
}

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

input {
  width: 100%;
  padding: 0.95rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}
input:focus {
  outline: none;
  border-color: var(--violet-glow);
  background: rgba(124, 58, 237, 0.08);
}
input::placeholder { color: var(--text-muted); }

button {
  padding: 0.95rem 1.1rem;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
  background: linear-gradient(135deg, var(--violet), #6425d0);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
button:not(:disabled):hover { box-shadow: 0 6px 28px rgba(183, 148, 246, 0.5); transform: translateY(-1px); }

.error { color: #f87171; font-size: 0.9rem; }
.hidden { display: none; }

/* --- Genre select --- */
#select-screen h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.8rem;
  letter-spacing: 0.02em;
  font-weight: 400;
  text-align: center;
}

.toggle-group { display: flex; gap: 0.5rem; width: 100%; }
.toggle {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  box-shadow: none;
}
.toggle.active {
  background: linear-gradient(135deg, var(--violet), #6425d0);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}

.genre-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.genre-chip {
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  width: auto;
  transition: all 0.15s ease;
}
.genre-chip:hover { border-color: rgba(183, 148, 246, 0.4); color: var(--text); }
.genre-chip.selected {
  background: linear-gradient(135deg, var(--violet), #6425d0);
  border-color: transparent;
  color: var(--text);
  box-shadow: 0 0 16px rgba(183, 148, 246, 0.4);
}

/* --- Spin reel --- */
.spin-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.reel-viewport {
  position: relative;
  width: 100%;
  height: 300px;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--card-border);
}
.reel-viewport::before, .reel-viewport::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 8px, transparent 8px 20px);
  animation: marquee-chase 1.2s linear infinite;
  opacity: 0.8;
  z-index: 2;
}
.reel-viewport::before { top: 0; }
.reel-viewport::after { bottom: 0; animation-direction: reverse; }
@keyframes marquee-chase {
  from { background-position: 0 0; }
  to { background-position: 40px 0; }
}

.reel {
  display: flex;
  gap: 12px;
  height: 100%;
  align-items: center;
  padding: 0 20px;
  will-change: transform;
}
.reel-card {
  flex-shrink: 0;
  width: 140px;
  height: 210px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(23,11,49,0.5));
}
.reel-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reel-marker {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 3px;
  background: var(--gold);
  box-shadow: 0 0 16px var(--gold);
  transform: translateX(-50%);
  z-index: 3;
}
.reel-vignette {
  position: absolute;
  top: 0; bottom: 0;
  width: 60px;
  pointer-events: none;
  z-index: 2;
}
.reel-vignette.left { left: 0; background: linear-gradient(90deg, var(--bg-void), transparent); }
.reel-vignette.right { right: 0; background: linear-gradient(270deg, var(--bg-void), transparent); }

/* --- Flip card --- */
.flip-card {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 2 / 3;
  perspective: 1200px;
}
.flip-inner {
  position: relative;
  width: 100%; height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}
.flip-card.flipped .flip-inner {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

.flip-front, .flip-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.flip-front img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.tap-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text);
  background: rgba(8, 5, 26, 0.65);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  pointer-events: none;
}

.flip-back {
  transform: rotateY(180deg);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
}
.flip-back h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
  font-weight: 400;
}
.trailer-wrap iframe {
  width: 100%; aspect-ratio: 16/9; border-radius: 8px; border: none;
}
.rating {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.95rem;
}
#result-overview { font-size: 0.85rem; line-height: 1.5; opacity: 0.85; flex: 1; }

#boot-screen { justify-content: center; }
#boot-screen .logo { animation: spotlight-breathe 1.6s ease-in-out infinite; }

/* --- Trailer thumbnail (back face) --- */
.trailer-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
}
.trailer-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.trailer-thumb .play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.trailer-thumb .play-icon svg { width: 52px; height: 52px; filter: drop-shadow(0 2px 10px rgba(0,0,0,0.6)); }
.trailer-thumb:hover .play-icon svg { transform: scale(1.08); }
.trailer-thumb .play-icon svg { transition: transform 0.15s ease; }

/* --- Full-screen trailer modal (sits outside the flip card's transform) --- */
.trailer-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 2, 14, 0.92);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.trailer-modal.hidden { display: none; }
.trailer-modal-inner {
  width: 100%;
  max-width: 720px;
}
.trailer-modal-inner iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: 10px;
}
.trailer-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
