:root {
  --bg: #15171c; --panel: #1f2229; --panel-2: #262a33; --line: #343945;
  --text: #eef0f4; --muted: #9aa1ae; --accent: #f28a3c; --accent-2: #ffb36b;
  --blue: #7cc4ff; --blue-2: #a9d8ff; --blue-soft: rgba(124, 196, 255, .14);
  --win: #37c56a; --draw: #e2c04b; --loss: #e45b5b; --live: #ff7a1a;
  --radius: 12px;
}
:root[data-theme="light"] {
  --bg: #f3f4f7; --panel: #ffffff; --panel-2: #f6f7fa; --line: #dde0e6;
  --text: #15171c; --muted: #5d6573; --accent: #e8702a; --accent-2: #b94a00;
  --blue: #1f7ad1; --blue-2: #155fa6; --blue-soft: rgba(31, 122, 209, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  background-image: radial-gradient(900px 400px at 0% -10%, var(--blue-soft), transparent 70%);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; display: flex; flex-direction: column; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 20px; background: var(--panel); flex-wrap: wrap;
  border-bottom: 2px solid; border-image: linear-gradient(90deg, var(--blue), var(--accent)) 1; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-weight: 900; letter-spacing: 1px; font-size: 20px; color: var(--accent); line-height: 1; }
.logo em { display: block; font-style: normal; font-size: 11px; letter-spacing: 3px; color: var(--blue); }
h1 { margin: 0; font-size: 22px; letter-spacing: .3px; }
.sub { color: var(--muted); font-size: 13px; }
.now { text-align: right; display: flex; align-items: center; gap: 12px; }
.now > div { text-align: right; }
.theme { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 50%;
  width: 36px; height: 36px; cursor: pointer; font-size: 16px; line-height: 1; flex: 0 0 auto; }
