/* Site pages: Home, Join, Lobby, Profile, Sign in.
   Builds on tokens.css (theme variables, .btn, .ib, .field, .panel, cards, tooltips). */

html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: inherit; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.5; }

/* ---- Header ---------------------------------------------------------------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; max-width: 1120px; margin: 0 auto; padding: 16px;
}
/* Header lockup: 40px mark, 6px gap, 24px wordmark (HANDOFF §12) */
.logo { display: flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; font-size: 24px; font-weight: 600; flex: none; }
.logo__mark { flex: none; transition: transform .25s cubic-bezier(.2, .7, .2, 1.4); }
.logo:hover .logo__mark { transform: rotate(6deg); }
.logo__card { color: var(--logo2); }
.site-header__actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nav-link { color: var(--muted); font-size: 15px; font-weight: 500; text-decoration: none; padding: 12px 8px; }
.nav-link:hover { color: var(--ink); }
.ib:hover { transform: rotate(-12deg); }
.btn.sm { min-height: 44px; padding: 0 16px; font-size: 15px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.chip {
  display: flex; align-items: center; gap: 8px; min-height: 44px; min-width: 0; padding: 0 14px 0 6px;
  border-radius: 22px; background: var(--chip); color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 600;
}
.chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12ch; }
.chip__tag { font-weight: 500; color: var(--muted); }

/* ---- Avatars ------------------------------------------------------------------ */
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--chip); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 18px;
}
.avatar--me { background: var(--accent); color: var(--on-accent); }
.avatar--xs { width: 32px; height: 32px; font-size: 15px; }
.avatar--md { width: 48px; height: 48px; font-size: 20px; }
.avatar--lg { width: 64px; height: 64px; font-size: 28px; }
.avatar--xl { width: 72px; height: 72px; font-size: 32px; }

