:root {
  --bg: #17122b;
  --panel: #241b45;
  --panel2: #2e2260;
  --ink: #f4f1ff;
  --muted: #bdb2e8;
  --purple: #a855f7;
  --purple-glow: #c084fc;
  --blue: #38bdf8;
  --blue-glow: #7dd3fc;
  --gold: #ffb020;
  --good: #4ade80;
  --bad: #f87171;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
}
main { max-width: 680px; margin: 0 auto; padding: 16px 16px 90px; }
.loading { color: var(--muted); text-align: center; margin-top: 60px; }
a { color: var(--blue-glow); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 2px solid var(--panel2);
  background: #1d1739; color: var(--ink); font-size: 16px; font-family: inherit; margin: 4px 0 12px;
}
label { font-weight: 800; font-size: 14px; color: var(--muted); }
.btn {
  display: inline-block; border: 0; border-radius: 12px; padding: 13px 20px;
  background: var(--purple); color: #fff; font-weight: 900; font-size: 16px; text-decoration: none;
}
.btn.blue { background: #0284c7; }
.btn.ghost { background: transparent; border: 2px solid var(--purple); color: var(--ink); }
.btn.gold { background: var(--gold); color: #17122b; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.err { color: var(--bad); min-height: 22px; font-weight: 700; }
.hint { color: var(--muted); font-size: 15px; }
.card {
  background: var(--panel); border-radius: 18px; padding: 20px; margin: 14px 0;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.card h2, .card h3 { margin-top: 0; }

/* ---- welcome background (naked: photo only, no color wash) ---- */
.welcome-bg {
  position: fixed;
  /* longhands first: fallback for Safari < 14.1, which drops `inset` */
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url('/assets/bg/carnival-clean.webp');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
.welcome-content { position: relative; z-index: 1; }
.welcome-content .card {
  background: transparent;
  box-shadow: none;
}
.welcome-content h2,
.welcome-content .hint,
.welcome-content label,
.welcome-content .foot {
  color: #fff;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .68), 0 1px 4px rgba(0, 0, 0, .8);
}
.welcome-content .err { text-shadow: 0 1px 8px rgba(0, 0, 0, .75); }
.welcome-content input {
  background: rgba(15, 11, 32, .45);
  border-color: rgba(255, 255, 255, .55);
  color: #fff;
}
/* welcome only: Log in gets the same readable treatment as the inputs
   (its ghost styling — transparent fill, pale text — washed out
   against the bright photo). Sign up free keeps the purple fill. */
.welcome-content .btn.ghost {
  background: rgba(15, 11, 32, .45);
  border-color: rgba(255, 255, 255, .55);
  color: #fff;
}
/* welcome only: header floats directly on the photo (no dark bar / pill) */
body:has(.welcome-bg) #topbar { background: transparent; }
body:has(.welcome-bg) .brand .panel { background: transparent; border-color: transparent; }
body:has(.welcome-bg) .tagline {
  color: #fff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .82), 0 1px 3px rgba(0, 0, 0, .85);
}
/* same treatment via a body class (set by app.js) for Safari < 15.4, which drops :has() rules entirely */
body.welcome-on #topbar { background: transparent; }
body.welcome-on .brand .panel { background: transparent; border-color: transparent; }
body.welcome-on .tagline {
  color: #fff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .82), 0 1px 3px rgba(0, 0, 0, .85);
}

/* ---- header / wordmark ---- */
#topbar { background: #0f0b20; padding: 10px 16px; position: -webkit-sticky; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; max-width: 680px; margin: 0 auto; }
.brand .panel {
  background: #0b0817; border-radius: 14px; padding: 8px 18px 10px; display: inline-block;
  border: 1px solid #33265e;
}
/* Neon-sign wordmark: rendered image assets (blue-violet). Width-driven
   sizing with a vw cap so the brand row never overflows small phones;
   height follows the image aspect ratio. */
.logo-line { display: block; width: 250px; max-width: 56vw; height: auto; }
.logo-stacked { display: block; width: 272px; max-width: 62vw; height: auto; }
.tagline { color: var(--muted); font-size: 13px; font-weight: 700; }

/* ---- mascot: layered — the body stays still, only the arm waves ---- */
.mascot-row { display: flex; gap: 14px; align-items: flex-start; margin: 14px 0; }
.mascot {
  position: relative; display: inline-block; flex: 0 0 auto;
  width: 84px; aspect-ratio: 646 / 595;
}
.mascot img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mascot .mascot-arm {
  transform-origin: 76% 44%;
  animation: arm-wave 2.6s ease-in-out infinite;
}
@keyframes arm-wave {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(10deg); }
}
@media (prefers-reduced-motion: reduce) {
  .mascot .mascot-arm { animation: none; }
}
.bubble {
  background: #fff; color: #241b45; border-radius: 16px; padding: 12px 16px;
  position: relative; font-weight: 700; flex: 1;
}
.bubble::before {
  content: ''; position: absolute; left: -8px; top: 26px; width: 16px; height: 16px;
  background: #fff; transform: rotate(45deg); border-radius: 3px;
}
.cheer .mascot .mascot-arm { animation-duration: 1.1s; }

/* ---- nav tabs ---- */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; background: #0f0b20; z-index: 20;
  display: flex; justify-content: center; gap: 2px; padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
nav.tabs button {
  background: transparent; border: 0; color: var(--muted); font-weight: 900; font-size: 14px;
  padding: 10px 12px; border-radius: 10px;
}
nav.tabs button.active { background: var(--panel2); color: #fff; }
nav.tabs .dot { color: var(--gold); }

/* ---- profile cards / deck ---- */
.photo { width: 100%; border-radius: 14px; display: block; }
.avatar {
  width: 100%; aspect-ratio: 1.2; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--purple), #0284c7); font-size: 72px; font-weight: 900; color: #fff;
}
.avatar.sm { width: 54px; height: 54px; aspect-ratio: auto; font-size: 22px; border-radius: 50%; flex: 0 0 auto; }
img.avatar-img { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.badge-verified { color: var(--gold); font-weight: 900; }
.badge-id { color: #7aa2ff; font-weight: 900; }
.badge-founding { color: var(--purple-glow); font-weight: 900; }
.launch-card { text-align: center; }
.countdown { font-size: 30px; font-weight: 900; letter-spacing: 1px; margin: 6px 0; }
.tag {
  display: inline-block; background: var(--panel2); border-radius: 999px; padding: 3px 10px;
  font-size: 13px; font-weight: 800; color: var(--muted); margin: 2px 2px 2px 0;
}
.tag.sample { background: #7c2d12; color: #fed7aa; }
.tag.shared { background: #14532d; color: #bbf7d0; }
.q { color: var(--muted); font-weight: 800; font-size: 14px; margin: 12px 0 2px; }
.deck-actions { display: flex; gap: 12px; margin-top: 16px; }
.deck-actions .btn { flex: 1; font-size: 18px; padding: 16px; }
.pass-btn { background: #3f3f46 !important; }

/* ---- availability grid ---- */
table.grid { border-collapse: collapse; width: 100%; }
table.grid th, table.grid td { padding: 6px 4px; text-align: center; font-size: 14px; }
table.grid th { color: var(--muted); }
.slotbox {
  width: 100%; padding: 9px 2px; border-radius: 9px; border: 2px solid var(--panel2);
  background: #1d1739; color: var(--muted); font-weight: 800; font-size: 13px;
}
.slotbox.on { background: var(--purple); border-color: var(--purple); color: #fff; }

/* ---- chat ---- */
.thread { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 16px; background: var(--panel2); align-self: flex-start; }
.msg.mine { background: var(--purple); align-self: flex-end; }
.msg .when { display: block; font-size: 11px; color: rgba(255,255,255,.65); margin-top: 4px; }
.msg.system { align-self: center; background: transparent; border: 1px dashed var(--purple); color: var(--muted); font-size: 13px; text-align: center; max-width: 92%; }
.match-row { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--panel); border: 0; border-radius: 14px; padding: 12px; color: var(--ink); margin: 8px 0; }
.match-row .last { color: var(--muted); font-size: 14px; }

/* ---- video picker ---- */
.videogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.videogrid button { background: var(--panel2); border: 3px solid transparent; border-radius: 12px; padding: 4px; color: var(--ink); font-weight: 800; font-size: 13px; }
.videogrid button.sel { border-color: var(--gold); }
.videogrid img { width: 100%; border-radius: 8px; display: block; }
video.preview { width: 100%; border-radius: 14px; margin: 10px 0; background: #000; }

.price { font-size: 22px; font-weight: 900; }
.strike { text-decoration: line-through; color: var(--muted); }
.date-status { font-weight: 900; }
.date-status.confirmed { color: var(--good); }
.date-status.pending { color: var(--gold); }
footer.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 0 30px; }

/* ---- host: mascot as continuous assistant ---- */
.host {
  position: fixed; left: 12px; z-index: 30;
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 8px;
  max-width: calc(100vw - 24px);
}
.host-btn {
  background: var(--panel); border: 2px solid var(--panel2); border-radius: 50%;
  width: 58px; height: 58px; padding: 5px; flex: 0 0 auto; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
}
.host-btn .mascot { width: 100%; }
.host-bubble {
  background: #fff; color: #241b45; border-radius: 14px; padding: 9px 12px;
  font-weight: 700; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.35);
  position: relative; max-width: 204px; cursor: pointer;
}
.host-bubble::before {
  content: ''; position: absolute; left: -6px; bottom: 16px; width: 12px; height: 12px;
  background: #fff; transform: rotate(45deg); border-radius: 2px;
}
.host-tip { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.host[data-state="open"] .host-bubble { max-width: 266px; cursor: default; }
.host[data-state="open"] .host-tip { white-space: normal; max-width: 240px; }
.host-actions { display: none; gap: 8px; margin-top: 10px; }
.host[data-state="open"] .host-actions { display: flex; }
.host[data-state="mini"] .host-bubble { display: none; }
.impr-btn { width: 100%; margin-top: 10px; }

/* ---- bottom sheets (advice / impressions) ---- */
.sheet-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  background: rgba(10, 7, 24, .72); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--panel); width: 100%; max-width: 680px; max-height: 88vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h3 { margin: 0; }
.sheet-x { background: transparent; border: 0; color: var(--muted); font-size: 28px; font-weight: 900; line-height: 1; padding: 4px 8px; }
.advice-tip { font-size: 20px; font-weight: 800; line-height: 1.45; margin: 16px 0; }
.advice-nav { justify-content: space-between; align-items: center; }

/* ---- impression star ratings + owner report card ---- */
.rate-row { padding: 9px 0; border-bottom: 1px solid var(--panel2); }
.rate-label { font-weight: 900; font-size: 16px; }
.rate-hint { display: block; color: var(--muted); font-weight: 700; font-size: 13px; }
.rate-stars { margin-top: 2px; }
.star {
  background: transparent; border: 0; padding: 2px 3px; cursor: pointer;
  font-size: 30px; line-height: 1.1; color: #4b4470;
}
.star.on { color: var(--gold); }
.tally {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--panel2); font-weight: 800;
}
.tally:last-child { border-bottom: 0; }
.tally-stars { color: var(--gold); font-size: 15px; letter-spacing: 1px; }
.tally-stars strong { color: var(--ink); }

/* ---- rating entries (locked / unlocked) ---- */
.rating-entry {
  border: 1px solid var(--panel2); border-radius: 12px;
  padding: 12px 14px; margin: 10px 0;
}
.rating-head { display: flex; justify-content: space-between; align-items: baseline; }
.rating-line { display: flex; justify-content: space-between; padding: 2px 0; font-weight: 700; }
.rating-comment { margin: 8px 0 2px; }
.rating-entry .blur { filter: blur(5px); opacity: .8; user-select: none; pointer-events: none; }
.imp-comment { padding: 8px 0; border-bottom: 1px solid var(--panel2); }
.imp-comment:last-child { border-bottom: 0; }

/* ---- sense of humor page ---- */
.humor-img { width: 100%; border-radius: 14px; display: block; }
.humor-caption {
  background: #fff; color: #241b45; border-radius: 16px; padding: 14px 16px;
  font-weight: 800; font-size: 19px; line-height: 1.4; margin-top: 14px; position: relative;
}
.humor-caption::before {
  content: ''; position: absolute; left: 44px; top: -7px; width: 14px; height: 14px;
  background: #fff; transform: rotate(45deg); border-radius: 2px;
}
.humor-empty { font-weight: 800; margin: 12px 0 4px; }
.humor-thumb { width: 132px; border-radius: 10px; display: block; margin: 6px 0 4px; }
.form-sub { margin: 20px 0 4px; }

/* ---- smart puzzles ---- */
.puzzle-block { padding: 12px 0 14px; border-bottom: 1px solid var(--panel2); }
.puzzle-row { display: flex; gap: 6px; }
.matrix-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 302px; }
.puzzle-panel {
  background: #1d1739; border: 2px solid var(--panel2); border-radius: 10px;
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center; flex: 1; min-width: 0;
}
.matrix-grid .puzzle-panel { flex: none; }
.puzzle-panel.qmark { color: var(--muted); font-size: 26px; font-weight: 900; }
.puzzle-panel.their-pick { border-color: var(--gold); }
.puzzle-opts { display: flex; gap: 6px; margin-top: 8px; }
.puzzle-opt {
  flex: 1; min-width: 0; background: #1d1739; border: 3px solid var(--panel2);
  border-radius: 10px; padding: 3px; cursor: pointer;
}
.puzzle-opt.sel { border-color: var(--gold); }
.puzzle-opt.right { border-color: var(--good); }
.puzzle-opt.wrong { border-color: var(--bad); }
.puzzle-opt:disabled { opacity: 1; cursor: default; }
.glyph { width: 100%; height: auto; display: block; }
.smart-score { font-size: 20px; font-weight: 900; margin: 10px 0 2px; }

/* ---- talent videos ---- */
.talent-video { width: 100%; border-radius: 14px; margin: 10px 0; background: #000; }
.talent-slot-line { font-weight: 800; }

/* ---- quest: "Before you bother" ---- */
.quest-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(127, 127, 127, 0.18); }
.quest-row:last-of-type { border-bottom: 0; }
.quest-q { font-weight: 700; }
.quest-a { font-weight: 900; white-space: nowrap; }
.quest-edit { margin: 14px 0; }
.quest-edit .quest-q { margin: 0 0 6px; }
.quest-opt.on { background: var(--purple); border-color: var(--purple); color: #fff; }
.align-note { background: rgba(127, 127, 127, 0.12); border-radius: 12px; padding: 10px 12px; margin-top: 12px; }

/* ---- ask your host ---- */
.ask-form { display: flex; gap: 8px; margin-top: 12px; }
.ask-form input { flex: 1; min-width: 0; }
.ask-q { font-weight: 800; margin: 12px 0 4px; }
.ask-a { margin: 0 0 8px; }
#ask-log { max-height: 40vh; overflow-y: auto; }

/* ---- older-Safari fallbacks ----
   Flexbox `gap` needs Safari 14.5+. app.js probes for it and adds
   .no-flex-gap to <html> when missing; these margins then carry the
   spacing `gap` was providing. Grid gap (Safari 10.1+) and the 2px
   nav-tab gap (padding already separates the buttons) need no cover. */
.no-flex-gap .brand > * + * { margin-left: 12px; }
.no-flex-gap .mascot-row .bubble { margin-left: 14px; }
.no-flex-gap .btnrow > * + * { margin-left: 10px; }
.no-flex-gap .deck-actions .btn + .btn { margin-left: 12px; }
.no-flex-gap .thread .msg + .msg { margin-top: 8px; }
.no-flex-gap .match-row > * + * { margin-left: 12px; }
.no-flex-gap .host .host-bubble { margin-left: 8px; }
.no-flex-gap .host-actions .btn + .btn { margin-left: 8px; }
.no-flex-gap .puzzle-row .puzzle-panel + .puzzle-panel { margin-left: 6px; }
.no-flex-gap .puzzle-opts .puzzle-opt + .puzzle-opt { margin-left: 6px; }
.no-flex-gap .sheet-head .sheet-x { margin-left: 12px; }

/* Country flag badge — top-right corner, makes each market feel like home */
.country-flag { position: fixed; top: 10px; right: 10px; width: 32px; height: auto; border-radius: 5px; box-shadow: 0 1px 6px rgba(0,0,0,.45); z-index: 60; }

.ask-a { white-space: pre-line; }
.ask-pending { opacity: .55; }
