/* Who Am I? — a card table at night.
   Indigo felt, gold foil card edges, pink for actions, teal for yes.
   The one showpiece is the card: it deals onto the table, tilts under your finger and flips. */

:root {
  --bg0: #0c0c24;
  --bg1: #16163b;
  --bg2: #2a2370;
  --panel: #1c1d48;
  --panel2: #262763;
  --line: rgba(255, 255, 255, 0.11);
  --text: #f6f0e4;
  --muted: #aeacd6;
  --pink: #ff5c93;
  --pink-hi: #ff7aa8;
  --teal: #3fe0c5;
  --gold: #f2c46d;
  --red: #ff7070;
  --ink-on-pink: #2a0b1a;
  --display: 'Gloock', Georgia, 'Times New Roman', serif;
  --ui: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
  /* shape of the card pictures: width / height of the white-bordered cards after prepare_cards.py */
  --card-ratio: 0.694;
  --card-radius: 4% / 2.8%;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(120% 70% at 50% -8%, var(--bg2) 0%, rgba(42, 35, 112, 0) 62%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 100%) fixed;
  background-color: var(--bg0);
  overflow-x: hidden;
}

/* felt grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

h1, h2, h3, p { margin: 0; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: 0.005em; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; padding: 0 1.25rem;
  border: 0; border-radius: 999px;
  font-weight: 700; font-size: 1rem;
  background: var(--panel2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--pink); color: var(--ink-on-pink); box-shadow: 0 8px 24px -8px rgba(255, 92, 147, 0.7); }
.btn-primary:hover { background: var(--pink-hi); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1.5px rgba(255, 112, 112, 0.55); }
.btn-small { min-height: 38px; padding: 0 0.9rem; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }

.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, 0.07); color: var(--text);
}
.icon-btn svg { width: 22px; height: 22px; }

.field { display: grid; gap: 0.4rem; }
.field > label, .field > .lbl { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; min-height: 52px; padding: 0 1rem; border-radius: 14px;
  border: 0; background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: 1.05rem;
}
.input::placeholder { color: rgba(174, 172, 214, 0.6); }
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--gold); }

/* ------------------------------------------------------------------- card back */
.cardback {
  position: relative; aspect-ratio: var(--card-ratio); border-radius: 16px;
  border: 2px solid var(--gold);
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.22), transparent 55%),
    repeating-linear-gradient(45deg, rgba(242, 196, 109, 0.16) 0 2px, transparent 2px 15px),
    repeating-linear-gradient(-45deg, rgba(242, 196, 109, 0.16) 0 2px, transparent 2px 15px),
    linear-gradient(160deg, #3b2a8c, #7a2a8f 58%, #c2306f);
  box-shadow: 0 18px 30px -14px rgba(0, 0, 0, 0.7);
  display: grid; place-items: center;
}
.cardback::before {
  content: ''; position: absolute; inset: 7px; border-radius: 10px;
  border: 1px solid rgba(242, 196, 109, 0.5);
}
.cardback .q { font-family: var(--display); color: var(--gold); font-size: 4.6em; line-height: 1; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }

/* -------------------------------------------------------------------- home */
.home { max-width: 460px; margin: 0 auto; padding: calc(var(--safe-t) + 28px) 20px 40px; display: grid; gap: 26px; }
.home-top { display: flex; justify-content: flex-end; }
.lang-btn { background: transparent; border: 0; color: var(--muted); font-weight: 600; padding: 8px 4px; }

