/* Elbowroom — a late-night train. You pick your seats at night; the train arrives at dawn. */
:root {
  --ink: #0a0d16;
  --ink-2: #0f1320;
  --panel: #131828;
  --panel-2: #192036;
  --line: #232b42;
  --line-2: #2e3854;
  --text: #eceff5;
  --text-2: #a3abc0;
  --text-3: #6b7490;
  --lamp: #ffc35a;          /* window light: the one accent */
  --lamp-ink: #2a1c02;
  --shared: #8fb3ff;
  --shared-bg: #1a2747;
  --crowded: #ff7a66;
  --crowded-bg: #3a1a1e;
  --r: 14px;
  --font: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(.22, .9, .3, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --bar-h: 0px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--ink); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--ink); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.45; letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11";
  display: flex; flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 520px; margin: 0 auto; padding: 0 20px calc(var(--bar-h) + 40px); }
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.035em; line-height: 1.02; font-weight: 600; }
p { margin: 0; }
svg { display: block; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 6px; }

.eyebrow { font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
.accent { color: var(--lamp); }

/* ---------- top bar ---------- */
.top { width: 100%; max-width: 520px; margin: 0 auto; padding: 18px 20px 8px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 650; font-size: 20px; letter-spacing: -0.045em; }
.brand-mark { width: 22px; height: 22px; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.ib {
  appearance: none; border: 0; background: transparent; cursor: pointer; color: var(--text-2);
  height: 38px; min-width: 38px; padding: 0 9px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--mono); font-size: 13px; font-weight: 500; transition: background .15s, color .15s;
}
.ib:hover { background: var(--panel); color: var(--text); }
.ib svg { width: 19px; height: 19px; }
.ib.on { color: var(--lamp); }

/* ---------- scene ---------- */
.scene { position: relative; margin: 6px -20px 0; height: 210px; overflow: hidden; }
.scene svg { width: 100%; height: 100%; }
.scene::after { content: ""; position: absolute; inset: auto 0 0 0; height: 60px; background: linear-gradient(transparent, var(--ink)); pointer-events: none; }
.drift { animation: drift 60s linear infinite; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(-400px); } }
.ties { animation: ties .5s linear infinite; }
@keyframes ties { to { stroke-dashoffset: -24; } }
.bob { animation: bob 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes bob { 50% { transform: translateY(0.8px); } }
.win { transition: fill .6s var(--ease); }
.rider { opacity: 0; transform: translateY(6px); transition: opacity .5s var(--ease), transform .5s var(--spring); }
.lit .rider { opacity: 1; transform: none; }
.twinkle { animation: twinkle 3.5s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .25; } }

/* ---------- headline block ---------- */
.head { margin-top: -18px; position: relative; z-index: 1; }
.head h1 { font-size: clamp(36px, 10.4vw, 48px); margin-top: 10px; }
.head h1 .accent { color: var(--lamp); }
.head .sub { margin-top: 10px; font-size: 16.5px; color: var(--text-2); max-width: 34ch; }

/* ---------- segmented control ---------- */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; margin: 22px 0 18px; }
.seg button {
  flex: 1; appearance: none; border: 0; background: transparent; cursor: pointer; padding: 9px 10px; border-radius: 999px;
  font-size: 14.5px; font-weight: 550; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .2s var(--ease), color .2s;
}
.seg button[aria-selected="true"] { background: var(--lamp); color: var(--lamp-ink); }
.seg .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--lamp); }
.seg button[aria-selected="true"] .dot { background: var(--lamp-ink); }

