/* ============================================================
   SideQuest — design system
   Mobile-first. Dark, party-forward palette.
   ============================================================ */

:root {
  --bg:            #0d0a1a;
  --bg-2:          #150f2b;
  --surface:       #1c1536;
  --surface-2:     #251c47;
  --line:          #35295f;
  --line-soft:     #2a2050;

  --text:          #f2eeff;
  --text-dim:      #a99ecb;
  --text-faint:    #6f6394;

  --brand:         #b14aff;   /* purple */
  --brand-2:       #ff3d8b;   /* magenta */
  --accent:        #c8ff4d;   /* lime */
  --gold:          #ffc93c;
  --logo-amber:    #f59e0b;   /* from logo.svg — used for BETA marks */
  --good:          #35e08a;
  --bad:           #ff5c6c;

  --radius:        16px;
  --radius-sm:     10px;
  --radius-lg:     24px;

  --shadow:        0 10px 40px rgba(0, 0, 0, .45);
  --glow:          0 0 32px rgba(177, 74, 255, .35);

  --rail:          180px;      /* ad rail width */
  --max:           760px;      /* content max width */

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-display: "Space Grotesk", var(--font);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(177, 74, 255, .22), transparent 60%),
    radial-gradient(900px 600px at 90% 0%,   rgba(255, 61, 139, .16), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -.02em; }
h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); margin: 0 0 .3em; line-height: 1.12; }
h2 { font-size: 1.25rem; margin: 0 0 .6em; }
h3 { font-size: 1rem;    margin: 0 0 .4em; }
p  { margin: 0 0 1em; }
a  { color: var(--accent); }

/* ---------- Layout: content + optional ad rails ---------- */

.shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  max-width: calc(var(--max) + (var(--rail) + 24px) * 2);
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
  align-content: start;
}

.shell > .rail { display: none; }

@media (min-width: 1180px) {
  .shell.with-rails {
    grid-template-columns: var(--rail) minmax(0, 1fr) var(--rail);
  }
  .shell.with-rails > .rail { display: block; }
}

.content { min-width: 0; max-width: var(--max); width: 100%; margin: 0 auto; }

.rail { position: sticky; top: 20px; align-self: start; }

/* ---------- Ad slots ---------- */

.ad {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .02);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad .ad-ph {
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
  padding: 8px;
}

.ad-rail    { min-height: 600px; }
.ad-bottom  { min-height: 90px; margin-top: 28px; }
.ad-inline  { min-height: 90px; margin: 20px 0; }

/* Sticky bottom banner used on the live game screens */
.ad-sticky {
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin-top: 24px;
  background: rgba(13, 10, 26, .92);
  backdrop-filter: blur(8px);
}

/* The sticky banner only appears during live play (when the rails are off),
   so reserve room for it there or it covers the last card. */
.shell:not(.with-rails) .content { padding-bottom: 108px; }

/* ---------- Brand / header ---------- */

.brandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
}

/* The brand mark is assets/img/logo-mark.svg — a badge-only crop of the full
   lockup. The full logo.svg carries its own wordmark, which is unreadable at
   34px and would duplicate the text beside it, so it is used only on the home
   hero. The SVG draws its own rounded corners and background. */
.logo-mark {
  width: 34px; height: 34px;
  flex: none;
  display: block;
}

/* "BETA" beside the wordmark. Amber ties it to the logo's own accent. */
.beta {
  font-size: .72em;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--logo-amber);
  white-space: nowrap;
}

/* Home hero — the full lockup, big enough for its wordmark to read. */
.logo-hero {
  display: block;
  width: clamp(150px, 44vw, 210px);
  height: auto;
  margin: 0 auto 14px;
  filter: drop-shadow(0 10px 34px rgba(0, 0, 0, .55));
}

.beta-pill {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 13px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--logo-amber);
  background: rgba(245, 158, 11, .12);
  border: 1px solid rgba(245, 158, 11, .45);
}

