/* FairSpin — mobile-first styles. System font stack, no webfonts. */
:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --ink: #1d1b16;
  --muted: #6b655a;
  --brand: #2a9d8f;
  --brand-dark: #1f7a6f;
  --accent: #e9c46a;
  --danger: #c0392b;
  --border: #e2ddd1;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(29, 27, 22, 0.08);
  --focus: #1a73e8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}
a { color: var(--brand-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff;
  padding: 0.6rem 1rem; z-index: 200; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; color: #fff; }

.site-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.site-header .wrap {
  display: flex; align-items: center; gap: 1rem;
  max-width: 1100px; margin: 0 auto; padding: 0.6rem 1rem;
}
.brand { font-weight: 800; font-size: 1.25rem; text-decoration: none; color: var(--ink); }
.brand .dot { color: var(--brand); }
.site-nav { margin-left: auto; display: flex; gap: 0.25rem; flex-wrap: wrap; }
.site-nav a {
  text-decoration: none; color: var(--muted); padding: 0.4rem 0.6rem; border-radius: 8px;
  font-size: 0.95rem;
}
.site-nav a:hover { background: var(--bg); color: var(--ink); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.prose { max-width: 720px; }
.prose h1 { font-size: 1.9rem; line-height: 1.2; margin: 1.2rem 0 0.6rem; }
.prose h2 { font-size: 1.35rem; margin: 1.8rem 0 0.5rem; }
.prose p, .prose li { color: #33302a; }

/* ---------- app layout ---------- */
.app { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .app { grid-template-columns: 380px 1fr; align-items: start; }
  .stage { order: 2; } .editor-panel { order: 1; }
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem;
}
.card h2 { margin: 0 0 0.6rem; font-size: 1.1rem; }

.stage { text-align: center; position: relative; }
.wheel-wrap { position: relative; display: inline-block; max-width: 100%; }
canvas.wheel { width: min(92vw, 520px); max-width: 100%; height: auto; display: block; }
canvas.fx {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
}
.pointer {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 14px solid transparent; border-right: 14px solid transparent;
  border-top: 22px solid var(--danger);
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
}
.winner-banner {
  min-height: 2.2rem; font-size: 1.3rem; font-weight: 700; margin: 0.5rem 0;
}

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); border-radius: 10px; padding: 0.6rem 1rem; font-size: 1rem;
  cursor: pointer; line-height: 1.2;
}
.btn:hover { background: #f0ece1; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--brand); border-color: var(--brand-dark); color: #fff;
  font-size: 1.25rem; font-weight: 700; padding: 0.8rem 2.2rem;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #e5b8b1; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; margin: 0.6rem 0; }

textarea.entries {
  width: 100%; min-height: 180px; resize: vertical;
  font: 1rem/1.5 inherit; padding: 0.6rem; border: 1px solid var(--border);
  border-radius: 8px; background: #fffdf8;
}
.entry-meta { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin: 0.4rem 0; font-size: 0.9rem; color: var(--muted); flex-wrap: wrap; }
.entry-meta > span { display: contents; }
.app > * { min-width: 0; }
.odds-list { max-height: 220px; overflow: auto; margin: 0.5rem 0; padding: 0; list-style: none; font-size: 0.9rem; }
.odds-list li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.2rem 0; border-bottom: 1px dashed var(--border); }
.odds-list .pct { font-variant-numeric: tabular-nums; color: var(--muted); }
.note { font-size: 0.85rem; color: #8a6d1a; background: #fdf3d8; border: 1px solid #f0dfae; border-radius: 8px; padding: 0.4rem 0.6rem; margin: 0.4rem 0; }
.note:empty { display: none; }

label.inline { display: flex; align-items: center; gap: 0.45rem; font-size: 0.95rem; margin: 0.35rem 0; cursor: pointer; }
input[type="number"].small { width: 4.5rem; padding: 0.3rem 0.4rem; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }

.history { list-style: none; margin: 0.5rem 0; padding: 0; max-height: 220px; overflow: auto; font-size: 0.9rem; }
.history li { padding: 0.3rem 0; border-bottom: 1px dashed var(--border); display: flex; gap: 0.5rem; justify-content: space-between; }
.history .seed { color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.8rem; }
.tally { font-size: 0.85rem; color: var(--muted); }

.elim-tray { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }
.elim-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; background: #f3efe4;
  border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem 0.35rem 0.25rem 0.7rem;
  font-size: 0.85rem;
}
.elim-chip button { border: none; background: var(--brand); color: #fff; border-radius: 999px; padding: 0.2rem 0.6rem; cursor: pointer; font-size: 0.8rem; }

/* ---------- templates gallery ---------- */
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem; margin-top: 0.6rem; }
.template-btn {
  border: 1px solid var(--border); background: #fffdf8; border-radius: 10px;
  padding: 0.7rem 0.5rem; cursor: pointer; font-size: 0.9rem; text-align: center;
}
.template-btn:hover { border-color: var(--brand); }
.template-btn .emoji { font-size: 1.5rem; display: block; }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 18, 14, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 14px; padding: 1.4rem;
  max-width: 440px; width: 100%; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal h2 { margin-top: 0; }
.modal .winner-name { font-size: 1.8rem; font-weight: 800; margin: 0.6rem 0; overflow-wrap: anywhere; }
.modal .fairness-line { font-size: 0.8rem; color: var(--muted); font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.qr-canvas { image-rendering: pixelated; border: 8px solid #fff; box-shadow: var(--shadow); max-width: 100%; }
.share-link-box { display: flex; gap: 0.4rem; margin: 0.6rem 0; }
.share-link-box input { flex: 1; min-width: 0; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem; }

/* ---------- present mode ---------- */
body.present .site-header, body.present .site-footer,
body.present .editor-panel, body.present .side-panels, body.present .templates-card,
body.present .page-intro { display: none; }
body.present .app { grid-template-columns: 1fr; max-width: 900px; margin: 0 auto; }
body.present .wrap { max-width: 100%; }
.exit-present { position: fixed; bottom: 1rem; right: 1rem; z-index: 60; opacity: 0.7; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 2rem; background: var(--surface); }
.site-footer .wrap { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; font-size: 0.9rem; color: var(--muted); padding-top: 1.2rem; padding-bottom: 1.2rem; }
.site-footer nav { display: flex; gap: 1rem; flex-wrap: wrap; }

.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem 1rem; margin: 0.6rem 0; }
.faq summary { cursor: pointer; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---- competitor-killer pack: verify page, small buttons, forms ---- */
.btn-small { font-size: 0.75rem; padding: 0.2rem 0.55rem; border-radius: 6px; }
.form-row { margin: 0.8rem 0; }
.form-row > label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.form-row input[type="text"], .form-row input[type="number"], .form-row textarea {
  width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; box-sizing: border-box; font-family: inherit; background: #fff; color: var(--ink);
}
.form-row .hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; font-size: 0.85rem; }
.verify-result { margin-top: 1rem; }
.verify-result ol { padding-left: 1.3rem; }
.verify-result li { margin: 0.5rem 0; }
.verify-winner { font-size: 1.8rem; font-weight: 800; margin: 0.6rem 0; overflow-wrap: anywhere; }
.match-ok { color: #1a7a3a; font-weight: 700; }
.match-bad { color: #b3261e; font-weight: 700; }
