/* Heads Up Picks — styled to feel like iMessage: blue is you, gray is them.
   Follows the phone's light/dark setting automatically. */

:root {
  color-scheme: light dark;

  /* Light (iOS light mode) */
  --bg: #ffffff;
  --card: #f2f2f7;
  --fill: #e5e5ea;          /* buttons, inputs, gray bubbles */
  --fill-strong: #d1d1d6;
  --text: #000000;
  --muted: #6c6c70;
  --line: rgba(60, 60, 67, 0.18);
  --blue: #007aff;          /* you: selections, main buttons, your bubbles */
  --on-blue: #ffffff;
  --theirs: #e9e9eb;        /* their bubbles */
  --on-theirs: #000000;
  --good: #34c759;
  --bad: #ff3b30;
  --gold: #ffcc00;
  --topbar: rgba(255, 255, 255, 0.85);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark (iOS dark mode) */
    --bg: #000000;
    --card: #1c1c1e;
    --fill: #2c2c2e;
    --fill-strong: #3a3a3c;
    --text: #ffffff;
    --muted: #8e8e93;
    --line: rgba(84, 84, 88, 0.6);
    --blue: #0a84ff;
    --theirs: #3a3a3c;
    --on-theirs: #ffffff;
    --good: #30d158;
    --bad: #ff453a;
    --gold: #ffd60a;
    --topbar: rgba(0, 0, 0, 0.8);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue); text-decoration: none; }
main { max-width: 520px; margin: 0 auto; padding: 16px 16px 32px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--topbar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
}
/* Centered like the name at the top of an iMessage conversation */
.brand { justify-self: center; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -0.3px; white-space: nowrap; }
.brand-logo { width: 26px; height: 26px; flex: none; }
.logo-bubble { fill: var(--blue); }
.compose { justify-self: end; display: grid; place-items: center; width: 32px; height: 32px; color: var(--blue); }
.compose svg { width: 24px; height: 24px; }
.compose[hidden] { display: none; }

/* ---------- basics ---------- */

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.h2 { margin: 4px 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.big-emoji { font-size: 44px; line-height: 1; margin-bottom: 6px; }
.section-title { margin: 20px 4px 8px; font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.intro { margin: -2px 4px 12px; }
.error { color: var(--bad); font-weight: 600; margin: 8px 0 0; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--fill); color: var(--muted); }

/* ---------- matchup header (team colors) ---------- */

.hero {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.22)),
    linear-gradient(100deg, var(--team-a, #1c1c1e) 0%, var(--team-a, #1c1c1e) 22%, var(--team-b, #2c2c2e) 78%, var(--team-b, #2c2c2e) 100%);
  color: #fff; padding: 18px; box-shadow: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hero-title { font-weight: 600; font-size: 14px; color: rgba(255, 255, 255, 0.9); }
.hero-pill {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.25); color: #fff; white-space: nowrap; text-shadow: none;
}
.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 18px 0 14px; text-align: center; }
.team-badge {
  width: 52px; height: 52px; margin: 0 auto 8px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  background: rgba(0, 0, 0, 0.22); border: 2px solid rgba(255, 255, 255, 0.5); color: #fff;
}
.team-name { font-weight: 700; font-size: 17px; }
.at { color: rgba(255, 255, 255, 0.7); font-weight: 700; padding: 0 8px; }
.hero-when { text-align: center; font-size: 13px; color: rgba(255, 255, 255, 0.8); }
.hero .matchup { font-size: 20px; font-weight: 700; margin: 12px 0; }

/* ---------- picks form ---------- */

.q { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 0.5px solid var(--line); }
.q:last-of-type { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.q-text { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.q-num {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--fill); color: var(--muted);
}
.opts { display: flex; gap: 8px; }
.opt {
  flex: 1; padding: 12px 8px; border: 0; border-radius: 999px;
  background: var(--fill); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, color 0.15s ease;
}
.opt:active { transform: scale(0.97); }
.opt.on { background: var(--blue); color: var(--on-blue); }
.opt.on::before { content: "\2713  "; }

label.field { display: block; font-weight: 600; margin-bottom: 8px; }
.field-hint { margin: -4px 0 8px; }
input[type=text], input[type=number], input[type=password], input[type=datetime-local], select, textarea {
  width: 100%; padding: 12px 14px; border: 0; border-radius: 12px;
  background: var(--bg); color: var(--text); font: inherit;
  outline: 1px solid var(--line);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); }
input:disabled { opacity: 0.6; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 13px; min-height: 220px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 0; background: var(--fill); color: var(--text);
  border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.chip:active { background: var(--fill-strong); }

.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 14px; line-height: 1.4; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--blue); flex: none; }
.check a { text-decoration: underline; }
.check-error span { color: var(--bad); }

/* Sticky bar with progress + main button */
.submit-bar {
  position: sticky; bottom: 0; margin: 4px -16px 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.progress { height: 5px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--blue); border-radius: 999px; transition: width 0.25s ease; }
.progress-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 8px 0 10px; text-align: center; }

/* ---------- buttons ---------- */

.btn {
  display: block; width: 100%; padding: 15px; border: 0; border-radius: 999px;
  background: var(--blue); color: var(--on-blue);
  font: inherit; font-weight: 600; font-size: 17px; text-align: center; cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.99); opacity: 0.85; }
