:root {
  --bg: #101417;
  --surface: #182026;
  --surface-2: #212b33;
  --line: #2c3842;
  --text: #f1ece2;
  --muted: #93a1ab;
  --green: #2fb36a;
  --green-dim: #1d4d33;
  --red: #e2483c;
  --red-dim: #5a2420;
  --cream: #efe3c8;
  --gold: #e9b949;
  --radius: 14px;
  color-scheme: dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.45; }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: var(--cream); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.15; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 560px; }

/* hlavička */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; color: var(--text); }
.brand .dot { width: 26px; height: 26px; border-radius: 50%; background:
  radial-gradient(circle, var(--red) 0 18%, var(--cream) 19% 34%, var(--green) 35% 50%, #111 51% 66%, var(--red) 67% 82%, #111 83%); flex: none; }
.topbar .spacer { flex: 1; }

/* karty a mřížka */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 14px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }

/* formuláře */
label { display: block; font-size: .875rem; color: var(--muted); margin-bottom: 4px; }
input, select { width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; outline: none; }
input:focus, select:focus { border-color: var(--green); }
input.code { font-size: 1.4rem; letter-spacing: .15em; text-transform: uppercase; font-weight: 700; text-align: center; }
.field { flex: 1; min-width: 120px; }

.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; min-height: 46px; user-select: none; }
.btn:hover { border-color: #3d4c58; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); border-color: var(--green); color: #07130c; }
.btn.danger { background: var(--red-dim); border-color: var(--red); color: #ffd9d4; }
.btn.ghost { background: transparent; }
.btn.big { font-size: 1.15rem; padding: 16px 22px; min-height: 58px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* tabulky */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; }
tr.adv td:first-child { box-shadow: inset 3px 0 0 var(--green); }
tr.me td { background: rgba(47,179,106,.08); }
.table-scroll { overflow-x: auto; }

/* štítky */
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.green { background: var(--green-dim); color: #b9f1cf; border-color: transparent; }
.tag.red { background: var(--red-dim); color: #ffd0ca; border-color: transparent; }
.tag.gold { background: #4a3a12; color: #ffe39a; border-color: transparent; }

/* statistiky */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.tile .v { white-space: nowrap; font-size: 1.8rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .l { font-size: .8rem; color: var(--muted); }
.tile.hero .v { color: var(--green); font-size: clamp(1.9rem, 6vw, 2.4rem); }

.big-id { font-size: 2.6rem; font-weight: 800; letter-spacing: .14em; font-variant-numeric: tabular-nums; color: var(--cream); }

/* tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 600; background: none; border: none; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--green); }

/* pavouk */
.bracket { display: flex; gap: 22px; overflow-x: auto; padding-bottom: 8px; }
.bracket .col { display: flex; flex-direction: column; min-width: 210px; }
.bracket .ms { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; flex: 1; }
.bracket .col h3 { font-size: .9rem; color: var(--muted); text-align: center; line-height: 1.4; }
.bm { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.bm.playing { border-color: var(--gold); }
.bm .p { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; }
.bm .p + .p { border-top: 1px solid var(--line); }
.bm .p.win { font-weight: 700; }
.bm .p.lose { color: var(--muted); }
.bm .p .s { font-variant-numeric: tabular-nums; font-weight: 700; }
.bm .meta { font-size: .7rem; color: var(--gold); padding: 3px 10px; background: rgba(233,185,73,.08); }

/* oznámení */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 12px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); }
.toast.err { border-color: var(--red); }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.err-box { background: var(--red-dim); border: 1px solid var(--red); color: #ffd9d4; padding: 12px 14px; border-radius: 10px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(5,8,10,.72); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; width: 100%; max-width: 460px; }
.modal h2 { margin-bottom: 12px; }
.choice { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.choice .btn { font-size: 1.4rem; min-height: 64px; }
.choice .btn.sel { background: var(--green); color: #07130c; border-color: var(--green); }

@media (max-width: 600px) {
  h1 { font-size: 1.4rem; }
  .big-id { font-size: 2rem; }
  th, td { padding: 7px 4px; }
}
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
body.tv { font-size: 22px; }

/* terče */
.boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 18px; }
.board { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 4px; align-content: start; }
.board .b { display: flex; justify-content: space-between; gap: 8px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.board .who { font-size: 1rem; line-height: 1.3; }
.board .stg { font-size: .8rem; color: var(--muted); }
.board.s-playing { border-left-color: var(--gold); }
.board.s-playing .st { color: var(--gold); }
.board.s-ready { border-left-color: var(--green); background: linear-gradient(90deg, rgba(47,179,106,.10), var(--surface) 70%); }
.board.s-ready .st { color: var(--green); }
.board.s-free { border-style: dashed; border-left-style: solid; }
.bm.ready { border-color: var(--green); }
.bm.ready .meta { color: #b9f1cf; background: rgba(47,179,106,.12); }
.bm .from { display: block; font-size: .7rem; color: var(--muted); font-weight: 400; }
.card + .grid, .grid + .card, .grid + .grid { margin-top: 14px; }
.chips-f { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-f { font: inherit; font-size: .9rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.chip-f.on { background: var(--green-dim); color: #b9f1cf; border-color: var(--green); }
