:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #eef1f8; --text: #121a2f; --muted: #5d6781;
  --line: #dfe4f0; --accent: #2f5bff; --accent-ink: #ffffff; --accent-soft: #e6ecff;
  --pos: #0f9d58; --pos-soft: #def6e9; --neg: #d93a3a; --neg-soft: #fde6e6; --gold: #f5c518;
  --shadow: 0 1px 2px rgba(18,26,47,.05), 0 8px 28px rgba(18,26,47,.07);
  --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111f; --surface: #151c30; --surface-2: #1c2540; --text: #eef1fb; --muted: #97a2c0;
    --line: #26304f; --accent: #6b8bff; --accent-ink: #0c111f; --accent-soft: #1d2a55;
    --pos: #3ddc8a; --pos-soft: #12372a; --neg: #ff6b6b; --neg-soft: #3d1a22;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.hero { padding: 40px 0 28px; }
.badge {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); padding: 5px 12px; border-radius: 999px;
}
.badge i { width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(90deg, var(--accent) 50%, var(--gold) 50%); }
h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.1; margin: 16px 0 10px; letter-spacing: -.02em; }
.lead { color: var(--muted); max-width: 640px; margin: 0; font-size: 17px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 20px; }
.card h2 { font-size: 18px; margin: 0 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }

.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field.is-disabled { opacity: .5; }
input[type=text], input[type=number] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1.5px solid transparent;
  border-radius: 12px; padding: 11px 13px; outline: none; transition: border-color .15s, background .15s;
}
input:focus { border-color: var(--accent); background: var(--surface); }
input:disabled { cursor: not-allowed; }
.stepper { display: flex; gap: 6px; }
.stepper button { flex: none; width: 42px; }

button { font: inherit; cursor: pointer; }
.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600; background: var(--surface-2); color: var(--text);
  transition: transform .1s, background .15s;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); padding: 6px 10px; font-size: 14px; }
.btn:focus-visible, input:focus-visible, .seg label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.note { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 14px; }
.note b { font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; }

