/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface-raised: #22223a;
  --primary: #FFB300;
  --primary-hover: #F49D00;
  --success: #2dc653;
  --text: #f0f0f0;
  --text-muted: #888;
  --border: #2e2e45;
  --radius: 20px;
  --radius-sm: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --transition: 0.25s ease;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── App Shell ──────────────────────────────────────────────── */
#app {
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 900px;
  position: relative;
  overflow: hidden;
}

/* ── Screen Base ────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity var(--transition), transform var(--transition);
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ── Typography ─────────────────────────────────────────────── */
h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }

.text-muted { color: var(--text-muted); font-size: 0.9rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 50px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  font-size: 1.1rem;
  padding: 16px;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* ── SETUP Screen ───────────────────────────────────────────── */
.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.app-logo .logo-icon { font-size: 2.2rem; }
.app-logo h1 { color: var(--primary); }

.app-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* City + Players horizontal row */
.city-players-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  align-items: flex-start;
}
.city-col { flex: 1; min-width: 0; }
.players-col { flex-shrink: 0; }
.city-players-row .name-input { margin-bottom: 0; width: 100%; }
.city-players-row .stepper { margin-bottom: 0; }

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Player count stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.stepper-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), background var(--transition);
}

.stepper-btn:hover { border-color: var(--primary); background: var(--surface); }
.stepper-count { font-size: 2rem; font-weight: 800; min-width: 36px; text-align: center; }

/* Name inputs */
#player-names {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.name-input {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.name-input:focus { border-color: var(--primary); }
.name-input::placeholder { color: var(--text-muted); }

/* Genre chips */
.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.genre-chip {
  background: var(--surface-raised);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 7px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.genre-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── LOADING Screen ─────────────────────────────────────────── */
#screen-loading {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#loading-error {
  display: none;
  color: var(--primary);
  font-size: 0.95rem;
  max-width: 280px;
}

#btn-retry { display: none; }

/* ── SWIPING Screen ─────────────────────────────────────────── */
#screen-swiping {
  padding: 16px 16px 20px;
}

.swiping-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.player-badge {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 14px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

#card-container {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* ── Swipe Guide (on SETUP + JOIN screens) ──────────────────── */
.swipe-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 20px;
  margin-bottom: 20px;
}

.swipe-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.swipe-action-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
}

.swipe-action--skip .swipe-action-icon {
  background: rgba(255, 179, 0, 0.15);
  color: var(--primary);
  border: 1.5px solid rgba(255, 179, 0, 0.4);
}
.swipe-action--skip { color: var(--primary); }

.swipe-action--like .swipe-action-icon {
  background: rgba(45, 198, 83, 0.15);
  color: var(--success);
  border: 1.5px solid rgba(45, 198, 83, 0.4);
}
.swipe-action--like { color: var(--success); }

.swipe-action-card {
  font-size: 2rem;
  line-height: 1;
  padding: 0 8px;
}

/* ── HANDOFF Screen ─────────────────────────────────────────── */
#screen-handoff {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 24px;
}

.handoff-icon { font-size: 4rem; }
.handoff-name {
  color: var(--primary);
  font-size: 1.8rem;
  font-weight: 800;
}

/* ── RESULTS Screen ─────────────────────────────────────────── */
#screen-results {
  gap: 16px;
}

#results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.result-poster {
  width: 48px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.result-title { font-weight: 600; margin-bottom: 4px; }
.result-likes { font-size: 0.85rem; color: var(--text-muted); }

#runoff-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── WINNER Screen ──────────────────────────────────────────── */
#screen-winner {
  gap: 0;
  padding: 20px;
  overflow-y: auto;
  align-items: flex-start;
  text-align: left;
}

.winner-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  width: 100%;
  text-align: center;
}
.winner-trophy { font-size: 2.2rem; }
.winner-label {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--primary);
}

/* Winner hero layout */
.winner-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 16px;
}

