:root {
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --surface-2: #EFEFF4;
  --segment-bg: #E4E4EA;
  --border: rgba(60,60,67,0.13);
  --border-strong: rgba(60,60,67,0.26);
  --text: #1C1C1E;
  --text-soft: #6E6E73;
  --text-faint: #8E8E93;

  --accent: #0A84FF;
  --accent-deep: #0066CC;
  --accent-soft: rgba(10,132,255,0.12);

  --benefit: #34C759;
  --benefit-deep: #248A3D;
  --risk: #FF3B30;
  --risk-deep: #D70015;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .display {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100svh; /* mobilní prohlížeče: skutečná výška bez schované adresní lišty */
  min-height: 100dvh; /* reaguje i na dynamické schovávání/zobrazování lišty */
  display: flex;
  flex-direction: column;
  /* V nainstalované appce (standalone/PWA) se kreslí obsah přes celou obrazovku
     včetně výřezu/notch a spodního "home indicatoru" – bez tohoto odstupu by
     horní lišta kolidovala se stavovým řádkem telefonu. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 8px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.brand .crest {
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 3px 8px;
  letter-spacing: 0.01em;
}

.brand h1 {
  font-size: 20px;
  color: var(--text);
  font-weight: 700;
}

.who {
  text-align: right;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.3;
}

.who button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  padding: 2px 0 0;
  cursor: pointer;
}

/* ---------- Segmented nav (styl iOS segmented control) ---------- */
.segmented {
  display: flex;
  background: var(--segment-bg);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  margin: 6px 16px 4px;
}
.segmented button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.16);
}

/* ---------- Generic layout ---------- */
.screen { padding: 12px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }

.round-pill {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
}
.round-pill.closed { border-color: rgba(255,59,48,0.4); color: var(--risk-deep); }

.round-desc {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.4;
  margin: 8px 2px 0;
  white-space: pre-wrap;
}

.card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h2 { font-size: 18px; color: var(--text); }
.card .subtitle { font-size: 13px; color: var(--text-soft); margin-top: 4px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }

/* ---------- Player list ---------- */
#peers-list, #rounds-list, #users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font: inherit;
  box-shadow: var(--shadow);
}
.player-row:active { background: var(--surface-2); }

.player-row .name { font-size: 15px; font-weight: 600; }

.player-row .status { font-size: 12px; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status.done { background: rgba(52,199,89,0.12); color: var(--benefit-deep); }
.status.todo { background: rgba(10,132,255,0.12); color: var(--accent-deep); }

/* ---------- Sliders ---------- */
.field { margin-top: 22px; }
.field:first-child { margin-top: 0; }

.field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.field .value-chip {
  font-size: 16px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 8px;
  color: #fff;
}
.value-chip.benefit { background: var(--benefit-deep); }
.value-chip.risk { background: var(--risk-deep); }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  border: none; /* barevný okraj dřív dělal skutečný CSS border, což zmenšovalo
                   dráhu, po které puk jezdí – puk pak na krajích nedojel přes
                   zaoblený roh. Barvu teď kreslíme uvnitř dráhy (box-shadow). */
  outline: none;
  margin: 0; /* Safari dává range inputu defaultní margin, což posouvá dráhu ovladače */
  padding: 0;
  background: transparent;
}
input[type="range"].benefit { background: #E4F8E9; }
input[type="range"].risk { background: #FDEAEA; }

/* Reset defaultní dráhy: bez tohohle si prohlížeč u pseudo-elementu dráhy
   nechává vlastní neviditelný margin/padding a "border-radius: inherit" se
   navíc mezi enginy chová nespolehlivě – proto vše nastavujeme explicitně,
   ne přes dědění. */
input[type="range"]::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 999px;
  box-sizing: border-box;
}
input[type="range"].benefit::-webkit-slider-runnable-track { box-shadow: inset 0 0 0 2px var(--benefit); }
input[type="range"].risk::-webkit-slider-runnable-track { box-shadow: inset 0 0 0 2px var(--risk); }

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 999px;
  box-sizing: border-box;
}
input[type="range"].benefit::-moz-range-track { box-shadow: inset 0 0 0 2px var(--benefit); }
input[type="range"].risk::-moz-range-track { box-shadow: inset 0 0 0 2px var(--risk); }

/* Bílý "puk" bez barevného obrysu, aby nesplýval a nepřekrýval se s fokusem */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  /* Když je appearance:none i na track, Safari/Chrome přestanou puk
     automaticky vystřeďovat na ose – dopočítáno ručně: (výška osy 12px − výška puku 30px) / 2 */
  margin-top: -9px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.06);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; border: none; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.06);
}
/* Fokus po tažení slideru: jemný prstenec, ne velký rámeček přes celý track */
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft), 0 1px 4px rgba(0,0,0,0.35); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--accent-soft), 0 1px 4px rgba(0,0,0,0.35); }

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-top: 8px;
}
.scale-end { display: inline-flex; align-items: baseline; }
.scale-end small { font-size: 11px; font-weight: 600; color: var(--text-faint); }