/* ---------- Cards ---------- */

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card--flush { padding: 0; overflow: hidden; }
.card--quiet { background: rgba(255, 255, 255, .025); box-shadow: none; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h2, .card-head h3 { margin: 0; }

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 22px;
  font: inherit;
  font-weight: 650;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
  min-height: 48px;
  text-align: center;
}
.btn:hover  { filter: brightness(1.12); }
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 26px rgba(177, 74, 255, .32);
}
.btn--accent { background: var(--accent); color: #17210a; }
.btn--good   { background: var(--good);   color: #04240f; }
.btn--bad    { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn--ghost  { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn--block  { width: 100%; }
.btn--lg     { padding: 17px 28px; font-size: 1.05rem; min-height: 56px; }
.btn--sm     { padding: 8px 14px; min-height: 38px; font-size: .88rem; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 160px; }

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }
.field > label,
.field-label {
  display: block;
  font-size: .82rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.field-hint { font-size: .82rem; color: var(--text-faint); margin-top: 6px; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  background: rgba(0, 0, 0, .28);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 13px 14px;
  min-height: 48px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(177, 74, 255, .22);
}
textarea { resize: vertical; min-height: 88px; }
::placeholder { color: var(--text-faint); }

.code-input {
  font-family: var(--font-display);
  font-size: 1.9rem;
  letter-spacing: .35em;
  text-align: center;
  text-transform: uppercase;
  padding: 16px 10px 16px 22px;
}

.char-count { font-size: .75rem; color: var(--text-faint); text-align: right; margin-top: 4px; }

/* ---------- Icon picker ---------- */

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
}

.icon-opt {
  aspect-ratio: 1;
  display: grid; place-items: center;
  font-size: 1.5rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.icon-opt:hover { transform: translateY(-2px); }
.icon-opt[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(200, 255, 77, .14);
  box-shadow: 0 0 0 2px rgba(200, 255, 77, .25);
}
.icon-opt:disabled { opacity: .22; cursor: not-allowed; transform: none; }

/* ---------- Quest pack picker ---------- */

.pack {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: rgba(255, 255, 255, .025);
}
.pack input { width: 20px; height: 20px; accent-color: var(--brand); margin-top: 3px; flex: none; }
.pack-body { flex: 1; min-width: 0; }
.pack-name { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pack-desc { font-size: .86rem; color: var(--text-dim); margin-top: 2px; }

.tag {
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.tag--18 { background: rgba(255, 92, 108, .16); color: #ffb3ba; border-color: rgba(255, 92, 108, .4); }

/* ---------- Quest card (the player's current mission) ---------- */

.quest {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(177, 74, 255, .35), transparent 60%),
    linear-gradient(160deg, var(--surface-2), var(--bg-2));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
  overflow: hidden;
}
.quest-eyebrow {
  font-size: .72rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}
.quest-text {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 5.5vw, 1.85rem);
  line-height: 1.25;
  margin: 0 0 16px;
}
.quest-points {
  display: inline-block;
  background: var(--gold); color: #241900;
  font-weight: 750; font-size: .9rem;
  padding: 5px 14px; border-radius: 999px;
}

/* ---------- Leaderboard ---------- */

.lb { list-style: none; margin: 0; padding: 0; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .03);
  margin-bottom: 8px;
  transition: background .3s ease;
}
.lb-row.is-me { background: rgba(177, 74, 255, .18); border: 1px solid rgba(177, 74, 255, .45); }
.lb-row.bump  { animation: bump .5s ease; }
.lb-rank {
  width: 30px; flex: none; text-align: center;
  font-family: var(--font-display); font-weight: 700; color: var(--text-faint);
}
.lb-row:nth-child(1) .lb-rank { color: var(--gold); }
.lb-row:nth-child(2) .lb-rank { color: #d5dbe6; }
.lb-row:nth-child(3) .lb-rank { color: #e0a06a; }
.lb-icon { font-size: 1.5rem; flex: none; }
.lb-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts  { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--accent); flex: none; }
.lb-badges { display: flex; gap: 5px; flex: none; }

@keyframes bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.035); background: rgba(200, 255, 77, .22); }
  100% { transform: scale(1); }
}

/* ---------- Player chips (lobby) ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px 7px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line-soft);
  font-size: .9rem;
}
.chip-icon { font-size: 1.15rem; }

/* ---------- Requests (verification) ---------- */

.req {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, .035);
}
.req--mine { border-left-color: var(--accent); }
.req-who { display: flex; align-items: center; gap: 8px; font-weight: 650; margin-bottom: 6px; }
.req-quest { color: var(--text-dim); font-size: .95rem; margin-bottom: 12px; }
.req-actions { display: flex; gap: 8px; }
.req-actions .btn { flex: 1; }

/* ---------- Room code ---------- */

.roomcode {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 11vw, 3.4rem);
  font-weight: 700;
  letter-spacing: .18em;
  text-align: center;
  color: var(--accent);
  background: rgba(0, 0, 0, .3);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px 10px 16px 28px;
  margin-bottom: 14px;
  word-break: break-all;
}