.winner-poster-wrap {
  width: 110px;
  height: 165px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  flex-shrink: 0;
}
.winner-poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.winner-info {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

/* Tier badge */
.winner-tier-badge {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 50px;
  display: inline-block;
  margin-bottom: 2px;
}
.tier-unicorn  { background: rgba(255,179,0,0.25); color: #FFB300; }
.tier-majority { background: rgba(45,198,83,0.2);  color: #2dc653; }
.tier-plurality{ background: rgba(33,150,243,0.2); color: #2196F3; }
.tier-wildcard { background: rgba(156,39,176,0.2); color: #9C27B0; }

.winner-title {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
}

.winner-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.winner-social-proof {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.winner-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  width: 100%;
}

.btn-new-session {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.btn-bookmyshow {
  background: linear-gradient(135deg, #e63946, #c1121f);
  color: #fff;
  font-size: 1rem;
  padding: 14px;
  border-radius: 50px;
  text-align: center;
  font-weight: 700;
  text-decoration: none;
  display: block;
  transition: opacity var(--transition);
}

.btn-bookmyshow:hover { opacity: 0.9; }

/* Runners-up */
.runners-section { width: 100%; margin-top: 20px; }
.runners-divider-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.runners-list { display: flex; gap: 10px; }
.runner-card {
  flex: 1;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface-raised);
  border-radius: 10px;
  padding: 10px;
  border: 1px solid var(--border);
}
.runner-poster-wrap {
  width: 48px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
}
.runner-poster { width: 100%; height: 100%; object-fit: cover; }
.runner-poster-placeholder {
  width: 100%; height: 100%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.runner-title { font-size: 0.78rem; font-weight: 700; line-height: 1.2; margin: 0 0 2px; }
.runner-meta  { font-size: 0.7rem; color: var(--text-muted); margin: 0 0 2px; }
.runner-likes { font-size: 0.68rem; color: var(--accent); font-weight: 600; margin: 0; }

/* Social heatmap */
.heatmap-section {
  width: 100%;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.heatmap-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}
.heatmap-movie { font-size: 0.75rem; font-weight: 600; }
.heatmap-names { font-size: 0.7rem; color: var(--text-muted); padding-left: 4px; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Name input spacing ─────────────────────────────────────── */
.name-input { margin-bottom: 20px; }

/* ── Styled select ──────────────────────────────────────────── */
.select-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3e%3cpolyline points='6,9 12,15 18,9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
  cursor: pointer;
}
.select-input option {
  background: var(--surface-raised);
  color: var(--text);
}

/* ── Timeout options ────────────────────────────────────────── */
.timeout-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.timeout-option {
  background: var(--surface-raised);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 7px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.timeout-option.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── JOIN Screen ────────────────────────────────────────────── */
.join-invite {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 12px;
}
.city-badge {
  display: inline-block;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 6px 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.error-text {
  color: var(--primary);
  font-size: 0.85rem;
  margin-top: 6px;
  min-height: 18px;
}

/* ── SHARE Screen ───────────────────────────────────────────── */

/* Timer bar */
.share-timer-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}
.share-timer-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 100%;
  transition: width 1s linear;
}
.share-timer-fill.urgent { background: #e63946; animation: pulse-dot 1.5s ease infinite; }
.share-timer-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.share-timer-label.urgent { color: #e63946; }
.btn-whatsapp--large { font-size: 1.05rem; padding: 16px; }

.step-label {
  font-size: 0.85rem;
  margin-bottom: 10px;
  margin-top: 4px;
}

/* Options disclosure */
.share-options {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.share-options summary {
  cursor: pointer;
  user-select: none;
  padding: 8px 0;
  font-weight: 600;
  list-style: none;
}
.share-options summary::-webkit-details-marker { display: none; }
.share-options .timeout-options { margin-top: 10px; }

.share-url-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  overflow: hidden;
}
.share-url-text {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: monospace;
}
.btn-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #25d366;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity var(--transition);
  width: 100%;
}
.btn-whatsapp:hover { opacity: 0.9; }
.share-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 16px 0;
}
.share-divider::before,
.share-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── WAITING Screen ─────────────────────────────────────────── */
#screen-waiting {
  gap: 0;
}

.waiting-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
}

.participants-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}
.participant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.participant-row.is-me {
  border-left: 3px solid var(--primary);
}
.participant-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.you-badge {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 700;
}
.poke-btn {
  font-size: 1.1rem;
  text-decoration: none;
  line-height: 1;
  opacity: 0.8;
  transition: opacity var(--transition);
}
.poke-btn:hover { opacity: 1; }
.participant-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.participant-status {
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 50px;
  padding: 4px 10px;
}
.status-done {
  background: rgba(45, 198, 83, 0.15);
  color: var(--success);
}
.status-swiping {
  background: var(--surface);
  color: var(--text-muted);
}
.ready-count {
  margin-top: 14px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.countdown {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

