:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #f43f5e;
  --accent-2: #0ea5e9;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at top, #1e293b 0%, #0f172a 70%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.app { max-width: 560px; margin: 0 auto; padding: 20px 16px 32px; min-height: 100%; }
a { color: inherit; }
h1, h2 { margin: 0 0 12px; }

.muted { color: var(--muted); }
.hidden { display: none !important; }
.error {
  background: rgba(239, 68, 68, .15);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text);
  border: none; border-radius: 999px;
  padding: 10px 18px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); }
.btn.small { padding: 6px 12px; font-size: .9em; }
.btn.round {
  width: 64px; height: 64px; border-radius: 50%;
  font-size: 24px;
}
.btn.round.like { background: var(--good); }
.btn.round.pass { background: var(--panel-2); color: var(--muted); }

/* ---------- Home ---------- */
.hero { padding: 36px 0 8px; }
.hero h1 {
  font-size: clamp(2.4rem, 7vw, 3.2rem);
  text-align: center;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.02em;
  margin: 0 0 18px;
}
.accent-word {
  background: linear-gradient(120deg, #f43f5e 0%, #fb923c 60%, #f59e0b 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  font-style: italic;
}
.tagline {
  text-align: center; color: var(--text);
  margin: 0 auto 10px; max-width: 32ch;
  font-size: 1.1em; line-height: 1.45;
}
.trust-line {
  text-align: center; color: var(--muted);
  margin: 0 0 36px; font-size: .85em; letter-spacing: .04em;
}

.primary-cta { padding: 22px 22px 26px; }
.primary-cta label { font-size: .95em; }
.btn.primary.big {
  width: 100%; padding: 14px 20px;
  font-size: 1.05em; font-weight: 700; letter-spacing: .01em;
  background: linear-gradient(135deg, var(--accent) 0%, #fb7185 100%);
  box-shadow: 0 6px 20px rgba(244, 63, 94, .25);
}
.btn.primary.big:active { transform: scale(.98); }

.join-toggle { margin: 18px 0 6px; font-size: .92em; }
.join-toggle a { color: var(--muted); text-decoration: none; border-bottom: 1px dashed var(--panel-2); padding-bottom: 1px; }
.join-toggle a:hover { color: var(--text); border-bottom-color: var(--text); }
.join-form { margin-top: 8px; }

.how-it-works { margin-top: 32px; padding: 18px 18px 6px; background: var(--panel); border-radius: var(--radius); }
.how-it-works h2 { font-size: 1em; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 12px; }
.how-it-works .steps { margin: 0; padding: 0 0 8px 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.how-it-works .steps li {
  counter-increment: step;
  padding-left: 36px; position: relative;
  color: var(--muted); font-size: .95em; line-height: 1.45;
}
.how-it-works .steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: .8em; font-weight: 700;
}
.how-it-works .steps strong { color: var(--text); }
.card-form {
  background: var(--panel);
  padding: 18px 18px 22px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  display: grid; gap: 12px;
}
.card-form label { display: grid; gap: 6px; color: var(--muted); font-size: .9em; }
.card-form input, select, .filter-form input, .filter-form select {
  background: #0b1220; color: var(--text);
  border: 1px solid var(--panel-2); border-radius: 10px;
  padding: 10px 12px; font: inherit;
}
.divider { text-align: center; color: var(--muted); margin: 14px 0; }

/* ---------- Group header / filters ---------- */
.group-header { margin-bottom: 18px; }
.group-code code {
  background: var(--panel); padding: 2px 10px; border-radius: 8px;
  letter-spacing: .2em; font-weight: 700;
}
.invite { display: flex; gap: 8px; margin-top: 8px; }
.invite input { flex: 1; background: var(--panel); color: var(--muted); border: 1px solid var(--panel-2); border-radius: 10px; padding: 8px 10px; font-size: .9em; }

.filter-form fieldset {
  background: var(--panel); border: 1px solid var(--panel-2);
  border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px;
}
.filter-form legend { padding: 0 6px; color: var(--muted); font-size: .85em; text-transform: uppercase; letter-spacing: .08em; }

.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  margin-left: 6px; padding: 0;
  border: 1px solid var(--panel-2); border-radius: 50%;
  background: transparent; color: var(--muted);
  font: inherit; font-size: .75em; line-height: 1;
  cursor: pointer; vertical-align: middle;
  text-transform: none; letter-spacing: 0;
}
.info-btn:hover, .info-btn:focus { color: var(--text); border-color: var(--text); outline: none; }

.info-popover {
  margin: 0 0 10px;
  background: var(--panel-2); border: 1px solid var(--panel-2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .85em; line-height: 1.4;
  color: var(--text);
}
.info-popover[hidden] { display: none; }
.info-popover dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.info-popover dt { font-weight: 700; color: var(--accent); }
.info-popover dd { margin: 0; color: var(--muted); }
.filter-form .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-form .row label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: .9em; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel-2); border-radius: 999px;
  padding: 6px 12px; font-size: .85em; cursor: pointer;
  user-select: none;
}
.chip input { display: none; }
.chip:has(input:checked) { background: var(--accent); color: white; }

