/* LarpApp web styling.
   The custom properties mirror LarpColors in the Flutter app so both clients
   read as one product. Change a token here and in theme.dart together. */
:root {
  --bg: #08080c;
  --surface: #14141d;
  --surface-high: #1e1e2b;
  --border: #2a2a3a;
  --violet: #8b5cf6;
  --violet-deep: #6d28d9;
  --gold: #ffc542;
  --win: #3ddc97;
  --loss: #ff4d6d;
  --text: #ffffff;
  --muted: #8a8a9e;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.shell {
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 20px 80px;
  /* A column so a page can ask for "the rest of the screen" without anyone
   * having to hard-code the height of the header above it. The judging feed
   * is the only page that does, and it is the difference between a card that
   * fits the viewport and one that hangs 23px off the bottom. */
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  box-sizing: border-box;
}

/* ---------------------------------------------------------------- header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 8px;
}
.logo { font-size: 22px; font-weight: 900; letter-spacing: -0.5px; }
.logo em { font-style: normal; color: var(--violet); }

.nav { display: flex; gap: 6px; }
.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid transparent;
}
.nav a:hover { color: var(--text); }
.nav a.active {
  color: var(--violet);
  background: rgba(139, 92, 246, 0.16);
  border-color: var(--violet);
}

/* ------------------------------------------------------------------ type */
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
}
.hero {
  font-size: clamp(40px, 9vw, 64px);
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
  margin: 10px 0 0;
}
.hero-gold {
  font-size: clamp(34px, 8vw, 56px);
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.1;
  background: linear-gradient(180deg, #ffe082, var(--gold), #e0a020);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h2.section { font-size: 24px; font-weight: 800; margin: 4px 0 14px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 14px; }

.stats { display: flex; justify-content: space-between; gap: 12px; }
.stat .value { font-size: 22px; font-weight: 800; }
.stat .label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
}

/* --------------------------------------------------------------- buttons */
.btn {
  display: block;
  width: 100%;
  padding: 18px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--violet), var(--violet-deep));
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  font-family: inherit;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.gold {
  background: linear-gradient(135deg, #ffe082, var(--gold), #e0a020);
  color: #211a04;
}
.btn.ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
}
.btn + .btn { margin-top: 10px; }

/* ---------------------------------------------------------------- inputs */
.field {
  width: 100%;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.field:focus { outline: none; border-color: var(--violet); }

/* ------------------------------------------------------------------ tier */
.tier {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  border: 1px solid;
}

/* ----------------------------------------------------------- leaderboard */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tab {
  white-space: nowrap;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.tab.active {
  color: var(--violet);
  border-color: var(--violet);
  background: rgba(139, 92, 246, 0.16);
}
.tab.active.gold {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(255, 197, 66, 0.14);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.row.me { border-color: var(--violet); background: rgba(139, 92, 246, 0.12); }
.row .pos { width: 30px; font-weight: 900; color: var(--muted); }
.row .pos.top { color: var(--gold); }
.row .flag { font-size: 18px; }
.row .who { flex: 1; min-width: 0; }
.row .who .name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .metric { text-align: right; }
.row .metric .n { font-weight: 900; }

/* ----------------------------------------------------------------- duels */
.duel { display: flex; gap: 12px; align-items: flex-start; }
.duel .vs { align-self: center; font-weight: 900; color: var(--muted); }
.side { flex: 1; min-width: 0; text-align: center; }
.photo {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-high);
  display: block;
}
.photo.mine { border: 2.5px solid var(--violet); }
.side.clickable { cursor: pointer; }
.side.clickable:hover .photo { border-color: var(--violet); }
.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-high);
  overflow: hidden;
  margin: 10px 0 6px;
}
.bar > i { display: block; height: 100%; background: var(--muted); }
.bar > i.mine { background: var(--violet); }

.verdict { font-size: 96px; font-weight: 900; line-height: 1; }
.verdict.win { color: var(--win); }
.verdict.loss { color: var(--loss); }

