:root {
  --bg: #121212;
  --bg-alt: #191918;
  --card: #1d1c1a;
  --card-border: #34322e;
  --text: #f2f0ec;
  --muted: #9a9690;
  --accent: #f5a623;
  --accent-dim: #d98a1a;
  --accent-ink: #2a1600;
  --accent2: #e8543e;
  --gold: #ffc857;
  --danger: #ff5470;
  --radius: 16px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-glow::before,
.bg-glow::after,
.bg-glow-blob {
  content: "";
  position: absolute;
  width: 55vw;
  height: 55vw;
  max-width: 700px;
  max-height: 700px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.28;
  will-change: transform, opacity;
}

.bg-glow::before {
  top: -18%;
  left: -12%;
  background: radial-gradient(circle, var(--accent), transparent 65%);
  animation: driftOne 18s ease-in-out infinite, pulseOne 7s ease-in-out infinite;
}

.bg-glow::after {
  bottom: -22%;
  right: -14%;
  background: radial-gradient(circle, var(--accent2), transparent 65%);
  animation: driftTwo 22s ease-in-out infinite, pulseTwo 9s ease-in-out infinite;
}

.blob-3 {
  width: 42vw;
  height: 42vw;
  max-width: 540px;
  max-height: 540px;
  top: 38%;
  left: 50%;
  opacity: 0.18;
  background: radial-gradient(circle, var(--gold), transparent 65%);
  animation: driftThree 26s ease-in-out infinite, pulseThree 11s ease-in-out infinite;
}

@keyframes driftOne {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(12vw, 14vh) scale(1.2); }
  66% { transform: translate(-6vw, 8vh) scale(0.9); }
}

@keyframes driftTwo {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40% { transform: translate(-14vw, -12vh) scale(1.15); }
  70% { transform: translate(7vw, -5vh) scale(0.88); }
}

@keyframes driftThree {
  0%, 100% { transform: translate(-50%, 0) scale(1); }
  50% { transform: translate(-30%, -16vh) scale(1.25); }
}

@keyframes pulseOne {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.34; }
}

@keyframes pulseTwo {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.32; }
}

@keyframes pulseThree {
  0%, 100% { opacity: 0.12; }
  50% { opacity: 0.24; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-glow::before,
  .bg-glow::after,
  .bg-glow-blob {
    animation: none;
  }
}

.hero {
  position: relative;
  z-index: 1;
  padding: 64px 20px 40px;
  text-align: center;
}

.hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 24px;
}

.brand-mark { font-size: 1rem; }

.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.25;
  padding-bottom: 4px;
  margin: 0 0 14px;
  background: linear-gradient(120deg, #ffffff 30%, #ffd9a0 70%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0;
  line-height: 1.5;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px -30px rgba(0, 0, 0, 0.6);
}

.panel {
  padding: 28px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0;
}

.panel-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.usernames {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.username-row-wrapper {
  animation: rowIn 0.25s ease;
}

.username-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-error {
  color: var(--danger);
  font-size: 0.78rem;
  margin: 6px 0 0 44px;
  min-height: 0;
}

.field-error:empty {
  margin: 0;
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar-dot,
.who-badge,
.title-avatar {
  overflow: hidden;
}

.avatar-dot img,
.who-badge img,
.title-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.title-avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--avatar-color, var(--accent));
}

.avatar-dot {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-ink);
  background: var(--avatar-color, var(--accent));
  transition: transform 0.15s ease;
}

.username-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.username-input {
  width: 100%;
  padding: 12px 40px 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.98rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.username-input::placeholder { color: #5a6472; }

.username-input:focus {
  outline: none;
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(232, 84, 62, 0.18);
}

.username-input-wrap.invalid .username-input {
  border-color: var(--danger);
}

.username-input-wrap.invalid .username-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 84, 112, 0.18);
}

.remove-user {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.remove-user:hover:not(:disabled) {
  background: rgba(255, 84, 112, 0.15);
  color: var(--danger);
}

.remove-user:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

button:focus { outline: none; }

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(232, 84, 62, 0.35);
}

button:active { transform: scale(0.97); }

button.ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-width: 140px;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
}

