/* Výběh na Tábor: smrková zeleň, mlha a žlutá startovních čísel. */
:root {
  --fog: #F1F4F0;
  --paper: #FFFFFF;
  --ink: #15231C;
  --spruce: #1B4332;
  --spruce-2: #2C5E46;
  --muted: #5C6B63;
  --rule: #D3DBD4;
  --tint: #E2EDE4;
  --bib: #F4C20D;
  --bib-ink: #2A2200;
  --live: #C22F1B;
  --narrow: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Liberation Sans Narrow", "Helvetica Neue", Arial, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* skrytý prvek zůstane skrytý, i když má vlastní display */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fog); color: var(--ink); font: 16px/1.5 var(--text); }
a { color: var(--spruce); text-underline-offset: 2px; }
a:hover { color: var(--spruce-2); }
:focus-visible { outline: 3px solid var(--bib); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* hlavička */
.top { background: var(--spruce); color: #fff; }
.top-in { display: flex; align-items: center; gap: 8px 28px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 0; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 600 1.5rem/1 var(--narrow); letter-spacing: .01em; padding-bottom: 10px; }
.brand svg { width: 44px; height: 28px; color: var(--bib); }
.nav { display: flex; gap: 2px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; flex: 1 1 auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #D9E6DD; text-decoration: none; white-space: nowrap; padding: 8px 10px 12px; border-bottom: 3px solid transparent; font-size: .95rem; }
.nav a:hover { color: #fff; }
.nav a[aria-current] { color: #fff; border-bottom-color: var(--bib); font-weight: 600; }
.nav a.is-live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #FF5A43; margin-right: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.adminbar { background: var(--bib); color: var(--bib-ink); font-size: .9rem; }
.adminbar .wrap { display: flex; gap: 18px; padding-top: 6px; padding-bottom: 6px; flex-wrap: wrap; }
.adminbar a { color: var(--bib-ink); font-weight: 600; }

.main { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
.foot { border-top: 1px solid var(--rule); color: var(--muted); font-size: .875rem; }
.foot .wrap { display: flex; justify-content: space-between; gap: 16px; padding-top: 16px; padding-bottom: 24px; flex-wrap: wrap; }
.foot a { color: var(--muted); }

/* typografie */
h1, h2, h3 { font-family: var(--narrow); font-weight: 600; line-height: 1.1; margin: 0; color: var(--spruce); }
h1 { font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -.005em; }
h2 { font-size: 1.6rem; margin-top: 40px; margin-bottom: 12px; }
h3 { font-size: 1.2rem; margin-top: 24px; margin-bottom: 8px; }
p { margin: 0 0 12px; max-width: 68ch; }
.lead { color: var(--muted); margin-top: 6px; }
.muted { color: var(--muted); }
.num, td.t, th.t { font-variant-numeric: tabular-nums; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 16px; }
.tools { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; }

/* přepínače a tlačítka */
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: var(--paper); }
.seg a { padding: 7px 14px; text-decoration: none; color: var(--ink); font-size: .9rem; border-left: 1px solid var(--rule); }
.seg a:first-child { border-left: 0; }
.seg a[aria-current] { background: var(--spruce); color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--spruce); background: var(--spruce); color: #fff; padding: 9px 16px; border-radius: 8px; font: 600 .95rem var(--text); text-decoration: none; cursor: pointer; min-height: 42px; }
.btn:hover { background: var(--spruce-2); color: #fff; }
.btn.ghost { background: var(--paper); color: var(--spruce); border-color: var(--rule); }
.btn.ghost:hover { border-color: var(--spruce); }
.btn.danger { background: var(--paper); color: var(--live); border-color: #E3B5AD; }
.btn.small { padding: 5px 10px; min-height: 34px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.years { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 20px; padding: 0; list-style: none; }
.years a { display: block; padding: 3px 8px; border-radius: 6px; text-decoration: none; font: 500 1rem var(--narrow); color: var(--muted); font-variant-numeric: tabular-nums; }
.years a:hover { background: var(--tint); color: var(--spruce); }
.years a[aria-current] { background: var(--spruce); color: #fff; }

/* tabulky */
.tablewrap { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; overflow-x: auto; margin: 0 0 16px; }
table.res { border-collapse: collapse; width: 100%; font-size: .95rem; }
.res th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--muted); padding: 10px 10px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--paper); }
.res td { padding: 8px 10px; border-bottom: 1px solid #E8EDE9; vertical-align: baseline; }
.res tr:last-child td { border-bottom: 0; }
.res td.t, .res th.t { text-align: right; white-space: nowrap; }
.res td.rank { width: 1%; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.res td.time { font: 600 1.15rem/1 var(--narrow); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; color: var(--ink); }
.res tr.top1 td.time { color: var(--spruce); }
.res tbody tr:hover td { background: #F7FAF7; }
.res.zebra tbody tr:nth-child(even) td { background: #EEF0EE; }
.who { font-weight: 600; text-decoration: none; color: var(--ink); }
.who:hover { text-decoration: underline; }
.up { color: #1F7A46; } .down { color: #A3472F; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--tint); color: var(--spruce); vertical-align: 1px; white-space: nowrap; }
.tag.pb { background: var(--bib); color: var(--bib-ink); }
.or { display: inline-block; font-size: .62em; font-weight: 700; line-height: 1.35; padding: 0 4px; border-radius: 3px; background: var(--bib); color: var(--bib-ink); margin-left: 3px; vertical-align: 1.5px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bib { display: inline-block; min-width: 2em; text-align: center; padding: 1px 5px; border-radius: 4px; background: var(--bib); color: var(--bib-ink); font: 700 .9rem/1.3 var(--narrow); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .wide { display: none; }
  .res td, .res th { padding-left: 7px; padding-right: 7px; }
  .tablewrap { margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; }
}

/* úvodní stránka */
.main.has-hero { padding-top: 0; }
body.home { overflow-x: hidden; }
.hero { background: var(--spruce); color: #fff; margin: 0 calc(50% - 50vw) 28px; position: relative; overflow: hidden; }
.hero .wrap { max-width: 1080px; }
.hero .wrap { position: relative; padding-top: 28px; padding-bottom: 0; }
.hero h1 { color: #fff; font-size: clamp(2.6rem, 9vw, 4.6rem); line-height: .95; max-width: 9em; }
.hero p { color: #CFE0D4; max-width: 46ch; margin-top: 12px; }
.hero .wrap { padding-bottom: 8px; }
.hillbox { position: relative; height: clamp(64px, 11vw, 140px); margin-top: 58px; }
.hillbox svg.hill { display: block; width: 100%; height: 100%; }
.hillbox svg.tower { position: absolute; left: 86.1%; bottom: 76%; width: clamp(26px, 2.7vw, 34px); height: auto; transform: translateX(-50%); }
.hero .rec { position: absolute; right: 16px; top: 30px; text-align: right; }
.hero .rec b { display: block; font: 600 clamp(2rem, 6vw, 3.4rem)/1 var(--narrow); color: var(--bib); font-variant-numeric: tabular-nums; }
.hero .rec span { font-size: .85rem; color: #CFE0D4; }
.hero .rec a { color: #fff; }
@media (max-width: 640px) { .hero .rec { position: static; text-align: left; margin-top: 14px; } }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0 0 28px; padding: 0; list-style: none; }
.facts li { padding: 14px 16px 12px 0; }
.facts b { display: block; font: 600 2rem/1 var(--narrow); color: var(--spruce); font-variant-numeric: tabular-nums; }
.facts span { color: var(--muted); font-size: .875rem; }
.livebox { display: flex; align-items: center; gap: 14px; background: var(--paper); border: 2px solid var(--live); border-radius: 10px; padding: 12px 16px; margin-bottom: 24px; flex-wrap: wrap; }
.livebox strong { color: var(--live); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 28px; }

/* grafy */
.chart { width: 100%; height: auto; display: block; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; margin-bottom: 16px; }
.chart .grid { stroke: #E3E9E4; stroke-width: 1; }
.chart .axis { font: 11px var(--text); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--spruce); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--paper); stroke: var(--spruce); stroke-width: 2.5; }
.chart .dot.pb { fill: var(--bib); }
.chart .bar { fill: var(--spruce-2); }

/* formuláře */
label { font-size: .875rem; font-weight: 600; display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; padding: 9px 10px; border: 1px solid #B9C5BC; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; min-height: 42px; }
textarea { min-height: 140px; }
.form { display: grid; gap: 12px; max-width: 520px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; align-items: end; }
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.flash { background: var(--bib); color: var(--bib-ink); padding: 10px 14px; border-radius: 8px; font-weight: 600; max-width: none; }
.err { background: #FBE9E5; color: #7A2012; padding: 10px 14px; border-radius: 8px; max-width: none; }
.search { max-width: 360px; }
.inline { display: inline; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin: 0 0 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a[aria-current] { color: var(--spruce); border-bottom-color: var(--spruce); }

/* seznam závodníků */
.people { columns: 4 220px; column-gap: 24px; list-style: none; padding: 0; margin: 0; }
.people li { break-inside: avoid; padding: 3px 0; }
.people .muted { font-size: .85rem; }

/* startovka v telefonu */
.pick { list-style: none; margin: 0; padding: 0; }
.pick li { border-bottom: 1px solid #E8EDE9; }
.pick li:last-child { border-bottom: 0; }
.pick button { all: unset; box-sizing: border-box; display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 13px 14px; cursor: pointer; font-size: 1.05rem; }
.pick button:active { background: var(--tint); }
.pick button span.next { color: var(--muted); font-size: .85rem; white-space: nowrap; }

/* online výsledky */
.clock { font: 600 clamp(2.4rem, 10vw, 4rem)/1 var(--narrow); font-variant-numeric: tabular-nums; color: var(--spruce); }
.livehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 16px; }
.res tr.fresh td { animation: fresh 3.5s ease-out; }
@keyframes fresh { from { background: #FCEFB6; } to { background: transparent; } }
.oncourse { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; margin: 0 0 16px; padding: 0; }
.oncourse li { white-space: nowrap; }

/* stopky */
body.app { background: #fff; }
body.app .main { padding-top: 10px; padding-bottom: 24px; }
body.app .foot, body.app .adminbar { display: none; }
body.app .nav { display: none; }
body.app .brand { font-size: 1.1rem; padding-bottom: 8px; }
body.app .brand svg { width: 30px; height: 20px; }
.sw-top { position: sticky; top: 0; z-index: 5; background: #fff; padding: 6px 0 10px; border-bottom: 1px solid var(--rule); margin-bottom: 10px; }
/* čas stopek: stejné písmo jako odpočet do startu, jen o kousek menší */
.sw-clock { font: 700 clamp(4rem, 26vw, 8.5rem)/1 var(--narrow); font-variant-numeric: tabular-nums; color: var(--ink); text-align: center; letter-spacing: .01em; }
.sw-clock.long { font-size: clamp(3rem, 19vw, 6rem); }   /* přes hodinu je čas delší, zmenší se, aby se vešel */
.sw-status { display: flex; justify-content: space-between; gap: 10px; font-size: .85rem; color: var(--muted); }
.sw-status .bad { color: var(--live); font-weight: 700; }
.sw-stop { width: 100%; min-height: 84px; border: 0; border-radius: 14px; background: var(--live); color: #fff; font: 700 1.9rem var(--narrow); letter-spacing: .02em; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.sw-stop:active { filter: brightness(.85); }
.sw-go { background: var(--spruce); }
.sw-pending { background: var(--bib); color: var(--bib-ink); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-weight: 600; }
.sw-pending ol { margin: 4px 0 0; padding-left: 22px; font-variant-numeric: tabular-nums; }
.sw-pending button { all: unset; cursor: pointer; text-decoration: underline; margin-left: 10px; font-weight: 400; }
.bibs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin: 12px 0; }
.bibs button { border: 2px solid var(--spruce); background: #fff; color: var(--ink); border-radius: 12px; min-height: 68px; padding: 4px 2px; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.bibs button b { font: 700 1.8rem/1 var(--narrow); font-variant-numeric: tabular-nums; }
.bibs button small { font-size: .68rem; line-height: 1.15; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.bibs button:active { background: var(--bib); }
.bibs button.wait { border-color: var(--rule); color: #9AA69F; }
.bibs button.wait b { color: #9AA69F; }
.bibs.assign button { border-color: var(--bib); background: #FFFBEA; }
.sw-list { list-style: none; margin: 0; padding: 0; }
.sw-list li { display: grid; grid-template-columns: 2.6em 1fr auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid #E8EDE9; }
.sw-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-list .tm { font: 600 1.25rem/1 var(--narrow); font-variant-numeric: tabular-nums; text-align: right; }
.sw-list .tm small { display: block; font: 400 .72rem var(--text); color: var(--muted); }
.sw-list li.warn .nm { color: var(--live); }
.sw-list li.unsent .tm::after { content: " •"; color: var(--live); }
.sw-list button.rowbtn { all: unset; display: contents; cursor: pointer; }
.toast { position: fixed; left: 12px; right: 12px; bottom: 14px; background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; z-index: 20; box-shadow: 0 6px 24px rgba(21,35,28,.35); }
.toast button { all: unset; cursor: pointer; color: var(--bib); font-weight: 700; padding: 6px 8px; }
dialog { border: 0; border-radius: 14px; padding: 18px; width: min(420px, calc(100vw - 24px)); color: var(--ink); }
dialog::backdrop { background: rgba(21,35,28,.55); }
dialog h3 { margin-top: 0; }
dialog .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.starter { text-align: center; padding: 10px 0 20px; }
.starter .cd { font: 700 clamp(5rem, 34vw, 11rem)/1 var(--narrow); font-variant-numeric: tabular-nums; color: var(--spruce); }
.starter .cd.go { color: var(--live); }
.starter .nextname { font: 600 1.6rem var(--narrow); }
.starter ol { text-align: left; max-width: 340px; margin: 16px auto 0; padding: 0; list-style: none; color: var(--muted); }
.starter ol li { display: flex; gap: 10px; padding: 4px 0; align-items: center; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* tisk */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { background: #fff; font-size: 9.5pt; }
  .top, .adminbar, .foot, .noprint, .years, .seg, .tools { display: none !important; }
  .main { padding: 0 !important; }
  .wrap { max-width: none; padding: 0 !important; }
  .tablewrap { border: 0; overflow: visible; margin: 0; }
  .res td, .res th { padding: 2.5px 3px; border-bottom: .5pt solid #999; white-space: nowrap; }
  table.res { font-size: 9.5pt; }
  .res th { font-size: 8pt; }
  .res tr { break-inside: avoid; }
  .res tbody tr:nth-child(even) td { background: #E9E9E9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tag { font-size: 7pt; }
  .res td.time { font-size: 10.5pt; line-height: inherit; }
  .wide { display: table-cell !important; }
  h1 { font-size: 20pt; color: #000; }
  a { color: #000; text-decoration: none; }
  .tag.pb { border: .5pt solid #000; background: none; }
}
.pick button[disabled] { opacity: .5; cursor: default; }
.res td.grip { width: 1%; padding: 0 14px; font-size: 1.3rem; line-height: 44px; color: var(--muted); cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.res tr.tazeny td { background: #FCEFB6 !important; }
.res tr.tazeny td.grip { color: var(--ink); cursor: grabbing; }
body.taham { -webkit-user-select: none; user-select: none; cursor: grabbing; }

.sw-clock.stopped { color: var(--muted); }

.sw-stop small { display: block; font: 400 .95rem/1.2 var(--text); letter-spacing: 0; opacity: .9; margin-top: 2px; }

.foot-links { display: inline-flex; gap: 18px; }

/* stopky: tlačítko Zapsat čas zůstává pod časem, listuje se jen čísly a seznamem */
.sw-stopwrap { position: sticky; top: var(--sw-top-h, 150px); z-index: 4; background: #fff; padding: 2px 0 10px; margin-bottom: -2px; box-shadow: 0 8px 8px -8px rgba(21,35,28,.18); }
@media (max-height: 720px) { .sw-stopwrap .sw-stop { min-height: 68px; font-size: 1.6rem; } }

/* obrazovka startéra: čas, odpočet, počet zbývajících a tlačítko pípání drží nahoře, listuje se jen seznamem */
.st-fixed { position: sticky; top: 0; z-index: 5; background: #fff; padding-bottom: 10px; box-shadow: 0 8px 8px -8px rgba(21,35,28,.18); }
.st-fixed .sw-top { position: static; margin-bottom: 4px; }
.st-fixed .st-head { padding: 4px 0 0; }
.st-left { text-align: center; font-weight: 600; margin: 6px auto 8px; max-width: none; min-height: 1.5em; }
.st-soundrow { text-align: center; margin: 0; max-width: none; }
.starter.st-list { padding-top: 6px; }
.starter.st-list ol { margin-top: 6px; }
@media (max-height: 720px) { .st-fixed .cd { font-size: clamp(4rem, 26vw, 7rem); } .st-fixed .sw-clock { font-size: clamp(3rem, 19vw, 5rem); } }

/* spuštění z plochy telefonu jako aplikace: místo pro výřez displeje a spodní proužek */
.toast { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
body.app .main { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
