:root {
  --paper: #f5f1ea;
  --surface: #ffffff;
  --ink: #161412;
  --muted: #6b645c;
  --line: #e2dbd0;
  --red: #d8141e;
  --red-ink: #ffffff;
  --like: #16a34a;
  --nope: #d8141e;
  --shadow: 0 18px 40px -18px rgba(40, 20, 10, .45), 0 2px 6px rgba(40, 20, 10, .08);
  --radius: 18px;
  --display: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131110;
    --surface: #1e1b19;
    --ink: #f3eee7;
    --muted: #a39a90;
    --line: #34302c;
    --shadow: 0 18px 40px -18px rgba(0, 0, 0, .8), 0 2px 6px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #131110;
  --surface: #1e1b19;
  --ink: #f3eee7;
  --muted: #a39a90;
  --line: #34302c;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .8), 0 2px 6px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}
[hidden] { display: none !important; }

h1, h2 { font-family: var(--display); font-weight: 800; letter-spacing: -.01em; line-height: 1.05; margin: 0; }
h1 { font-size: clamp(28px, 7vw, 38px); }
h2 { font-size: 22px; }
.muted { color: var(--muted); margin: 0; }
.fineprint { color: var(--muted); font-size: 13px; margin: 0; }

.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--red-ink);
  background: var(--red);
  display: inline-block;
  padding: 4px 10px 3px;
  border-radius: 4px;
  align-self: flex-start;
}
.brand span { opacity: .6; }
.brand.small { font-size: 12px; padding: 3px 8px 2px; }

/* ---------- Screens ---------- */
.screen { min-height: 100dvh; padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.center { display: grid; place-items: center; }
.panel {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.field input {
  font: inherit;
  font-size: 18px;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--red); }
.error { color: var(--nope); font-size: 14px; font-weight: 600; margin: 0; }

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  cursor: pointer;
  transition: transform .1s, filter .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--red); color: var(--red-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); font-size: 15px; padding: 10px 18px; }
.btn.ghost:hover { border-color: var(--ink); }
.btn.link { background: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 10px 8px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Swipe ---------- */
.swipe {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: max(14px, env(safe-area-inset-top));
  user-select: none;
  -webkit-user-select: none;
}
.topbar { width: 100%; max-width: 460px; display: flex; justify-content: space-between; align-items: center; }
.progress-text { font-family: var(--display); font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.progress { width: 100%; max-width: 460px; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--red); transition: width .25s ease; }

.deck {
  --bar: 58px;
  --w: min(92vw, calc((68dvh - var(--bar)) * .75), 400px);
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 4 / 3 + var(--bar));
  margin-top: 6px;
}
.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
  will-change: transform;
  transform-origin: 50% 90%;
}
.card.dragging { cursor: grabbing; }
.card.behind { transform: scale(.94) translateY(14px); filter: brightness(.92); pointer-events: none; }
.card img { width: 100%; flex: 1; min-height: 0; object-fit: cover; display: block; background: #222; pointer-events: none; -webkit-user-drag: none; }
.card .label {
  height: var(--bar);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  border-top: 1px solid var(--line);
}
.card .label::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.stamp {
  position: absolute;
  top: 26px;
  padding: 4px 12px;
  border: 4px solid currentColor;
  border-radius: 10px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 40px;
  letter-spacing: .06em;
  background: rgba(255,255,255,.85);
  opacity: 0;
  pointer-events: none;
}
.stamp.like { left: 20px; color: var(--like); transform: rotate(-14deg); }
.stamp.nope { right: 20px; color: var(--nope); transform: rotate(14deg); }

.controls { display: flex; align-items: center; gap: 22px; margin-top: 8px; }
.round {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .12s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.round:hover { transform: scale(1.06); }
.round:active { transform: scale(.94); }
.round svg { width: 34px; height: 34px; fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.round.nope svg { stroke: var(--nope); }
.round.like svg { stroke: var(--like); }
.round.nope:hover { background: color-mix(in srgb, var(--nope) 10%, var(--surface)); }
.round.like:hover { background: color-mix(in srgb, var(--like) 10%, var(--surface)); }
.round.small { width: 48px; height: 48px; }
.round.small svg { width: 22px; height: 22px; stroke: var(--muted); stroke-width: 2.4; }
.round.small:disabled { opacity: .35; cursor: default; transform: none; }
.round.spacer { visibility: hidden; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

@media (max-height: 640px) {
  .deck { --bar: 46px; }
  .card .label { font-size: 21px; }
  .controls { gap: 16px; margin-top: 2px; }
  .round { width: 60px; height: 60px; }
  .round svg { width: 28px; height: 28px; }
  .hint { display: none; }
}

/* ---------- Senden ---------- */
.spinner {
  width: 42px; height: 42px; margin: 8px auto 0;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--red);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#screen-sending .panel { align-items: center; text-align: center; }

/* ---------- Ergebnis ---------- */
.results { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.results-head { display: flex; flex-direction: column; gap: 10px; }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: start; }
.podium-item { display: flex; flex-direction: column; gap: 8px; }
.podium-item .thumb { position: relative; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); aspect-ratio: 3/4; background: #222; }
.podium-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.podium-item .place {
  position: absolute; top: 8px; left: 8px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--red); color: #fff;
  font-family: var(--display); font-weight: 800; font-size: 19px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.podium-item.p1 { order: 2; }
.podium-item.p2 { order: 1; padding-top: 28px; }
.podium-item.p3 { order: 3; padding-top: 48px; }
.podium-item .meta { font-size: 14px; line-height: 1.3; }
.podium-item .meta strong { font-family: var(--display); font-size: 18px; display: block; }

.rank-list-wrap { display: flex; flex-direction: column; gap: 12px; }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  display: grid;
  grid-template-columns: 34px 52px 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 14px 8px 10px;
}
.rank-row .pos { font-family: var(--display); font-weight: 800; font-size: 20px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-row img { width: 52px; height: 69px; object-fit: cover; border-radius: 6px; display: block; background: #222; }
.rank-row .info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rank-row .title { font-weight: 700; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; background: var(--like); border-radius: 99px; }
.rank-row .pct { text-align: right; font-variant-numeric: tabular-nums; }
.rank-row .pct strong { font-family: var(--display); font-size: 22px; display: block; line-height: 1; }
.rank-row .pct span { font-size: 12px; color: var(--muted); white-space: nowrap; }

.participants { display: flex; flex-direction: column; gap: 12px; }
.participants .count { color: var(--muted); font-weight: 700; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 15px; }

.results-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-bottom: 20px; }
.results-foot form { margin-left: auto; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow);
  margin: 0;
  max-width: calc(100vw - 32px);
}

@media (max-width: 480px) {
  .podium { gap: 8px; }
  .podium-item .meta { font-size: 12px; }
  .podium-item .meta strong { font-size: 15px; }
  .rank-row { grid-template-columns: 26px 44px 1fr auto; gap: 10px; padding-right: 10px; }
  .rank-row img { width: 44px; height: 59px; }
  .results-foot form { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
