/* Layout: one centred column; couples as a wrapping card grid, each card split by a "pod wall". */
:root {
  --bg: #f6f2f4;
  --surface: #ffffff;
  --ink: #2a1f2d;
  --muted: #6e6172;
  --line: #e4dbe2;
  --accent: #a3245c;
  --accent-ink: #ffffff;
  --yes: #2f7d5b;
  --no: #b8332e;
  --split: #b27512;
  --living: #3d6fb4;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17121a;
    --surface: #221b26;
    --ink: #f1e9ef;
    --muted: #a898a8;
    --line: #3a2f3e;
    --accent: #e0629a;
    --accent-ink: #1a0f15;
    --yes: #5cc497;
    --no: #ef6f69;
    --split: #e3a94a;
    --living: #7aa7e8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--body);
}
a { color: var(--accent); }
h1, h2 { font-family: var(--display); line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { background: var(--bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main.wrap { padding-block: 28px 64px; display: grid; gap: 20px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding-block: 12px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.35rem; color: var(--ink); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--accent); }
/* Host dropdown in the top bar */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .15s; }
.menu[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.menu summary:hover, .menu.is-active summary { color: var(--accent); }
.menu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.menu-list {
  position: absolute; top: calc(100% + 8px); left: -10px; z-index: 10; min-width: 160px;
  display: grid; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 14%, transparent);
}
.menu-list a { padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.menu-list a:hover { background: var(--bg); }
.menu-list a[aria-current="page"] { color: var(--accent); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .menu summary::after { transition: none; } }

/* Tabs between the Host pages */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; margin-bottom: -1px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

.me { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.balance { font-variant-numeric: tabular-nums; }
.balance strong { color: var(--accent); font-size: 1.1rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; }

/* Messages */
.flash { margin: 0; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.flash-ok { border-color: var(--yes); }
.flash-error { border-color: var(--no); }

.page-head { display: grid; gap: 6px; max-width: 65ch; }
.page-head p { margin: 0; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 24px; }
.empty p { margin: 0 0 4px; }

/* Forms */
input, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: 8px; padding: 8px 16px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }

.auth { max-width: 380px; display: grid; gap: 10px; }
.auth p { margin: 0; }
.stack { display: grid; gap: 6px; }
.stack label { font-weight: 600; font-size: .9rem; margin-top: 6px; }
.stack .btn { margin-top: 12px; }

/* Couple cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 16px; }
.couple {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; display: grid; gap: 16px; align-content: start;
}
.couple.status-settled { opacity: .85; }
.couple-head { display: grid; gap: 8px; }
.names { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; font-size: 1.3rem; }
.names span:first-child { text-align: right; }
.names span { min-width: 0; overflow-wrap: anywhere; }
/* The pod wall: the frosted panel they talk through before they meet. */
.wall { width: 6px; height: 34px; border-radius: 3px; background: linear-gradient(var(--accent), transparent); opacity: .7; }
.meta { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: .85rem; }

.pill { display: inline-block; font-size: .78rem; font-weight: 600; letter-spacing: .02em; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; }
.pill-open { color: var(--yes); }
.pill-locked { color: var(--split); }
.pill-settled { color: var(--muted); }
.pill-won { color: var(--yes); }
.pill-lost { color: var(--no); }

.outcomes { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.outcome { --c: var(--muted); display: grid; gap: 4px; }
.outcome-yes { --c: var(--yes); }
.outcome-no { --c: var(--no); }
.outcome-split { --c: var(--split); }
.outcome-stay { --c: var(--living); }
.outcome-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.outcome-label { font-weight: 600; }
.outcome-num { font-variant-numeric: tabular-nums; color: var(--c); font-weight: 600; white-space: nowrap; font-size: .92rem; }
.outcome-sub { font-size: .82rem; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--c); border-radius: 3px; }
.outcome.is-result .outcome-label::after { content: " ✓"; color: var(--c); }

.couple-foot { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; font-variant-numeric: tabular-nums; }
.bet-form { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; }
.result { font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.is-me td { background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 600; }

/* Host */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 14px; }
.row-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.field { display: grid; gap: 4px; flex: 1 1 160px; }
.field label { font-size: .85rem; font-weight: 600; }
.host-list { list-style: none; margin: 0; padding: 0; display: grid; }
.host-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; padding-block: 12px; border-top: 1px solid var(--line); }
.host-list li:first-child { border-top: 0; }
.host-actions, .settle-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.confirm { font-size: .85rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* Phases and cast */
h3 { font-family: var(--display); font-size: 1rem; margin: 0 0 6px; }
.phase { display: grid; gap: 16px; }
.phase + .phase { border-top: 1px solid var(--line); padding-top: 28px; }
.eyebrow { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.pair-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.pair-form .field { flex: 1 1 150px; }
.pair-form .field-amount { flex: 0 1 110px; }
.heart { font-family: var(--display); font-size: 1.5rem; color: var(--accent); padding-bottom: 4px; }
.cast { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.cast-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.gender-pick { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.gender-pick legend { font-size: .85rem; font-weight: 600; padding: 0; margin-bottom: 4px; }
.gender-pick label { font-weight: 400; display: flex; gap: 6px; align-items: center; }
.input-short { width: 5em; }
.settle-pods { border-top: 1px solid var(--line); padding-top: 14px; }
.panel p { margin: 0; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; counter-reset: step; }
.steps li { counter-increment: step; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.steps li::before { content: counter(step) ". "; }
.steps li.current { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.steps li.done { color: var(--yes); }
.steps li.done::before { content: "✓ "; }

/* Photos */
.avatar {
  --size: 40px;
  position: relative; flex: none; display: inline-grid; place-items: center;
  width: var(--size); height: var(--size); border-radius: 50%; overflow: hidden;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent); font-family: var(--display); font-weight: 700;
  font-size: calc(var(--size) * .38); line-height: 1;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }
/* Full-body portraits (head near the top): enlarge and pin to the top so the face fills the circle. */
.avatar-full img { inset: auto; left: 50%; top: 0; width: 280%; height: auto; max-width: none; transform: translate(-50%, -4%); object-fit: fill; }
.avatar-sm { --size: 28px; }
.avatar-md { --size: 40px; }
.avatar-lg { --size: 64px; }
.avatar-xl { --size: 84px; }
.pair-cell { display: inline-flex; align-items: center; gap: 4px; }
.pair-cell > span:last-child, .pair-cell > strong { margin-left: 6px; white-space: normal; }

.names .partner { display: grid; justify-items: center; gap: 8px; text-align: center; }
.names span:first-child { text-align: center; }

.faces-group { display: grid; gap: 10px; }
.faces { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px 4px; }
.face {
  width: 100%; display: grid; justify-items: center; gap: 6px; padding: 8px 4px;
  background: none; border: 2px solid transparent; border-radius: 12px;
  font: inherit; color: var(--ink); text-align: center;
}
button.face { cursor: pointer; }
button.face:hover { background: var(--surface); }
button.face:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.face[aria-pressed="true"] { border-color: var(--accent); background: var(--surface); }
.face-name { font-size: .88rem; font-weight: 500; line-height: 1.25; }

.cast-row { display: grid; gap: 4px; padding-block: 6px; border-top: 1px solid var(--line); }
.cast-row-main { display: flex; align-items: center; gap: 10px; }
.push-right { margin-left: auto; }
.photo-edit summary { cursor: pointer; font-size: .85rem; color: var(--accent); width: fit-content; }
.photo-edit form { padding-block: 8px 4px; }
.photo-edit input[type="file"] { padding: 6px; }

.reset-password { flex-basis: 100%; font-size: .9rem; }
a.link-btn { font-size: inherit; }
.round-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }

/* Your own bets */
.my-bet { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.my-bet .bet-edit { order: 3; flex-basis: 100%; }
.my-bet .bet-edit:not([open]) { flex-basis: auto; order: 0; }
.bet-edit summary { cursor: pointer; color: var(--accent); width: fit-content; }
.bet-edit form { padding-top: 8px; }
.my-pairs { list-style: none; margin: 0; padding: 0; display: grid; }
.my-pairs li { display: grid; gap: 6px; padding-block: 10px; border-top: 1px solid var(--line); }
.my-pairs li:first-child { border-top: 0; padding-top: 0; }
.my-pair-row { display: flex; align-items: center; gap: 10px; }
.my-pair-row .pair-cell > span:last-child { line-height: 1.35; }
.face-taken { opacity: .45; }
.face-note { font-size: .75rem; color: var(--muted); margin-top: -4px; }

@media (max-width: 480px) {
  .faces { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .avatar-xl { --size: 68px; }
  h1 { font-size: 1.6rem; }
  .me { margin-left: 0; }
  .bet-form { grid-template-columns: 1fr 80px; }
  .bet-form select { grid-column: 1 / -1; }
}

/* Predictions */
.predict-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.earned { color: var(--yes); font-weight: 600; }
.field-points { flex: 0 1 150px; }

/* Voter badges: first letter per player, name on hover/focus */
.voters { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.voter {
  --h: 330;
  position: relative; display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: hsl(var(--h) 55% 42%); color: #fff;
  font-size: .72rem; font-weight: 700; line-height: 1; cursor: default;
}
.voter.is-me { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.voter.has-picture { overflow: hidden; background: var(--line); }
.voter img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.voter-xl { width: 96px; height: 96px; font-size: 2.4rem; flex: none; }
.voter-xl.is-me { box-shadow: none; }
.voter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* One floating window for every hover preview, placed by script so scroll boxes can't clip it. */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  display: grid; justify-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap;
  background: var(--ink); color: var(--surface); font-size: .78rem; font-weight: 500;
}
.tooltip.has-img {
  padding: 8px; border-radius: 12px; font-size: .85rem; font-weight: 600;
  box-shadow: 0 10px 30px color-mix(in srgb, #000 35%, transparent);
}
.tooltip-img { width: 220px; height: 220px; border-radius: 10px; object-fit: cover; background: var(--line); }
.tooltip-img.is-portrait { width: 220px; height: 330px; object-position: center top; }
.voters-empty { font-size: .8rem; color: var(--muted); }
td.voters-cell { white-space: normal; min-width: 120px; }
.outcome .voters, .outcome .voters-empty { margin-top: 2px; }

/* Golden goblet: the unit scores are counted in. Sized to the surrounding text. */
img.cup { display: inline-block; width: auto; height: 1.3em; vertical-align: -0.28em; margin-inline: .05em; }
th img.cup { height: 1.5em; vertical-align: middle; }
.balance img.cup { height: 1.4em; }
.crown { margin-left: 4px; font-size: 1.1em; cursor: default; }

/* Account page */
.account-panel { max-width: 640px; }
.picture-row { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.picture-forms { flex: 1 1 260px; gap: 10px; }
.picture-forms p { margin: 0; }
.small { font-size: .85rem; }
input[type="file"] { max-width: 100%; }

/* Cast picker at the top of the pods; filters the pairings table once predictions are closed */
.cast-picker { display: grid; gap: 12px; }
.cast-picker p { margin: 0; }
.cast-picker .faces-group h2 { font-size: 1rem; }
.cast-picker .face-name { font-size: .8rem; }
.filter-note { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--accent); }
.filter-note .link-btn { margin-left: 6px; color: var(--accent); }
.voters-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.remove-mine .link-btn { font-size: .85rem; }
/* Keep the hover preview inside small screens */
@media (max-width: 480px) {
  .tooltip-img { width: 160px; height: 160px; }
  .tooltip-img.is-portrait { width: 160px; height: 240px; }
}
.tooltip.has-img { font-size: .95rem; }