.hero { display: grid; justify-items: center; gap: 14px; text-align: center; margin-top: 4px; }
.fan { position: relative; width: 190px; height: 160px; font-size: 10px; }
.fan .cardback { position: absolute; width: 96px; left: 47px; top: 6px; transform-origin: 50% 120%; }
.fan .cardback:nth-child(1) { transform: rotate(-17deg); }
.fan .cardback:nth-child(2) { transform: rotate(0deg); z-index: 1; }
.fan .cardback:nth-child(3) { transform: rotate(17deg); }
.hero h1 { font-size: clamp(2.6rem, 11vw, 3.4rem); line-height: 1; }
.hero p { color: var(--muted); max-width: 26ch; }

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border-radius: 24px; padding: 20px; display: grid; gap: 16px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.panel h2 { font-size: 1.15rem; font-weight: 700; }
.who-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.who-row .hi { font-family: var(--display); font-size: 1.6rem; }
.link { background: none; border: 0; padding: 6px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

.code-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.code-input { text-transform: uppercase; letter-spacing: 0.35em; font-family: var(--display); font-size: 1.5rem; text-align: center; padding-left: 0.35em; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.resume { display: grid; gap: 8px; }
.resume-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 12px 16px; border-radius: 16px; border: 0; background: rgba(0, 0, 0, 0.24); text-align: left;
  box-shadow: inset 0 0 0 1px var(--line);
}
.resume-item .c { font-family: var(--display); font-size: 1.35rem; letter-spacing: 0.12em; }
.resume-item .n { color: var(--muted); font-size: 0.9rem; }

/* ------------------------------------------------------------------- sheets */
.scrim {
  position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; justify-items: center;
  background: rgba(5, 5, 20, 0.66); backdrop-filter: blur(6px);
  animation: fade 0.18s ease;
}
.sheet {
  width: min(100%, 520px); max-height: 92dvh; overflow: auto;
  background: linear-gradient(180deg, #25266a, #1a1b46);
  border-radius: 26px 26px 0 0; padding: 22px 20px calc(22px + var(--safe-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  display: grid; gap: 18px;
  animation: rise 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet h2 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; line-height: 1.15; }
.sheet p { color: var(--muted); }
.sheet .actions { display: grid; gap: 10px; }
.scrim.center { align-items: center; padding: 20px; }
.scrim.center .sheet { border-radius: 26px; }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-opt {
  aspect-ratio: 1; border-radius: 14px; border: 0; font-size: 1.55rem; background: rgba(0, 0, 0, 0.26);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.avatar-opt[aria-pressed='true'] { background: rgba(242, 196, 109, 0.18); box-shadow: inset 0 0 0 2.5px var(--gold); }

.stepper { display: flex; align-items: center; gap: 14px; }
.stepper b { font-family: var(--display); font-size: 1.8rem; font-weight: 400; min-width: 2ch; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 0.92rem;
  background: rgba(0, 0, 0, 0.26); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted);
}
.chip[aria-pressed='true'] { background: rgba(63, 224, 197, 0.16); color: var(--teal); box-shadow: inset 0 0 0 2px var(--teal); }
.hint { font-size: 0.85rem; color: var(--muted); }

/* --------------------------------------------------------------------- room */
.room { min-height: 100dvh; padding-bottom: calc(110px + var(--safe-b)); }
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 10px) max(14px, calc((100vw - 980px) / 2 + 16px)) 10px; background: linear-gradient(180deg, rgba(12, 12, 36, 0.92), rgba(12, 12, 36, 0.6) 80%, transparent);
  backdrop-filter: blur(8px);
}
.code-chip {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px;
  border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.07); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
.code-chip .c { font-family: var(--display); font-size: 1.35rem; letter-spacing: 0.22em; padding-left: 0.22em; }
.code-chip svg { width: 18px; height: 18px; color: var(--muted); }
.score-pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 10px; border-radius: 999px;
  background: rgba(242, 196, 109, 0.14); box-shadow: inset 0 0 0 1px rgba(242, 196, 109, 0.4);
}
.score-pill .e { font-size: 1.25rem; }
.score-pill .s { font-family: var(--display); font-size: 1.4rem; color: var(--gold); min-width: 1ch; text-align: center; }
.score-pill .s.bump { animation: bump 0.5s ease; }

.view { max-width: 980px; margin: 0 auto; padding: 8px 16px 0; }

/* empty / waiting */
.waiting {
  display: grid; justify-items: center; gap: 12px; text-align: center; padding: 22px 18px; margin: 4px 0 18px;
  border-radius: 22px; background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px var(--line);
}
.waiting h2 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; }
.waiting p { color: var(--muted); }
.waiting .code-big { font-family: var(--display); font-size: 2.4rem; letter-spacing: 0.25em; padding-left: 0.25em; color: var(--gold); }

