:root { color-scheme: dark; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #0e0f13;
  color: #f2f2f5;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden; /* cards fly off the sides; don't show a scrollbar for it */
  -webkit-user-select: none;
  user-select: none;
}
header { padding: 18px 0 8px; text-align: center; }
header h1 { margin: 0; font-size: 1.6rem; letter-spacing: .5px; }
header p { margin: 4px 0 0; opacity: .55; font-size: .8rem; }

#stage {
  position: relative;
  width: min(92vw, 380px);
  /* Fit the first fold: on short (mobile) screens shrink the poster so the vote
     buttons + hint below are never cut off; cap at 560px on tall screens. The
     ~250px reserve covers the header, buttons, hint and margins. svh keeps it
     correct while the mobile URL bar is showing; the vh line is an old-browser
     fallback. */
  height: 560px;
  height: clamp(240px, calc(100vh - 250px), 560px);
  height: clamp(240px, calc(100svh - 250px), 560px);
  margin-top: 10px;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #1a1c22;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  touch-action: none;
  will-change: transform;
  transition: transform .42s ease, opacity .42s ease;
}
/* A freshly-swapped card starts small and behind, then settles forward — so the
   next movie animates in from behind the one flying away. */
.card.htmx-added { transform: scale(.9); opacity: 0; }
.poster {
  flex: 1;
  background-size: cover;
  background-position: center;
  background-color: #23262f;
  position: relative;
}
.verdict {
  position: absolute;
  top: 22px;
  padding: 10px 22px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: 1.5px;
  opacity: 0;
  border: 5px solid;
  text-transform: uppercase;
  transition: opacity .1s;
}
.verdict.yes { left: 18px; color: #38d39f; border-color: #38d39f; transform: rotate(-12deg); }
.verdict.no { right: 18px; color: #ff5d6c; border-color: #ff5d6c; transform: rotate(12deg); }
/* "Don't know" pinned to the bottom of the poster so it's visible mid swipe-up. */
.verdict.skip {
  top: auto;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  font-size: 1.8rem;
  color: #c7ccd6;
  border-color: #c7ccd6;
}

.meta { padding: 14px 16px 16px; background: linear-gradient(180deg, #1a1c22, #15171c); }
.meta h2 { margin: 0; font-size: 1.25rem; }
.meta .sub { margin: 4px 0 0; opacity: .6; font-size: .82rem; }

#buttons { display: flex; gap: 26px; margin-top: 18px; }
button.act {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s;
}
button.act:active { transform: scale(.92); }
.no-btn { background: #ff5d6c; }
.yes-btn { background: #38d39f; }
/* "Don't know it" — secondary, so a touch smaller and muted gray. */
.skip-btn { background: #6b7280; width: 52px; height: 52px; font-size: 1.4rem; align-self: center; }

.hint { margin-top: 14px; font-size: .75rem; opacity: .45; text-align: center; }

/* --- guided flow: swipe -> arena -> results, one screen at a time --- */
.screen { display: flex; flex-direction: column; align-items: center; width: 100%; }
.screen[hidden] { display: none; }
.progress {
  margin-top: 6px;
  font-size: .72rem;
  letter-spacing: .8px;
  text-transform: uppercase;
  opacity: .6;
  font-variant-numeric: tabular-nums;
}
.progress[hidden] { display: none; }
.results-title { margin: 16px 0 2px; font-size: 1.15rem; opacity: .85; }
.results-actions { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }
.pill {
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .04);
  color: #e7e9ee;
  font-size: .9rem;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.pill:hover { background: rgba(255, 255, 255, .09); }
.pill.primary { background: #38d39f; border-color: #38d39f; color: #08120d; font-weight: 700; }
.pill.primary:hover { background: #2fc492; }

#empty { text-align: center; padding: 40px 20px; opacity: .7; line-height: 1.4; }
#empty code { background: #23262f; padding: 2px 6px; border-radius: 5px; }

/* Live leaderboard. It sits in normal flow below the controls; the page scrolls
   to it rather than it floating over the swipe UI. */
.toplist {
  width: min(92vw, 380px);
  margin: 20px auto 32px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  background: rgba(255, 255, 255, .03);
}
.tl-head {
  font-size: .7rem;
  letter-spacing: .6px;
  text-transform: uppercase;
  opacity: .55;
  margin-bottom: 7px;
}
.tl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tl-list li { display: flex; align-items: center; gap: 9px; font-size: .85rem; }
.tl-rank { opacity: .4; width: 1.1em; text-align: right; font-variant-numeric: tabular-nums; }
.tl-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-pct { font-weight: 700; color: #38d39f; font-variant-numeric: tabular-nums; min-width: 2.6em; text-align: right; }
.tl-pct.low { color: #ff5d6c; }
.tl-empty { font-size: .8rem; opacity: .5; }

/* --- header nav (swipe <-> arena) --- */
.nav { margin-top: 8px; }
.nav a { color: #8ab4ff; text-decoration: none; font-size: .8rem; opacity: .85; }
.nav a:hover { opacity: 1; text-decoration: underline; }

/* --- arena: two posters head to head --- */
#arena-stage { width: min(94vw, 460px); margin-top: 12px; }
.arena {
  display: flex;
  align-items: stretch;
  gap: 10px;
  position: relative;
}
/* Each freshly-swapped pair expands in. */
.arena { animation: arena-in .4s cubic-bezier(.2, .7, .3, 1.15) both; }
@keyframes arena-in { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
.vs-card {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #1a1c22;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .1s ease, border-color .1s ease;
}
.vs-card:hover { border-color: #38d39f; }
.vs-card:active { transform: scale(.97); }
.vs-card .poster { flex: 1; min-height: 300px; background-size: cover; background-position: center; background-color: #23262f; position: relative; }
/* arena.js drives the press/charge + win choreography via inline transforms; the
   winner slides to center and shrinks from its own center. */
.vs-card { transform-origin: center; }
/* Scumbag hat, perched on the winner's poster on a superlike (long-press). */
.vs-card .hat {
  position: absolute;
  top: 5%;
  left: 5%;
  width: 46%;
  transform: rotate(-8deg);
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .55));
}
.vs-card .hat[hidden] { display: none; }
.vs-card .meta { padding: 10px 12px 12px; background: linear-gradient(180deg, #1a1c22, #15171c); }
.vs-card .meta h2 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-card .meta .sub { margin: 3px 0 0; opacity: .6; font-size: .78rem; }
.vs-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 1px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #0e0f13;
  border: 2px solid rgba(255, 255, 255, .15);
  pointer-events: none;
}
.battle-skip {
  display: block;
  margin: 16px auto 0;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .03);
  color: #c7ccd6;
  font-size: .8rem;
  cursor: pointer;
}
.battle-skip:hover { background: rgba(255, 255, 255, .08); }

/* The poster being pressed swells while the long-press charges (arena.js sets the
   inline scale); cards shouldn't be text-selectable mid-press. */
.vs-card { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* --- arena: superlike (long-press) flourish — scumbag hat + angelic aura --- */
.vs-card.superliked { border-color: #ffe08a; }
.vs-card.superliked {
  animation: aura 1s ease-in-out infinite alternate;
}
@keyframes aura {
  from { box-shadow: 0 0 0 2px rgba(255, 223, 128, .65), 0 0 18px 5px rgba(255, 213, 110, .55); }
  to   { box-shadow: 0 0 0 4px rgba(255, 240, 180, 1), 0 0 46px 16px rgba(255, 213, 110, .95); }
}
.vs-card.superliked .hat { animation: hat-drop .45s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes hat-drop {
  from { transform: translateY(-34px) rotate(-34deg); opacity: 0; }
  to   { transform: rotate(-8deg); opacity: 1; }
}

/* --- canon: Elo-ranked tier list --- */
.tl-elo { font-weight: 700; color: #ffce5d; font-variant-numeric: tabular-nums; min-width: 3em; text-align: right; }
.tl-elo.provisional { opacity: .5; font-style: italic; }
.tier {
  width: 1.5em;
  height: 1.5em;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 800;
  font-size: .75rem;
  color: #0e0f13;
}
.tier-S { background: #ff5d6c; }
.tier-A { background: #ffaf5d; }
.tier-B { background: #ffce5d; }
.tier-C { background: #8a8f9c; }