.clock { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.phase { color: var(--blue); font-weight: 600; font-size: 14px; margin-top: 4px; }

.tabs { display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.tabs { scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 0 0 auto; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; cursor: pointer; }
.tabs button:hover { border-color: var(--blue); color: var(--blue); }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 700; }

.announce { margin: 12px 16px 0; padding: 12px 16px; border-radius: var(--radius);
  background: var(--accent); color: #111; font-weight: 700; }

main { flex: 1; padding: 16px; max-width: 1300px; width: 100%; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { margin: 0 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--blue-2);
  padding-left: 10px; border-left: 3px solid var(--blue); line-height: 1.2; }
.card h2 .pill { float: right; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--muted); text-transform: none; letter-spacing: 0; }
.pill.live { background: var(--live); color: #111; border-color: var(--live); font-weight: 700; }
.pill.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
td.rank, td.rank + td { white-space: nowrap; }
tr.hl td { background: var(--blue-soft); }
tr.now td { background: var(--blue-soft); font-weight: 700; box-shadow: inset 3px 0 0 var(--blue); }
tr.done td { color: var(--muted); }
.rank { font-weight: 800; font-size: 18px; width: 48px; }
.rank.r1 { color: #ffd700; } .rank.r2 { color: #c0c0c0; } .rank.r3 { color: #cd7f32; }
.r-w { color: var(--win); font-weight: 700; } .r-d { color: var(--draw); font-weight: 700; } .r-l { color: var(--loss); }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
a { color: var(--blue); }

.match { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.match:last-child { border-bottom: 0; }
.match .t { font-weight: 700; font-size: 17px; }
.match .t.away { text-align: right; }
.match .t small { display: block; font-weight: 500; color: var(--blue-2); font-size: 13px; }
.match .t em { display: block; font-style: normal; font-weight: 400; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.tl b { display: block; } .tl small { display: block; color: var(--blue-2); font-size: 12px; line-height: 1.2; }
.match .score { text-align: center; min-width: 96px; }
.match .score b { font-size: 22px; letter-spacing: 1px; }
.match .score span { display: block; font-size: 11px; color: var(--blue); text-transform: uppercase; letter-spacing: 1px; }
.hero { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.hero .big { font-size: 40px; font-weight: 900; line-height: 1.1; }
.hero .next { color: var(--muted); }
.countdown { font-size: 28px; font-weight: 800; color: var(--blue); font-variant-numeric: tabular-nums; }
.members { color: var(--muted); font-size: 14px; }
.team-card { display: flex; gap: 12px; align-items: flex-start; }
.team-card .no { font-size: 28px; font-weight: 900; color: var(--blue); min-width: 44px; }
.team-card .nm { font-weight: 700; }
.team-card .tag { font-size: 11px; color: var(--blue); background: var(--blue-soft); padding: 1px 7px; border-radius: 999px; }
.round-select { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.round-select button { border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.round-select button.active { background: var(--blue); color: #0b1b2b; border-color: var(--blue); font-weight: 700; }
footer { display: flex; justify-content: space-between; padding: 10px 20px; color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--line); flex-wrap: wrap; gap: 8px; }
@media (max-width: 640px) {
  .top { padding: 10px 14px; gap: 6px; }
  .brand { gap: 10px; } .logo { font-size: 16px; } .logo em { font-size: 9px; letter-spacing: 2px; }
  h1 { font-size: 17px; } .sub { font-size: 12px; }
  .now { width: 100%; justify-content: space-between; }
  .now > div { display: flex; align-items: baseline; gap: 10px; text-align: left; }
  .clock { font-size: 24px; } .phase { margin-top: 0; font-size: 13px; }
  .tabs { padding: 8px 10px; gap: 4px; }
  .tabs button { padding: 7px 11px; font-size: 13px; }
  main { padding: 10px; }
  .card { padding: 12px; border-radius: 10px; }
  .card h2 { font-size: 13px; }
  .grid { gap: 10px; grid-template-columns: 1fr; }
  .hero { gap: 10px; } .hero .big { font-size: 26px; } .countdown { font-size: 22px; }
  th, td { padding: 7px 6px; font-size: 14px; }
  .rank { font-size: 16px; width: 32px; }
  .match { padding: 8px 0; gap: 6px; } .match .t { font-size: 15px; } .match .score { min-width: 64px; }
  .match .t small { font-size: 12px; } .tl small { font-size: 11px; }
  .match .score b { font-size: 18px; } .match .score span { font-size: 10px; }
  .r-col { display: none; }          /* per-round MPs hidden on phones; see Results tab */
  .only-mobile { display: block; }
  footer { padding: 8px 12px; font-size: 11px; }
}
.only-mobile { display: none; }
/* kiosk / projector mode: ?big=1 */
body.big { font-size: 20px; }
body.big .clock { font-size: 48px; } body.big h1 { font-size: 28px; }
body.big th, body.big td { padding: 12px 14px; font-size: 20px; }
body.big .match .t { font-size: 24px; } body.big .match .score b { font-size: 30px; }

/* ---------- buttons, inputs, admin ---------- */
.btn { display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: #111; font-weight: 700;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; text-decoration: none; line-height: 1.2; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn.danger { background: transparent; color: var(--loss); border-color: var(--loss); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.inp { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 15px; }
.inp:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.inp.mp { width: 72px; text-align: center; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.inp.wide { flex: 1; min-width: 200px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.act { white-space: nowrap; text-align: right; } .act .btn + .btn { margin-left: 6px; }
.small { font-size: 12px; }
.tabs .admin-tab { border-color: var(--blue); color: var(--blue); }
.tabs .admin-tab.active { background: var(--blue); color: #0b1b2b; }
.tabs .logout { margin-left: auto; color: var(--muted); border-color: var(--line); }
table.entry td { vertical-align: middle; }
.hand .btn { margin-top: 4px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--blue); color: #0b1b2b; font-weight: 700; padding: 10px 16px; border-radius: 10px; transition: .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--loss); color: #fff; }
@media (max-width: 640px) {
  table.entry th:first-child, table.entry td:first-child { display: none; }
  .inp.mp { width: 56px; font-size: 16px; }
  .act .btn + .btn { margin-left: 0; margin-top: 4px; }
  .act { white-space: normal; }
  .row .inp:not(.mp) { flex: 1 1 100%; }
  .row .btn { flex: 0 0 auto; }
}
.card.dirty { border-color: var(--accent); }
.card.dirty .save-round { box-shadow: 0 0 0 3px rgba(242,138,60,.35); }

/* overview: wider matchups column, bigger team + captain names */
@media (min-width: 900px) {
  .overview-grid { grid-template-columns: 3fr 2fr; }
}
.matchups-card .match { padding: 14px 0; }
.matchups-card .match .t { font-size: 24px; line-height: 1.15; }
.matchups-card .match .t small { font-size: 18px; font-weight: 600; margin-top: 2px; }
.matchups-card .match .t em { font-size: 11px; margin-top: 2px; }
.matchups-card .match .score b { font-size: 26px; }
.matchups-card .match .score span { font-size: 12px; }
body.big .matchups-card .match .t { font-size: 30px; }
body.big .matchups-card .match .t small { font-size: 22px; }
@media (max-width: 640px) {
  .matchups-card .match { padding: 10px 0; }
  .matchups-card .match .t { font-size: 19px; }
  .matchups-card .match .t small { font-size: 15px; }
  .matchups-card .match .score b { font-size: 20px; }
}

/* overview rankings: all 12 teams, scrolls within the height of the matchups card */
.rankings-card { display: flex; flex-direction: column; }
.rankings-card .scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.rankings-card thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
@media (min-width: 900px) {
  .overview-grid { align-items: stretch; }
  .rankings-card { max-height: 100%; }
  .rankings-card .scroll { height: 0; }             /* flex basis 0: the matchups card sets the row height */
}
.rankings-card th, .rankings-card td { white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.rankings-card td:nth-child(2) { white-space: normal; }

/* ---------- final results (after round 6) ---------- */
.final-hero { text-align: center; padding: 28px 16px; margin-bottom: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--blue) 18%, var(--panel)), var(--panel) 55%, color-mix(in srgb, var(--accent) 16%, var(--panel))); }
.final-kicker { color: var(--blue); text-transform: uppercase; letter-spacing: 3px; font-size: 13px; font-weight: 700; }
.final-title { font-size: 48px; font-weight: 900; line-height: 1.1; margin: 6px 0; }
.final-sub { color: var(--muted); }
.podium { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 16px; align-items: end; margin-bottom: 16px; }
.podium-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; text-align: center; position: relative; }
.podium-card.p1 { border-color: #ffd700; box-shadow: 0 0 0 1px #ffd700 inset, 0 12px 40px rgba(255, 215, 0, .12); padding-top: 26px; padding-bottom: 26px; }
.podium-card.p2 { border-color: #c0c0c0; }
.podium-card.p3 { border-color: #cd7f32; }
.podium-card .medal { font-size: 40px; line-height: 1; }
.podium-card.p1 .medal { font-size: 56px; }
.podium-card .place { text-transform: uppercase; letter-spacing: 2px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.podium-card.p1 .place { color: #ffd700; } .podium-card.p2 .place { color: #c0c0c0; } .podium-card.p3 .place { color: #cd7f32; }
.podium-card .pname { font-size: 28px; font-weight: 900; margin-top: 4px; }
.podium-card.p1 .pname { font-size: 36px; }
.podium-card .pmembers { color: var(--blue-2); font-size: 18px; font-weight: 600; line-height: 1.5; margin-top: 8px; }
.podium-card.p1 .pmembers { font-size: 21px; }
.podium-card .pstats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-size: 13px; }
.podium-card .pstats b { color: var(--text); font-size: 16px; }
.final-table td { font-size: 17px; }
.final-table tr.top1 td { background: rgba(255, 215, 0, .08); }
.final-table tr.top2 td { background: rgba(192, 192, 192, .07); }
.final-table tr.top3 td { background: rgba(205, 127, 50, .08); }
@media (max-width: 760px) {
  .podium { grid-template-columns: 1fr; }
  .podium-card.p1 { order: -1; }
  .final-title { font-size: 34px; }
  .podium-card .pname { font-size: 24px; } .podium-card.p1 .pname { font-size: 28px; }
}
body.big .final-title { font-size: 64px; }
body.big .podium-card .pname { font-size: 34px; } body.big .podium-card.p1 .pname { font-size: 44px; }
.final-table th, .final-table td { white-space: nowrap; }
.final-table td:nth-child(2) { white-space: normal; }
.site { color: var(--blue); font-weight: 700; letter-spacing: .2px; }
footer .site { font-size: 14px; }
body.big footer .site { font-size: 20px; }
