/* ═══ Полигон/dbd — дизайн-токены ═══
   Ночь у костра: тёмный лес, зола, уголёк.
   Сигнатура — дуальность: шалфей выживших / ржавчина маньяка. */

:root {
  --night: #131110;
  --ash: #1d1a17;
  --ash-2: #262220;
  --line: #35302b;
  --fog: #8f887e;
  --bone: #e9e2d6;
  --ember: #e8842c;
  --ember-dim: #a35d1f;
  --surv: #7fb8a4;
  --surv-dim: #2b4038;
  --kill: #c14e38;
  --kill-dim: #46271f;
  --danger: #d4553f;
  --ok: #7fb87f;
  --r: 12px;
  --font-display: 'Unbounded', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --font-data: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; background: var(--night); color: var(--bone);
  font: 16px/1.6 var(--font-body);
  min-height: 100vh; display: flex; flex-direction: column;
}
body::before { /* туман у линии горизонта */
  content: ''; position: fixed; inset: auto 0 0 0; height: 40vh; pointer-events: none;
  background: linear-gradient(to top, rgba(143,136,126,.05), transparent); z-index: 0;
}
a { color: inherit; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(22px, 4vw, 34px); letter-spacing: .01em; }
h2 { font-size: clamp(17px, 2.6vw, 22px); }
h3 { font-size: 15px; font-weight: 500; }

:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Шапка ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--night) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffc26b, var(--ember) 55%, #7a3d10);
  box-shadow: 0 0 14px 2px rgba(232, 132, 44, .45);
}
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .06em; }
.brand-text em { font-style: normal; color: var(--fog); font-weight: 500; }
.topnav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topnav a, .topnav button {
  text-decoration: none; color: var(--fog); background: none; border: 0;
  padding: 7px 12px; border-radius: 8px; font-weight: 500; font-size: 14px;
}
.topnav a:hover, .topnav button:hover { color: var(--bone); background: var(--ash); }
.topnav .nav-cta {
  color: var(--night); background: var(--ember); font-weight: 700;
}
.topnav .nav-cta:hover { background: #f2963f; color: var(--night); }
.nav-user { display: flex; align-items: center; gap: 8px; color: var(--bone); font-size: 14px; padding: 4px 8px; }
.nav-user img { width: 26px; height: 26px; border-radius: 50%; }

/* ── Каркас страницы ── */
.view { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: clamp(20px, 4vw, 40px) 16px 64px; position: relative; z-index: 1; }
.footer {
  border-top: 1px solid var(--line); color: var(--fog); font-size: 13px;
  padding: 18px clamp(16px, 4vw, 40px);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.footer-duo i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 5px 0 8px; }
.d-surv { background: var(--surv); } .d-kill { background: var(--kill); }

/* ── Лента турниров ── */
.feed-section { margin-bottom: 40px; }
.feed-label {
  font-family: var(--font-data); font-size: 12px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--fog); margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px;
}
.feed-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.tcard {
  display: block; text-decoration: none; background: var(--ash);
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; margin-bottom: 22px;
  transition: border-color .18s, transform .18s;
}
.tcard:hover { border-color: var(--ember-dim); transform: translateY(-2px); }
.tcard-head { padding: 18px 22px 14px; }
.tcard-eyebrow {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  font-family: var(--font-data); font-size: 12px; color: var(--fog);
}
.tcard-title { font-family: var(--font-display); font-size: clamp(18px, 3vw, 24px); font-weight: 700; }
.tcard-cover { aspect-ratio: 21/9; background: var(--ash-2); position: relative; overflow: hidden; }
.tcard-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tcard-cover .cover-fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  background:
    radial-gradient(ellipse 60% 90% at 50% 115%, rgba(232,132,44,.16), transparent),
    repeating-linear-gradient(105deg, transparent 0 34px, rgba(53,48,43,.5) 34px 35px);
  color: var(--line); font-family: var(--font-display); font-size: 40px; font-weight: 700;
}
.tcard-body { padding: 14px 22px 18px; color: var(--fog); font-size: 15px; }
.tcard-meta {
  display: flex; gap: 18px; flex-wrap: wrap; padding: 0 22px 16px;
  font-family: var(--font-data); font-size: 13px; color: var(--fog);
}

/* статусная полоса — тлеющий уголёк для «идёт сейчас» */
.status-strip { height: 3px; background: var(--line); }
.status-strip.announced { background: linear-gradient(90deg, var(--ember-dim), var(--line)); }
.status-strip.running {
  background: linear-gradient(90deg, #7a3d10, var(--ember), #ffc26b, var(--ember), #7a3d10);
  background-size: 220% 100%;
  animation: smolder 3.2s linear infinite;
}
.status-strip.finished { background: var(--surv-dim); }
.status-strip.cancelled { background: var(--kill-dim); }
@keyframes smolder { to { background-position: -220% 0; } }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-family: var(--font-data); font-size: 11.5px; letter-spacing: .04em;
  border: 1px solid var(--line); color: var(--fog);
}
.badge.running { color: var(--ember); border-color: var(--ember-dim); }
.badge.announced { color: var(--bone); }
.badge.finished { color: var(--surv); border-color: var(--surv-dim); }
.badge.cancelled, .badge.rejected { color: var(--kill); border-color: var(--kill-dim); }
.badge.draft { color: var(--fog); border-style: dashed; }
.badge.pending { color: var(--ember); border-color: var(--ember-dim); }
.badge.accepted, .badge.verified { color: var(--surv); border-color: var(--surv-dim); }
.badge.submitted { color: var(--bone); }
.badge.surv { color: var(--surv); border-color: var(--surv-dim); }
.badge.kill { color: var(--kill); border-color: var(--kill-dim); }