/* ---- Page layouts ------------------------------------------------------------- */
.page { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page--center { display: flex; align-items: center; justify-content: center; padding-bottom: 72px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 24px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--lg { gap: 20px; }
.stack--sm { gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > .grow { flex: 1 1 140px; }
.label { font-size: 14px; font-weight: 600; }
.lead { font-size: 17px; line-height: 1.55; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.linkbtn {
  min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--ink);
  font: 600 15px var(--font-body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.inline-link { color: var(--ink); font-weight: 600; }
.rise.d2 { animation-delay: .12s; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.pop { animation: pop .3s cubic-bezier(.2, .7, .2, 1.4) both; }

/* Flash messages */
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.45; background: var(--bg); border: 1.5px solid var(--line);
  animation: rise .35s cubic-bezier(.2, .7, .2, 1) both;
}
.notice svg { flex: none; margin-top: 1px; }
.notice--error { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.notice--error svg { color: var(--accent); }
.notice--ok svg { color: var(--ok); }

/* ---- Home ---------------------------------------------------------------------- */
.home { display: flex; flex-direction: column; gap: 72px; padding-top: 32px; }
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); gap: 48px; align-items: center; }
.hero__title { font-size: clamp(36px, 7vw, 60px); line-height: 1.05; text-wrap: balance; }
.hero__lead { font-size: 18px; line-height: 1.55; color: var(--muted); max-width: 46ch; }
.start { padding: 20px; max-width: 460px; }
.fan { --cw: clamp(72px, 13vw, 132px); display: flex; justify-content: center; align-items: flex-end; padding: 32px 0; animation: float 5s ease-in-out infinite; }
.fan .card { margin: 0 calc(var(--cw) * -.16); transition: transform .25s; }
@keyframes float { 50% { transform: translateY(-8px); } }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 20px; }
.step { padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.step h2 { margin-top: 6px; font-size: 22px; }
.step p { font-size: 15px; line-height: 1.55; color: var(--muted); }
.step__num {
  width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; font-size: 20px; transition: transform .2s;
}
.step:hover .step__num { transform: scale(1.08) rotate(-6deg); }
.keep { padding: 28px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.keep__text { display: flex; flex-direction: column; gap: 6px; flex: 1 1 320px; }
.keep__text h2 { font-size: 24px; }
.keep__text p { font-size: 15px; line-height: 1.55; color: var(--muted); max-width: 60ch; }

/* "Back to your game" on Home */
.rejoin { padding: 14px; max-width: 460px; display: flex; flex-direction: column; gap: 10px; }
.rejoin__title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.rejoin__live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: blink 1.4s ease-in-out infinite; }
.rejoin__list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.rejoin__game {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 10px 10px 12px;
  border-radius: 14px; background: var(--bg); color: var(--ink); text-decoration: none;
}
.rejoin__seats { display: flex; flex: none; }
.rejoin__seats .avatar { box-shadow: 0 0 0 2px var(--bg); }
.rejoin__seats .avatar + .avatar { margin-left: -10px; }
.rejoin__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rejoin__text strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rejoin__btn { flex: none; }
.rejoin__game:hover .rejoin__btn { transform: translateY(-1px); }
@media (max-width: 420px) { .rejoin__seats { display: none; } }
@media (prefers-reduced-motion: reduce) { .rejoin__live { animation: none; } }

/* ---- Join / Sign in / closed: one centred card ------------------------------------ */
.card-panel { width: 100%; max-width: 440px; padding: 28px; display: flex; flex-direction: column; gap: 22px; border-radius: 24px; }
.card-panel .btn, .card-panel .field { min-height: 52px; font-size: 17px; }
.invite { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.invite h1 { font-size: 30px; line-height: 1.15; text-wrap: balance; }
.invite p { font-size: 15px; color: var(--muted); }
.wave { animation: wave 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(-8deg); } 30% { transform: rotate(6deg); } }
.welcome { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--bg); }
.welcome__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.welcome__text strong { font-size: 16px; }

/* ---- Profile ------------------------------------------------------------------------ */
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head h1 { font-size: 30px; line-height: 1.1; overflow-wrap: anywhere; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--chip); font-size: 13px; font-weight: 600; }
.pill--ok { color: var(--ok); }
.ticks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 15px; line-height: 1.45; }
.ticks li { display: flex; gap: 10px; }
.ticks svg { flex: none; margin-top: 1px; color: var(--ok); }
.done { padding: 18px; border-radius: 16px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { padding: 12px; border-radius: 14px; background: var(--bg); text-align: center; }
.stat strong { display: block; font-family: var(--font-display); font-size: 26px; font-weight: 600; }
.stat span { font-size: 13px; color: var(--muted); }

/* ---- Lobby ----------------------------------------------------------------------------- */
.lobby-title { font-size: clamp(30px, 6vw, 44px); line-height: 1.1; overflow-wrap: anywhere; }
.share { padding: 20px; }
.share__link {
  flex: 1 1 220px; min-width: 0; min-height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1.5px dashed var(--line); background: var(--bg); color: var(--ink);
  font: 500 16px ui-monospace, Menlo, monospace; text-overflow: ellipsis;
}
.share__code { letter-spacing: .08em; color: var(--ink); }
.nudge {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px;
  border-radius: 16px; background: var(--chip); color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.45;
}
.nudge strong { white-space: nowrap; color: var(--accent); }
.table-panel { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.table-panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.table-panel__head h2 { font-size: 22px; }
.seats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.seat-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px; border-radius: 14px; background: var(--bg); }
.seat-row__name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.seat-row__note { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seat-row__note--ok { color: var(--ok); }
.seat-row.is-away { opacity: .6; }
.seat-row--empty { background: none; border: 1.5px dashed var(--line); color: var(--muted); }
.seat-row--empty .avatar { background: none; }
/* Bots (HANDOFF 8c): a square avatar with a robot, a "Bot" label and a level badge.
   Bots differ from people by shape and label, not colour alone. */
.avatar--bot { border-radius: 12px; background: var(--chip); color: var(--ink); }
.seat-row--bot, .seat-row--pick { gap: 10px; padding: 6px 6px 6px 12px; }
.seat-row--pick { flex-wrap: wrap; gap: 8px; box-shadow: inset 0 0 0 1.5px var(--accent); }
.seat-row--empty:has(.seat-row__add) { padding: 6px 6px 6px 12px; }
.seat-row__tag { font-size: 13px; font-weight: 500; color: var(--muted); }
.seat-row__wait { flex: 1; font-size: 15px; }
.seat-row__pick-title { flex: 1 1 90px; font-size: 15px; font-weight: 600; }
.seat-row__add { min-height: 44px; padding: 0 14px; font-size: 14px; gap: 6px; }
.lv-group { display: flex; gap: 6px; }
.seg { min-width: 52px; min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--line); background: transparent;
  color: var(--ink); font: 600 15px Inter, system-ui, sans-serif; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s; }
.seg:hover { border-color: var(--ink); }
.seg.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.lvb { min-height: 44px; padding: 0 2px; border: 0; background: none; cursor: pointer; display: inline-flex; align-items: center; }
.lv { padding: 5px 10px; border-radius: 999px; font: 600 13px/1 Inter, system-ui, sans-serif; border: 1.5px solid var(--ink); color: var(--ink); transition: transform .15s; white-space: nowrap; }
.lvb:hover .lv { transform: translateY(-1px); }
.lv.medium { background: var(--chip); border-color: var(--chip); }
.lv.hard { background: var(--ink); color: var(--bg); }
.ib--plain { border-color: transparent; background: transparent; }
@media (max-width: 420px) { .lv-group { flex: 1 1 100%; } .lv-group .seg { flex: 1; } }
@media (prefers-reduced-motion: reduce) { .lv, .seg { transition: none; } }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
.settings { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
/* Lobby: the rules everyone can read */
.settings__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.settings__head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.chips { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--chip); font-size: 14px; font-weight: 500; }
.chip.pop { animation: pop .3s cubic-bezier(.2, .7, .2, 1.4) both; }

/* Game rules dialog (host) */
.dialog.dialog--wide { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.rules-dialog { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.rules-dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.rules-dialog__head h2 { margin: 0; font-size: 26px; font-weight: 600; }
.rules-dialog__head p, .rules-dialog .stack p, .rules-dialog h3 { margin: 0; }
.rules-dialog__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.stack--xs { gap: 4px; }
.steppers { position: relative; display: flex; flex-wrap: wrap; gap: 16px; }
.steppers .tip-anchor { position: static; display: inline-flex; }
.stepper-field { flex: 1 1 180px; display: flex; flex-direction: column; gap: 2px; }
.stepper { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 16px; background: var(--bg); border: 1.5px solid var(--line); }
.sb {
  width: 48px; height: 48px; flex: none; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .12s, border-color .15s;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.sb:hover { border-color: var(--muted); }
.sb:active { transform: scale(.92); }
.sb:disabled { opacity: .35; cursor: default; transform: none; }
.sv { flex: 1; text-align: center; font-size: 26px; font-weight: 600; line-height: 1; }
.sv.bump { animation: bump .2s ease-out; }
@keyframes bump { from { transform: scale(1.25); } }
.deal-note { margin: -8px 0 0; line-height: 1.5; color: var(--muted); }
.deal-note.is-over { color: var(--accent); }
.rule {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: transparent; color: var(--ink); text-align: left; font-family: inherit; cursor: pointer; transition: border-color .15s;
}
.rule:hover { border-color: var(--muted); }
.rule:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.rule__card {
  width: 34px; height: 46px; flex: none; border-radius: 5px; background: #FDFCF9; color: #7B2046; border: 1px solid #E6E1DA;
  display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600;
}
.rule__text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.rule__card--bot { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--chip); color: var(--ink); }
.leave-pref { display: flex; flex-direction: column; gap: 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.leave-pref h2 { margin: 0; font-size: 18px; font-weight: 600; }
.rule__name { font-size: 16px; font-weight: 600; }
.rule__desc { font-size: 14px; line-height: 1.4; color: var(--muted); }
.sw { width: 52px; height: 32px; flex: none; border-radius: 999px; background: var(--line); position: relative; transition: background-color .2s; }
.sw::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s cubic-bezier(.2, .7, .2, 1.3);
}
.rule[aria-checked="true"] .sw { background: var(--accent); }
.rule[aria-checked="true"] .sw::after { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { .sv.bump, .chip.pop { animation: none; } .sw, .sw::after, .sb { transition: none; } }
.start-btn { min-height: 56px; font-size: 18px; width: 100%; }

/* QR dialog */
.dialog {
  border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); width: min(360px, calc(100vw - 32px));
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog[open] { animation: rise .3s cubic-bezier(.2, .7, .2, 1) both; }
.dialog__body { padding: 24px; display: flex; flex-direction: column; gap: 16px; align-items: center; text-align: center; }
.dialog__body h2 { font-size: 22px; }
.qr { width: 100%; max-width: 260px; padding: 12px; border-radius: 14px; background: #FFFFFF; }
.qr svg { display: block; width: 100%; height: auto; }

/* ---- Tooltips (behaviour in site.js) ------------------------------------------------------ */
/* The tooltip spans the row it explains: the anchor row is the positioning
   context for the link tip; a whole .steppers row is the context for the rules dialog. */
.tip-anchor { position: relative; display: flex; align-items: center; gap: 2px; }
.tipb span { transition: transform .15s, background-color .15s, color .15s; }
.tipb:hover span, .tipb[aria-expanded="true"] span { background: var(--ink); color: var(--bg); border-color: var(--ink); transform: scale(1.1); }
.tip { font-weight: 400; }
.tipx {
  display: block; min-height: 44px; padding: 0; border: 0; background: none; color: inherit;
  font: 600 14px var(--font-body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

@media (min-width: 640px) {
  .site-header { padding: 16px 24px; }
  .page { padding-left: 24px; padding-right: 24px; }
}
#lobby-error:empty { display: none; }
@media (max-width: 420px) {
  .nav-link--how { display: none; }
  .chip__name { max-width: 7ch; }
}
/* The narrowest phones keep the mark and drop the wordmark when signed in (the chip needs the room). */
@media (max-width: 380px) {
  .site-header:has(.chip) .logo__word { display: none; }
}
