/* Layout: one column; ladder tabs, a scoreboard with standings, then the props drawn as ladder rungs climbing toward the goal */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #141a24;
  --muted: #5d6878;
  --line: #d3d9e1;
  --rail: #9aa5b4;
  --nba: #c4511f;
  --nhl: #1f63a8;
  --win: #1d7a46;
  --win-bg: #e1f2e7;
  --loss: #b3261e;
  --loss-bg: #f8e1df;
  --push: #7a6a1d;
  --push-bg: #f3eed6;
  --soft: #e7ebf2;
  --accent: var(--nba);
  --f-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --f-body: "Barlow", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --surface: #171e28; --ink: #e8edf3; --muted: #93a0b2; --line: #2a3442; --rail: #4c5869;
    --nba: #f07a45; --nhl: #5aa2ec;
    --win: #5fd08f; --win-bg: #173326; --loss: #f2867e; --loss-bg: #3a1c1b; --push: #e0c96a; --push-bg: #333016; --soft: #222b38;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; }
.wrap { max-width: 820px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 20px 56px; display: grid; gap: 18px; }
.sport-nba { --accent: var(--nba); }
.sport-nhl { --accent: var(--nhl); }
code { font-family: var(--f-mono); font-size: .85em; }

.demo-banner { background: var(--push-bg); color: var(--push); border-radius: 8px; padding: 8px 12px; font-size: .85rem; }

