/* TESSERAE — shared styles */
:root {
  --bg: #121010;
  --bg-grad: radial-gradient(1200px 600px at 50% -200px, #3a1d10 0%, rgba(18,16,16,0) 70%);
  --surface: #1c1917;
  --surface-2: #26211e;
  --surface-3: #312a25;
  --ink: #f3ebde;
  --muted: #b8ac9c;
  --faint: #8a7f72;
  --line: #3b332d;
  --ember: #ff7a3d;
  --ember-ink: #ff9a66;
  --ember-soft: rgba(255,122,61,.14);
  --gold: #e3b552;
  --seam: #ff7a3d;
  --merchant: #7fb2e5;
  --good: #5fc48a;
  --bad: #ff6b6b;
  --paper: #efe4cf;
  --paper-ink: #2a2118;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --radius: 14px;
  --font-head: "Oswald", "Arial Narrow", Impact, sans-serif;
  --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-type: "Special Elite", "Courier New", monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3ecdf;
  --bg-grad: radial-gradient(1200px 600px at 50% -200px, #f7d9bf 0%, rgba(243,236,223,0) 70%);
  --surface: #fffaf2;
  --surface-2: #efe5d4;
  --surface-3: #e4d6c0;
  --ink: #1f1813;
  --muted: #5c4f43;
  --faint: #7a6c5e;
  --line: #d6c7b0;
  --ember: #b9461b;
  --ember-ink: #a33b13;
  --ember-soft: rgba(185,70,27,.12);
  --gold: #8a6512;
  --seam: #c4521f;
  --merchant: #2f6ea8;
  --good: #23824d;
  --bad: #c0322f;
  --paper: #fbf3e3;
  --paper-ink: #2a2118;
  --shadow: 0 10px 26px rgba(70,45,20,.16);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-grad), var(--bg);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--ember-ink); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.15; letter-spacing: .01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 7vw, 3.6rem); text-transform: uppercase; }
h2 { font-size: clamp(1.5rem, 4.5vw, 2.1rem); text-transform: uppercase; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
small, .small { font-size: .88rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.center { text-align: center; }
.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; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: #000; padding: .5em 1em; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-wrap { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: .5rem; padding: .55rem 1rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--font-head); font-weight: 700; letter-spacing: .12em; color: var(--ink); text-decoration: none; font-size: 1.15rem; margin-right: auto; }
.brand svg { width: 28px; height: 28px; }
.nav-links { display: flex; gap: .15rem; list-style: none; margin: 0; padding: 0; }
.nav-links a { display: block; padding: .4rem .6rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-family: var(--font-head); font-size: .95rem; letter-spacing: .04em; text-transform: uppercase; }
.nav-links a:hover { color: var(--ink); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--ember-ink); background: var(--ember-soft); }
.icon-btn { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; display: inline-grid; place-items: center; cursor: pointer; font-size: 1.1rem; flex: none; }
.icon-btn:hover { border-color: var(--ember); }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: inline-grid; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--line); padding: .5rem; box-shadow: var(--shadow); }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .75rem 1rem; font-size: 1.05rem; }
}