/* ------------------------------------------------------------- player cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 22px 14px; padding-top: 8px; }

.pc { display: grid; gap: 8px; perspective: 1100px; align-self: start; }
.pc.deal { animation: deal 0.55s cubic-bezier(0.2, 0.85, 0.25, 1) both; animation-delay: calc(var(--i, 0) * 90ms); }

.flip {
  position: relative; aspect-ratio: var(--card-ratio); width: 100%; border-radius: var(--card-radius); cursor: pointer;
  transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.3, 0.8, 0.25, 1);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.pc.flipped .flip { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; border-radius: var(--card-radius); overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 2px solid var(--gold); box-shadow: 0 18px 30px -14px rgba(0, 0, 0, 0.75), 0 2px 0 rgba(255, 255, 255, 0.12) inset;
  background: var(--panel);
}
.face.front { border: 0; background: transparent; }
.face.front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face.front .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 34px 10px 10px;
  background: linear-gradient(180deg, transparent, rgba(8, 8, 28, 0.88));
  font-family: var(--display); font-size: 1.12rem; line-height: 1.15; text-align: center; text-wrap: balance;
}
.face.front .cat {
  position: absolute; top: 8px; left: 8px; padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  background: rgba(10, 10, 32, 0.66); color: var(--gold); backdrop-filter: blur(4px);
}
/* foil sheen that follows the finger / pointer */
.face.front::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light; opacity: 0; transition: opacity 0.25s ease;
  background:
    radial-gradient(circle at var(--mx, 50%) var(--my, 30%), rgba(255, 255, 255, 0.95), transparent 46%),
    linear-gradient(115deg, rgba(255, 92, 147, 0.55), rgba(63, 224, 197, 0.55), rgba(242, 196, 109, 0.55));
}
.flip.tilting .face.front::after { opacity: 0.9; }