header.top { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1 { font-family: var(--f-display); font-weight: 900; font-size: 2.6rem; line-height: .9; margin: 0; text-transform: uppercase; }
h1 small { display: block; font-family: var(--f-body); font-weight: 500; font-size: .8rem; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-top: 6px; }
.who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.role { font-family: var(--f-mono); font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; background: var(--soft); color: var(--muted); }
.role.admin { background: var(--ink); color: var(--bg); }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; font-weight: 600; }
button:hover { border-color: var(--ink); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 8px; }
button.ghost:hover { color: var(--ink); }
button.danger { color: var(--loss); }
button.small { padding: 5px 10px; font-size: .82rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { display: flex; align-items: center; gap: 8px; border-radius: 999px; padding: 6px 14px 6px 8px; }
.tab .lg { font-family: var(--f-mono); font-size: .7rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--accent); color: #fff; }
.tab[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tab.plain { padding: 6px 14px; color: var(--muted); }
.tab.plain.dashed { border-style: dashed; }
.tab.plain[aria-selected="true"] { color: var(--ink); border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.view { display: grid; gap: 18px; }
.board { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 10px; padding: 18px; display: grid; gap: 16px; }
.board-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: start; }
h2 { font-family: var(--f-display); font-weight: 800; font-size: 1.9rem; text-transform: uppercase; margin: 0; line-height: 1; text-wrap: balance; }
.meta { color: var(--muted); font-size: .85rem; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.me td { background: var(--soft); }
.pos { color: var(--win); } .neg { color: var(--loss); }
.calc { color: var(--muted); font-style: italic; }

.pill { font-family: var(--f-mono); font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; white-space: nowrap; display: inline-block; }
.p-pending { background: var(--soft); color: var(--accent); }
.p-win { background: var(--win-bg); color: var(--win); }
.p-loss { background: var(--loss-bg); color: var(--loss); }
.p-push { background: var(--push-bg); color: var(--push); }
.p-alive { background: var(--soft); color: var(--ink); }

/* Props drawn as ladder rungs */
.ladder { position: relative; display: grid; gap: 12px; padding-left: 34px; }
.ladder::before, .ladder::after { content: ""; position: absolute; top: 8px; bottom: 8px; width: 3px; background: var(--rail); border-radius: 2px; }
.ladder::before { left: 6px; }
.ladder::after { left: 22px; }
.rung { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; min-width: 0; }
.rung::before { content: ""; position: absolute; left: -34px; width: 34px; top: 28px; height: 3px; background: var(--rail); }
.rung.res-win { border-left: 4px solid var(--win); }
.rung.res-loss { border-left: 4px solid var(--loss); }
.rung.res-push { border-left: 4px solid var(--push); }
.rung.res-pending { border-left: 4px solid var(--accent); }
.rung.cap { background: transparent; border-style: dashed; padding: 10px 14px; display: flex; gap: 12px; align-items: baseline; }
.rung.cap::before { top: 50%; }
.rung-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; }
.no { font-family: var(--f-display); font-weight: 900; font-size: 1.6rem; color: var(--muted); min-width: 1.4em; text-align: center; line-height: 1; }
.cap .no { font-size: .8rem; letter-spacing: .1em; min-width: 0; }
.prop { font-weight: 600; overflow-wrap: anywhere; }
.sub { font-size: .82rem; color: var(--muted); }
.legs { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 8px; }
.leg { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.leg:last-child { border-bottom: 0; }
.leg .admin-row { grid-column: 1 / -1; }
.leg-name { font-weight: 600; overflow-wrap: anywhere; }
.admin-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.admin-row .w { color: var(--win); } .admin-row .l { color: var(--loss); } .admin-row .p { color: var(--push); }

/* Panels & forms */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; display: grid; gap: 12px; }
.panel h3, .mine h3 { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: 1.25rem; text-transform: uppercase; }
.mine { display: grid; gap: 8px; background: var(--soft); border-radius: 8px; padding: 10px 12px; }
.mine h3 { font-size: 1rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; align-items: end; }
label.wide { grid-column: span 2; }
@media (max-width: 420px) { label.wide { grid-column: auto; } }
label { display: grid; gap: 4px; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); min-width: 0; }
input, select { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 8px 10px; font-size: .95rem; text-transform: none; letter-spacing: 0; font-weight: 500; width: 100%; min-width: 0; }
.mine input { background: var(--surface); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint { font-size: .82rem; color: var(--muted); }
.err { font-size: .85rem; color: var(--loss); }
.ok { font-size: .85rem; color: var(--win); }

.empty { text-align: center; padding: 40px 18px; justify-items: center; }
.empty p { margin: 0; color: var(--muted); max-width: 44ch; }
.auth { max-width: 420px; justify-self: center; width: 100%; }
.foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

@media (max-width: 520px) {
  h1 { font-size: 2.1rem; }
  .rung-head { grid-template-columns: auto minmax(0, 1fr); }
  .rung-head > :last-child { grid-column: 2; }
}

/* Ladder sections: Ladder / Suggestions / Chat */
.segs { display: flex; gap: 4px; padding: 4px; background: var(--soft); border-radius: 10px; width: fit-content; max-width: 100%; overflow-x: auto; }
.seg { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 7px; white-space: nowrap; }
.seg:hover { color: var(--ink); }
.seg.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

/* Suggestions */
.suggestions { display: grid; gap: 10px; }
.sub-head { margin: 8px 0 0; font-family: var(--f-display); font-weight: 800; font-size: 1rem; text-transform: uppercase; color: var(--muted); }
.suggestion { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.suggestion.used { opacity: .7; }
.vote { display: grid; justify-items: center; gap: 0; min-width: 46px; padding: 6px 8px; line-height: 1.1; }
.vote span { font-size: .75rem; color: var(--muted); }
.vote b { font-family: var(--f-mono); font-size: .95rem; }
.vote.on { border-color: var(--accent); color: var(--accent); }
.vote.on span { color: var(--accent); }
.note { margin: 6px 0 4px; font-size: .9rem; overflow-wrap: anywhere; }
.sg-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 520px) {
  .suggestion { grid-template-columns: auto minmax(0, 1fr); }
  .sg-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* Live chat */
.chat { gap: 10px; }
.chat-list { height: min(60vh, 520px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; overscroll-behavior: contain; }
.chat-empty { margin: auto; text-align: center; }
.chat-day { align-self: center; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 6px 0 2px; }
.chat-msg { align-self: flex-start; max-width: min(80%, 560px); background: var(--soft); border-radius: 12px 12px 12px 4px; padding: 7px 11px; }
.chat-msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-radius: 12px 12px 4px 12px; }
.chat-meta { display: flex; gap: 8px; align-items: baseline; font-size: .75rem; color: var(--muted); }
.chat-meta b { color: var(--ink); font-weight: 600; }
.chat-del { padding: 0 4px; font-size: .72rem; opacity: 0; }
.chat-msg:hover .chat-del, .chat-del:focus-visible { opacity: 1; }
@media (hover: none) { .chat-del { opacity: 1; } }
.chat-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }

/* Auto-grading */
.auto-grade { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.auto-grade > div { min-width: 0; flex: 1 1 260px; }
.auto-note { font-size: .8rem; color: var(--push); margin-top: 2px; }

/* Chat extras */
.chat-form .tool { padding: 6px 10px; font-size: 1rem; line-height: 1; }
.chat-form .gif-btn { font-family: var(--f-mono); font-size: .75rem; font-weight: 700; }
.chat-form .tool.on { border-color: var(--accent); color: var(--accent); }
.chat-body.big { font-size: 2rem; line-height: 1.2; }
.chat-gif { display: block; max-width: min(260px, 100%); height: auto; border-radius: 8px; margin-top: 4px; }
.chat-msg.has-gif { padding: 7px; }
.picker { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; max-height: 180px; overflow-y: auto; }
.emoji { border: 0; background: transparent; font-size: 1.4rem; padding: 4px; line-height: 1; border-radius: 6px; }
.emoji:hover, .emoji:focus-visible { background: var(--soft); }
.gif-panel { display: grid; gap: 8px; }
.gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; max-height: 260px; overflow-y: auto; }
.gif-pick { padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--soft); aspect-ratio: 4 / 3; max-width: 100%; }
.gif-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.giphy-credit { font-size: .7rem; color: var(--muted); text-align: right; letter-spacing: .04em; }

/* Live progress on pending player props */
.live { display: grid; gap: 4px; margin-top: 6px; }
.live-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: .8rem; }
.live-top b { font-family: var(--f-mono); font-size: .82rem; font-variant-numeric: tabular-nums; }
.live-status { font-family: var(--f-mono); font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.live-status.on { color: var(--loss); }
.live-status.on::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: middle; animation: live-pulse 1.6s ease-in-out infinite; }
.live-note { font-size: .75rem; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.live.hit .bar > span { background: var(--win); }
.live.hit .live-note { color: var(--win); }
@media (prefers-reduced-motion: reduce) { .bar > span { transition: none; } }
.live.bust .bar > span { background: var(--loss); }
.live.bust .live-note { color: var(--loss); }
@keyframes live-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-status.on::before { animation: none; } }
.court { margin-left: auto; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.court.on { background: var(--win-bg); color: var(--win); }
.court.out { background: var(--loss-bg); color: var(--loss); }