/* ---------- layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
section { margin: 2.5rem 0; }
.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-3 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { margin-top: 0; }
.kicker { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .2em; font-size: .8rem; color: var(--ember-ink); margin-bottom: .4rem; display: block; }

.hero { text-align: center; padding: 1.5rem 0 .5rem; }
.hero p.lede { font-size: clamp(1.05rem, 2.6vw, 1.25rem); color: var(--muted); max-width: 640px; margin: 0 auto 1rem; }
.hero .badge { display: inline-block; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: .2rem .8rem; font-size: .82rem; color: var(--muted); margin-bottom: 1rem; font-family: var(--font-head); letter-spacing: .1em; text-transform: uppercase; }

/* ---------- buttons ---------- */
.btn { --b: var(--ember); display: inline-flex; align-items: center; justify-content: center; gap: .5rem; font-family: var(--font-head); text-transform: uppercase; letter-spacing: .08em; font-size: 1rem; font-weight: 600; padding: .75rem 1.25rem; border-radius: 10px; border: 2px solid var(--b); background: var(--b); color: #1a0d05; cursor: pointer; text-decoration: none; transition: transform .12s ease, filter .12s ease, background .12s; min-height: 46px; }
:root[data-theme="light"] .btn { color: #fff; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ember); }
.btn.gold { --b: var(--gold); }
.btn.small { padding: .45rem .8rem; font-size: .85rem; min-height: 36px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; filter: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.btn-row.center { justify-content: center; }

/* ---------- forms ---------- */
label { font-family: var(--font-head); letter-spacing: .05em; text-transform: uppercase; font-size: .85rem; color: var(--muted); display: block; margin-bottom: .3rem; }
.label-like { font-family: var(--font-head); letter-spacing: .05em; text-transform: uppercase; font-size: .85rem; color: var(--muted); display: block; margin-bottom: .3rem; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem; min-height: 44px;
}
input[type="text"]:focus, select:focus, textarea:focus { border-color: var(--ember); outline: none; box-shadow: 0 0 0 3px var(--ember-soft); }
input[type="range"] { width: 100%; accent-color: var(--ember); height: 32px; }
.field { margin-bottom: 1rem; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.field-row output { font-family: var(--font-head); font-size: 1.1rem; color: var(--ink); }
.seg { display: flex; flex-wrap: wrap; gap: .35rem; }
.seg button { flex: 1 1 auto; font-family: var(--font-head); font-size: .95rem; letter-spacing: .04em; padding: .5rem .6rem; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; min-height: 42px; }
.seg button[aria-pressed="true"] { background: var(--ember); color: #1a0d05; border-color: var(--ember); }
:root[data-theme="light"] .seg button[aria-pressed="true"] { color: #fff; }
.switch { display: flex; align-items: center; gap: .6rem; cursor: pointer; text-transform: none; font-family: var(--font-body); font-size: 1rem; color: var(--ink); letter-spacing: 0; }
.switch input { width: 22px; height: 22px; accent-color: var(--ember); }

/* ---------- stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: .8rem .9rem; }
.stat .v { font-family: var(--font-head); font-size: 2rem; line-height: 1.05; color: var(--ink); display: block; }
.stat .k { font-size: .82rem; color: var(--muted); font-family: var(--font-head); text-transform: uppercase; letter-spacing: .06em; }
.stat.hot .v { color: var(--ember-ink); }

/* ---------- slips ---------- */
.slip {
  font-family: var(--font-type); background: var(--paper); color: var(--paper-ink);
  padding: 1rem 1.25rem; border-radius: 3px; box-shadow: 0 6px 18px rgba(0,0,0,.35);
  position: relative; display: inline-block; min-width: 220px; text-align: center; font-size: 1.35rem;
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.035) 0 1px, transparent 1px 26px);
}
.slip::before, .slip::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: rgba(0,0,0,.12); top: 50%; }
.slip small { display: block; font-size: .8rem; opacity: .7; }

/* ---------- reaping card ---------- */
.reap-card { background: linear-gradient(160deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); border-radius: 18px; padding: 1.25rem; position: relative; overflow: hidden; }
.reap-card::after { content: ""; position: absolute; inset: auto -40px -40px auto; width: 160px; height: 160px; border-radius: 50%; background: var(--ember-soft); filter: blur(10px); }
.big-odds { font-family: var(--font-head); font-size: clamp(2.6rem, 11vw, 4.4rem); line-height: 1; color: var(--ember-ink); }
.slips-count { font-family: var(--font-head); font-size: 1.2rem; }

.compare { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.compare li { display: grid; grid-template-columns: 6.5rem 1fr 3.2rem; align-items: center; gap: .5rem; font-size: .95rem; }
.compare .bar { height: 12px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.compare .bar i { display: block; height: 100%; background: var(--faint); border-radius: 6px; transition: width .5s ease; }
.compare li.you .bar i { background: var(--ember); }
.compare li.you { font-weight: 700; }
.compare .n { text-align: right; font-family: var(--font-head); }

.dot-bowl-wrap { position: relative; }
#dotBowl { width: 100%; aspect-ratio: 1 / 1; display: block; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.08), rgba(255,255,255,0) 50%), var(--surface-2); border: 2px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .9rem; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .35rem; background: var(--c); vertical-align: middle; }

/* ---------- draw stage / overlay ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5,3,2,.82); display: grid; place-items: center; z-index: 200; padding: 1rem; }
.overlay .stage { text-align: center; max-width: 520px; width: 100%; }
.overlay .announce { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .25em; color: #e9d9c2; margin-bottom: 1rem; }
.unfold { animation: unfold .9s cubic-bezier(.2,.8,.2,1) both; transform-origin: top center; }
@keyframes unfold { 0% { transform: perspective(600px) rotateX(-88deg) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120%); background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 10px; font-family: var(--font-head); letter-spacing: .04em; z-index: 300; transition: transform .25s ease; max-width: 92vw; text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 2rem 1rem; color: var(--muted); font-size: .9rem; text-align: center; }
.site-footer p { max-width: 760px; margin: .4rem auto; }

/* ---------- misc ---------- */
.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-3); font-size: .8rem; font-family: var(--font-head); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pill.hot { background: var(--ember-soft); color: var(--ember-ink); }
.divider { height: 1px; background: var(--line); margin: 1.5rem 0; border: 0; }
.callout { border-left: 4px solid var(--ember); background: var(--surface-2); padding: .9rem 1rem; border-radius: 0 10px 10px 0; }
.tile-links { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.tile-link { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; transition: transform .15s ease, border-color .15s; }
.tile-link:hover { transform: translateY(-3px); border-color: var(--ember); }
.tile-link .ico { font-size: 1.8rem; display: block; margin-bottom: .35rem; }
.tile-link strong { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .05em; font-size: 1.15rem; display: block; }
.tile-link span.d { color: var(--muted); font-size: .95rem; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
th { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .05em; font-size: .82rem; color: var(--muted); }

.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .85rem; padding: .35rem .55rem; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -115%); opacity: 0; transition: opacity .1s; font-family: var(--font-body); z-index: 5; }
.chart-tip.show { opacity: 1; }

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