:root {
  /* тёмная тема по умолчанию (как у Dotabuff/STRATZ); светлая — кнопкой в шапке (data-theme="light") */
  color-scheme: dark;
  --bg: #0f1217;
  --panel: #171b22;
  --panel-2: #1e232c;
  --text: #e6e8ec;
  --muted: #9aa3b5;
  --line: #2a303b;
  --accent: #e0745f;
  --accent-soft: #3a2420;
  --strong: #4ade80;
  --weak: #f87171;
  --ours: #7aa2ff;
  --theirs: #fb923c;
  --chip: #252a34;
  --gold: #e5b85c;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f3f4f7;
  --text: #1d2128;
  --muted: #677084;
  --line: #e1e4ea;
  --accent: #b8432f;
  --accent-soft: #fbeae6;
  --strong: #1f7a3f;
  --weak: #b42318;
  --ours: #1d4ed8;
  --theirs: #9a3412;
  --chip: #eef0f4;
  --gold: #a16207;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--ours); text-decoration: none; }
a:hover { text-decoration: underline; }

header.top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 8px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topline { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; }
.status { color: var(--muted); font-size: 12px; margin-left: auto; display: flex; gap: 12px; align-items: center; }
.status form { margin: 0; }
.status button { font-size: 12px; }

nav.menu { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
nav.menu a, nav.menu summary {
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
nav.menu a.active, nav.menu a:hover { background: var(--chip); text-decoration: none; }
nav.menu a.cta { background: var(--accent); color: #fff; font-weight: 600; }
nav.menu details { position: relative; }
nav.menu details[open] .dropdown { display: flex; }
nav.menu .dropdown {
  display: none;
  flex-direction: column;
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px;
  min-width: 160px;
}

main { padding: 16px; max-width: 1400px; margin: 0 auto; }

h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 22px 0 8px; }
h3 { font-size: 15px; margin: 16px 0 6px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.grid-wide { display: grid; grid-template-columns: repeat(auto-fit, minmax(600px, 1fr)); gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; cursor: pointer; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--chip); }
.table-wrap { overflow-x: auto; }

.strong { color: var(--strong); font-weight: 600; }
.weak { color: var(--weak); font-weight: 600; }
.ours { color: var(--ours); font-weight: 600; }
.theirs { color: var(--theirs); }

.chip {
  display: inline-block;
  background: var(--chip);
  border-radius: 10px;
  padding: 1px 8px;
  margin: 1px 2px 1px 0;
  white-space: nowrap;
}
.chip.strong { color: var(--strong); }
.chip.ban { text-decoration: line-through; color: var(--muted); }

.draft-strip { display: flex; flex-wrap: wrap; gap: 3px; }
.draft-strip .step { border-radius: 4px; padding: 1px 6px; font-size: 12px; border: 1px solid var(--line); }
.draft-strip .step.ours { border-color: var(--ours); }
.draft-strip .step.ban { color: var(--muted); text-decoration: line-through; }
.draft-strip .step.pick { font-weight: 600; }

.warnings { background: var(--accent-soft); border-color: var(--accent); }
.warnings li { margin: 2px 0; }

.plan table { width: auto; }
.plan blockquote { color: var(--muted); border-left: 3px solid var(--line); margin: 0; padding-left: 10px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs a { padding: 3px 10px; border-radius: 6px; background: var(--chip); color: var(--text); }
.tabs a.active { background: var(--accent); color: #fff; }

input[type=search], input[type=text], select {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}
button {
  font: inherit;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--chip);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

@media (max-width: 700px) {
  .grid2, .grid-wide { grid-template-columns: 1fr; }
  main { padding: 10px; }
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- драфт */
.draft-setup { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.draft-setup .spacer { flex: 1; }
.turn { font-weight: 700; font-size: 16px; padding: 3px 10px; border-radius: 6px; }
.turn.ours-turn { background: var(--ours); color: #fff; }
.turn.their-turn { background: var(--theirs); color: #fff; }
#search { width: min(520px, 100%); font-size: 16px; }

.draft-board { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.draft-board .side h3 { margin-top: 0; }
.draft-board .chips { margin-bottom: 6px; }
.assign { padding: 2px 0; }
.remaining { margin-top: 6px; }

.draft-advice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.draft-advice .panel.focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.draft-advice h3 { margin-top: 0; }
ol.advice { margin: 0; padding-left: 20px; }
ol.advice li { margin: 3px 0; }
.reason { font-size: 11px; color: var(--muted); background: var(--chip); border-radius: 8px; padding: 0 6px; white-space: nowrap; }
.hero-pick { padding: 1px 6px; font-weight: 600; }

.hero-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.hero-grid .hero { margin: 1px; padding: 2px 6px; font-size: 12px; }
.hero-grid .hero:disabled { opacity: 0.3; text-decoration: line-through; cursor: default; }
.hero-grid .hero.match { border-color: var(--accent); background: var(--accent-soft); }

/* лента 24 ходов: клик по сделанному ходу — исправить */
.ribbon-panel { padding: 8px; }
.ribbon { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; }
.ribbon .slot { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 3px 5px; min-width: 0;
  font-size: 12px; text-align: left; border-width: 1px 1px 1px 4px; background: var(--panel-2); min-height: 44px; }
.ribbon .slot.ours { border-left-color: var(--ours); }
.ribbon .slot.theirs { border-left-color: var(--theirs); }
.ribbon .slot .kind { font-size: 10px; color: var(--muted); white-space: nowrap; }
.ribbon .slot .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ribbon .slot.ban .who, .ribbon .slot.ban img { text-decoration: line-through; opacity: 0.55; filter: grayscale(0.8); }
.ribbon .slot.pick .who { font-weight: 600; }
.ribbon .slot .hero-ico { width: 18px; height: 18px; }
.ribbon .slot.current { outline: 2px solid var(--accent); }
.ribbon .slot.editing { outline: 2px dashed var(--accent); background: var(--accent-soft); }
.ribbon .slot:disabled { cursor: default; }
.ribbon .slot.future { opacity: 0.5; }
.ribbon-hint { margin-top: 4px; }

/* три колонки как в клиенте: мы | сейчас | они */
.draft-main { display: grid; grid-template-columns: minmax(260px, 300px) minmax(0, 1fr) minmax(280px, 340px); gap: 12px; align-items: start; }
.draft-main .side h3 { margin: 0 0 8px; }
.draft-main .center { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.draft-main .center .panel { margin-bottom: 12px; }
.slots { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.pslot { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--panel-2); }
.ours-side .pslot.picked { border-left: 3px solid var(--ours); }
.their-side .pslot.picked { border-left: 3px solid var(--theirs); }
.slot-hero { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.hero-portrait.empty { display: inline-block; border: 1px dashed var(--line); background: transparent; }
.slot-player { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.slot-player .pos { font-weight: 700; color: var(--muted); width: 12px; }
.slot-player .nick { font-size: 14px; }
.slot-assign { font-size: 11px; padding: 1px 3px; margin-left: auto; max-width: 110px; }
.recent { margin-top: 3px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; }
.recent .mini { display: inline-flex; align-items: center; gap: 2px; color: var(--text); }
.recent .hero-ico { width: 18px; height: 18px; }
.odds { margin-top: 3px; }
.ban-row { display: flex; flex-wrap: wrap; gap: 3px; }
.ban-chip .hero-ico { width: 26px; height: 26px; filter: grayscale(1); opacity: 0.6; }

.search-panel { position: relative; }
#search { width: 100%; font-size: 16px; }
.suggest { list-style: none; margin: 4px 0 0; padding: 0; }
.suggest li { padding: 3px 8px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.suggest li.sel { background: var(--accent-soft); outline: 1px solid var(--accent); }
.warn { margin-top: 6px; padding: 6px 10px; border-radius: 6px; background: var(--accent-soft);
  border: 1px solid var(--accent); font-weight: 600; }
.advice-panel.focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.advice-panel:not(.focus) { opacity: 0.85; }
.advice-panel h3 { margin-top: 0; }
.hero-pick { display: inline-flex; align-items: center; gap: 5px; }
.reason.more { cursor: help; }

.hint { font-size: 11px; font-weight: 400; color: var(--muted); }
button.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 600; display: inline-flex;
  align-items: center; gap: 3px; }
button.nick { color: var(--text); }
button.nick:hover { color: var(--accent); }
.small-btn { font-size: 12px; padding: 2px 8px; margin-left: 8px; }
#lanes td, #lanes th { padding: 3px 8px; }

/* сетка героев портретами, как в клиенте */
.hero-grid .tiles { display: flex; flex-wrap: wrap; gap: 4px; }
.hero-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px; width: 70px;
  background: var(--panel-2); font-size: 10px; line-height: 1.1; }
.hero-tile span { max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-tile:disabled { opacity: 0.25; filter: grayscale(1); cursor: default; }
.hero-tile.match { border-color: var(--accent); background: var(--accent-soft); }

/* боковая карточка игрока */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 96vw); background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35); padding: 14px 16px; overflow-y: auto; z-index: 50; }
.drawer-close { position: absolute; top: 10px; right: 12px; }
.drawer h3 { margin-top: 0; padding-right: 40px; }
.drawer h4 { margin: 14px 0 4px; }
table.compact td, table.compact th { padding: 2px 6px; }

@media (max-width: 1100px) {
  .draft-main { grid-template-columns: 1fr; }
  .ribbon { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------- вход */
main.login { max-width: 360px; margin: 12vh auto; }
main.login form { display: flex; flex-direction: column; gap: 10px; }
main.login h1 { margin: 0; }
main.login input[type=password] { font-size: 16px; padding: 8px 10px; }

/* ---------------------------------------------------------------- герои и игроки */
.hero-tag { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.hero-ico { width: 20px; height: 20px; border-radius: 3px; object-fit: cover; vertical-align: middle; flex: none; }
.hero-ico.fallback { display: inline-grid; place-items: center; background: var(--chip); color: var(--muted);
  font-size: 9px; font-weight: 700; }
.hero-portrait { width: 64px; height: 36px; border-radius: 4px; object-fit: cover; flex: none; background: var(--chip); }
.profiles { display: inline-flex; gap: 3px; vertical-align: middle; }
.profiles a { font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 4px; background: var(--chip);
  color: var(--muted); line-height: 16px; }
.profiles a:hover { color: var(--text); text-decoration: none; }
.rank { position: relative; display: inline-block; width: 24px; height: 24px; vertical-align: middle; }
.rank-ico { width: 24px; height: 24px; }
.rank-star { position: absolute; left: 0; top: 0; width: 24px; height: 24px; }
.theme-toggle { font-size: 12px; }

/* ---------------------------------------------------------------- контрпики */
.counters-form { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; }
.counters-form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.counters-form input { min-width: 200px; }
.counters-form p { flex-basis: 100%; margin: 0; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.lane-options { list-style: none; margin: 0; padding: 0; }
.lane-options > li { margin-bottom: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.lane-options .who { font-size: 13px; color: var(--muted); min-width: 150px; }
#lane-box { margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.grid3 td.num { white-space: nowrap; }
.stage { margin: 0 0 12px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 4px; }
/* ---------------------------------------------------------------- состав на игру */
.lineup summary { cursor: pointer; }
.lineup-form { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: end; margin-top: 10px; }
.lineup-form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.lineup-buttons { display: flex; gap: 8px; }