/* ---------- Swipe ---------- */
.swipe { display: flex; flex-direction: column; gap: 14px; min-height: 90vh; }
.swipe-header { display: flex; justify-content: space-between; align-items: center; }
.pill {
  background: var(--panel); color: var(--muted);
  padding: 4px 12px; border-radius: 999px; font-size: .9em;
}
.pill.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; color: var(--text); }
.pill.host { background: #2a4365; color: #c6dcff; }
.pill.status-lobby { background: #3a3a1e; color: #f0e7a0; }
.pill.status-swiping { background: #1f3a2a; color: #a8e0b9; }
.pill.status-finished { background: #3a1f2a; color: #e0a8bc; }

.code-large { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; font-size: 1.1em; padding: 2px 10px; background: var(--panel); border-radius: 6px; }
.code-mono  { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.center-text { text-align: center; }

.past-groups-section { margin-top: 28px; }
.past-groups-section h3 { margin: 0 0 10px; font-size: 1em; color: var(--muted); font-weight: 600; }
.past-groups { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.past-group .past-group-form {
  display: grid; gap: 8px;
  padding: 12px; border-radius: 10px; background: var(--panel);
}
.past-group-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.past-group-body { display: grid; gap: 2px; }
.small { font-size: .85em; }

.filter-summary {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: .85em; line-height: 1.3;
  padding: 6px 10px; border-radius: 8px;
  background: var(--panel);
}
.filter-summary-text { flex: 1 1 auto; }
.filter-edit { flex: 0 0 auto; color: var(--accent); text-decoration: none; font-weight: 600; }
.filter-edit:hover { text-decoration: underline; }

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }

.deck {
  position: relative;
  flex: 1;
  min-height: 420px;
  display: flex; align-items: center; justify-content: center;
}
.card {
  background: var(--panel);
  border-radius: 18px;
  overflow: hidden;
  width: 100%; max-width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
  touch-action: none; user-select: none;
  transition: transform .22s ease-out;
  will-change: transform;
}
.card[data-dir="like"] { box-shadow: 0 0 0 3px var(--good), 0 10px 40px rgba(0,0,0,.4); }
.card[data-dir="pass"] { box-shadow: 0 0 0 3px var(--danger), 0 10px 40px rgba(0,0,0,.4); }

.card.fly-left  { transform: translateX(-120vw) rotate(-30deg) !important; }
.card.fly-right { transform: translateX( 120vw) rotate( 30deg) !important; }

.poster {
  aspect-ratio: 2 / 3;
  background: #000 center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
}
.no-poster {
  color: var(--muted); padding: 20px; text-align: center; font-weight: 600;
}
.card .meta { padding: 14px 16px 18px; }
.card .meta h2 { font-size: 1.15rem; }
.card .sub { color: var(--muted); font-size: .9em; margin-bottom: 8px; }
.card .ratings { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.overview {
  color: var(--muted); font-size: .9em; line-height: 1.4;
  max-height: 5.6em; overflow: hidden; margin: 0;
}

.rating {
  font-size: .75em; font-weight: 700; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 6px; background: var(--panel-2);
}
.rating.imdb { background: #f5c518; color: #111; }
.rating.rt   { background: #fa320a; color: white; }
.rating.mc   { background: #00ce7a; color: #111; }
.score {
  display: inline-block;
  font-size: .72em; font-weight: 700; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 6px;
  margin-left: 4px;
}
.score.s1 { background: #3a3a1e; color: #f0e7a0; }   /* mild — yellow */
.score.s2 { background: #4a2a1a; color: #ffb98a; }   /* moderate — orange */
.score.s3 { background: #5a1a1a; color: #ffc9c9; }   /* severe — red */

.score-grid { display: grid; gap: 14px; margin-top: 8px; }
.score-row {
  display: grid;
  grid-template-columns: 110px 1fr 120px;
  align-items: center;
  gap: 12px;
}
.score-label { color: var(--muted); font-size: .9em; }
.score-value {
  color: var(--text); font-size: .85em; text-align: right;
  font-variant-numeric: tabular-nums;
}
/*
 * Native <input type="range"> styling.
 * The thumb is centered on the value's position along the track,
 * so to make it sit flush with the track edges at min/max, the
 * INPUT element extends a half-thumb-width past each side of the
 * visible track. The visible track is drawn on the input's own
 * background but inset by that same amount via padding.
 */
.score-slider {
  --thumb: 22px;
  --track-h: 6px;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: var(--thumb);
  background: transparent;
  outline: none; padding: 0; margin: 0;
  cursor: pointer;
}
/* Track */
.score-slider::-webkit-slider-runnable-track {
  height: var(--track-h);
  background: var(--panel-2);
  border-radius: 999px;
}
.score-slider::-moz-range-track {
  height: var(--track-h);
  background: var(--panel-2);
  border-radius: 999px;
  border: none;
}
/* Thumb */
.score-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: var(--thumb); height: var(--thumb); border-radius: 50%;
  background: var(--accent); border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  margin-top: calc((var(--track-h) - var(--thumb)) / 2);
}
.score-slider::-moz-range-thumb {
  width: var(--thumb); height: var(--thumb); border-radius: 50%;
  background: var(--accent); border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

.swipe-actions {
  display: flex; justify-content: center; gap: 36px; padding: 18px 0 8px;
}

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

/* ---------- Likes ---------- */
.likes-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.legend.all     { color: var(--good); }
.legend.partial { color: var(--warn); }

.likes-list { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 10px; }
.like-item {
  display: flex; gap: 12px;
  background: var(--panel); border-radius: var(--radius);
  padding: 10px; border: 1px solid var(--panel-2);
}
.like-item.all     { border-color: var(--good); }
.like-item.partial { border-color: var(--warn); }

.thumb {
  width: 60px; height: 90px;
  border-radius: 8px; background: #000 center / cover no-repeat;
  flex: 0 0 auto;
}
.like-item .info { flex: 1; min-width: 0; }
.like-item .title-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.like-item .sub { color: var(--muted); font-size: .85em; margin: 2px 0 4px; }
.like-item .ratings.small { display: flex; gap: 4px; flex-wrap: wrap; }

.badge {
  font-size: .7em; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.badge.all     { background: var(--good); color: white; }
.badge.partial { background: var(--warn); color: #111; }

/* ---------- Waiting ---------- */
.waiting { text-align: center; padding: 40px 20px; }
.spinner {
  width: 36px; height: 36px; margin: 24px auto;
  border: 4px solid var(--panel-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