.face.back {
  transform: rotateY(180deg); padding: 16px 14px; display: grid; align-content: start; gap: 10px; overflow: auto;
  background:
    radial-gradient(circle at 80% 0%, rgba(122, 42, 143, 0.55), transparent 60%),
    linear-gradient(180deg, #25266a, #17183f);
}
.face.back .bn { font-family: var(--display); font-size: 1.3rem; line-height: 1.1; color: var(--gold); text-wrap: balance; }
.face.back .bc { font-size: 0.78rem; font-weight: 700; color: var(--teal); }
.face.back .bio { font-size: 0.9rem; line-height: 1.45; color: #e9e4f6; }

.pc .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.pc .who { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-weight: 700; }
.pc .who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc .pts { font-family: var(--display); color: var(--gold); font-size: 1.15rem; }

.mark {
  min-height: 44px; border: 0; border-radius: 14px; font-weight: 700; font-size: 0.92rem; padding: 6px 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; line-height: 1.15;
  background: rgba(63, 224, 197, 0.14); color: var(--teal); box-shadow: inset 0 0 0 1.5px rgba(63, 224, 197, 0.55);
  transition: transform 0.12s ease, background 0.15s ease;
}
.mark:active { transform: scale(0.97); }
.mark svg { width: 18px; height: 18px; flex: none; }
.mark.waiting-me { background: rgba(242, 196, 109, 0.12); color: var(--gold); box-shadow: inset 0 0 0 1.5px rgba(242, 196, 109, 0.55); }
.mark.busy { background: rgba(255, 255, 255, 0.05); color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line); cursor: default; }

.footnote { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 26px; }

/* -------------------------------------------------------------------- notes */
.notes { max-width: 560px; margin: 0 auto; display: grid; gap: 18px; padding-top: 6px; }
.notes-head { display: grid; grid-template-columns: 92px 1fr; gap: 16px; align-items: center; }
.notes-head .cardback { font-size: 6.5px; transform: rotate(-6deg); }
.notes-head h2 { font-family: var(--display); font-weight: 400; font-size: 1.8rem; line-height: 1.05; margin-bottom: 6px; }
.notes-head p { color: var(--muted); font-size: 0.93rem; }

.notelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.note {
  display: grid; grid-template-columns: 44px 1fr 40px; align-items: center; gap: 6px; padding: 4px 6px 4px 4px;
  border-radius: 16px; background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px var(--line);
  animation: pop 0.22s ease;
}
.note .t { padding: 8px 4px; overflow-wrap: anywhere; }
.note.is-yes .t { color: #d6fff7; }
.note.is-no .t { color: #c7c4e4; text-decoration: line-through; text-decoration-color: rgba(255, 112, 112, 0.8); }
.mk {
  width: 40px; height: 40px; border-radius: 12px; border: 0; display: grid; place-items: center; font-weight: 800;
  background: rgba(0, 0, 0, 0.26); color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line);
}
.mk svg { width: 20px; height: 20px; }
.mk.yes { background: rgba(63, 224, 197, 0.18); color: var(--teal); box-shadow: inset 0 0 0 2px var(--teal); }
.mk.no { background: rgba(255, 112, 112, 0.16); color: var(--red); box-shadow: inset 0 0 0 2px var(--red); }
.note .del { width: 36px; height: 36px; border: 0; background: none; color: var(--muted); border-radius: 50%; display: grid; place-items: center; }
.note .del svg { width: 18px; height: 18px; }
.empty-note { text-align: center; color: var(--muted); padding: 18px 10px; border-radius: 16px; box-shadow: inset 0 0 0 1.5px var(--line); }

.addnote { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.giveup-wrap { display: grid; justify-items: center; padding-top: 10px; }

/* --------------------------------------------------------------- standings */
.standings { max-width: 560px; margin: 0 auto; display: grid; gap: 22px; padding-top: 6px; }
.st-head { display: flex; align-items: center; justify-content: space-between; }
.st-head h2 { font-family: var(--display); font-weight: 400; font-size: 1.9rem; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 0.85rem; font-weight: 700; color: var(--teal); }
.live::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 0 rgba(63, 224, 197, 0.7); animation: pulse 1.8s infinite; }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; padding-top: 6px; }
.pod { display: grid; justify-items: center; gap: 6px; text-align: center; min-width: 0; }
.pod .av { font-size: 2rem; line-height: 1; }
.pod .pn { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .bar-b {
  width: 100%; border-radius: 16px 16px 6px 6px; display: grid; place-items: start center; padding-top: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)); box-shadow: inset 0 0 0 1px var(--line);
  transform-origin: bottom; animation: grow 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.pod.r1 .bar-b { height: 124px; background: linear-gradient(180deg, rgba(242, 196, 109, 0.5), rgba(242, 196, 109, 0.12)); box-shadow: inset 0 0 0 1.5px rgba(242, 196, 109, 0.7); }
.pod.r2 .bar-b { height: 92px; }
.pod.r3 .bar-b { height: 70px; }
.pod .sc { font-family: var(--display); font-size: 1.9rem; line-height: 1; }
.pod.r1 .sc { color: var(--gold); }
.pod .crown { width: 26px; height: 26px; color: var(--gold); }
.pod .crown-sp { height: 26px; }

.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px var(--line);
}
.rank.me { background: rgba(242, 196, 109, 0.1); box-shadow: inset 0 0 0 1.5px rgba(242, 196, 109, 0.55); }
.rank.gone { opacity: 0.55; }
.rank .pos { font-family: var(--display); font-size: 1.25rem; color: var(--muted); text-align: center; }
.rank .nm { font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank .nm span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .sub { font-size: 0.82rem; color: var(--muted); font-weight: 500; }
.rank .pt { font-family: var(--display); font-size: 1.6rem; color: var(--gold); }
.tag { font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: var(--muted); }

/* --------------------------------------------------------------------- host */
.host { max-width: 560px; margin: 0 auto; display: grid; gap: 16px; padding-top: 6px; }
.host .big-code { text-align: center; font-family: var(--display); font-size: 3rem; letter-spacing: 0.25em; padding-left: 0.25em; color: var(--gold); }
.host-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.host-row .l { display: grid; gap: 2px; }
.host-row .l b { font-weight: 700; }
.switch { position: relative; width: 56px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(0, 0, 0, 0.35); box-shadow: inset 0 0 0 1.5px var(--line); transition: background 0.2s; }
.switch span::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::after { transform: translateX(24px); }
.switch input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.plist { display: grid; gap: 8px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-radius: 16px; background: rgba(0, 0, 0, 0.22); }
.prow .nm { flex: 1; font-weight: 700; display: flex; gap: 8px; align-items: center; min-width: 0; }
.prow .nm span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px);
  background: radial-gradient(90% 60% at 50% 20%, rgba(122, 42, 143, 0.55), rgba(8, 8, 28, 0.94) 70%); backdrop-filter: blur(8px); overflow: auto;
  animation: fade 0.25s ease;
}
.reveal { display: grid; gap: 18px; justify-items: center; text-align: center; width: min(100%, 360px); }
.reveal h2 { font-family: var(--display); font-weight: 400; font-size: 2.3rem; line-height: 1.05; }
.reveal .pc { width: min(64vw, 260px); }
.reveal .flip { animation: unveil 1s cubic-bezier(0.25, 0.8, 0.25, 1) 0.2s backwards; }
.reveal .bio { color: #e4dff2; font-size: 0.98rem; max-width: 34ch; }
.reveal .pt { font-family: var(--display); font-size: 1.5rem; color: var(--gold); }
.reveal .was { color: var(--muted); font-weight: 600; }
.reveal .name { font-family: var(--display); font-size: 1.7rem; line-height: 1.1; }

.final { width: min(100%, 520px); display: grid; gap: 22px; }
.final h2 { font-family: var(--display); font-weight: 400; font-size: 2.6rem; line-height: 1; text-align: center; }
.final .winner { text-align: center; color: var(--gold); font-family: var(--display); font-size: 1.5rem; }

/* ---------------------------------------------------------------------- tabs */
.tabs {
  position: fixed; z-index: 30; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%);
  width: min(92vw, 440px); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 6px;
  border-radius: 999px; background: rgba(18, 18, 48, 0.86); backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.8), inset 0 0 0 1px var(--line);
}
.tab {
  display: grid; justify-items: center; gap: 1px; padding: 8px 4px 7px; border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  font-size: 0.74rem; font-weight: 700; transition: background 0.2s, color 0.2s;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-selected='true'] { background: var(--pink); color: var(--ink-on-pink); }

