*{box-sizing:border-box}
:root{--bg:#120d33;--card:#1f1850;--card2:#291f63;--line:#3a2f7d;--txt:#f4f1ff;--mut:#b9b0e0;--gold:#ffd23f;--cyan:#33e0ff;--ok:#5ee08a;--warn:#ffb347}
html,body{margin:0;height:100%}
body{background:radial-gradient(ellipse at top,#3b1d6e 0%,#1b1446 45%,#0b0820 100%) fixed;color:var(--txt);font:14px/1.3 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;-webkit-text-size-adjust:100%;overflow:hidden}
button{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
button:focus-visible{outline:2px solid var(--cyan);outline-offset:1px}
h1,h2,h3,h4,p{margin:0}

/* app shell: always exactly one screen tall */
.app{height:100vh;height:100dvh;display:flex;flex-direction:column;padding:env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left)}

/* header */
.bar{flex:0 0 auto;display:flex;align-items:center;gap:12px;padding:6px 12px;background:rgba(18,13,51,.94);border-bottom:1px solid var(--line)}
.back{color:var(--gold);text-decoration:none;font-weight:700;font-size:13px;white-space:nowrap}
.ttl{min-width:0}
.ttl h1{font-size:17px;letter-spacing:.2px;white-space:nowrap}
.sub{color:var(--mut);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.status{flex:1;min-width:0;font-size:12.5px;color:var(--mut);background:var(--card);border:1px solid var(--line);border-radius:999px;padding:4px 12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}
.status b{color:var(--txt)}
.status.done{border-color:var(--ok)}
.status.warn{border-color:var(--warn);color:#ffe2b8}
.status:empty{visibility:hidden}
.actions{display:flex;gap:6px;flex:0 0 auto}
.actions button,.mini{background:var(--card2);border:1px solid var(--line);border-radius:9px;padding:6px 11px;font-size:13px;font-weight:700;white-space:nowrap}
.actions button:disabled{opacity:.4;cursor:default}
.actions button.dim{opacity:.55}
.actions .pri{background:var(--gold);color:#1b1446;border-color:var(--gold)}
#reset.armed{background:#ff5f6d;border-color:#ff5f6d;color:#fff;opacity:1}

/* phone tabs (hidden on wide screens) */
.tabs{flex:0 0 auto;display:flex;border-bottom:1px solid var(--line)}
.tabs button{flex:1;background:none;border:0;border-bottom:3px solid transparent;padding:7px 4px;font-weight:800;color:var(--mut)}
.tabs button[aria-selected=true]{color:var(--txt);border-bottom-color:var(--gold)}

.layout{flex:1 1 auto;min-height:0;display:flex;padding:8px 12px 4px;gap:16px}
.panel{display:none;min-height:0;min-width:0;flex-direction:column}
.panel.on{display:flex;flex:1}

/* week strip */
.weekbar{flex:0 0 auto;display:flex;gap:4px;align-items:stretch}
.nav{flex:0 0 30px;background:var(--card);border:1px solid var(--line);border-radius:8px;font-size:18px;font-weight:800;padding:0}
.nav:disabled{opacity:.3;cursor:default}
.weeks{flex:1;display:flex;gap:3px;overflow-x:auto;scrollbar-width:none;min-width:0}
.weeks::-webkit-scrollbar{display:none}
.wk{flex:1 0 34px;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--card);border:1px solid var(--line);border-radius:8px;padding:2px 0;line-height:1.1}
.wk b{font-size:14px}
.wk i{font-style:normal;font-size:12px;color:var(--mut)}
.wk.fin{background:#18123f}.wk.fin b{color:var(--mut)}
.wk.set i{color:var(--ok)}
.wk.open i{color:var(--gold)}
.wk.sel{background:var(--gold);border-color:var(--gold);color:#1b1446}
.wk.sel b,.wk.sel i{color:#1b1446}
.weekhead{flex:0 0 auto;display:flex;align-items:center;gap:10px;margin:6px 0 6px}
.weekhead h2{font-size:16px;white-space:nowrap}
.wkinfo{flex:1;min-width:0;color:var(--mut);font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mini{padding:3px 9px;font-size:12px}

/* games: grid filled to the available height */
.games{flex:1 1 auto;min-height:0;display:grid;grid-auto-flow:column;grid-template-columns:1fr;gap:5px}
.game{min-height:0;display:grid;grid-template-columns:1fr 58px 1fr;gap:4px;background:var(--card);border:1px solid var(--line);border-radius:10px;padding:3px}
.game.picked{border-color:#ffd23f66}
.tm{min-width:0;min-height:0;display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:0;background:var(--card2);border:2px solid transparent;border-radius:8px;padding:1px 8px;text-align:left;line-height:1.15;overflow:hidden}
.tm.home{align-items:flex-end;text-align:right}
.tm .l1{display:flex;align-items:baseline;gap:6px;white-space:nowrap}
.tm.home .l1{flex-direction:row-reverse}
.tm .ab{font-size:15px;letter-spacing:.4px}
.tm .rc{font-size:12px;color:var(--mut)}
.tm .nm{font-size:12px;color:var(--mut);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.tm.pick{background:var(--gold);color:#1b1446;border-color:#fff4}
.tm.pick .nm,.tm.pick .rc{color:#3b2b00}
.tm.lose{opacity:.5}
.mid{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:0;overflow:hidden}
.when{font-size:12px;color:var(--mut);white-space:nowrap}
.tie{background:var(--card2);border:1px solid var(--line);border-radius:6px;padding:0 8px;font-size:12px;font-weight:800;line-height:1.5}
.tie.pick{background:var(--cyan);color:#06303a;border-color:var(--cyan)}
.game.final{background:#18123f}
.game.final .tm{cursor:default;background:#1d1650}
.game.final .tm.win{border-color:var(--ok)}
.game.final .tm.lose{opacity:.55}
.sc{font-size:15px}
.lock{font-size:12px;color:var(--ok);font-weight:700;letter-spacing:.4px}

/* results */
.seg{flex:0 0 auto;display:flex;align-items:center;gap:4px;margin-bottom:6px}
.seg button{background:var(--card);border:1px solid var(--line);border-radius:9px;padding:5px 14px;font-weight:800;font-size:13px;color:var(--mut)}
.seg button[aria-selected=true]{background:var(--cyan);border-color:var(--cyan);color:#06303a}
.legend{margin-left:auto;font-size:12px;color:var(--mut);white-space:nowrap}
.lg{display:inline-block;width:10px;height:10px;border-radius:50%;margin:0 4px 0 10px;vertical-align:-1px}
.lg.div{background:var(--gold)}.lg.wc{background:var(--cyan)}
.view{display:none;flex:1 1 auto;min-height:0;flex-direction:column}
.view.on{display:flex}
.two{flex:1 1 auto;min-height:0;display:grid;grid-template-columns:1fr 1fr;gap:10px}
.conf{min-width:0;min-height:0;display:flex;flex-direction:column;gap:3px}
.conf h3{flex:0 0 auto;font-size:14px;color:var(--gold);letter-spacing:.5px}
.conf h4{flex:0 0 auto;font-size:12px;color:var(--mut);font-weight:700;text-transform:uppercase;letter-spacing:.6px;margin-top:3px}
.seed{flex:1 1 0;min-height:0;max-height:52px;display:flex;align-items:center;gap:8px;width:100%;background:var(--card);border:1px solid var(--line);border-radius:9px;padding:0 8px;text-align:left;overflow:hidden}
.seed:hover{border-color:var(--cyan)}
.seed.out{background:#18123f;opacity:.85}
.sn{flex:0 0 24px;height:24px;border-radius:50%;display:grid;place-items:center;font-weight:800;font-size:13px;background:var(--card2)}
.seed.div .sn{background:var(--gold);color:#1b1446}
.seed.wc .sn{background:var(--cyan);color:#06303a}
.si{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.2}
.si .l1{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.si b{font-size:14px}
.nk{font-size:12px;color:var(--mut)}
.si .k{font-size:12px;color:var(--mut);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.rec{font-weight:700;font-size:13px;white-space:nowrap}
.info{flex:0 0 20px;height:20px;border-radius:50%;border:1px solid var(--line);display:grid;place-items:center;font-size:12px;font-weight:800;color:var(--cyan)}
.badge{font-size:12px;font-weight:800;border-radius:5px;padding:0 5px;margin-left:5px;border:0;line-height:1.4}
.badge.u{background:var(--warn);color:#3a1f00}
.badge.t{background:#ffffff26;color:var(--txt)}
.mu{flex:1 1 0;min-height:0;max-height:110px;display:flex;flex-direction:column;justify-content:center;gap:2px;background:var(--card);border:1px solid var(--line);border-radius:10px;padding:4px 10px}
.mu.bye{border-color:#ffd23f88;max-height:70px}
.mu .lbl{font-size:12px;color:var(--mut)}
.mu .t{display:flex;align-items:baseline;gap:7px;font-size:14px;white-space:nowrap;overflow:hidden}
.mu .t .rec{margin-left:auto}
.sn2{display:inline-grid;place-items:center;min-width:20px;height:20px;border-radius:50%;background:var(--card2);font-weight:800;font-size:12px}
.note{flex:0 0 auto;font-size:12px;color:var(--mut);margin-top:6px}
table.st{flex:1 1 0;min-height:0;width:100%;border-collapse:separate;border-spacing:0;background:var(--card);border:1px solid var(--line);border-radius:9px;font-size:13px}
table.st caption{text-align:left;font-weight:800;font-size:12.5px;color:var(--gold);padding:0 2px 1px}
.st th,.st td{padding:1px 6px;text-align:right;white-space:nowrap}
.st td{border-top:1px solid var(--line)}
.st th{font-size:12px;color:var(--mut);font-weight:600}
.st td:first-child,.st th:first-child{text-align:left}
.st tr.lead td:first-child b{color:var(--gold)}
.st .badge{cursor:pointer}
.two > .conf:has(table){gap:6px}

/* footer */
.foot{flex:0 0 auto;display:flex;gap:10px;align-items:center;flex-wrap:wrap;padding:3px 12px calc(4px + env(safe-area-inset-bottom));font-size:12px;color:var(--mut);border-top:1px solid #3a2f7d88}
.foot b{color:var(--txt)}
.u2{display:none}
.lnk{background:none;border:0;color:var(--cyan);padding:0;font-size:12px;text-decoration:underline}

/* dialog */
dialog{background:var(--card);color:var(--txt);border:1px solid var(--line);border-radius:14px;max-width:560px;width:92vw;max-height:80dvh;padding:0;overflow:auto}
dialog::backdrop{background:#0008}
.dlg-h{position:sticky;top:0;display:flex;align-items:center;gap:10px;padding:12px 14px 8px;background:var(--card);border-bottom:1px solid var(--line)}
.dlg-h h3{flex:1;font-size:16px;color:var(--gold)}
.x{background:var(--card2);border:1px solid var(--line);border-radius:8px;width:32px;height:32px;padding:0}
.dlg-b{padding:10px 16px 16px;font-size:13.5px;line-height:1.45;color:#e4ddff}
.dlg-b p{margin:0 0 8px}
.dlg-b .k{color:var(--mut)}
.dlg-b ol{margin:4px 0;padding-left:20px}
.dlg-b li{margin:4px 0}
.dlg-b .u{color:#ffd29a}
.dlg-b a{color:var(--cyan)}

.toast{position:fixed;left:50%;bottom:40px;transform:translateX(-50%) translateY(20px);opacity:0;background:var(--gold);color:#1b1446;font-weight:700;border-radius:12px;padding:10px 14px;transition:.2s;pointer-events:none;z-index:9;max-width:90vw}
.toast.on{opacity:1;transform:translateX(-50%)}

/* ---------- wide screens: games | results side by side, no page scroll ---------- */
@media (min-width:900px){
  .tabs{display:none}
  .panel{display:flex}
  #p-games{flex:1.08 1 0}
  #p-playoffs{flex:1 1 0}
  .games{grid-template-columns:1fr 1fr;column-gap:8px}
}
@media (min-width:900px) and (max-width:1100px){
  .legend{display:none}
  .bk-t{display:none}
  .status{font-size:12px;padding:4px 8px}
}
@media (min-width:1500px){
  .layout{padding:10px 20px 6px;gap:24px}
  .tm .ab,.sc{font-size:17px}
  .si b,.mu .t{font-size:15px}
}
/* short desktop windows: tighten vertical rhythm */
@media (min-width:900px) and (max-height:740px){
  .bar{padding:4px 12px}
  .weekhead{margin:4px 0}
  .tm .nm{display:none}
  .seed{gap:6px}
  .si .k{display:none}
}

/* ---------- phones / narrow: Games | Playoffs tabs ---------- */
@media (max-width:899px){
  .bar{gap:8px;padding:6px 10px;flex-wrap:wrap}
  .bk-t{display:none}
  .back{font-size:18px}
  .ttl{flex:1}
  .ttl h1{font-size:16px}
  .actions button{padding:6px 9px}
  .lbl{display:none}
  .status{order:5;flex:1 0 100%;text-align:left;padding:2px 10px;font-size:12px}
  .layout{padding:6px 8px 2px}
  .weeks .wk{flex:0 0 36px}
  .legend{display:none}
  .seg button{flex:1;padding:6px 4px}
  .two{gap:6px}
  .seed{padding:0 5px;gap:5px}
  .sn{flex-basis:22px;height:22px}
  .seed .nk{display:none}
  .info{display:none}
  .st .opt{display:none}
  .st .nk{display:none}
  .mu{padding:3px 6px}
  .mu .nk{display:none}
  .foot{gap:2px 8px;padding:2px 10px calc(3px + env(safe-area-inset-bottom));flex-wrap:nowrap;white-space:nowrap}
  .u1{display:none}.u2{display:inline}
  .tm .nm{display:none}
  .game{grid-template-columns:1fr 62px 1fr;padding:2px}
  .when{line-height:1.1}
  .tie{line-height:1.3}
  .mid{gap:1px}
  .weekhead{margin:4px 0}
  .foot .src{display:none}
}
@media (max-width:899px) and (max-height:700px){
  .tm .nm{display:none}
  .si .k{display:none}
}
@media (min-width:900px) and (max-width:1199px){.st .nk{display:none}}
@media (min-width:900px) and (max-height:640px){.st th,.st td{padding:0 6px}table.st caption{font-size:12px;padding:0 2px}}
/* very short phones: keep rows tappable and let the game list scroll a little instead of clipping */
@media (max-width:899px) and (max-height:799px){.games{overflow-y:auto}.game{min-height:42px}}