.qr-wrap {
  display: grid; place-items: center;
  background: #fff; padding: 14px; border-radius: var(--radius);
  width: fit-content; margin: 0 auto 14px;
}

/* ---------- Status / misc ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .78rem; font-weight: 650;
  padding: 5px 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--line);
}
.pill--live { color: var(--good); border-color: rgba(53, 224, 138, .4); background: rgba(53, 224, 138, .12); }
.pill--live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
.pill--ended { color: var(--text-faint); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.muted   { color: var(--text-dim); }
.faint   { color: var(--text-faint); }
.center  { text-align: center; }
.stack > * + * { margin-top: 12px; }
.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;
}

.slogan { font-size: 1.15rem; color: var(--text-dim); margin-bottom: 28px; }

.divider { height: 1px; background: var(--line-soft); margin: 20px 0; border: 0; }

.empty { text-align: center; color: var(--text-faint); padding: 22px 10px; font-size: .92rem; }

.list-reset { list-style: none; margin: 0; padding: 0; }

.quest-preview li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .03);
  margin-bottom: 7px;
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
}
.quest-preview .pts { color: var(--gold); font-weight: 650; flex: none; font-size: .88rem; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 3, 12, .78);
  backdrop-filter: blur(5px);
  display: grid; place-items: center;
  padding: 18px;
}
.modal {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.pick-list { display: grid; gap: 8px; margin: 14px 0 4px; }
.pick {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
  width: 100%;
}
.pick:hover { border-color: var(--brand); background: rgba(177, 74, 255, .14); }

/* ---------- Toast ---------- */

#toasts {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 200; display: grid; gap: 8px; width: min(92vw, 420px);
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  box-shadow: var(--shadow);
  font-size: .93rem;
  animation: toastIn .22s ease;
}
.toast--good { border-left-color: var(--good); }
.toast--bad  { border-left-color: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Celebration ---------- */

#celebrate {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center;
  background: rgba(5, 3, 12, .8);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.celebrate-card {
  text-align: center;
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
.celebrate-emoji { font-size: 4.5rem; line-height: 1; }
.celebrate-title {
  font-family: var(--font-display); font-size: 2rem; margin: 10px 0 4px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.celebrate-pts { font-size: 1.3rem; color: var(--accent); font-weight: 700; }

@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.confetti {
  position: fixed; top: -12px; width: 9px; height: 14px;
  z-index: 299; pointer-events: none; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* ---------- Winner ---------- */

.winner {
  text-align: center;
  padding: 28px 20px;
  border-radius: var(--radius-lg);
  background: radial-gradient(120% 120% at 50% 0%, rgba(255, 201, 60, .28), transparent 62%),
              linear-gradient(180deg, var(--surface-2), var(--bg-2));
  border: 1px solid rgba(255, 201, 60, .35);
  margin-bottom: 16px;
}
.winner-icon  { font-size: 4rem; line-height: 1; margin-bottom: 10px; }
.winner-name  { font-family: var(--font-display); font-size: 1.9rem; margin: 6px 0 2px; }
.winner-pts   { color: var(--gold); font-weight: 700; }
.reward {
  margin-top: 16px; padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 201, 60, .1);
  border: 1px dashed rgba(255, 201, 60, .45);
}

/* ---------- Setup warning ---------- */

.setup-warn {
  background: rgba(255, 92, 108, .12);
  border: 1px solid rgba(255, 92, 108, .45);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.setup-warn code {
  background: rgba(0, 0, 0, .4); padding: 2px 6px; border-radius: 5px;
  font-size: .88em;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
