/* Samesies: one stylesheet for every page. */

:root {
  --paper: #fbf6ee;
  --card: #ffffff;
  --ink: #1d1a17;
  --ink-soft: #5d5750;
  --ink-faint: #8f877d;
  --line: #e8e0d4;
  --brand: #ef5a3c;        /* tomato */
  --brand-dark: #c8432a;
  --sun: #ffd25c;          /* highlight */
  --match: #2c9a6a;        /* "you matched" green */
  --match-soft: #dff3e8;
  --you: #fff1c7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(29, 26, 23, .04), 0 6px 24px -12px rgba(29, 26, 23, .18);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --anchor-h: 0px;         /* set by ads.js when the bottom ad is showing */
  --rail-w: 160px;
}

@media (min-width: 1480px) { :root { --rail-w: 300px; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
#join-area > section { margin-bottom: 18px; }
#groups-area > section { margin-top: 18px; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  padding-bottom: calc(var(--anchor-h) + env(safe-area-inset-bottom));
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- page layout: left rail | game | right rail ---------- */

.page {
  display: grid;
  grid-template-columns: 1fr minmax(0, 620px) 1fr;
  gap: 28px;
  padding: 0 16px;
  min-height: 100vh;
}
.page > main { grid-column: 2; width: 100%; padding-bottom: 32px; }
.ad-rail { display: none; padding-top: 88px; }
.ad-rail .ad-slot { position: sticky; top: 24px; }
.ad-rail.left { grid-column: 1; justify-self: end; }
.ad-rail.right { grid-column: 3; justify-self: start; }

/* Rails only appear when there's room for them beside the game. */
@media (min-width: 1100px) {
  .ad-rail { display: block; width: var(--rail-w); }
}

/* ---------- ad slots ---------- */

.ad-slot { margin: 0 auto; }
.ad-slot[data-size="rail"] { width: var(--rail-w); min-height: 600px; }
.ad-placeholder {
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  width: 100%; height: 100%;
  border: 2px dashed #d9cfc1; border-radius: 12px;
  color: #b0a596; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(0,0,0,.015) 10px 20px);
  text-align: center; gap: 4px;
}
.ad-slot[data-size="rail"] .ad-placeholder { height: 600px; }

.ad-anchor {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: none; justify-content: center; align-items: center;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
}
.ad-anchor.showing { display: flex; }
.ad-anchor .ad-slot { width: 320px; height: 50px; }
@media (min-width: 760px) { .ad-anchor .ad-slot { width: 728px; height: 90px; } }
.ad-anchor-close {
  position: absolute; top: -26px; right: 12px;
  border: 1px solid var(--line); border-bottom: 0; background: var(--paper);
  border-radius: 8px 8px 0 0; padding: 2px 10px; font-size: 13px; cursor: pointer; color: var(--ink-soft);
}

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

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 22px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo svg { width: 34px; height: 34px; }
.logo-word { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.top-meta { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 600;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 800; font-size: 16px;
}
.icon-btn:hover { border-color: var(--ink-faint); }

/* ---------- cards & buttons ---------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.card + .card, .card + section, section + .card { margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 14px 22px; font-weight: 800; font-size: 17px;
  background: var(--ink); color: #fff; cursor: pointer; text-decoration: none;
  transition: transform .06s ease, background .15s ease;
}
.btn:hover { background: #000; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.brand { background: var(--brand); }
.btn.brand:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink-faint); background: #fff; }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; font-size: 14px; }

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 14px; }
.error { color: var(--brand-dark); font-weight: 600; min-height: 1.4em; margin: 8px 0 0; font-size: 15px; }
.center { text-align: center; }

input[type="text"] {
  width: 100%; padding: 16px 18px; font-size: 20px; border-radius: 12px;
  border: 2px solid var(--line); background: #fff; outline: none; transition: border-color .15s;
}
input[type="text"]:focus { border-color: var(--ink); }
label.field { display: block; font-weight: 700; margin: 12px 0 6px; font-size: 15px; }
label.field + input { font-size: 17px; padding: 12px 14px; }

/* ---------- play screen ---------- */

.progress { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.progress span { width: 34px; height: 6px; border-radius: 99px; background: var(--line); }
.progress span.done { background: var(--ink); }
.progress span.now { background: var(--brand); }
.q-count { text-align: center; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--ink-faint); font-weight: 700; }
.prompt {
  text-align: center; font-size: clamp(26px, 6vw, 36px); line-height: 1.15; font-weight: 800;
  letter-spacing: -0.02em; margin: 10px 0 24px; text-wrap: balance;
}
.hint { text-align: center; margin: 0 0 20px; color: var(--ink-soft); }
.answer-row { display: flex; flex-direction: column; gap: 12px; }
.play-nav { display: flex; justify-content: space-between; margin-top: 14px; }

/* ---------- intro ---------- */

.hero { text-align: center; padding: 26px 22px 30px; }
.hero h1 { font-size: clamp(30px, 7vw, 44px); line-height: 1.05; letter-spacing: -0.03em; margin: 6px 0 12px; }
.hero p { font-size: 18px; color: var(--ink-soft); margin: 0 auto 22px; max-width: 30em; }
.steps { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 12px; text-align: left; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps b.n {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sun); font-weight: 800;
}
.example {
  background: var(--paper); border-radius: var(--radius-sm); padding: 14px; margin: 0 0 22px; text-align: left; font-size: 15px;
}
.example .bars { margin-top: 8px; }

/* ---------- results ---------- */

.score-card { text-align: center; padding: 28px 22px; }
.score-title { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--ink-faint); font-weight: 700; }
.score-big { font-size: clamp(48px, 12vw, 68px); font-weight: 900; letter-spacing: -0.04em; line-height: 1; margin: 8px 0 2px; }
.score-big small { font-size: .38em; color: var(--ink-faint); font-weight: 700; letter-spacing: 0; }
.verdict { font-size: 22px; font-weight: 800; margin: 6px 0 4px; }
.squares { font-size: 26px; letter-spacing: 4px; margin: 10px 0 16px; }
.score-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.provisional {
  margin: 16px auto 0; max-width: 32em; background: var(--you); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; text-align: left;
}
.countdown { margin-top: 14px; color: var(--ink-soft); font-size: 15px; }
.countdown b { font-variant-numeric: tabular-nums; color: var(--ink); }

.round h3 { margin: 0 0 4px; font-size: 19px; letter-spacing: -0.01em; }
.round-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.round-score { flex: none; font-weight: 900; font-size: 18px; padding: 4px 10px; border-radius: 10px; background: var(--paper); }
.round-score.hi { background: var(--match-soft); color: var(--match); }
.round-score.zero { color: var(--ink-faint); }
.your-line { margin: 4px 0 14px; color: var(--ink-soft); font-size: 15px; }
.your-line b { color: var(--ink); }

.bars { display: grid; gap: 6px; }
.bar {
  position: relative; display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-radius: 10px; background: var(--paper); overflow: hidden; font-weight: 700; font-size: 15px;
}
.bar .fill { position: absolute; inset: 0 auto 0 0; background: #efe6d8; border-radius: 10px; }
.bar.you .fill { background: var(--sun); }
.bar.you { outline: 2px solid var(--ink); }
.bar > span { position: relative; }
.bar .count { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-weight: 600; }
.bar .tag { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; background: var(--ink); color: #fff; padding: 2px 6px; border-radius: 6px; margin-left: 6px; }

/* ---------- groups ---------- */

.groups h2, .section-title { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 6px; }
.group { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.group:first-of-type { border-top: 0; margin-top: 8px; padding-top: 0; }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.group-head h3 { margin: 0; font-size: 19px; }
.leaderboard { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 4px; }
.leaderboard li {
  display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 10px; background: var(--paper); font-weight: 600;
}
.leaderboard li.you { background: var(--you); }
.leaderboard .pending { color: var(--ink-faint); font-weight: 500; }
.group-round { margin-top: 12px; }
.group-round h4 { margin: 0 0 6px; font-size: 15px; }
.mates { display: flex; flex-wrap: wrap; gap: 6px; }
.mate { padding: 5px 10px; border-radius: 999px; background: var(--paper); font-size: 14px; border: 1px solid var(--line); }
.mate.match { background: var(--match-soft); border-color: #b8e2cc; color: #1d6e4b; font-weight: 700; }
.mate.you { background: var(--you); border-color: #f0d98a; }
.invite { display: flex; gap: 8px; margin-top: 10px; }
.group { transition: opacity .3s ease, transform .3s ease; }
.group.leaving { opacity: 0; transform: translateX(-12px); }
.events { list-style: none; padding: 0; margin: 4px 0 8px; display: grid; gap: 2px; font-size: 13px; color: var(--ink-faint); }
.events li::before { content: '•'; margin-right: 6px; }
.events li.joined::before, .events li.created::before { color: var(--match); }
.events li.left::before { color: var(--brand); }
.invite input { font-size: 14px !important; padding: 8px 10px !important; }
.join-banner { border: 2px solid var(--ink); }
details.create summary { cursor: pointer; font-weight: 700; }
.form-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- modal ---------- */

dialog {
  border: 0; border-radius: 20px; padding: 0; max-width: 520px; width: calc(100% - 32px);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); color: var(--ink);
}
dialog::backdrop { background: rgba(29, 26, 23, .45); }
dialog .card { box-shadow: none; border: 0; }

/* ---------- footer & static pages ---------- */

.foot { margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; font-size: 14px; color: var(--ink-faint); }
.foot nav { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.foot a { color: var(--ink-soft); }
.prose h1 { font-size: 34px; letter-spacing: -0.02em; margin: 0 0 6px; }
.prose h2 { font-size: 20px; margin: 26px 0 6px; }
.prose p, .prose li { color: #3c3732; }
.todo { background: #fff3cd; border: 1px dashed #d4a72c; padding: 1px 6px; border-radius: 6px; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--anchor-h) + 24px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700;
  z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

.loading { text-align: center; padding: 60px 0; color: var(--ink-faint); }

@media (max-width: 520px) {
  .card { padding: 18px; }
  .top { padding-top: 12px; }
  .logo-word { font-size: 22px; }
  .chip.date { display: none; }
}

/* ---------- legal pages ---------- */
.legal h2 { margin-top: 28px; }
.legal h3 { margin: 22px 0 6px; font-size: 17px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0 6px; }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.legal-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); }
@media (max-width: 620px) {
  .legal-table thead { display: none; }
  .legal-table tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .legal-table td { display: block; border: 0; padding: 3px 0; }
  .legal-table td:nth-child(2)::before { content: "Why: "; font-weight: 600; }
  .legal-table td:nth-child(3)::before { content: "Kept: "; font-weight: 600; }
}
.my-data { background: var(--paper, #fbf6ee); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px 12px; }
.pid-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pid-row code { font-size: 13px; word-break: break-all; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.danger { color: #b3261e; border-color: #e7b4ae; }
.btn.danger:hover { background: #fdf0ee; border-color: #b3261e; }
.btn.danger-solid { background: #b3261e; }
.btn.danger-solid:hover { background: #8f1d17; }

/* ---------- seasonal card (only while a seasonal theme is on) ---------- */
.seasonal-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  border: 2px solid var(--brand); margin-top: 18px;
}
.seasonal-card h2 { margin: 0 0 4px; font-size: 19px; }
.seasonal-card p { margin: 0 0 4px; }
.seasonal-card p.faint { margin: 6px 0 0; }
.seasonal-emoji { font-size: 40px; line-height: 1; }
.seasonal-emoji.big { font-size: 56px; margin-bottom: 6px; }
@media (max-width: 560px) {
  .seasonal-card { grid-template-columns: auto 1fr; }
  .seasonal-card .btn { grid-column: 1 / -1; width: 100%; }
}