.empty {
  border: 1px dashed var(--line); border-radius: var(--r); padding: 36px 20px;
  text-align: center; color: var(--fog);
}

/* ── Страница турнира ── */
.tpage-cover { border-radius: var(--r); overflow: hidden; margin: 14px 0 20px; border: 1px solid var(--line); }
.tpage-cover img { width: 100%; display: block; aspect-ratio: 21/9; object-fit: cover; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; color: var(--fog); padding: 10px 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--bone); border-bottom-color: var(--ember); }

.rules-md { color: var(--bone); max-width: 68ch; }
.rules-md h2 { margin-top: 1.4em; font-size: 17px; }
.rules-md p, .rules-md li { color: color-mix(in srgb, var(--bone) 85%, var(--fog)); }

/* ── Таблицы ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th {
  font-family: var(--font-data); font-size: 11.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--fog); font-weight: 600;
  background: var(--ash);
}
td.num, th.num { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
td.num.surv { color: var(--surv); }
td.num.kill { color: var(--kill); }
td.num.total { color: var(--bone); font-weight: 600; }
.rank { color: var(--fog); font-family: var(--font-data); width: 40px; }
tr.top1 .rank { color: var(--ember); font-weight: 700; }

/* ── Матчи ── */
.match-card { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; background: var(--ash); overflow: hidden; }
.match-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.match-head .grow { flex: 1; }
.match-round { font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.match-map { color: var(--fog); font-size: 13px; }
.match-body { padding: 6px 16px 12px; }
.mrow {
  display: flex; align-items: baseline; gap: 10px; padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
  font-size: 14px;
}
.mrow:last-child { border-bottom: 0; }
.mrow .side { width: 4px; align-self: stretch; border-radius: 2px; }
.mrow .side.surv { background: var(--surv); }
.mrow .side.kill { background: var(--kill); }
.mrow .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .pts { font-family: var(--font-data); font-weight: 600; }
.mrow details { flex-basis: 100%; }
.mrow summary { color: var(--fog); font-size: 12.5px; cursor: pointer; }
.breakdown { font-family: var(--font-data); font-size: 12.5px; color: var(--fog); padding: 6px 0 2px 14px; }
.breakdown div { display: flex; justify-content: space-between; gap: 12px; max-width: 340px; }

/* ── Формы ── */
.panel { background: var(--ash); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(18px, 3vw, 28px); }
.panel + .panel { margin-top: 18px; }
.form-narrow { max-width: 420px; margin: 6vh auto 0; }
label.f { display: block; margin-bottom: 14px; font-size: 14px; }
label.f > span { display: block; color: var(--fog); margin-bottom: 5px; font-size: 13px; }
input, select, textarea {
  width: 100%; background: var(--night); color: var(--bone);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { border-color: var(--ember-dim); outline: none; }
input[type="checkbox"] { width: auto; }
textarea { min-height: 110px; resize: vertical; }
.hint { color: var(--fog); font-size: 12.5px; margin-top: 4px; }
.field-err { color: var(--danger); font-size: 13px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ember); color: var(--night); border: 0;
  padding: 10px 18px; border-radius: 9px; font-weight: 700; font-size: 14px;
  text-decoration: none;
}
.btn:hover { background: #f2963f; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--bone); font-weight: 500; }
.btn.ghost:hover { border-color: var(--fog); background: var(--ash-2); }
.btn.steam { background: #1b2838; color: #c7d5e0; }
.btn.steam:hover { background: #24384f; }
.btn.danger { background: none; border: 1px solid var(--kill-dim); color: var(--kill); font-weight: 500; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

.auth-alt { text-align: center; color: var(--fog); font-size: 14px; margin: 14px 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--fog); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ── Конструктор результатов ── */
.rgrid { display: grid; gap: 12px; }
.rgrid .pcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--night); }
.pcard-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pcard-head .side-dot { width: 10px; height: 10px; border-radius: 3px; }
.side-dot.surv { background: var(--surv); } .side-dot.kill { background: var(--kill); }
.pcard-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pcard-fields label.f { margin-bottom: 0; }
.pcard-pts {
  margin-left: auto; font-family: var(--font-data); font-weight: 600; font-size: 15px;
}

/* конструктор правил */
.rule-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 45%, transparent); }
.rule-row select, .rule-row input { width: auto; min-width: 90px; flex: 0 1 auto; }
.metric-row { display: grid; grid-template-columns: 1fr 1fr 110px 130px 34px; gap: 8px; align-items: center; padding: 6px 0; }
@media (max-width: 640px) { .metric-row { grid-template-columns: 1fr 1fr; } }
.icon-btn { background: none; border: 0; color: var(--fog); font-size: 16px; padding: 4px; }
.icon-btn:hover { color: var(--danger); }

/* ── Тост ── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ash-2); border: 1px solid var(--line); color: var(--bone);
  padding: 11px 18px; border-radius: 10px; font-size: 14px; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--kill-dim); color: var(--danger); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.muted { color: var(--fog); }
.mono { font-family: var(--font-data); }