.btn:disabled { opacity: 0.5; }
.btn.secondary { background: var(--fill); color: var(--blue); margin-top: 8px; }
.btn + .btn { margin-top: 8px; }
.btn.danger { color: var(--bad); }
.small-btn { width: auto; display: inline-block; padding: 8px 16px; font-size: 15px; }
.link-btn { background: none; border: 0; color: var(--blue); font: inherit; font-size: 15px; cursor: pointer; padding: 0; }

/* ---------- challenge screens ---------- */

.challenged { background: var(--blue); color: #fff; }
.challenged .muted { color: rgba(255, 255, 255, 0.85); }
.challenged-kicker { font-size: 13px; font-weight: 600; opacity: 0.85; }
.challenged-name { font-size: 22px; font-weight: 700; margin: 4px 0 12px; letter-spacing: -0.4px; }
.challenged-stakes {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.18); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
}
.challenged-stakes span { font-size: 13px; font-weight: 600; opacity: 0.85; }
.challenged-stakes strong { font-size: 18px; text-align: right; overflow-wrap: anywhere; }

.stakes-card { text-align: center; }
.stakes-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stakes-value { font-size: 22px; font-weight: 700; margin: 4px 0; overflow-wrap: anywhere; }
.stakes-note { font-size: 12px; color: var(--muted); }

.share-link { display: flex; gap: 8px; margin: 12px 0; }
.share-link input { flex: 1; font-size: 14px; }

.handshake.pop .big-emoji { animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { 0% { transform: scale(0.3) rotate(-20deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.vs-line { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 18px; margin: 6px 0 8px; }
.vs-line span { color: var(--muted); font-weight: 600; font-size: 14px; }
.countdown-big { display: inline-block; margin-top: 4px; padding: 8px 14px; border-radius: 999px; background: var(--fill); font-weight: 600; }

.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 0.5px solid var(--line); font-size: 15px; }
.sum-row:first-child { border-top: 0; padding-top: 0; }
.sum-row:last-child { padding-bottom: 0; }
.sum-row strong { text-align: right; }

.preview-bar {
  position: sticky; top: 58px; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 12px; padding: 10px 14px; border-radius: 14px;
  background: var(--gold); color: #000; font-size: 13px; font-weight: 600;
}
.preview-bar a { color: #000; text-decoration: underline; }

/* ---------- lists (your challenges, admin games) ---------- */

.list { padding: 4px 16px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; color: var(--text); border-top: 0.5px solid var(--line); }
.list-row:first-child { border-top: 0; }
.row-sub { display: block; margin-top: 2px; }
.row-end { display: flex; align-items: center; flex: none; }
.mini-score { font-weight: 700; margin-right: 8px; }

.status { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--fill); color: var(--muted); white-space: nowrap; }
.status-open { color: var(--text); }
.status-accepted, .status-final { background: var(--blue); color: #fff; }
.status-live { color: var(--bad); }
.status-live::before { content: "● "; }

.game-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.game-chip { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 16px; background: var(--card); color: var(--text); font-size: 14px; }
.game-chip span { color: var(--muted); font-size: 12px; }
.game-chip.on { outline: 2px solid var(--blue); }

/* ---------- scoreboard: you in blue, them in gray ---------- */

.scoreboard { padding-bottom: 6px; }
.sb-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; gap: 8px; padding-bottom: 14px; }
.sb-name { font-weight: 600; overflow-wrap: anywhere; }
.sb-score { font-size: 42px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.sb-player.mine .sb-score { color: var(--blue); }
.sb-player.theirs .sb-score { color: var(--muted); }
.sb-player.won .sb-name::after { content: " 🏆"; }
.sb-mid { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.you { font-size: 11px; font-weight: 600; color: var(--blue); }

.sb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 0; border-top: 0.5px solid var(--line); }
.sb-q { grid-column: 1 / -1; font-size: 13px; color: var(--muted); font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.answer { margin-left: auto; font-size: 12px; color: var(--text); background: var(--fill); padding: 2px 8px; border-radius: 999px; }

/* Picks look like message bubbles */
.pick { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 12px; font-weight: 600; font-size: 15px; text-align: center; overflow-wrap: anywhere; }
.pick.mine { background: var(--blue); color: var(--on-blue); border-radius: 18px 18px 4px 18px; }
.pick.theirs { background: var(--theirs); color: var(--on-theirs); border-radius: 18px 18px 18px 4px; }
.pick-icon { font-size: 13px; }
.pick.miss { opacity: 0.4; }
.pick.miss .pick-icon { color: inherit; }
.pick.void { opacity: 0.5; }
.pick.neutral { font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.5; display: inline-block; }

.verdict .owes { font-size: 17px; margin-top: 6px; overflow-wrap: anywhere; }

.live-note { margin: 4px 0 0; display: flex; align-items: center; justify-content: center; gap: 6px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- admin ---------- */

.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 4px 8px; }
.admin-head .h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.admin-q { padding: 12px 0; border-top: 0.5px solid var(--line); }
.admin-q:first-child { border-top: 0; }
.admin-q input + input { margin-top: 8px; }

/* ---------- legal pages + footer ---------- */

.legal { line-height: 1.6; font-size: 15px; }
.legal h2 { font-size: 24px; letter-spacing: -0.4px; margin: 0 0 4px; }
.legal h3 { font-size: 17px; margin: 22px 0 6px; }
.legal ul { padding-left: 20px; margin: 6px 0; }
.legal .updated { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.site-footer { max-width: 520px; margin: 0 auto; padding: 8px 20px 40px; font-size: 12px; line-height: 1.5; color: var(--muted); text-align: center; }
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: var(--muted); text-decoration: underline; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
}