.error {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--loss);
  background: rgba(255, 77, 109, 0.12);
  border: 1px solid rgba(255, 77, 109, 0.4);
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 40px auto;
  border: 3px solid var(--surface-high);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ladder {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* ------------------------------------------------------------------ ammo */
.ammo {
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
}
.ammo:hover { border-color: var(--violet); }
.ammo-thumb {
  width: 72px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-high);
  flex-shrink: 0;
}
.ammo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--muted);
}
.ammo-text { min-width: 0; }

.photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
}

/* ------------------------------------------------------------- live stage */
.stage-tile {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-high);
}
.stage-still,
.stage-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.stage-flag { font-size: 46px; }

/* ------------------------------------------------------------------ masks */
.masks {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  /* `safe` centres the strip while it fits and falls back to left-aligned once
   * it overflows. Plain `center` centres the overflow too, which pushes the
   * first chips past the left edge where nothing can scroll them back. */
  justify-content: safe center;
}
.mask-chip {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  min-width: 60px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.mask-chip:hover { border-color: var(--violet); }
.mask-chip.active {
  border-color: var(--violet);
  background: rgba(139, 92, 246, 0.16);
  color: var(--text);
}
.mask-emoji { font-size: 24px; line-height: 1; }
.mask-label { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; }

.camera-preview {
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
  aspect-ratio: 4 / 5;
}

/* ----------------------------------------------------------- mask studio */
/* The editor sits where the picker was, directly under the live preview, so
 * every control is a few pixels from the face it changes. */
.mask-chip.make {
  border-style: dashed;
  color: var(--violet);
}
.mask-chip.make .mask-emoji { font-weight: 300; }

.studio { text-align: left; }
.studio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.studio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
}
.studio-row .field { margin-bottom: 0; }
.studio-label {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.link {
  border: 0;
  background: none;
  padding: 6px 0;
  color: var(--violet);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  cursor: pointer;
}
.link:disabled { opacity: 0.45; cursor: not-allowed; }
.link.danger { color: var(--loss); display: block; width: 100%; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.chip.active {
  border-color: var(--violet);
  background: rgba(139, 92, 246, 0.16);
  color: var(--text);
}

/* A scrolling strip rather than a wrapping grid: forty emoji wrapped would
 * push every control below it off the screen on a phone. */
.palette {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px;
  scrollbar-width: none;
}
.palette::-webkit-scrollbar { display: none; }
.swatch {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.swatch.active { border-color: var(--violet); background: rgba(139, 92, 246, 0.16); }
.swatch.dot { width: 30px; height: 30px; border-radius: 999px; }

.slider {
  flex: 1;
  min-width: 0;
  accent-color: var(--violet);
}

.piece {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 10px 0;
  background: var(--surface);
}

/* Inside a piece the kind toggle shares a row with Remove; letting it wrap
 * stacks two chips vertically and pushes the row twice as tall. */
.piece .studio-head .chips {
  flex-wrap: nowrap;
  justify-content: flex-start;
}

/* The live preview, pinned while the mask editor is open. */
.preview-slot.pinned {
  position: sticky;
  top: 8px;
  z-index: 5;
  padding-bottom: 10px;
  background: linear-gradient(var(--bg) 78%, transparent);
}
.preview-slot.pinned .camera-preview { max-width: 190px; }
.muted.small { font-size: 11px; line-height: 1.45; margin-top: 6px; }

/* A bot says so. Small and plain rather than apologetic or loud — it is a
 * fact about the opponent, not a warning. */
.bot-badge {
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-high);
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  vertical-align: middle;
}

/* ------------------------------------------------------------------ reels */
/* The judging feed: one duel per screen, snapped, scrolled with a thumb.
 *
 * It breaks out of `.shell`'s 780px column and its padding, because a feed
 * that is letterboxed inside a centred card does not read as a feed. The
 * negative margins undo the shell rather than fighting it, which keeps every
 * other page unchanged. */
.reels-frame {
  flex: 1;
  min-height: 0;
  position: relative;
  /* Undoes the shell's side padding and its bottom gutter, so the feed runs
   * edge to edge without the shell having to know about it. */
  margin: 0 -20px -80px;
}

.reels {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  /* `proximity`, not `mandatory`.
   *
   * This feed is never still: cards arrive every few seconds, vote counts
   * change under them, and a clock ticks once a second. A mandatory snap
   * re-snaps whenever its contents change, which lands mid-gesture and throws
   * the swipe back to the card it started on — a feed that looks frozen no
   * matter how hard you push it. Proximity still lands on a card when a swipe
   * ends near one, and leaves the gesture alone otherwise. */
  scroll-snap-type: y proximity;
  scrollbar-width: none;
  background: #000;
}
.reels::-webkit-scrollbar { display: none; }

.reel {
  position: relative;
  /* The scroll container's own height, whatever the header above it came to. */
  height: 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Two competitors, one above the other. Side by side would give each of them
 * half the width of a phone held upright, which is the wrong half to lose. */
.reel-half {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
}
.reel-half:active { filter: brightness(1.15); }

.reel-tile {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.reel-tile video,
.reel-tile img,
.reel-tile canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Names sit at the top of their own half, not the bottom.
 *
 * At the bottom the lower competitor's name landed underneath the call to
 * action and the two overlapped; at the top each name is unambiguously
 * attached to the face below it. */
.reel-name {
  position: absolute;
  left: 14px;
  top: 12px;
  z-index: 2;
  font-weight: 800;
  font-size: 15px;
  /* A shadow rather than a plate: the name has to stay readable over whatever
   * the camera happens to be pointing at, without boxing in the picture. */
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}

.reel-share {
  position: absolute;
  right: 14px;
  top: 12px;
  z-index: 2;
  font-weight: 800;
  font-size: 15px;
  color: var(--gold);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}

.reel-bar {
  position: absolute;
  left: 0;
  right: 0;
  /* Above the phone's own bottom chrome, which overlaps a 100dvh element on
   * iOS while the address bar is expanded. */
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

/* Only the card on screen holds the live connection, so the others say why
 * they are still rather than looking broken. */
.reel-idle {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 12, 0.55);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  pointer-events: none;
}

/* The round clock, pinned over the feed rather than drawn inside each card.
 *
 * A bar as well as a number: twelve seconds is short enough that a digit
 * changing once a second reads as a stutter, while a line visibly running out
 * tells you at a glance whether it is worth looking or worth voting. */
.reels-clock {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  /* Nothing here takes a touch: it sits over a feed that has to stay
   * swipeable through it. */
  pointer-events: none;
}
.reels-clock-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
}
.reels-clock-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--gold));
  transition: width 1s linear;
}
/* Centred, because the corners are taken: the competitor's name sits top-left
 * and their share of the vote top-right, and the clock landed on top of the
 * share. */
.reels-seconds {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 900;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}
.reels-seconds.low { color: var(--loss); }

.reel-bar.over { color: var(--muted); }

/* The competitor's own clock, on the live stage. */
.stage-clock {
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-high);
  margin: 10px 0 4px;
}
.stage-clock i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--gold));
  transition: width 1s linear;
}
.stage-seconds {
  text-align: center;
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.stage-seconds.low { color: var(--loss); }

/* ---------------------------------------------------------------- consent */
.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 2px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  cursor: pointer;
}
.consent input {
  /* The label owns the click; the box only shows the state. */
  pointer-events: none;
  /* Big enough to read on a phone. */
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  flex-shrink: 0;
  accent-color: var(--violet);
}
.consent a {
  color: var(--violet);
  text-decoration: underline;
}

/* ------------------------------------------------------------------ legal */
.legal { line-height: 1.6; }
.legal h3 {
  margin: 26px 0 6px;
  font-size: 15px;
  letter-spacing: 0.3px;
}
.legal p { color: var(--muted); margin: 0 0 10px; }
.legal a { color: var(--violet); }
