:root {
  --cream: #faf6ef;
  --ink: #101010;
  --muted: #6b6560;
  --aperol: #f4633a;
  --aperol-deep: #d94d26;
  --lavender: #b8a4e6;
  --lavender-soft: #dccff6;
  --card: #ffffff;
  --line: #ebe6de;
  --radius: 30px;
  --shadow: 0 24px 60px rgba(40, 24, 70, 0.14), 0 2px 6px rgba(0, 0, 0, 0.05);
  --display: "Archivo Black", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  min-height: 100dvh;
}

/* Living watercolor: soft blobs that drift at the edges, never behind text. */
.wash { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.6;
  will-change: transform;
  animation: drift 22s ease-in-out infinite alternate;
}
.blob-1 { width: 62vmin; height: 62vmin; top: -22vmin; right: -20vmin;
  background: radial-gradient(circle at 40% 40%, #c3b0f0 0%, var(--lavender-soft) 45%, transparent 72%); }
.blob-2 { width: 74vmin; height: 74vmin; bottom: -34vmin; left: -30vmin; animation-duration: 28s; animation-delay: -9s;
  background: radial-gradient(circle at 60% 50%, #c9b3f0 0%, var(--lavender-soft) 42%, transparent 70%); }
.blob-3 { width: 40vmin; height: 40vmin; bottom: 4vmin; right: -16vmin; opacity: 0.42; animation-duration: 19s; animation-delay: -4s;
  background: radial-gradient(circle, #ffc7b0 0%, #ffe0d2 40%, transparent 70%); }
.blob-4 { width: 30vmin; height: 30vmin; top: 30vmin; left: -12vmin; opacity: 0.35; animation-duration: 25s; animation-delay: -14s;
  background: radial-gradient(circle, #f6b39a 0%, transparent 70%); }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4vmin, -3vmin) scale(1.08); }
  100% { transform: translate(-3vmin, 4vmin) scale(0.96); }
}
@media (prefers-reduced-motion: reduce) {
  .blob, .face-stack img, .step, .tile, .pulse { animation: none !important; }
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
}

.card {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 38px 34px;
}

h1, h2, .display {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 0.98;
  margin: 0;
}
h1 { font-size: clamp(38px, 6.2vw, 58px); white-space: nowrap; }
h2 { font-size: clamp(34px, 6vw, 48px); }
.eyebrow {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--aperol);
  margin: 0 0 14px;
}
.lede { font-size: 20px; line-height: 1.4; color: var(--muted); margin: 16px 0 0; }
.lede strong { color: var(--ink); font-weight: 600; }

/* Welcome: poster + who's here */
.welcome-grid { display: grid; grid-template-columns: 1fr 150px; gap: 20px; align-items: start; }
.poster {
  width: 150px; height: 190px; border-radius: 18px; object-fit: cover;
  transform: rotate(4deg); box-shadow: 0 14px 30px rgba(120, 50, 20, 0.28);
  border: 5px solid #fff;
}
@media (max-width: 480px) { .welcome-grid { grid-template-columns: 1fr; } .poster { display: none; } }
.here {
  display: flex; align-items: center; gap: 12px; margin-top: 18px; min-height: 44px;
  border: 0; background: transparent; padding: 0; cursor: pointer; font-family: var(--body); text-align: left;
}
.here span { text-decoration: underline; text-decoration-color: var(--aperol); text-underline-offset: 4px; text-decoration-thickness: 2px; }
.here:active span { color: var(--aperol); }

/* Timeline */
.timeline { display: grid; gap: 0; position: relative; }
.timeline .stop { display: grid; grid-template-columns: 74px 22px 1fr; gap: 12px; align-items: start; padding: 6px 0 18px; }
.timeline .stop .t { font-family: var(--display); font-size: 18px; color: var(--muted); padding-top: 2px; }
.timeline .stop .dot { position: relative; width: 22px; height: 22px; }
.timeline .stop .dot::before { content: ""; position: absolute; top: 4px; left: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--line); }
.timeline .stop:not(:last-child) .dot::after { content: ""; position: absolute; top: 18px; bottom: -22px; left: 10px; width: 2px; background: var(--line); }
.timeline .stop.now .dot::before { background: var(--aperol); box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--aperol); }
.timeline .stop.now .t { color: var(--aperol); }
.timeline .stop.past .dot::before { background: var(--ink); box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--ink); }
.timeline .stop b { display: block; font-size: 18px; }
.timeline .stop p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.timeline .stop .face-stack { margin-top: 8px; }
.timeline .stop .face-stack img { width: 36px; height: 36px; }
.timeline.mini { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.timeline.mini .stop { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: #f4efe7; font-size: 15px; font-weight: 600; color: var(--muted); }
.timeline.mini .stop .t { font-size: 15px; padding: 0; color: inherit; }
.timeline.mini .stop .dot { order: -1; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.timeline.mini .stop .dot::before, .timeline.mini .stop .dot::after { display: none; }
.timeline.mini .stop.now { background: #fff1ea; color: var(--aperol-deep); }
.timeline.mini .stop.now .dot { background: var(--aperol); box-shadow: 0 0 0 3px rgba(244,99,58,0.25); }
.timeline.mini .stop.past { color: var(--ink); }
.timeline.mini .stop.past .dot { background: var(--ink); }
.timeline.mini .stop b { display: inline; font-size: 15px; font-weight: 600; }
.timeline.mini .stop p, .timeline.mini .stop .face-stack { display: none; }
.face-stack { display: flex; }
.face-stack img {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 3px solid #fff;
  margin-left: -12px; box-shadow: 0 3px 8px rgba(0,0,0,0.15); background: #eee;
  animation: pop 0.4s cubic-bezier(.2,1.4,.4,1) both;
}
.face-stack img:first-child { margin-left: 0; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
.here span { font-size: 16px; color: var(--muted); font-weight: 600; }

.peek {
  position: absolute; right: 18px; bottom: 16px; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: #c9c2b8; font-size: 22px; cursor: pointer; opacity: 0.55;
}
.peek:active { opacity: 1; color: var(--aperol); }

.btn {
  appearance: none;
  border: 0;
  width: 100%;
  min-height: 72px;
  padding: 0 28px;
  border-radius: 999px;
  font: 600 22px/1 var(--body);
  color: #fff;
  background: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
  touch-action: manipulation;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn-primary { background: var(--aperol); }
.btn-primary:active { background: var(--aperol-deep); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn-dashed {
  background: #fff7f3; color: var(--aperol-deep); box-shadow: inset 0 0 0 2px var(--aperol);
  border-style: dashed;
}
.btn-row { display: flex; gap: 12px; margin-top: 28px; }
.btn-row .btn { flex: 1; }
.btn-row .btn-back { flex: 0 0 96px; }
.stack { display: grid; gap: 12px; margin-top: 24px; }

.field {
  width: 100%;
  min-height: 76px;
  padding: 0 24px;
  border-radius: 20px;
  border: 2px solid var(--line);
  background: #fff;
  font: 500 28px/1 var(--body);
  color: var(--ink);
  outline: none;
  margin-top: 24px;
}
.field:focus { border-color: var(--ink); }
.field::placeholder { color: #b9b2aa; }

.choices { display: grid; gap: 14px; margin-top: 24px; }
.choice {
  appearance: none;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 22px;
  min-height: 92px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  text-align: left;
  cursor: pointer;
  font-family: var(--body);
  color: var(--ink);
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
  touch-action: manipulation;
}
.choice:active { transform: scale(0.99); }
.choice .icon { font-size: 36px; width: 48px; text-align: center; flex: none; }
.choice .label { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.choice .sub { display: block; font-size: 16px; color: var(--muted); margin-top: 4px; }
.choice[aria-pressed="true"] { border-color: var(--aperol); background: #fff4ef; box-shadow: 0 0 0 3px rgba(244, 99, 58, 0.18); }

.dots { display: flex; gap: 8px; margin-bottom: 22px; }
.dots span { width: 34px; height: 6px; border-radius: 99px; background: var(--line); }
.dots span.on { background: var(--aperol); }

.camera {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1;
  margin: 24px auto 0;
  border-radius: 30px;
  overflow: hidden;
  background: #15111c;
}
.camera video, .camera canvas, .camera img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.camera video { transform: scaleX(-1); }
.camera .hint {
  position: absolute; left: 0; right: 0; bottom: 14px; text-align: center;
  color: #fff; font-size: 15px; font-weight: 600; text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
.camera.fallback { display: flex; align-items: center; justify-content: center; color: #fff; text-align: center; padding: 24px; }

/* Group step */
.group { display: grid; gap: 12px; margin-top: 22px; }
.person {
  display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: 20px;
  border: 2px solid var(--line); background: #fff; animation: rise 0.3s ease both;
}
.person img { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; border: 3px solid var(--aperol); }
.person.plus img { border-color: var(--lavender); }
.person .who { flex: 1; }
.person .who b { display: block; font-size: 20px; }
.person .who span { font-size: 14px; color: var(--muted); }
.person .x { border: 0; background: #f2eee8; width: 40px; height: 40px; border-radius: 50%; font-size: 20px; color: var(--muted); cursor: pointer; }

/* Badge */
.badges { display: grid; gap: 16px; margin-top: 18px; }
.badge {
  border-radius: 26px;
  border: 2px solid var(--ink);
  padding: 20px;
  display: flex;
  gap: 18px;
  align-items: center;
  background: linear-gradient(180deg, #fff 0%, #fff8f4 100%);
}
.badge img {
  width: 108px; height: 108px; border-radius: 22px; object-fit: cover; flex: none;
  border: 3px solid var(--aperol);
}
.badge .name { font-family: var(--display); font-size: 30px; line-height: 1; }
.badge .chip {
  display: inline-block; margin-top: 10px; padding: 7px 13px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 700; letter-spacing: 0.04em;
}
.badge .with { margin-top: 12px; display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--muted); font-weight: 600; }
.badge .with img { width: 44px; height: 44px; border-radius: 12px; border-color: var(--lavender); }
.badge .with b { color: var(--ink); }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--aperol); animation: pulse 1.4s ease-in-out infinite; flex: none; }
@keyframes pulse { 0%, 100% { transform: scale(0.8); opacity: 0.5; } 50% { transform: scale(1.3); opacity: 1; } }

.small { font-size: 15px; color: var(--muted); margin: 18px 0 0; text-align: center; }
.error { color: var(--aperol-deep); font-weight: 600; margin: 14px 0 0; min-height: 1.2em; font-size: 16px; }

.step { display: none; animation: rise 0.28s ease both; }
.step.on { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Tonight overlay: pairs as brackets */
.overlay {
  position: fixed; inset: 0; z-index: 5; background: rgba(250, 246, 239, 0.985); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  overflow-y: auto; padding: 28px 20px 60px; -webkit-overflow-scrolling: touch;
}
.overlay .top { display: flex; align-items: center; justify-content: space-between; max-width: 1100px; margin: 0 auto 18px; }
.overlay .close { border: 0; background: var(--ink); color: #fff; border-radius: 999px; min-height: 56px; padding: 0 24px; font: 600 18px var(--body); }
.brackets { max-width: 1100px; margin: 0 auto; display: grid; gap: 28px; }
.bracket h3 { font-family: var(--display); font-size: 26px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.bracket h3 .tag { font-family: var(--body); }
.matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.match {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  background: #fff; border-radius: 20px; padding: 12px; box-shadow: var(--shadow); animation: rise 0.3s ease both;
}
.match .side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.match .side.r { flex-direction: row-reverse; text-align: right; }
.match img { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; flex: none; background: #eee; }
.match b { font-size: 16px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; }
.match .vs { font-family: var(--display); color: var(--aperol); font-size: 14px; letter-spacing: 0.08em; }
.match.waiting .side.r { opacity: 0.5; }
.match.waiting .side.r .ghost { width: 56px; height: 56px; border-radius: 14px; border: 2px dashed var(--lavender); }
.faces { display: flex; flex-wrap: wrap; gap: 8px; }
.faces img { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; }
.faces .f { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); width: 64px; }
.faces .f span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 64px; }

/* Admin / wall */
.admin { max-width: 1180px; width: 100%; margin: 0 auto; }
.admin header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: #fff; border-radius: 18px; padding: 12px 18px; box-shadow: var(--shadow); min-width: 120px; }
.stat b { display: block; font-family: var(--display); font-size: 30px; line-height: 1; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile { background: #fff; border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; position: relative; animation: rise 0.3s ease both; }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #eee; }
.tile .body { padding: 14px 16px 16px; }
.tile .name { font-family: var(--display); font-size: 22px; line-height: 1.05; }
.tile .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--muted); }
.tag { padding: 5px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; letter-spacing: 0.04em; background: var(--ink); color: #fff; }
.tag.pong { background: var(--aperol); }
.tag.die { background: #7c5cd6; }
.tag.none { background: #9a9389; }
.tag.plus { background: #fff; color: var(--aperol-deep); box-shadow: inset 0 0 0 2px var(--aperol); }
.status { font-size: 14px; margin-top: 8px; font-weight: 600; }
.status.paired { color: #1d8a4e; }
.status.waiting { color: var(--aperol-deep); }
.remove {
  position: absolute; top: 10px; right: 10px; border: 0; border-radius: 999px; width: 36px; height: 36px;
  background: rgba(16,16,16,0.7); color: #fff; font-size: 18px; cursor: pointer;
}
.wall .remove, .wall .admin-only { display: none; }
.wall .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 20px; }

/* How to play */
.howto-row { margin: 18px 0 0; font-size: 16px; color: var(--muted); text-align: center; }
.howto {
  appearance: none; border: 0; background: none; padding: 6px 2px; font: 600 16px var(--body); color: var(--aperol-deep);
  text-decoration: underline; text-decoration-color: var(--aperol); text-underline-offset: 4px; text-decoration-thickness: 2px; cursor: pointer;
}
.howto:active { color: var(--aperol); }
.badge .howto { font-size: 14px; padding: 4px 0; margin-top: 6px; display: inline-block; }
.sheet-wrap { position: fixed; inset: 0; z-index: 6; background: rgba(16, 16, 16, 0.45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.sheet { width: 100%; max-width: 680px; max-height: 92dvh; overflow-y: auto; background: #fff; border-radius: 30px; padding: 32px; box-shadow: var(--shadow); animation: rise 0.25s ease both; }
.sheet-body { display: grid; grid-template-columns: 1fr 200px; gap: 24px; align-items: start; margin-top: 18px; }
@media (max-width: 560px) { .sheet-body { grid-template-columns: 1fr; } }
.rules { margin: 0; padding-left: 22px; display: grid; gap: 10px; font-size: 17px; line-height: 1.4; }
.rules li::marker { color: var(--aperol); font-weight: 700; }
.qr { text-align: center; }
.qr img { width: 200px; height: 200px; border-radius: 18px; border: 2px solid var(--line); padding: 8px; background: #fff; }
.qr p { margin: 10px 0 0; font-size: 14px; color: var(--muted); font-weight: 600; line-height: 1.4; }
.qr p span { font-weight: 500; }
