:root {
  --bg: #14110e; --panel: #1d1915; --panel2: #262019; --line: #3a3128; --line2: #4d4133;
  --text: #ebdfc6; --muted: #a39479; --gold: #d9a441; --gold2: #f0c56a; --red: #c8553d;
  --jade: #5fa38a; --blue: #6f95c9; --violet: #a07bc4; --pink: #d77fa1;
  --serif: "PT Serif", Georgia, serif; --sans: "PT Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
body { background-image: radial-gradient(ellipse at top, #221c15 0%, var(--bg) 60%); min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0 0 10px; letter-spacing: .3px; }
h2 { font-size: 20px; color: var(--gold2); }
h3 { font-size: 16px; color: var(--gold); }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
a { color: var(--gold2); }

/* вход */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.login-box { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 32px 28px; text-align: center; max-width: 360px; width: 100%; }
.login-box form { display: flex; gap: 8px; margin-top: 14px; }
.login-box input { flex: 1; }
.seal { width: 64px; height: 64px; margin: 0 auto 10px; border: 2px solid var(--red); color: var(--red); border-radius: 10px; display: grid; place-items: center; font: 700 36px var(--serif); transform: rotate(-4deg); }
.seal.small { width: 40px; height: 40px; font-size: 22px; margin: 0; flex: none; }

/* шапка */
.top { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); background: rgba(20,17,14,.85); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px); }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.sect-name { font: 700 19px var(--serif); color: var(--gold2); cursor: pointer; }
.res { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.res span b { color: var(--gold2); font-weight: 700; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 12px 14px; font: 15px var(--sans); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--gold2); border-bottom-color: var(--gold); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--line2); color: var(--text); font-size: 12px; text-align: center; }
.badge:empty { display: none; }
.badge.red { background: var(--red); color: #fff; }
main { padding: 18px 20px 60px; max-width: 1280px; margin: 0 auto; }

/* сетки и карточки */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } main { padding: 14px 16px 60px; } .top { padding: 12px 16px; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.card.hl { border-color: var(--gold); }
.card.warn { border-color: var(--red); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.stat { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.stat:last-child { border-bottom: 0; }

/* кнопки/поля */
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); padding: 6px 12px; border-radius: 8px; font: 14px var(--sans); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.gold { background: var(--gold); color: #1a140c; border-color: var(--gold); font-weight: 700; }
.btn.gold:hover:not(:disabled) { background: var(--gold2); color: #1a140c; }
.btn.red { border-color: var(--red); color: #f0a08c; }
.btn.sm { padding: 3px 9px; font-size: 13px; }
input, select { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 10px; font: 14px var(--sans); max-width: 100%; }
input[type=range] { padding: 0; accent-color: var(--gold); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { background: none; border: 0; color: var(--muted); padding: 5px 11px; cursor: pointer; font: 13px var(--sans); }
.seg button.on { background: var(--gold); color: #1a140c; font-weight: 700; }

/* хроника */
.chron { list-style: none; margin: 0; padding: 0; }
.chron li { padding: 8px 2px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 118px 1fr; gap: 10px; }
.chron li .d { color: var(--muted); font-size: 12px; padding-top: 2px; }
.chron li.important .t { color: var(--gold2); }
.chron li.battle .t { color: #f0a08c; }
.chron li.drama .t { color: #e3b3c8; }
.chron li.world .t { color: #a9c3e6; }
@media (max-width: 600px) { .chron li { grid-template-columns: 1fr; gap: 2px; } }

/* таблицы */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 400; font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line2); cursor: pointer; white-space: nowrap; user-select: none; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }
.bar { height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--gold); }
.bar.jade > i { background: var(--jade); }
.bar.red > i { background: var(--red); }
.chip { display: inline-block; white-space: nowrap; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line2); margin: 1px 2px 1px 0; }
.chip.gold { border-color: var(--gold); color: var(--gold2); }
.chip.red { border-color: var(--red); color: #f0a08c; }
.chip.jade { border-color: var(--jade); color: #9ed6c0; }
.chip.pink { border-color: var(--pink); color: #f0b6cc; }
.chip.blue { border-color: var(--blue); color: #b3cbeb; }
.race { font-size: 15px; }
.name { font-weight: 700; white-space: nowrap; }

/* люди-карточки */
.person { display: flex; flex-direction: column; gap: 6px; }
.attrs { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 4px 12px; font-size: 13px; }
.attrs div b { color: var(--text); }
.rel { display: grid; grid-template-columns: 1fr 90px 90px; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.relbar { height: 6px; background: var(--panel2); border-radius: 4px; position: relative; }
.relbar i { position: absolute; top: 0; height: 100%; border-radius: 4px; }

/* карта */
.map { width: 100%; height: auto; background: #171410; border-radius: 10px; border: 1px solid var(--line); }
.map text { font: 12px var(--sans); fill: var(--text); pointer-events: none; }
.map .terr { cursor: pointer; }
.map .terr:hover circle.body { stroke: var(--gold2); stroke-width: 3; }

/* модалка, тост */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: grid; place-items: start center; padding: 40px 16px; overflow-y: auto; }
.modal-box { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; width: min(760px, 100%); padding: 20px 22px; position: relative; }
.x { position: absolute; right: 12px; top: 8px; background: none; border: 0; color: var(--muted); font-size: 26px; cursor: pointer; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--gold); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); }
.toast.err { border-color: var(--red); }
.report-lines { list-style: none; padding: 0; margin: 0; }
.report-lines li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.section-gap { margin-top: 16px; }

/* лобби */
.lobby { max-width: 1000px; margin: 0 auto; padding: 32px 16px 60px; }
.lobby .hero { text-align: center; margin-bottom: 22px; }
.lobby .hero h1 { font-size: 34px; color: var(--gold2); margin-top: 6px; }
.sect-pick { display: flex; flex-direction: column; gap: 8px; border-left: 4px solid var(--c, var(--gold)); }

/* шапка: мелкие кнопки, полоска дня */
.icon-btn { background: none; border: 1px solid transparent; color: var(--muted); border-radius: 6px; cursor: pointer; font-size: 15px; padding: 0 5px; }
.icon-btn:hover { color: var(--gold2); border-color: var(--line2); }
.top { position: sticky; }
.daybar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.daybar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); width: 0; transition: width 1s linear; }
.chron li.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: rgba(217,164,65,.18); } to { background: transparent; } }

/* пути */
.paths { display: grid; gap: 6px; }
.path { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.path .ic { font-size: 16px; text-align: center; }
.help-note { background: var(--panel2); border: 1px dashed var(--line2); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--muted); }
.help-note b { color: var(--text); }
.ranks-line { display: flex; gap: 6px; flex-wrap: wrap; }

/* dev */
.dev { border-top: 1px dashed var(--red); padding: 12px 20px 24px; max-width: 1280px; margin: 0 auto; }
.dev .row { gap: 6px; }
.dev .lbl { color: #f0a08c; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; margin-right: 6px; }

/* вход */
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.err-text { color: #f0a08c; min-height: 18px; }
.user-box { display: flex; align-items: center; gap: 4px; color: var(--muted); }

/* дашборд */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.tile-top { display: flex; gap: 8px; align-items: center; }
.tile-ic { width: 28px; height: 28px; border-radius: 8px; background: var(--panel2); display: grid; place-items: center; font-size: 15px; }
.tile-val { font: 700 24px var(--serif); color: var(--text); }
.stack { display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin: 8px 0 6px; background: var(--panel2); }
.stack i { display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 700; color: #14110e; min-width: 18px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); }
.legend b { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* хроника: иконка вида записи */
.chron .ki { display: inline-block; width: 18px; color: var(--muted); }
.chron li.important .t { color: #fff3dc; font-weight: 700; }
.chron li.important .ki { color: var(--gold); }
.chron li.drama .ki { color: var(--pink); }
.chron li.battle .ki { color: var(--red); }

/* тренировочные бои */
.spar { border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; margin-top: 10px; background: var(--panel2); }
.spar.live { border-color: var(--jade); }
.spar.live.grudge { border-color: var(--red); box-shadow: 0 0 0 1px rgba(200,85,61,.25) inset; }
.versus { display: grid; grid-template-columns: 1fr 34px 1fr; gap: 8px; align-items: center; margin: 8px 0; }
.vs { font: 700 13px var(--serif); color: var(--red); text-align: center; }
.fighter { font-size: 13px; margin-bottom: 4px; }
.fighter.down { opacity: .5; }
.spar-log { list-style: none; margin: 6px 0 8px; padding: 0; }
.spar-log li { padding: 2px 0; border-bottom: 1px dashed var(--line); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
details summary { cursor: pointer; }

/* рисунок секты */
.scene { width: 100%; height: auto; border-radius: 10px; display: block; }
.scene .bld { cursor: pointer; }
.scene .bld:hover .lbl, .scene .bld.sel .lbl { fill: var(--gold2); }
.scene .lbl { font: 700 12px var(--sans); fill: #d8cbb0; paint-order: stroke; stroke: #1c1712; stroke-width: 3px; }
.pips { display: flex; gap: 5px; margin-bottom: 8px; }
.pips i { width: 22px; height: 6px; border-radius: 3px; background: var(--line2); }
.pips i.on { background: var(--gold); }
.cmp { display: flex; gap: 10px; align-items: center; background: var(--panel2); border-radius: 8px; padding: 10px; }
.cmp .arrow { color: var(--gold); font-size: 20px; }

/* карта: подписи с обводкой */
.map text.halo { paint-order: stroke; stroke: #171410; stroke-width: 4px; stroke-linejoin: round; }

/* контраст: неактивные золотые кнопки и чипы без «жёлтого на жёлтом» */
.btn.gold:disabled { background: var(--panel2); color: var(--muted); border-color: var(--line2); }
.chip.gold { background: rgba(217,164,65,.12); color: #f3dcae; }
.card.hl { border-color: rgba(217,164,65,.55); }
.seg button.on { background: #e8dcc4; color: #1a140c; }
.fighter .fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