/* ------------------------------------------------------------------- toasts */
#toasts { position: fixed; z-index: 100; top: calc(var(--safe-t) + 12px); left: 0; right: 0; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 14px; }
.toast {
  max-width: 460px; padding: 12px 18px; border-radius: 16px; font-weight: 600; text-align: center;
  background: #2b2c70; box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.18); animation: toast 0.3s ease both;
}
.toast.err { background: #5b1f3c; box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.7), inset 0 0 0 1.5px rgba(255, 112, 112, 0.6); }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 90; pointer-events: none; }

/* ----------------------------------------------------------------- keyframes */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.5); } 100% { transform: scale(1); } }
@keyframes grow { from { transform: scaleY(0.1); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(63, 224, 197, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 224, 197, 0); } }
@keyframes deal {
  from { opacity: 0; transform: translateY(-120px) translateX(var(--dx, 0px)) rotate(var(--rot, -10deg)) scale(0.85); }
  to { opacity: 1; transform: none; }
}
@keyframes unveil {
  0% { transform: rotateY(180deg) scale(0.9); }
  70% { transform: rotateY(-8deg) scale(1.04); }
  100% { transform: rotateY(0deg) scale(1); }
}

/* ------------------------------------------------------------------- layout */
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 28px 18px; }
  .face.front .cap { font-size: 1.25rem; }
  .face.back .bio { font-size: 0.98rem; }
  .scrim { align-items: center; }
  .sheet { border-radius: 26px; }
}

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