:root {
  --bg: #0b0d17;
  --panel: #141827;
  --panel-2: #1b2033;
  --line: #262c42;
  --text: #e8ecf7;
  --muted: #8b93ad;
  --accent: #7c8cff;
  --accent-2: #4cc9f0;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1d2440 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 28, 0.86);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px; color: #0b0d17;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: 0.2px; }
.brand .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: 0.15s;
}
.tab:hover { color: var(--text); background: #ffffff0d; }
.tab.active {
  color: var(--text);
  background: #ffffff14;
  border-color: var(--line);
}

.top-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: 0.15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #5a6bff);
  border-color: transparent;
  font-weight: 600;
}
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }

/* ---------- раскладка ---------- */
.main {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 22px 32px;
  flex: 1;
  align-items: start;
}

.panel.side {
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 88px;
}

.block, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.block-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.block-head h2, .card h2 { margin: 0; font-size: 15px; letter-spacing: 0.3px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }

.counter {
  font-size: 12px; color: var(--muted);
  background: #ffffff0f; padding: 2px 8px; border-radius: 20px;
}

.input {
  width: 100%;
  background: #0f1322;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
}
.input:focus { border-color: var(--accent); }

.row { display: flex; gap: 8px; margin-top: 8px; }
.row .input { flex: 1; }

.hint { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 8px 0 0; }

/* ---------- зона загрузки ---------- */
.drop-zone {
  border: 2px dashed #2f3a5c;
  border-radius: 12px;
  padding: 18px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
}
.drop-zone:hover, .drop-zone.over {
  border-color: var(--accent);
  color: var(--text);
  background: #7c8cff14;
}
.drop-zone small { font-size: 11px; opacity: 0.8; }

/* ---------- пул карточек ---------- */
.pool {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px;
  min-height: 40px;
  max-height: 260px;
  overflow-y: auto;
}

.pool-chip {
  position: relative;
  width: 52px; height: 52px;
  border-radius: 10px;
  overflow: hidden;
  background: #0f1322;
  border: 1px solid var(--line);
  cursor: grab;
  display: grid; place-items: center;
  font-size: 11px;
  text-align: center;
  padding: 2px;
}
.pool-chip img { width: 100%; height: 100%; object-fit: cover; }
.pool-chip .chip-emoji { font-size: 24px; line-height: 1; }
.pool-chip .chip-text { font-size: 10px; color: var(--muted); word-break: break-word; }
.pool-chip.dragging { opacity: 0.4; }
.pool-chip .chip-del {
  position: absolute; top: 1px; right: 1px;
  width: 16px; height: 16px; border-radius: 50%;
  border: none; background: #000000b0; color: #fff;
  font-size: 11px; line-height: 1; cursor: pointer;
  opacity: 0; transition: 0.15s;
}
.pool-chip:hover .chip-del { opacity: 1; }

/* ---------- тир-доска ---------- */
.tier-card { padding: 0; overflow: hidden; }
.tiers { display: flex; flex-direction: column; }

.tier-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 30px;
  border-bottom: 1px solid var(--line);
  min-height: 78px;
}

.tier-label {
  background: var(--tier-color);
  color: #101223;
  font-weight: 800;
  font-size: 18px;
  display: grid; place-items: center;
  cursor: pointer;
  user-select: none;
  position: relative;
  text-align: center;
  padding: 6px;
}
.tier-label i { font-style: normal; font-size: 12px; opacity: 0; position: absolute; bottom: 4px; right: 6px; }
.tier-label:hover i { opacity: 0.7; }