/* ---------- buttons ---------- */
.btn {
  appearance: none; cursor: pointer; border: 0; border-radius: 999px; padding: 15px 22px;
  background: var(--lamp); color: var(--lamp-ink); font-weight: 600; font-size: 16px; letter-spacing: -0.015em;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: transform .12s var(--ease), opacity .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { background: var(--panel-2); color: var(--text-3); cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.ghost:hover { background: var(--panel); }
.btn.wide { width: 100%; }
.btn.sm { padding: 10px 16px; font-size: 14.5px; }
.btn svg { width: 18px; height: 18px; }
.textbtn { appearance: none; border: 0; background: none; cursor: pointer; color: var(--text-2); font-size: 14.5px; padding: 6px 0; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; }
.textbtn:hover { color: var(--text); }

input[type="text"] {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--ink-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; transition: border-color .15s;
}
input[type="text"]::placeholder { color: var(--text-3); }
input[type="text"]:focus { outline: none; border-color: var(--lamp); }

/* ---------- surfaces ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin: 14px 0; }
.panel.lamp { border-color: rgba(255, 195, 90, .45); background: linear-gradient(180deg, rgba(255,195,90,.07), transparent 70%), var(--panel); }
.panel h3 { font-size: 20px; letter-spacing: -0.03em; }
.panel .sub { margin-top: 6px; color: var(--text-2); font-size: 15px; }
.rule { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- board ---------- */
.board-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.board-head h2 { font-size: 28px; }
.board-head .meta { text-align: right; font-family: var(--mono); font-size: 12.5px; color: var(--text-3); line-height: 1.5; white-space: nowrap; }
.board-head .meta b { color: var(--text); font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.dense { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.tile {
  position: relative; appearance: none; cursor: pointer; user-select: none;
  min-height: 60px; padding: 10px 6px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-size: 15px; font-weight: 550; letter-spacing: -0.02em; line-height: 1.1; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  overflow-wrap: break-word; hyphens: auto;
  transition: background .18s var(--ease), border-color .18s, color .18s, transform .12s var(--ease);
}
.grid.c4 .tile { font-size: 14px; }
.grid.dense .tile { min-height: 52px; font-size: 13px; border-radius: 10px; }
.tile.long { font-size: 12.5px; }
.tile:hover { border-color: var(--line-2); }
.tile:active { transform: scale(.96); }
.tile.picked { background: var(--lamp); border-color: var(--lamp); color: var(--lamp-ink); }
.tile.picked::before {
  content: attr(data-n); position: absolute; top: 6px; left: 7px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; opacity: .55;
}
.tile.pop { animation: pop .28s var(--spring); }
@keyframes pop { 0% { transform: scale(.94); } 60% { transform: scale(1.04); } 100% { transform: none; } }
.tile.nope { animation: nope .3s ease; }
@keyframes nope { 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
.tile.hide { display: none; }

.tile.r-open { background: transparent; border-style: dashed; color: var(--text-3); font-weight: 450; cursor: default; }
.tile.r-solo { background: var(--lamp); border-color: var(--lamp); color: var(--lamp-ink); cursor: default; }
.tile.r-shared { background: var(--shared-bg); border-color: rgba(143,179,255,.5); color: var(--shared); cursor: default; }
.tile.r-crowded { background: var(--crowded-bg); border-color: rgba(255,122,102,.5); color: var(--crowded); cursor: default; }
.tile.mine { box-shadow: 0 0 0 2px var(--ink), 0 0 0 3.5px var(--text); }
.tile .who { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0; opacity: .8; line-height: 1.25; }
.tile.in { animation: tin .45s var(--ease) both; }
@keyframes tin { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.filter { margin-bottom: 10px; }

.key { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0 12px; font-size: 13px; color: var(--text-2); }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.k-solo { background: var(--lamp); } .k-shared { background: var(--shared); } .k-crowded { background: var(--crowded); }

/* ---------- riders (who's in) ---------- */
.riders { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 14px; color: var(--text-2); }
.faces { display: flex; }
.face { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 650; color: var(--ink); border: 2px solid var(--ink); margin-left: -7px; flex: none; }
.faces .face:first-child { margin-left: 0; }
.face.new { animation: pop .45s var(--spring); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 0 0 rgba(255,195,90,.5); animation: ping 2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(255,195,90,0); } 100% { box-shadow: 0 0 0 0 rgba(255,195,90,0); } }

/* ---------- bottom bar ---------- */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--ink) 30%); }
.bar-in { max-width: 488px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; background: rgba(19, 24, 40, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 16px 40px rgba(0,0,0,.45); }
.seats { flex: 1; display: flex; gap: 6px; min-width: 0; }
.seat { flex: 1; min-width: 0; height: 36px; border-radius: 999px; border: 1px dashed var(--line-2); display: grid; place-items: center; padding: 0 10px; font-size: 13px; font-weight: 550; color: var(--text-3); overflow: hidden; }
.seat span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.seat.full { border: 0; background: var(--panel-2); color: var(--text); }
.seat.full.in { animation: pop .3s var(--spring); }
.bar .btn { padding: 11px 20px; flex: none; }
.sealed-line { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.sealed-line svg { width: 18px; height: 18px; color: var(--lamp); flex: none; }
.sealed-line b { display: block; font-size: 14.5px; font-weight: 600; }
.sealed-line small { font-family: var(--mono); font-size: 12px; color: var(--text-3); }

/* ---------- results ---------- */
.score { font-size: clamp(64px, 19vw, 92px); font-weight: 600; letter-spacing: -0.06em; line-height: .9; }
.score .of { color: var(--text-3); }
.score-sub { margin-top: 10px; font-size: 17px; color: var(--text-2); }
.badge { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; padding: 6px 12px 6px 10px; border-radius: 999px; border: 1px solid rgba(255,195,90,.4); color: var(--lamp); font-size: 13.5px; font-weight: 550; }
.badge svg { width: 14px; height: 14px; }
.picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.pick { border-radius: 12px; padding: 12px 10px; border: 1px solid var(--line); }
.pick b { display: block; font-size: 14.5px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.pick small { display: block; margin-top: 4px; font-size: 12px; opacity: .85; }
.pick.solo { background: var(--lamp); border-color: var(--lamp); color: var(--lamp-ink); }
.pick.shared { background: var(--shared-bg); border-color: rgba(143,179,255,.5); color: var(--shared); }
.pick.crowded { background: var(--crowded-bg); border-color: rgba(255,122,102,.5); color: var(--crowded); }
.notes { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 0; }
.notes li { padding: 13px 0; border-top: 1px solid var(--line); font-size: 15px; color: var(--text-2); }
.notes li b { color: var(--text); font-weight: 600; }
.notes li:first-child { border-top: 0; }
.table { list-style: none; padding: 0; margin: 0; }
.table li { display: grid; grid-template-columns: 22px 26px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.table li:first-child { border-top: 0; }
.table .pos { font-family: var(--mono); font-size: 13px; color: var(--text-3); }
.table li.top .pos { color: var(--lamp); }
.table .nm { font-weight: 550; letter-spacing: -0.015em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .nm small { display: block; font-family: var(--mono); font-size: 11px; color: var(--lamp); font-weight: 500; }
.dots { display: flex; gap: 4px; }
.dots i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.dots .solo { background: var(--lamp); } .dots .shared { background: var(--shared); } .dots .crowded { background: var(--crowded); }
.table .pts { font-family: var(--mono); font-size: 14px; font-weight: 500; }
.section-title { margin: 28px 0 10px; }

/* ---------- ceremony ---------- */
.dawn {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto; display: flex; flex-direction: column; align-items: center;
  background: var(--ink); text-align: center; padding: 0 20px calc(28px + env(safe-area-inset-bottom));
}
.dawn .scene { width: calc(100% + 40px); max-width: 560px; margin: 0 -20px; height: 230px; }
.dawn .x { position: absolute; top: 14px; right: 14px; z-index: 2; }
.dawn h2 { font-size: clamp(34px, 9.6vw, 44px); margin-top: 4px; }
.dawn .eyebrow { margin-top: 2px; position: relative; z-index: 2; }
.dawn .scene::after { height: 36px; }
.dawn .beat { margin-top: 10px; min-height: 22px; color: var(--text-2); font-size: 15px; }
.cards { display: flex; gap: 10px; justify-content: center; margin: 26px 0 8px; perspective: 1000px; width: 100%; max-width: 420px; }
.card { flex: 1; aspect-ratio: 3 / 4; position: relative; transform-style: preserve-3d; transition: transform .6s var(--ease); }
.card.flipped { transform: rotateY(180deg); }
.card .f { position: absolute; inset: 0; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; }
.card .back { background: var(--panel); border: 1px solid var(--line-2); color: var(--text-2); }
.card .back svg { width: 22px; height: 22px; color: var(--lamp); }
.card .back span { font-size: 14px; font-weight: 550; color: var(--text); }
.card .front { transform: rotateY(180deg); border: 1px solid var(--line); }
.card .front b { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.card .front small { font-size: 12px; }
.card .front.solo { background: var(--lamp); color: var(--lamp-ink); border-color: var(--lamp); box-shadow: 0 0 40px rgba(255,195,90,.35); }
.card .front.shared { background: var(--shared-bg); color: var(--shared); border-color: rgba(143,179,255,.5); }
.card .front.crowded { background: var(--crowded-bg); color: var(--crowded); border-color: rgba(255,122,102,.5); }
.card.shake { animation: shake .35s ease; }
@keyframes shake { 25% { translate: -5px 0; } 50% { translate: 5px 0; } 75% { translate: -3px 0; } }
.verdict { min-height: 130px; margin-top: 18px; }
.verdict.show { animation: rise .55s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.dawn-actions { width: 100%; max-width: 360px; display: grid; gap: 10px; margin-top: 8px; }

/* ---------- landing ---------- */
.hero .scene { height: 250px; }
.hero h1 { font-size: clamp(44px, 13vw, 62px); letter-spacing: -0.055em; }
.landing-ctas { display: grid; gap: 10px; margin-top: 26px; }
.live-count { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 14px; font-size: 13.5px; color: var(--text-3); }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--text-2); font-size: 15px; }
.steps li:first-child { border-top: 0; }
.steps li::before { content: counter(s, decimal-leading-zero); font-family: var(--mono); font-size: 12px; color: var(--lamp); padding-top: 2px; }
.steps b { color: var(--text); font-weight: 600; }
.myboards a { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--line); text-decoration: none; font-weight: 550; }
.myboards a:first-of-type { border-top: 0; }
.myboards a span:last-child { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); }
.err { color: var(--crowded); font-size: 14px; }

/* ---------- dialogs, toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 22px; background: var(--panel); color: var(--text);
  width: calc(100% - 28px); max-width: 420px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(5, 7, 13, .72); backdrop-filter: blur(4px); }
dialog[open] { animation: rise .35s var(--ease); }
dialog h2 { font-size: 26px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 18px 0; border: 1px solid var(--line); border-radius: 14px; }
.stats div { padding: 14px 6px; text-align: center; border-left: 1px solid var(--line); }
.stats div:first-child { border-left: 0; }
.stats b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -0.04em; }
.stats span { font-size: 11.5px; color: var(--text-3); }
.dist { display: grid; gap: 7px; }
.dist div { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.dist span.b { height: 22px; border-radius: 6px; background: var(--panel-2); display: flex; align-items: center; justify-content: flex-end; padding: 0 8px; color: var(--text); min-width: 28px; }
.dist span.b.hl { background: var(--lamp); color: var(--lamp-ink); }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle:first-child { border-top: 0; }
.toggle input { width: 20px; height: 20px; accent-color: var(--lamp); }

#toast {
  position: fixed; left: 50%; top: 16px; z-index: 90; transform: translate(-50%, -24px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--ink); padding: 10px 16px; border-radius: 999px; font-size: 14.5px; font-weight: 600;
  transition: opacity .2s, transform .3s var(--spring); box-shadow: 0 12px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; }

.foot { width: 100%; max-width: 520px; margin: 0 auto; padding: 10px 20px 28px; display: flex; justify-content: space-between; font-size: 13px; color: var(--text-3); }
.foot a { color: var(--text-3); text-decoration: none; }
.loading { margin: 120px 0; text-align: center; font-family: var(--mono); font-size: 13px; color: var(--text-3); }

@media (min-width: 480px) { .grid:not(.c4):not(.dense) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* live percentages after locking in */
.live-list { display: grid; gap: 14px; margin-top: 14px; }
.lv b { font-weight: 600; letter-spacing: -0.015em; }
.lv .num { font-size: 14px; }
.track { height: 6px; border-radius: 99px; background: var(--panel-2); margin-top: 8px; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 99px; transition: width .6s var(--ease); }
.track i.r-solo { background: var(--lamp); } .track i.r-shared { background: var(--shared); } .track i.r-crowded { background: var(--crowded); }