.field textarea {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px; /* 16px = iOS Safari nezvětšuje stránku automaticky po kliknutí do pole */
  line-height: 1.35;
  resize: vertical;
  min-height: 52px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.15s, background-color 0.15s;
}
.field textarea::placeholder { color: var(--text-faint); font-size: 13px; line-height: 1.35; }
.field textarea.invalid { border-color: var(--risk); background: #FDEAEA; }
.field textarea.invalid::placeholder { color: var(--risk-deep); font-size: 13px; font-weight: 700; line-height: 1.35; }
.field textarea:focus, select:focus, .pin-input:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.field .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 18px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-deep); }
.btn.ghost { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; margin-top: 0; }
.btn.danger { background: var(--risk); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 0; }

.msg { font-size: 13px; padding: 10px 12px; border-radius: var(--radius-sm); }
.msg.error { background: rgba(255,59,48,0.1); color: var(--risk-deep); }
.msg.ok { background: rgba(52,199,89,0.1); color: var(--benefit-deep); }

/* ---------- Login ---------- */
.login-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}
.login-brand .crest {
  font-size: 22px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 6px 12px;
}
.login-brand .brand-word { font-size: 28px; font-weight: 700; color: var(--text); }

select, .pin-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 16px; /* 16px = iOS Safari nezvětšuje stránku automaticky po kliknutí do pole */
  background: var(--surface-2);
  color: var(--text);
  margin-top: 6px;
}

/* ---------- Coach: souhrn – karta na hráčku, hlavní číslo + dva zdrojové údaje ---------- */
.summary-grid { display: flex; flex-direction: column; gap: 10px; }

.player-summary-row {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.player-summary-row .row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15.5px;
  font-weight: 700;
  margin-bottom: 12px;
}
.player-summary-row .chevron { color: var(--text-faint); font-size: 18px; font-weight: 400; }

.stat-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-group { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat-group .stat-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint); font-weight: 700; margin-bottom: 3px;
}
.stat-group .stat-total { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-group .stat-total.pos { color: var(--benefit-deep); }
.stat-group .stat-total.neg { color: var(--risk-deep); }
.stat-group .stat-total.zero { color: var(--text-soft); }
.stat-group .stat-total.muted { color: var(--text-faint); font-size: 16px; font-weight: 600; }
.stat-group .stat-parts { font-size: 11.5px; color: var(--text-soft); margin-top: 3px; }
.stat-group .stat-count { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }

/* ---------- Coach: akordeon (detail hráčky) ---------- */
.accordion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 16px;
  box-shadow: var(--shadow);
}
.accordion summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after {
  content: '›';
  color: var(--text-faint);
  font-size: 18px;
  transform: rotate(90deg);
  transition: transform .15s ease;
}
.accordion[open] summary::after { transform: rotate(270deg); }
.accordion .count-badge { color: var(--text-faint); font-weight: 600; font-size: 12.5px; margin-left: 4px; }

.rating-card { padding: 10px 0; border-top: 1px solid var(--border); }
.rating-card:first-child { border-top: none; }
.rating-card-name { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.rating-card-row { display: flex; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.rating-card-row .num { font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.rating-card-row .num.benefit { color: var(--benefit-deep); }
.rating-card-row .num.risk { color: var(--risk-deep); }
.rating-card-row .num.pos { color: var(--benefit-deep); }
.rating-card-row .num.neg { color: var(--risk-deep); }
.rating-card-row .num.zero { color: var(--text-soft); }
.rating-card-note { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.empty-state.small { padding: 14px 0; font-size: 13px; text-align: left; }

/* ---------- Coach: karty kol (Kola) ---------- */
.round-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.round-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.round-card-head .name { font-weight: 700; font-size: 15px; }
.round-pill-small {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: rgba(52,199,89,0.12); color: var(--benefit-deep); font-weight: 600;
}
.round-pill-small.closed { background: rgba(255,59,48,0.1); color: var(--risk-deep); }
.round-card-desc { font-size: 12.5px; color: var(--text-soft); margin-top: 6px; }
.round-card .field { margin-top: 12px; }
.round-card .btn-row { margin-top: 12px; }

/* ---------- Coach: tabulka podrobných záznamů ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11.5px; color: var(--text-soft); }
td.note { white-space: normal; min-width: 160px; font-size: 12.5px; color: var(--text-soft); }
td.num { font-weight: 700; }
td.num.pos { color: var(--benefit-deep); }
td.num.neg { color: var(--risk-deep); }

.empty-state { text-align: center; color: var(--text-faint); padding: 40px 20px; font-size: 14px; }

.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.01em; color: var(--text-soft); }