.tier-items {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 8px;
  min-height: 74px;
  align-content: flex-start;
  background: #10131f;
}
.tier-items.over { background: #7c8cff1f; }

.tier-items .pool-chip { width: 58px; height: 58px; }

.pool-empty { color: #4d5570; font-size: 12px; padding: 8px; }

.tier-del {
  border: none; background: transparent; color: #4d5570;
  cursor: pointer; font-size: 13px;
}
.tier-del:hover { color: #ff5d5d; }

.pool-drop {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px;
  min-height: 84px;
  background: #0d1019;
  align-content: flex-start;
}
.pool-drop.over { background: #7c8cff1f; }

/* ---------- редактор категорий ---------- */
.tiers-editor { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.tier-edit-row {
  display: flex; align-items: center; gap: 6px;
  background: #0f1322; border: 1px solid var(--line);
  border-radius: 9px; padding: 4px 6px;
}
.tier-edit-row input[type="text"] {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 13px; outline: none;
}
.tier-edit-row input[type="color"] {
  width: 26px; height: 22px; border: none; background: transparent; cursor: pointer; padding: 0;
}
.tier-edit-row button {
  border: none; background: transparent; color: #4d5570; cursor: pointer; font-size: 13px;
}
.tier-edit-row button:hover { color: #ff5d5d; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill {
  border: 1px solid var(--line);
  background: #0f1322;
  color: var(--muted);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
}
.pill:hover { border-color: var(--accent); color: var(--text); }
.pill.active { background: #7c8cff26; color: var(--text); border-color: var(--accent); }

/* ---------- оценка 1–100 ---------- */
.work { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.view { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }

.score-head, .bracket-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.s-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.score-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex; gap: 10px; align-items: flex-start;
}
.score-rank {
  font-weight: 800; font-size: 13px; color: var(--muted);
  width: 22px; text-align: center;
}
.score-thumb {
  width: 44px; height: 44px; border-radius: 9px; overflow: hidden;
  background: #0f1322; display: grid; place-items: center; flex: none;
  font-size: 20px;
}
.score-thumb img { width: 100%; height: 100%; object-fit: cover; }
.score-main { flex: 1; min-width: 0; }
.score-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.score-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-value { color: var(--accent-2); font-weight: 700; }
.score-bar { height: 5px; background: #0f1322; border-radius: 4px; margin: 6px 0 4px; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.score-main input[type="range"] { width: 100%; accent-color: var(--accent); }

.empty-note {
  grid-column: 1 / -1;
  color: var(--muted); font-size: 13px; padding: 24px; text-align: center;
  border: 1px dashed var(--line); border-radius: 12px;
}

/* ---------- турнир ---------- */
.bracket { overflow-x: auto; padding-bottom: 6px; }
.bracket-rounds { display: flex; gap: 16px; min-width: max-content; align-items: flex-start; }
.round { display: flex; flex-direction: column; gap: 10px; min-width: 168px; }
.round h4 { margin: 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }

.match {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
}

.duel {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px; border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.15s;
  background: #0f1322;
}
.duel:hover { border-color: var(--accent); }
.duel-img {
  width: 34px; height: 34px; border-radius: 8px; overflow: hidden;
  background: #171b2c; display: grid; place-items: center; flex: none;
  font-size: 12px; color: var(--muted);
}
.duel-img img { width: 100%; height: 100%; object-fit: cover; }
.duel-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel.win { background: #7ee7872e; border-color: #7ee787; }
.duel.lose { opacity: 0.42; }

.rank-list { margin: 0; padding-left: 20px; font-size: 13px; color: var(--muted); }
.rank-list li { padding: 3px 0; }
.rank-list li.champ { color: #ffd166; font-weight: 700; }

/* ---------- облако ---------- */
.cloud-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.cloud-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.cloud-card h3 { margin: 0; font-size: 14px; }
.cloud-meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.cloud-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.cloud-chip {
  width: 28px; height: 28px; border-radius: 7px; overflow: hidden;
  background: #0f1322; display: grid; place-items: center; font-size: 15px;
}
.cloud-chip img { width: 100%; height: 100%; object-fit: cover; }
.cloud-actions { display: flex; gap: 6px; margin-top: auto; }

/* ---------- футер и тост ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 10px 22px;
  font-size: 12px;
  color: var(--muted);
  display: flex; gap: 8px;
}

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translate(-50%, 20px);
  background: #1d2440;
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.22s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .main { grid-template-columns: 1fr; }
  .panel.side { position: static; }
  .tier-row { grid-template-columns: 74px minmax(0, 1fr) 26px; }
}
