: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;
  --panel: rgba(19, 23, 25, .88);
  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: transparent; 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: 28px; height: 28px; flex: none; background: url("logo.png") center / contain no-repeat; }
.topbar .spacer { flex: 1; }

/* karty a mřížka */
.card { background: var(--panel); 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(--panel); 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); }
.live { display: grid; gap: 2px; margin-top: 2px; }
.live .lh, .live .lr { display: grid; grid-template-columns: 1fr 3em 3.6em; align-items: center; gap: 8px; }
.live .lh { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: right; }
.live .lr { font-size: 1rem; padding: 3px 0; }
.live .lr .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live .lr .lg { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.live .lr .rm { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.35em; }
.live .lr.on .rm, .live .lr.on .lg { color: var(--gold); }
.live .tdot { display: inline-block; width: .5em; height: .5em; border-radius: 50%; background: var(--gold); margin-right: .4em; vertical-align: middle; animation: tpulse 1.4s ease-in-out infinite; }
@keyframes tpulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .live .tdot { animation: none; } }
.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); }

/* stupně vítězů */
.podium-card { position: relative; overflow: hidden; padding-top: 22px; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 10px; max-width: 640px; margin: 0 auto; }
.pod { display: flex; flex-direction: column; align-items: stretch; text-align: center; min-width: 0; }
.pod .who { padding: 0 4px 10px; min-width: 0; }
.pod .nm { font-weight: 800; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }
.pod .nm a { color: inherit; text-decoration: none; }
.pod .av { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.pod .cup { font-size: 2.2rem; line-height: 1; margin-bottom: 6px; }
.pod .step { border-radius: 10px 10px 0 0; display: flex; justify-content: center; padding-top: 10px; font-weight: 900; font-size: 2rem; color: rgba(0,0,0,.55); transform-origin: bottom; }
.pod.p1 .step { height: 150px; background: linear-gradient(180deg, #f3cf6a, #c8962a); }
.pod.p2 .step { height: 110px; background: linear-gradient(180deg, #e6e9ee, #a7adb6); }
.pod.p3 .step { height: 80px; background: linear-gradient(180deg, #e0a06e, #a8642f); }
.pod.p1 .nm { color: var(--gold); font-size: 1.25rem; }
.fourth { text-align: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.fourth .pl { font-weight: 800; color: var(--muted); margin-right: 4px; }
.fourth a { color: inherit; font-weight: 700; text-decoration: none; }
.standings tr.top td:first-child b { display: inline-block; min-width: 2.2em; }
.standings tr.top1 td:first-child b { color: var(--gold); }
.standings tr.top2 td:first-child b { color: #d9dde3; }
.standings tr.top3 td:first-child b { color: #e0a06e; }
.podium-card.anim .step { animation: podRise .9s cubic-bezier(.2,.8,.2,1) both; }
.podium-card.anim .who { animation: podFade .6s ease-out both; }
.podium-card.anim .p3 .step { animation-delay: .1s; } .podium-card.anim .p3 .who { animation-delay: .7s; }
.podium-card.anim .p2 .step { animation-delay: .5s; } .podium-card.anim .p2 .who { animation-delay: 1.1s; }
.podium-card.anim .p1 .step { animation-delay: .9s; } .podium-card.anim .p1 .who { animation-delay: 1.6s; }
.podium-card.anim .fourth { animation: podFade .6s ease-out 2s both; }
.podium-card.anim .cup { animation: cupPop .7s cubic-bezier(.3,1.6,.5,1) 1.9s both; }
@keyframes podRise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes podFade { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes cupPop { from { transform: scale(0) rotate(-30deg); } to { transform: none; } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; left: var(--x); width: 8px; height: 13px; background: var(--c); border-radius: 2px; opacity: 0; animation: confFall 2.6s ease-in calc(1.8s + var(--d)) both; }
@keyframes confFall { 0% { opacity: 0; transform: translateY(0) rotate(0); } 6% { opacity: 1; } 100% { opacity: 0; transform: translateY(330px) rotate(var(--r)); } }
@media (max-width: 520px) { .pod .nm { font-size: .9rem; } .pod.p1 .nm { font-size: 1rem; } .pod.p1 .step { height: 110px; } .pod.p2 .step { height: 80px; } .pod.p3 .step { height: 58px; } .pod .step { font-size: 1.5rem; } }
@media (prefers-reduced-motion: reduce) { .podium-card.anim *, .podium-card.anim .fourth { animation: none !important; } .confetti { display: none; } }

/* ---------- pozadí: tlumené světlo nad terčem, vodoznak terče, jemné zrno ---------- */
html { background: #0a0d10; }
body::before, body::after { content: ''; position: fixed; pointer-events: none; z-index: -1; }
body::after {
  inset: 0; z-index: -2;
  background: linear-gradient(rgba(8, 10, 12, .25), rgba(8, 10, 12, .25)), url("bg.jpg") center / cover no-repeat, #121514;
}
body::before { display: none; }
.topbar { background: rgba(14, 19, 23, .78); -webkit-backdrop-filter: blur(12px) saturate(140%); backdrop-filter: blur(12px) saturate(140%); }
.card { box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -18px rgba(0, 0, 0, .8); }
/* při hře na tabletu nic nerozptyluje */
body.playing::before, body.playing::after { display: none; }
body.playing { background: var(--bg); }
@media print { body::before, body::after { display: none; } }


/* legy po kolech pavouka */
.ko-legs { display: grid; gap: 8px; margin: 12px 0; }
.ko-legs .kl { display: grid; grid-template-columns: 1fr 76px auto; align-items: center; gap: 10px; margin: 0; color: var(--text); font-size: 1rem; }
.ko-legs .kl input { text-align: center; font-weight: 700; padding: 8px; }
.ko-legs .kl input:disabled { opacity: .5; }
.bracket .col h3 .legs-h { display: block; font-size: .72rem; font-weight: 500; color: var(--muted); margin-top: 2px; text-transform: none; letter-spacing: 0; }

/* přehled hráčů */
table.ov th { cursor: pointer; white-space: nowrap; user-select: none; }
table.ov th::after { content: attr(data-dir); margin-left: 4px; color: var(--gold); font-size: .7em; }
table.ov td { white-space: nowrap; }
table.ov tbody tr:hover td { background: rgba(255, 255, 255, .03); }