button.ghost:hover { background: rgba(255, 255, 255, 0.04); }

.plus {
  font-size: 1rem;
  color: var(--accent);
  font-weight: 700;
}

button.primary {
  flex: 1;
  min-width: 180px;
  padding: 13px 20px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.98rem;
  box-shadow: 0 10px 25px -10px rgba(245, 166, 35, 0.45);
}

button.primary:hover { filter: brightness(1.06); }

button.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(42, 22, 0, 0.35);
  border-top-color: var(--accent-ink);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -2px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#status {
  color: var(--muted);
  font-size: 0.9rem;
  transition: opacity 0.2s ease;
}

#status.has-content {
  margin-top: 16px;
}

#status.error { color: var(--danger); }
#status.error #statusVisual::before { content: "⚠️ "; }

.filter-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 24px 0;
  margin: 0;
}

.mood-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  margin: 0 0 18px;
  animation: fadeUp 0.3s ease;
}

.mood-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.mood-chip:hover {
  border-color: var(--accent2);
}

.mood-chip.active {
  border-color: var(--accent);
  background: rgba(245, 166, 35, 0.15);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.28);
  font-weight: 700;
}

.mood-chip:focus { outline: none; }

.mood-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(232, 84, 62, 0.35);
}

.mood-chip.active:focus-visible {
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.5);
}

.results {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.result-section {
  animation: fadeUp 0.35s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.5;
  margin: 0 0 4px;
  padding-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.section-title-prefix {
  white-space: nowrap;
  flex: none;
}

.section-title-prefix-short {
  display: none;
}

.section-title-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

@media (max-width: 480px) {
  .section-title-prefix-full {
    display: none;
  }

  .section-title-prefix-short {
    display: inline;
  }

  .shuffle-label {
    display: none;
  }

  .shuffle-btn {
    padding: 8px;
  }

  .shuffle-btn .shuffle-icon {
    margin: 0;
  }
}

.section-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 14px;
}

.section-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.section-sub-row .section-sub {
  margin: 0;
}

.film-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.film-grid > li {
  display: flex;
}

.film-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-decoration: none;
  color: var(--text);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: var(--card);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.film-card:hover {
  transform: translateY(-4px);
  border-color: rgba(232, 84, 62, 0.45);
  box-shadow: 0 16px 30px -18px rgba(232, 84, 62, 0.3);
}

.poster {
  aspect-ratio: 2 / 3;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: var(--poster-bg, linear-gradient(150deg, #2b3140, #1a1f29));
}

.poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-fallback-title {
  display: none;
}

.poster.poster-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
}

.poster.poster-fallback::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.35), transparent 45%);
}

.poster.poster-fallback .poster-fallback-title {
  display: -webkit-box;
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.92);
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.film-meta {
  padding: 8px 10px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.film-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}

.film-title {
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.film-year {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.who-badges {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.who-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--avatar-color, var(--accent));
}

.who-badge.everyone-badge {
  width: auto;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  background: rgba(245, 166, 35, 0.18);
  color: var(--accent);
}

.film-rating {
  font-size: 0.72rem;
  color: #ffc857;
  white-space: nowrap;
}

button.shuffle-btn {
  flex: none;
  min-width: 0;
  font-size: 0.8rem;
  padding: 7px 14px;
  border-color: var(--card-border);
  color: var(--muted);
}

.shuffle-btn:hover {
  background: rgba(245, 166, 35, 0.08);
  border-color: rgba(245, 166, 35, 0.4);
  color: var(--accent);
}

.shuffle-btn .shuffle-icon {
  width: 15px;
  height: 15px;
  flex: none;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.section-title-row .shuffle-btn {
  margin-left: auto;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state .emoji { font-size: 2rem; display: block; margin-bottom: 10px; }

.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
  color: #6b6a66;
  font-size: 0.8rem;
}

.footer p {
  margin: 0 0 4px;
}

.footer p:last-child {
  margin-bottom: 0;
}

.footer a {
  color: inherit;
  text-decoration: underline;
}

.footer a:hover {
  color: var(--text);
}

@media (max-width: 480px) {
  .panel { padding: 20px; }
  .film-grid { grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); }
}