.matches { display: grid; gap: 10px; }
.match {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 92px auto 44px 40px; gap: 10px; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
}
.num { font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; padding: 8px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); transition: all .15s; white-space: nowrap; }
.seg input[value=win]:checked + span { background: var(--pos); color: #fff; }
.seg input[value=lose]:checked + span { background: var(--neg); color: #fff; }
.contrib {
  text-align: center; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; padding: 6px 0; border-radius: 10px;
  background: var(--surface-2); color: var(--muted);
}
.contrib[data-sign=pos] { background: var(--pos-soft); color: var(--pos); }
.contrib[data-sign=neg] { background: var(--neg-soft); color: var(--neg); }
.icon { border: 0; background: transparent; color: var(--muted); border-radius: 10px; height: 40px; font-size: 18px; }
.icon:hover { background: var(--neg-soft); color: var(--neg); }
.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.result { position: sticky; top: 16px; }
.result .big { font-size: 64px; line-height: 1; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 6px 0 4px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
[data-sign=pos] { color: var(--pos); } [data-sign=neg] { color: var(--neg); }
.warn { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--neg-soft); color: var(--neg); font-size: 14px; }

.doc { margin-top: 28px; }
.doc .card { padding: 28px; }
.doc h2 { font-size: clamp(22px, 3.5vw, 28px); margin: 0 0 6px; letter-spacing: -.01em; display: block; }
.doc h3 { font-size: 18px; margin: 30px 0 8px; }
.doc p, .doc li { color: var(--muted); max-width: 72ch; }
.doc p { margin: 8px 0; } .doc ul { padding-left: 20px; margin: 8px 0; }
.doc strong, .doc b { color: var(--text); }
.formula {
  margin: 12px 0; padding: 14px 18px; border-radius: 14px; background: var(--surface-2); border-left: 4px solid var(--accent);
  font: 500 17px/1.7 "Cambria Math", "STIX Two Math", Georgia, serif; color: var(--text); overflow-x: auto; white-space: nowrap;
}
.formula small { display: block; font: 13px/1.4 system-ui, sans-serif; color: var(--muted); margin-top: 4px; white-space: normal; }
.tbl-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; min-width: 420px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font-size: 13px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.example { background: var(--accent-soft); border-radius: 14px; padding: 16px 18px; margin: 12px 0; }
.example p, .example li { color: var(--text); }
.faq details { border-top: 1px solid var(--line); padding: 14px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; font-size: 16px; list-style: none; display: flex; justify-content: space-between; gap: 12px; min-height: 28px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 22px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 10px 0 0; }
.hero-link { display: inline-block; margin-top: 14px; color: var(--accent); font-weight: 600; text-decoration: none; }
.hero-link:hover { text-decoration: underline; }

/* Нижня панель результату на телефонах */
.bar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; align-items: center; gap: 14px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(18,26,47,.12); transform: translateY(0); transition: transform .2s;
}
.bar.is-hidden { transform: translateY(110%); }
.bar .b-main { flex: 1; min-width: 0; }
.bar .b-main small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.bar .b-main b { font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bar .b-delta { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.bar .btn { min-height: 44px; }
footer { color: var(--muted); font-size: 14px; padding: 36px 0 48px; }
footer a { color: var(--accent); }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .result { position: static; }
  .bar { display: flex; }
  body { padding-bottom: 84px; }
}
@media (max-width: 640px) {
  .hero { padding: 24px 0 16px; }
  .card { padding: 16px; }
  .doc .card { padding: 18px; }
  .fields { grid-template-columns: 1fr 1fr; gap: 10px; }
  .fields .field:first-child { grid-column: 1 / -1; }
  input[type=text], input[type=number] { min-height: 48px; font-size: 16px; }
  .match {
    grid-template-columns: 24px 84px minmax(0, 1fr) 48px;
    grid-template-areas: "n name name del" "n rate seg c";
    gap: 8px; padding: 10px 8px;
  }
  .match .num { grid-area: n; } .match .name { grid-area: name; } .match .rate { grid-area: rate; }
  .match .seg { grid-area: seg; display: flex; } .match .seg label { flex: 1; }
  .match .seg span { text-align: center; padding: 12px 2px; font-size: 13px; }
  .match { grid-template-columns: 22px 80px minmax(0, 1fr) 44px; }
  .match .contrib { grid-area: c; padding: 12px 0; }
  .match .delete { grid-area: del; height: 48px; width: 48px; }
  .actions .btn { min-height: 48px; }
  .actions .primary { flex: 1; }
  .result .big { font-size: 52px; }
  .formula { font-size: 15px; padding: 12px 14px; }
}
@media (hover: none) { .link:hover, .btn:hover { transform: none; } }

.keys { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -4px 0 14px; font-size: 13px; color: var(--muted); }
.keys span { display: inline-flex; align-items: center; gap: 5px; }
kbd {
  font: 600 12px/1 system-ui, sans-serif; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; min-width: 22px; text-align: center;
}
@media (hover: none) { .keys { display: none; } }
input::placeholder { color: var(--muted); opacity: .55; }

/* Пошук гравців і швидкий ввід */
.search-me { margin-bottom: 16px; }
.meta { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.meta b { color: var(--text); }
.bulk { margin-bottom: 16px; }
.bulk-row { display: flex; gap: 8px; }
.bulk-row input { flex: 1; min-width: 0; }
.bulk-row .btn { flex: none; }
.bulk .hint { margin: 8px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips:empty { display: none; }
.chip { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.win { background: var(--pos-soft); color: var(--pos); }
.chip.lose { background: var(--neg-soft); color: var(--neg); }
.chip.err { background: var(--neg-soft); color: var(--neg); outline: 1px dashed var(--neg); }
.chip.warn { outline: 1px dashed var(--muted); }
.src { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.dd {
  position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(18,26,47,.22); overflow: hidden; max-height: min(340px, 55vh); overflow-y: auto;
}
.dd-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 14px; cursor: pointer; align-items: center; }
.dd-item[aria-selected=true], .dd-item:hover { background: var(--accent-soft); }
.dd-item b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-item small { grid-column: 1; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-item .r { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.dd-item .r i { display: block; font-style: normal; font-weight: 500; font-size: 11px; color: var(--muted); }
.dd-empty { padding: 12px 14px; color: var(--muted); font-size: 14px; }
@media (max-width: 640px) { .bulk-row .btn { min-height: 48px; } .dd-item { padding: 12px 14px; } }
