/* Pocket Combats Remaster — тёмная тема (GDD §8). Цвета редкостей совпадают с items-data.js. */
:root {
  --bg: #0e1015;
  --bg-2: #12141a;
  --card: #1b1e27;
  --card-2: #222634;
  --card-3: #2a2f40;
  --line: #2e3344;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --dim: #5d6478;
  --accent: #d9a441;
  --accent-2: #f0c46a;
  --accent-ink: #1a1408;
  --ally: #6fa8ff;
  --foe: #e0a060;
  --good: #5fd068;
  --bad: #ff5d6c;
  --warn: #ffb347;
  --hp: #3fc46b;
  --hp-mid: #e6b43c;
  --hp-low: #e5484d;
  --rage: #d9534f;
  --energy: #e8c547;
  --mana: #4f8fe8;
  --shield: #8fd3ff;
  --r0: #9aa3b2;
  --r1: #5fd068;
  --r2: #4f9cff;
  --r3: #b27bff;
  --r4: #ff9f3d;
  --r5: #ff4d5e;
  --r6: #3fe0d0;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 6px 18px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1d2130 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; user-select: none; }
[hidden] { display: none !important; }

.app { max-width: 520px; height: 100%; margin: 0 auto; background: var(--bg-2); position: relative; overflow: hidden; box-shadow: 0 0 60px rgba(0, 0, 0, .6); }
.screen { height: 100%; display: flex; flex-direction: column; }
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; }
.pad { padding: 16px; }
.h { font-size: 20px; font-weight: 600; margin: 4px 0 14px; }
.muted { color: var(--muted); }
.meta { font-size: 12px; color: var(--muted); }

/* ---------- Верх и низ ---------- */
.topbar {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 8px 14px;
  background: linear-gradient(180deg, #1a1d27, #151821);
  border-bottom: 1px solid var(--line); z-index: 3;
}
.topbar h1 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; }
.brand img { height: 32px; }
.bottombar { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #151821; border-top: 1px solid var(--line); }
.icon-btn { border: 0; background: transparent; font-size: 20px; width: 36px; height: 36px; border-radius: 10px; }
.icon-btn:hover { background: rgba(255, 255, 255, .06); }

.tabs { display: flex; background: #151821; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button {
  flex: 1; position: relative; border: 0; background: none; padding: 8px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--dim); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.tabs button img { width: 24px; height: 24px; opacity: .5; filter: grayscale(1) brightness(1.6); }
.tabs button.on { color: var(--accent); }
.tabs button.on img { opacity: 1; filter: none; }
.tabs button.on::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 2px; background: var(--accent); border-radius: 2px; }
.dot-badge { position: absolute; top: 6px; right: calc(50% - 20px); min-width: 8px; height: 8px; border-radius: 4px; background: var(--bad); }

/* Шапка героя */
.hero-bar { gap: 12px; }
.hero-bar .portrait { width: 44px; height: 44px; border-radius: 12px; background: var(--card-2); overflow: hidden; flex: none; border: 1px solid var(--line); }
.hero-bar .portrait img { width: 100%; height: 100%; object-fit: cover; }
.hero-bar .who { flex: 1; min-width: 0; }
.hero-bar .who b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-bar .bar-line { display: flex; align-items: center; gap: 8px; }
.wallet { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; font-weight: 600; }
.wallet span { display: inline-flex; align-items: center; gap: 4px; }
.wallet img { width: 16px; height: 16px; }

/* ---------- Кнопки, поля ---------- */
.btn {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-height: 42px;
  background: var(--card-2); font-weight: 600; font-size: 14px; position: relative;
  transition: transform .06s, background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: #3d4458; background: var(--card-3); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ffd27a, #e4ae4a); }
.btn.danger { background: #3a1c22; border-color: #5c2731; color: #ffb3bb; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; }
.row-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.row-actions .btn { flex: 1; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
input[type="text"], #nick {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font: inherit; color: var(--text); background: var(--card);
}
#nick:focus { outline: 2px solid var(--accent); border-color: transparent; }
#nick.err { outline: 2px solid var(--bad); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 10px 16px; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.chip-btn { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.chip-btn.on { background: rgba(217, 164, 65, .18); border-color: var(--accent); color: var(--accent-2); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; }

/* ---------- Карточки и секции ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { padding: 14px; margin: 12px; }
.section > h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section > h3 .note { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent-2); }
.list { display: flex; flex-direction: column; gap: 8px; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #262a38; font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.kv b { font-variant-numeric: tabular-nums; }
.stat-ico { width: 16px; height: 16px; opacity: .8; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0; }
.empty-note { color: var(--dim); text-align: center; padding: 18px 0; }

/* Классы при создании */
.class-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.class-card { text-align: left; padding: 10px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); display: flex; flex-direction: column; gap: 6px; }
.class-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 164, 65, .15); }
.class-card .art { aspect-ratio: 1; border-radius: 10px; background: radial-gradient(circle at 50% 35%, #2b3144, #171a23); display: grid; place-items: center; overflow: hidden; }
.class-card .art img { width: 88%; height: 88%; }
.class-card b { font-size: 16px; }
.class-card .desc { font-size: 12px; color: var(--muted); }
.class-card .res { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Мир ---------- */
.banner { position: relative; height: 150px; overflow: hidden; border-bottom: 1px solid var(--line); background: #151821; }
.banner img { width: 100%; height: 100%; object-fit: cover; }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14, 16, 21, 0) 40%, rgba(14, 16, 21, .95)); }
.banner .title { position: absolute; left: 16px; right: 16px; bottom: 10px; z-index: 1; }
.banner .title b { display: block; font-size: 20px; text-shadow: 0 2px 8px #000; }
.banner .title span { font-size: 12px; color: var(--accent-2); font-weight: 600; }
.loc-desc { color: #b9c0d0; font-size: 14px; margin: 0; }
.mob {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--card-2); border-radius: 12px; padding: 8px 10px;
}
.mob:hover:not(:disabled) { border-color: #3d4458; }
.mob:disabled { opacity: .5; cursor: default; }
.mob .ava { width: 52px; height: 52px; }
.mob .txt { flex: 1; min-width: 0; }
.mob b { font-weight: 600; }
.mob.boss { border-color: #6b3b1f; background: linear-gradient(90deg, #2b1e18, var(--card-2)); }
.tag { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }
.tag.boss { background: #5a2a17; color: #ffb38a; }
.tag.kind { background: #262b3a; color: var(--muted); }
.lvl-badge { flex: none; min-width: 44px; padding: 4px 6px; border-radius: 10px; text-align: center; font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }
.lvl-badge.trivial { background: #2a2e3a; color: var(--dim); }
.lvl-badge.easy { background: rgba(63, 196, 107, .15); color: #7fe39c; }
.lvl-badge.fair { background: rgba(230, 180, 60, .15); color: #f2cc6a; }
.lvl-badge.hard { background: rgba(255, 140, 60, .15); color: #ffa766; }
.lvl-badge.deadly { background: rgba(229, 72, 77, .18); color: #ff8a8f; }
.route { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 12px 4px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; }
.route:first-of-type { border-top: 0; }
.route-name { font-weight: 600; color: var(--ally); }
.route-meta { font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.trivial { background: var(--dim); } .dot.easy { background: var(--hp); } .dot.fair { background: var(--hp-mid); } .dot.hard { background: #ff8c3c; } .dot.deadly { background: var(--hp-low); }
.progress { height: 8px; background: #262a38; border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
.progress.thin { height: 4px; }
.npc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.npc { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--card-2); border-radius: 12px; padding: 8px; }
.npc .ava { width: 44px; height: 44px; }
.npc b { font-size: 13px; display: block; }
.npc span { font-size: 11px; color: var(--muted); }

.ava { flex: none; border-radius: 12px; background: radial-gradient(circle at 50% 35%, #2b3144, #171a23); display: grid; place-items: center; overflow: hidden; font-size: 26px; }
.ava img { width: 92%; height: 92%; object-fit: contain; }

/* ---------- Предметы ---------- */
.tile {
  position: relative; aspect-ratio: 1; border-radius: 10px;
  background: radial-gradient(circle at 50% 40%, #252a3a, #181b25);
  border: 2px solid var(--rc, #343a4d); display: grid; place-items: center; overflow: hidden;
  user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.tile img { width: 76%; height: 76%; pointer-events: none; }
.tile .fallback { font-size: 22px; }
.tile.r1 { --rc: var(--r1); } .tile.r2 { --rc: var(--r2); } .tile.r3 { --rc: var(--r3); }
.tile.r4 { --rc: var(--r4); } .tile.r5 { --rc: var(--r5); } .tile.r6 { --rc: var(--r6); }

.tile .enh { position: absolute; top: 2px; left: 4px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.tile .stars { position: absolute; bottom: 1px; left: 3px; font-size: 9px; color: var(--accent-2); letter-spacing: -1px; text-shadow: 0 1px 2px #000; }
.tile .tier { position: absolute; top: 2px; right: 4px; font-size: 9px; font-weight: 700; color: var(--muted); }
.tile .virtue { position: absolute; bottom: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px currentColor; background: currentColor; }
.tile.cant::after { content: ""; position: absolute; inset: 0; background: rgba(229, 72, 77, .18); }
.tile.new { box-shadow: 0 0 0 2px rgba(240, 196, 106, .55); }
.tile.empty { border: 1px dashed #2c3142; background: #151821; }
.tile.empty img { width: 60%; height: 60%; opacity: .22; filter: grayscale(1) brightness(2); }
.tile.drop-ok { outline: 2px solid var(--good); outline-offset: 1px; }
.tile.drop-hover { outline: 2px solid var(--accent-2); background: #2a2f40; }
.tile.dragging { opacity: .25; }

.doll { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-areas:
  "head    portrait portrait amulet"
  "weapon  portrait portrait offhand"
  "body    portrait portrait hands"
  "belt    feet     ring1    ring2";
  gap: 8px; padding: 12px; }
.doll .slot-cell { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.doll .slot-cell small { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.doll .slot-cell .tile { width: 100%; }
.doll .portrait { grid-area: portrait; border-radius: 14px; background: radial-gradient(circle at 50% 40%, #2b3144, #12141a); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; }
.doll .portrait img { width: 80%; }
.doll .portrait .power { font-size: 12px; color: var(--accent-2); font-weight: 700; }
.bag-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 0 12px 12px; }
.bag-tools { display: flex; gap: 6px; padding: 0 12px 10px; flex-wrap: wrap; align-items: center; }
.bag-tools .grow { flex: 1; }
.trash { border: 1px dashed #5c2731; color: #ff9aa5; background: #24141a; border-radius: 10px; padding: 8px 10px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.trash.drop-hover { background: #3a1c22; border-style: solid; }
.trash.drop-ok { outline: 2px solid var(--bad); }
.materials { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; background: var(--card-2); font-size: 12px; font-weight: 700; }
.mat img { width: 28px; height: 28px; }
.drag-ghost { position: fixed; z-index: 100; width: 56px; height: 56px; pointer-events: none; transform: translate(-50%, -60%) scale(1.1); opacity: .95; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .6)); }

/* Карточка предмета */
.item-card { display: flex; flex-direction: column; gap: 10px; }
.item-head { display: flex; gap: 12px; align-items: center; }
.item-head .tile { width: 64px; flex: none; }
.item-name { font-size: 17px; font-weight: 700; line-height: 1.2; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.rc0 { color: var(--r0); } .rc1 { color: var(--r1); } .rc2 { color: var(--r2); } .rc3 { color: var(--r3); } .rc4 { color: var(--r4); } .rc5 { color: var(--r5); } .rc6 { color: var(--r6); }
.props { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.props li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.props .base { color: #cfd5e2; }
.props .affix { color: #a8c7ff; }
.props .neg { color: var(--bad); }
.props .t { flex: none; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 5px; background: #262b3a; color: var(--muted); min-width: 26px; text-align: center; }
.props .t.t6, .props .t.t7 { background: #3b2d12; color: var(--accent-2); }
.props .roll { flex: none; width: 34px; height: 4px; background: #262b3a; border-radius: 2px; overflow: hidden; margin-left: auto; }
.props .roll > div { height: 100%; background: var(--accent); }
.props .txt { flex: 1; }
.legend { border: 1px solid #5a3a14; background: linear-gradient(180deg, #2a1f12, #1f1a14); border-radius: 10px; padding: 8px 10px; }
.legend b { color: var(--r4); display: block; font-size: 13px; }
.legend span { font-size: 13px; color: #e6d2b0; }
.virtue-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #262b3a; }
.virtue-chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.compare { background: #151821; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.compare h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.diff { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
.diff .up { color: var(--good); } .diff .down { color: var(--bad); }
.req { color: var(--bad); font-size: 13px; }

/* ---------- Герой ---------- */
.stat-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #262a38; }
.stat-row:last-of-type { border-bottom: 0; }
.stat-row img { width: 22px; height: 22px; }
.stat-row .txt { flex: 1; min-width: 0; }
.stat-row .val { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.bonus { color: var(--good); font-size: 12px; margin-left: 3px; }
.pend { color: var(--accent-2); font-size: 12px; margin-left: 3px; }
.plus { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 20px; font-weight: 800; line-height: 1; }
.plus:disabled { background: #262b3a; color: var(--dim); cursor: default; }
.skill-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed #262a38; }
.skill-card:last-child { border-bottom: 0; }
.skill-card.locked { opacity: .45; }
.skill-ico { flex: none; width: 42px; height: 42px; border-radius: 10px; background: radial-gradient(circle at 50% 35%, #31374c, #1a1d27); border: 1px solid var(--line); display: grid; place-items: center; color: var(--accent-2); }
.skill-ico img { width: 24px; height: 24px; filter: invert(78%) sepia(36%) saturate(700%) hue-rotate(358deg) brightness(102%); }
.skill-card .txt { flex: 1; min-width: 0; }
.skill-card b { font-size: 14px; }
.skill-card .desc { font-size: 12px; color: var(--muted); }
.skill-card .lvl { font-size: 12px; font-weight: 700; color: var(--accent-2); }
.slots-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot-skill { border: 1px dashed var(--line); border-radius: 10px; padding: 6px; min-height: 64px; font-size: 11px; text-align: center; background: #151821; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot-skill.filled { border-style: solid; background: var(--card-2); }
.slot-skill .n { font-size: 10px; color: var(--dim); }
.points-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: rgba(217, 164, 65, .18); color: var(--accent-2); font-size: 12px; font-weight: 700; }
.virtue-sets { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Кузница ---------- */
.forge-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 12px 0; }
.forge-tabs button { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
.forge-tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.picker .tile.sel { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.forge-target { display: flex; gap: 12px; align-items: center; }
.forge-target .tile { width: 72px; flex: none; }
.chance { font-size: 26px; font-weight: 800; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.cost { display: flex; flex-wrap: wrap; gap: 8px; }
.cost span { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 3px 8px; border-radius: 8px; background: #151821; }
.cost span.short { color: var(--bad); }
.cost .mat-tier { font-style: normal; font-size: 9px; font-weight: 700; color: var(--muted); margin-left: -3px; align-self: flex-start; }
.cost img { width: 18px; height: 18px; }
.lock-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #262a38; }
.lock-row:last-child { border-bottom: 0; }
.lock-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.lock-row .txt { flex: 1; font-size: 14px; }
.flash { padding: 8px 10px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.flash.good { background: rgba(95, 208, 104, .12); color: #9ff0a6; }
.flash.bad { background: rgba(255, 93, 108, .12); color: #ffb3bb; }
.flash.neutral { background: #1f2330; color: #cfd5e2; }
select { font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }

/* ---------- Бой ---------- */
.battle-toggles { display: flex; gap: 6px; }
.timer { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
#timer-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
#timer-fill.low { background: var(--bad); }
.arena { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; padding: 12px; background: linear-gradient(180deg, #171a23, transparent); }
.vs { align-self: center; color: var(--dim); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.arena .fighter.foe { align-self: center; }   /* монстр не растягивается по высоте отряда, а стоит напротив «VS» */
.fighter { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; min-width: 0; }
.fighter.ally { border-top: 3px solid var(--ally); }
.fighter.foe { border-top: 3px solid var(--foe); }
.fighter.boss { box-shadow: 0 0 0 1px #6b3b1f, 0 0 20px rgba(255, 120, 60, .15); }
.fighter .head { display: flex; gap: 8px; align-items: center; }
.fighter .ava { width: 32px; height: 32px; flex: none; }
.fighter .head { gap: 5px; }
.vit { flex: 1 1 0; min-width: 40px; display: flex; flex-direction: column; gap: 3px; }
.vit .meter { margin: 0; }
.vit .meter.hp .track { height: 14px; }
.vit .meter.hp .v { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums; }
.vit .meter.res .track { height: 5px; }
.who { min-width: 0; flex: 0 1 auto; max-width: 40%; }
.fighter .head .effects, .pmate .effects { flex: none; min-width: 20px; margin: 0; min-height: 0; flex-direction: column; flex-wrap: nowrap; gap: 2px; }
.fighter .head .chip, .pmate .chip { padding: 0 2px; font-size: 8px; line-height: 1.4; text-align: center; white-space: nowrap; }
.chip.more { background: #2b3040; color: var(--muted); }
.fx-row { display: flex; gap: 8px; align-items: flex-start; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; color: inherit; font: inherit; cursor: pointer; }
.fx-row .chip { flex: none; min-width: 28px; text-align: center; margin-top: 1px; }
.fx-row .txt { flex: 1; min-width: 0; }
.fx-row .fx-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.fx-row .fx-head .meta { flex: none; }
.fighter .name { white-space: nowrap; }
.party { margin-top: 6px; padding-top: 4px; border-top: 1px solid var(--line); max-height: 76px; overflow-y: auto; overscroll-behavior: contain; }
.party[hidden] { display: none; }
.pmate { display: flex; align-items: center; gap: 6px; padding: 3px 0; min-width: 0; }
.pmate .name { font-size: 12px; font-weight: 600; color: var(--ally); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmate .lvl { font-size: 10px; color: var(--muted); }
.pmate.dead { opacity: .45; filter: grayscale(.9); }
/* цель монстра в общем бою: лёгкая красная обводка */
.fighter .head.aggro, .pmate.aggro { border-radius: 6px; outline: 1px solid rgba(235, 80, 70, .7); outline-offset: 2px; background: rgba(235, 80, 70, .07); box-shadow: 0 0 8px rgba(235, 80, 70, .2); }
.fighter .name { font-weight: 600; font-size: 12px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.fighter.ally .name { color: var(--ally); }
.fighter.foe .name { color: var(--foe); }
.fighter .lvl { font-size: 11px; color: var(--muted); }
.meter { margin-top: 6px; }
.meter .track { position: relative; height: 8px; background: #262a38; border-radius: 4px; overflow: hidden; }
.meter .fill { height: 100%; border-radius: 4px; transition: width .3s ease, background-color .3s; }
.meter .shield-fill { position: absolute; top: 0; right: 0; height: 100%; background: repeating-linear-gradient(45deg, rgba(143, 211, 255, .65) 0 4px, rgba(143, 211, 255, .35) 4px 8px); transition: width .3s; }
.meter .num { font-size: 10px; color: var(--muted); display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; margin-top: 1px; }
.meter.res .track { height: 5px; }
.effects { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; min-height: 18px; }
.chip { border: 0; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: rgba(143, 211, 255, .15); color: #a9dcff; }
.chip[data-fx] { cursor: pointer; }
.chip.debuff { background: rgba(255, 93, 108, .15); color: #ff9aa5; }
.fighter.hit { animation: shake .3s; }
.fighter.dead { opacity: .45; filter: grayscale(.9); }
@keyframes shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
.float { position: absolute; left: 50%; top: 30%; z-index: 3; transform: translateX(-50%); font-weight: 800; font-size: 20px; pointer-events: none; animation: floatUp .9s ease-out forwards; text-shadow: 0 2px 6px #000; }
@keyframes floatUp { 0% { transform: translate(-50%, 4px) scale(.7); opacity: 0; } 15% { transform: translate(-50%, 0) scale(1.1); opacity: 1; } 30% { transform: translate(-50%, -6px) scale(1); } 100% { transform: translate(-50%, -38px); opacity: 0; } }
.float.crit { font-size: 26px; animation-name: floatCrit; animation-duration: 1s; }
@keyframes floatCrit { 0% { transform: translate(-50%, 0) scale(.5) rotate(-8deg); opacity: 0; } 18% { transform: translate(-50%, -4px) scale(1.35) rotate(3deg); opacity: 1; } 35% { transform: translate(-50%, -8px) scale(1) rotate(0); } 100% { transform: translate(-50%, -42px); opacity: 0; } }
.float.grow { top: 55%; font-size: 15px; }

/* Вспышки на карточке бойца: цвет берётся из --fx (стихия удара, лечение, щит) */
.fighter { transition: opacity .5s, filter .5s; }
.fighter.ally .head { animation: fighterIn .35s ease-out backwards; }
.fighter.foe .head { animation: fighterInR .35s ease-out backwards; }
@keyframes fighterIn { from { opacity: 0; transform: translateX(-14px); } }
@keyframes fighterInR { from { opacity: 0; transform: translateX(14px); } }
.fighter::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; opacity: 0; }
.fighter.hit::after { animation: fxFlash .35s ease-out; background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--fx, #fff) 30%, transparent), transparent 70%); }
.fighter.hit-crit { animation: shakeHard .4s; }
.fighter.hit-crit::after { animation: fxFlash .45s ease-out; background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--fx, #fff) 45%, transparent), transparent 75%); box-shadow: 0 0 0 2px var(--fx, #fff) inset; }
.fighter.glow::after { animation: fxGlow .7s ease-out; box-shadow: 0 0 16px var(--fx, #6fe28f), 0 0 0 1px var(--fx, #6fe28f) inset; background: linear-gradient(0deg, color-mix(in srgb, var(--fx, #6fe28f) 22%, transparent), transparent 70%); }
.fighter.dodged { animation: dodge .35s ease-out; }
.fighter.ally-join::after { animation: fxGlow 1.1s ease-out; box-shadow: 0 0 20px var(--ally), 0 0 0 1px var(--ally) inset; }
@keyframes fxFlash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fxGlow { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
@keyframes shakeHard { 15% { transform: translateX(-6px) rotate(-1deg); } 35% { transform: translateX(6px) rotate(1deg); } 55% { transform: translateX(-4px); } 75% { transform: translateX(2px); } }
@keyframes dodge { 40% { transform: translateX(8px) skewX(-4deg); opacity: .75; } }
/* Светлый след: показывает, сколько здоровья только что снесли, и догоняет полоску */
.meter .lag { position: absolute; top: 0; left: 0; height: 100%; border-radius: 4px; background: rgba(255, 230, 200, .55); transition: width .45s ease-in .35s; }
.meter.hp .fill { position: relative; }

/* Кто-то вступил в общий бой */
.arena { position: relative; }
.join-banner {
  position: absolute; left: 50%; bottom: -22px; z-index: 5; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 24px);
  padding: 5px 12px 5px 6px; border-radius: 999px; font-size: 12px; white-space: nowrap; color: var(--text); pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .22) 50%, transparent 70%) no-repeat, linear-gradient(90deg, #1d3157, #24345a 50%, #1d3157);
  background-size: 250% 100%, 100% 100%; border: 1px solid var(--ally); box-shadow: 0 0 18px rgba(111, 168, 255, .45), 0 6px 18px rgba(0, 0, 0, .5);
  animation: joinIn .45s cubic-bezier(.2, 1.4, .4, 1) both, joinShine 1s .3s ease-out both, joinOut .35s 1.8s ease-in forwards;
}
.join-banner span { overflow: hidden; text-overflow: ellipsis; }
.join-banner b { color: var(--ally); }
.join-banner .ava { flex: none; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px var(--ally); }
@keyframes joinIn { from { opacity: 0; transform: translate(-50%, 12px) scale(.7); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes joinShine { from { background-position: 120% 0, 0 0; } to { background-position: -120% 0, 0 0; } }
@keyframes joinOut { to { opacity: 0; transform: translate(-50%, -8px) scale(.95); } }
.pmate.joining { animation: mateIn 1.4s ease-out both; border-radius: 8px; }
@keyframes mateIn { 0% { opacity: 0; transform: translateX(-16px); background: rgba(111, 168, 255, .35); } 25% { opacity: 1; transform: none; } 100% { background: transparent; } }

.log { flex: 1; overflow-y: auto; padding: 8px 14px 12px; margin: 0 12px 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; font-size: 14px; }
.entry { padding: 4px 0; animation: fadeIn .25s; color: #c9cfdc; }
.entry.poetry { white-space: pre-line; font-style: italic; color: var(--muted); text-align: center; padding: 10px 0; }
.entry.turn { text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); padding: 8px 0 2px; }
.entry.turn::before, .entry.turn::after { content: "—"; margin: 0 8px; color: #333949; }
.entry.passed, .entry.effect { color: var(--muted); font-size: 13px; }
.entry.skill { color: #e6d2b0; }
.entry.death { font-weight: 700; color: var(--text); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } }
.ch { font-weight: 600; }
.ch.t1 { color: var(--ally); } .ch.t2 { color: var(--foe); }
.skill-name { font-weight: 700; color: var(--accent-2); }
.dmg { font-weight: 800; white-space: nowrap; color: #f2f4f8; }
.dmg.k-block { color: #b9a3ff; } .dmg.k-crit { color: #ff6b5e; } .dmg.k-critblock { color: #ffb347; }
.dmg.k-heal { color: #6fe28f; } .dmg.k-mana { color: #7fb0ff; }
.dmg.k-poison { color: #9fd34c; } .dmg.k-bleed { color: #ff5d6c; } .dmg.k-burn, .dmg.k-fire { color: #ff9a4d; }
.dmg.k-cold { color: #8fd3ff; } .dmg.k-lightning { color: #f7e26b; } .dmg.k-magic, .dmg.k-arcane { color: #c39bff; }
.hp { color: var(--dim); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.skillbar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: #151821; border-top: 1px solid var(--line); }
.sk { position: relative; border: 1px solid var(--line); background: var(--card-2); border-radius: 12px; padding: 6px 2px 5px; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 600; line-height: 1.1; text-align: center; overflow: hidden; }
.sk img { width: 24px; height: 24px; }
.sk .cost { font-size: 10px; color: var(--muted); }
.sk.basic { background: linear-gradient(180deg, #2c3142, #222634); }
.sk.ready { border-color: #5a4720; box-shadow: 0 0 0 1px rgba(217, 164, 65, .25) inset; }
.sk:disabled { opacity: .45; cursor: default; }
.sk { transition: transform .08s, opacity .2s, border-color .2s, box-shadow .2s; }
.sk:active:not(:disabled) { transform: scale(.93); }
.sk.ready img { transition: transform .2s; }
.sk.ready:active img { transform: scale(1.15); }
.turnbar .fill.low { animation: lowPulse .8s ease-in-out infinite alternate; }
@keyframes lowPulse { to { filter: brightness(1.35); } }
.sk .cd { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 12, 16, .7); font-size: 18px; font-weight: 800; color: #fff; }
.sk .count { position: absolute; top: 3px; right: 5px; font-size: 11px; font-weight: 800; color: var(--accent-2); }

/* ---------- Шторка, итог, тосты ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: center; align-items: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); animation: fade .2s; }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; background: #181b24; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; padding: 6px 16px calc(18px + env(safe-area-inset-bottom)); animation: slideUp .22s ease-out; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: #333949; margin: 6px auto 10px; }
.sheet h2 { font-size: 16px; margin: 0 0 10px; }
.sheet p { margin: 0 0 8px; color: #c9cfdc; }
@keyframes slideUp { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.result { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px); padding: 16px; animation: fade .25s; }
.result-card { width: 100%; max-width: 400px; max-height: 90vh; overflow-y: auto; background: #181b24; border: 1px solid var(--line); border-radius: 18px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.result-banner { padding: 22px 16px; font-size: 26px; font-weight: 800; letter-spacing: .02em; background: linear-gradient(180deg, #4a3815, #2a2010); color: var(--accent-2); }
.result-banner.loss { background: linear-gradient(180deg, #3a1c22, #22141a); color: #ffb3bb; }
.result-body { padding: 14px 16px 4px; }
.result-body p { margin: 0 0 8px; }
.result-body .levelup { color: var(--accent-2); font-weight: 800; }
.loot-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0; }
.result-actions { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; }
.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: #222634; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: toastIn .25s; }
.toast.good { border-color: #2f6b3a; } .toast.bad { border-color: #6b2f37; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Рынок ---------- */
.market-seg { margin-bottom: 10px; }
.market-seg button { flex: 1; padding: 9px 6px; position: relative; font-size: 13px; }
.market-seg .dot-badge { top: 6px; right: 6px; }
.market-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.market-tools select { flex: 1; min-width: 0; padding: 6px 8px; font-size: 13px; }
.market-tools .icon-btn { flex: none; color: var(--muted); }
.lot { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); cursor: pointer; }
.lot > .tile { width: 52px; flex: none; }
.lot-txt { flex: 1; min-width: 0; font-size: 14px; }
.lot-txt b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lot-props { font-size: 12px; color: #c3c9d6; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lot-props .leg { color: var(--r4); font-weight: 600; }
.lot-props .neg, .craft-stats .neg { color: var(--bad); }
.lot-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; max-width: 104px; text-align: right; }
.lot-side .btn { white-space: nowrap; }
.market-pay { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.market-filters { display: flex; flex-direction: column; gap: 14px; }
.mf-block h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mf-block h4 small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--dim, var(--muted)); }
.mf-sub { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip-btn { padding: 6px 10px; font-size: 12px; }
.chips .chip-btn[style] { color: var(--chip); }
.chips .chip-btn[style].on { border-color: var(--chip); background: color-mix(in srgb, var(--chip) 18%, transparent); }
.mf-range { display: flex; gap: 6px; align-items: center; }
.mf-range select, .mf-range input { flex: 1; min-width: 0; padding: 7px 8px; font-size: 13px; }
.mf-range span { color: var(--muted); }
.mf-toggle { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.mf-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.market-apply { position: sticky; bottom: -16px; background: #171a23; padding: 10px 0 2px; margin-bottom: -4px; }
.sell-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 12px; }
input[type="number"] { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input[type="number"]:focus { outline: 2px solid var(--accent); border-color: transparent; }
.lot-info { margin-top: 6px; }

@media (max-width: 380px) {
  .bag-grid, .picker { grid-template-columns: repeat(5, 1fr); }
  .skillbar { grid-template-columns: repeat(3, 1fr); }
  .class-grid { grid-template-columns: 1fr 1fr; }
}

/* Одноцветные иконки (fill=currentColor) в <img> рисуются чёрными — осветляем под тёмную тему */
img[src*="assets/stats/"], img[src*="assets/ui/slots/"] { filter: invert(88%) sepia(8%) saturate(300%) hue-rotate(190deg); }
.skill-ico img[src*="assets/stats/"], .sk.ready img[src*="assets/stats/"] { filter: invert(76%) sepia(45%) saturate(650%) hue-rotate(358deg) brightness(100%); }
.tabs button img[src*="assets/ui/slots/"] { filter: invert(40%); }
.tabs button.on img[src*="assets/ui/slots/"] { filter: invert(72%) sepia(50%) saturate(700%) hue-rotate(358deg); }

/* ---------- Окно по центру (предметы, ресурсы, NPC) ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 14px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .62); backdrop-filter: blur(2px); animation: fade .15s; }
.modal {
  position: relative; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, #1d2130, #171a23); border: 1px solid #3a4055; border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(217, 164, 65, .12), 0 24px 60px rgba(0, 0, 0, .65); animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 16px; background: #1d2130; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; margin: 0; font-size: 16px; line-height: 1.2; }
.modal-tools { display: flex; gap: 4px; }
.modal .icon-btn img, .modal-tools img { width: 20px; height: 20px; }
.icon-btn.tool { border: 1px solid var(--line); background: var(--card); }
.icon-btn.tool.on { border-color: var(--accent); background: rgba(217, 164, 65, .15); }
.modal-body { padding: 14px 16px 16px; }
.modal-grid { padding: 0; margin: 8px 0; }
.sheet-wrap.over-modal { z-index: 50; }
.info-link { cursor: pointer; text-decoration: underline dotted rgba(255, 255, 255, .25); text-underline-offset: 3px; }
.info-sheet { display: flex; gap: 12px; align-items: flex-start; }
.info-sheet p { margin: 0 0 8px; }
.props .range { color: var(--dim); font-size: 12px; margin-left: 4px; white-space: nowrap; }
.props .t { cursor: pointer; }
.npc-head { margin-bottom: 10px; align-items: center; }
.npc-head p { margin: 0; font-style: italic; color: #e6d2b0; font-size: 14px; }

/* Плитки: замок, отметка, «лучше надетого» */
.tile .lock-badge { position: absolute; bottom: 1px; right: 2px; font-size: 10px; }
.tile .check-badge { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 900; color: #fff; background: rgba(95, 208, 104, .35); text-shadow: 0 2px 4px #000; }
.tile.checked { outline: 2px solid var(--good); outline-offset: 1px; }
.tile.locked { opacity: .55; }
.tile.up::after { content: "▲"; position: absolute; bottom: 1px; right: 3px; font-size: 10px; color: var(--good); text-shadow: 0 1px 2px #000; }

/* ---------- Бой на тике ---------- */
.tick-label { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.chip-btn.icon { padding: 3px 6px; display: inline-grid; place-items: center; }
.chip-btn.icon img { width: 16px; height: 16px; }
.chip-btn.hunt.on { background: rgba(95, 208, 104, .15); border-color: var(--good); color: #9ff0a6; }
.sk.picked { border-color: var(--accent-2); background: linear-gradient(180deg, #4a3815, #2a2010); box-shadow: 0 0 0 2px rgba(240, 196, 106, .35); }
.sk.picked::after { content: "выбрано"; position: absolute; top: 2px; left: 0; right: 0; font-size: 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-2); }

/* ---------- Мир на тике ---------- */
.mob.dead { opacity: .45; }
.mob.dead .ava { filter: grayscale(1); }
.mob-count { margin-left: 6px; font-weight: 800; color: var(--accent, #f0c46a); }
.mob-status { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 700; color: var(--warn); }
.boss-progress { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.buff { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; }
.buff img { width: 14px; height: 14px; }
.recipe { padding: 10px 0; border-bottom: 1px dashed #262a38; }
.recipe:last-child { border-bottom: 0; }
.recipe.off .txt b { color: var(--muted); }
.recipe .row .txt { flex: 1; min-width: 0; }
.recipe .cost { margin-top: 6px; }

/* ---------- Уники ---------- */
:root { --r7: #e8c26b; }
.rc7 { color: var(--r7); text-shadow: 0 0 12px rgba(232, 194, 107, .55); }
.modal.rar-7 { border-color: #a8781f; box-shadow: 0 0 0 1px rgba(232, 194, 107, .4), 0 0 60px rgba(232, 194, 107, .25), 0 24px 60px rgba(0, 0, 0, .65); }
.props .uniq { color: #f2d999; }
.uniq-block { border: 1px solid #6b5420; background: linear-gradient(180deg, #2d2412, #1e1a12); border-radius: 10px; padding: 8px 10px; margin-top: 8px; }
.uniq-block b { display: block; color: var(--r7); font-size: 13px; }
.uniq-block span { display: block; font-size: 12px; color: #d8c9a4; margin-top: 4px; }
.flavor { font-style: italic; color: #a89a7a; font-size: 13px; margin: 8px 0 2px; }
.uniq-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: 1px solid #4a3c1c; border-radius: 10px; background: #1f1b12; }
.uniq-row.locked { opacity: .5; }
.uniq-row .tile { width: 48px; height: 48px; flex: none; }
.uniq-row .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* ---------- Значок сложности в шапке ---------- */
.diff-badge { position: relative; flex: none; width: 40px; height: 40px; border: 0; padding: 0; background: none; display: grid; place-items: center; }
.diff-badge.small { width: 32px; height: 32px; }
.diff-badge .db-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--dc); background: radial-gradient(circle, color-mix(in srgb, var(--dc) 25%, transparent), transparent 70%); }
.diff-badge .db-num { position: relative; font-size: 11px; font-weight: 900; color: var(--dc); letter-spacing: -.02em; text-shadow: 0 0 6px color-mix(in srgb, var(--dc) 70%, transparent); }
@keyframes dbPulse { 50% { box-shadow: 0 0 14px var(--dc); } }
@keyframes dbFlame { 0%, 100% { box-shadow: 0 -2px 10px var(--dc), 0 0 4px var(--dc) inset; } 33% { box-shadow: 0 -6px 16px var(--dc), 0 0 8px var(--dc) inset; } 66% { box-shadow: 0 -3px 12px #ffd27a, 0 0 6px var(--dc) inset; } }
@keyframes dbBlood { 0%, 100% { transform: scale(1); box-shadow: 0 0 8px var(--dc); } 15% { transform: scale(1.12); box-shadow: 0 0 18px var(--dc); } 30% { transform: scale(1); } 45% { transform: scale(1.08); box-shadow: 0 0 14px var(--dc); } }
@keyframes dbRage { 0%, 100% { transform: rotate(0) scale(1); } 20% { transform: rotate(-6deg) scale(1.08); } 40% { transform: rotate(6deg) scale(1.08); } 60% { transform: rotate(-3deg); } }
.anim-pulse .db-ring { animation: dbPulse 2.4s ease-in-out infinite; }
.anim-flame .db-ring { animation: dbFlame 1.1s ease-in-out infinite; }
.anim-blood .db-ring { animation: dbBlood 1.4s ease-in-out infinite; }
.anim-rage .db-ring { animation: dbBlood 1s ease-in-out infinite, dbRage 2.5s ease-in-out infinite; }
.anim-void .db-ring { border-color: transparent; background: conic-gradient(from var(--spin), var(--dc), #b27bff, #f0c46a, var(--dc)); -webkit-mask: radial-gradient(circle, transparent 55%, #000 58%); mask: radial-gradient(circle, transparent 55%, #000 58%); animation: spin 2s linear infinite; }
.anim-void::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; box-shadow: 0 0 18px var(--dc); animation: dbPulse 1.6s ease-in-out infinite; pointer-events: none; }
.diff-row-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); }
.diff-row-item.on { border-color: var(--dc); box-shadow: 0 0 0 1px var(--dc) inset; }
.diff-row-item:disabled { opacity: .45; cursor: not-allowed; }
.diff-row-item .txt { flex: 1; }
.diff-row-item b { color: var(--dc); }

/* ---------- Сворачиваемые блоки героя ---------- */
.collapsible > h3 { cursor: pointer; user-select: none; margin-bottom: 0; }
.collapsible.open > h3 { margin-bottom: 10px; }

/* ---------- Кузница: явный режим ---------- */
.mode-head { display: flex; align-items: center; gap: 12px; margin: 12px; padding: 12px 14px; border-radius: 14px; background: linear-gradient(90deg, #3b2d12, #1b1e27); border: 1px solid #5a4720; }
.mode-head img { width: 34px; height: 34px; }
.mode-head b { display: block; font-size: 18px; color: var(--accent-2); }
.mode-seg { margin: 12px 0; width: 100%; }
.mode-seg button { flex: 1; }
.lock-row .t { font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 5px; background: #262b3a; color: var(--muted); }
.lock-row.sel { background: rgba(217, 164, 65, .08); border-radius: 8px; }

/* ---------- Без стандартных полос прокрутки ---------- */
* { scrollbar-width: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ---------- Окна: красный крестик, поверх экрана победы ---------- */
.modal-wrap { z-index: 45; }
.sheet-wrap.over-modal { z-index: 55; }
.modal-x { width: 34px; height: 34px; border-radius: 10px; background: #b8323c; border: 1px solid #e0505a; box-shadow: 0 2px 8px rgba(184, 50, 60, .45); }
.modal-x:hover { background: #d23b46; }
.modal-x img { filter: brightness(0) invert(1) !important; width: 16px !important; height: 16px !important; }
.props-label { margin: 14px 0 6px; padding-top: 10px; border-top: 1px dashed #2e3344; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.cost.drops span { font-weight: 500; }

/* ---------- Нижнее меню ---------- */
.menu-btn .burger { display: flex; flex-direction: column; gap: 4px; width: 22px; height: 24px; justify-content: center; }
.menu-btn .burger i { display: block; height: 2px; border-radius: 1px; background: currentColor; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); }
.menu-item:disabled { opacity: .45; cursor: default; }
.menu-item b { display: block; }
.menu-ico { width: 44px; height: 44px; border-radius: 10px; background: radial-gradient(circle at 50% 35%, #2b3144, #171a23); display: grid; place-items: center; overflow: hidden; }
.menu-ico img { width: 90%; height: 90%; }

/* ---------- Монстры: уровень на иконке, кнопка атаки ---------- */
.mob { cursor: pointer; }
.mob-ava { position: relative; overflow: visible; }
.mob-ava .lvl-badge { position: absolute; left: -6px; top: -6px; min-width: 24px; padding: 2px 5px; font-size: 11px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.attack-btn {
  flex: none; width: 48px; height: 48px; border-radius: 12px; border: 1px solid #6b3b1f;
  background: linear-gradient(180deg, #c0522e, #8f3418); color: #fff; display: grid; place-items: center;
  box-shadow: 0 3px 10px rgba(192, 82, 46, .35);
}
.attack-btn svg { width: 26px; height: 26px; fill: currentColor; }
.attack-btn:hover:not(:disabled) { background: linear-gradient(180deg, #d9653c, #a33d1c); }
.attack-btn:disabled { background: #262b3a; border-color: var(--line); color: var(--dim); box-shadow: none; cursor: default; }

/* ---------- Полоса хода в бою ---------- */
.turnbar { position: relative; height: 26px; margin: 0 12px 8px; border-radius: 13px; background: #1b1e27; border: 1px solid var(--line); overflow: hidden; }
.turnbar .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, rgba(217, 164, 65, .35), rgba(240, 196, 106, .55)); transition: width .1s linear; }
.turnbar .fill.low { background: linear-gradient(90deg, rgba(229, 72, 77, .35), rgba(255, 93, 108, .6)); }
.turnbar .mark { position: absolute; top: 2px; bottom: 2px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--foe); box-shadow: 0 0 6px var(--foe); }
.turnbar .mark.done { background: #5d6478; box-shadow: none; }
.turnbar .txt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text); text-shadow: 0 1px 2px #000; }

/* ---------- Эффекты редкостей: героическая и выше ---------- */
@property --spin { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes spin { to { --spin: 360deg; } }
@keyframes pulse3 { 50% { box-shadow: 0 0 14px rgba(178, 123, 255, .55), 0 0 6px rgba(178, 123, 255, .5) inset; } }
@keyframes flow { to { background-position: 200% 0; } }
@keyframes sweep { from { background-position: -150% 0, 0 0; } to { background-position: 250% 0, 0 0; } }
@keyframes rise { 0% { transform: translateY(6px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-22px); opacity: 0; } }

/* Чем выше редкость, тем богаче плитка: рамка всегда сплошная цвета редкости (как у обычных вещей),
   поверх — свечение, бегущая искра внутри рамки и блик. */
.tile.r3, .tile.r4, .tile.r5, .tile.r6, .tile.r7 { animation: var(--fx); }
.tile.r7 { --rc: var(--r7); }

/* Героическая: дыхание свечения */
.tile.r3 { --fx: glow3 3s ease-in-out infinite; background: radial-gradient(circle at 50% 40%, #2d2440, #181b25); }
@keyframes glow3 {
  0%, 100% { box-shadow: 0 0 4px rgba(178, 123, 255, .25), inset 0 0 8px rgba(178, 123, 255, .2); }
  50% { box-shadow: 0 0 12px rgba(178, 123, 255, .55), inset 0 0 14px rgba(178, 123, 255, .4); }
}

/* Искра, бегущая внутри рамки (общая основа для легендарной и выше) */
.tile.r4::before, .tile.r5::before, .tile.r6::before, .tile.r7::before {
  content: ""; position: absolute; inset: 0; border-radius: 8px; padding: 2px; pointer-events: none; z-index: 1;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin var(--spin-t, 7s) linear infinite;
}

/* Легендарная: тёплое свечение и одна искра */
.tile.r4 { --fx: glow4 2.8s ease-in-out infinite; --spin-t: 8s; background: radial-gradient(circle at 50% 40%, #3a2a18, #181b25); }
.tile.r4::before { background: conic-gradient(from var(--spin), transparent 0deg, transparent 250deg, rgba(255, 159, 61, .55) 300deg, #ffe2b8 350deg, transparent 360deg); filter: drop-shadow(0 0 2px var(--rc)); }
@keyframes glow4 {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 159, 61, .3), inset 0 0 10px rgba(255, 159, 61, .3); }
  50% { box-shadow: 0 0 16px rgba(255, 159, 61, .6), inset 0 0 16px rgba(255, 159, 61, .5); }
}

/* Мифическая: две искры навстречу, пульсирующий жар, блик по предмету */
.tile.r5 { --fx: glow5 2.2s ease-in-out infinite, sweep 5s ease-in-out infinite; --spin-t: 6s;
  background-image: linear-gradient(110deg, transparent 35%, rgba(255, 190, 196, .22) 50%, transparent 65%), radial-gradient(circle at 50% 40%, #40202a, #181b25); background-size: 250% 100%, 100% 100%; background-repeat: no-repeat; }
.tile.r5::before { padding: 3px; background: conic-gradient(from var(--spin), transparent 0deg, rgba(255, 77, 94, .5) 40deg, #ffd0d4 70deg, transparent 100deg, transparent 180deg, rgba(255, 77, 94, .5) 220deg, #ffd0d4 250deg, transparent 280deg); filter: drop-shadow(0 0 3px var(--rc)); }
@keyframes glow5 {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 77, 94, .4), inset 0 0 12px rgba(255, 77, 94, .35); }
  50% { box-shadow: 0 0 20px rgba(255, 77, 94, .75), inset 0 0 20px rgba(255, 77, 94, .6); }
}

/* Древняя: радужная рамка, переливающаяся граница, цветное свечение и блик */
.tile.r6 { --fx: glow6 6s linear infinite, sweep 4.2s ease-in-out infinite; --spin-t: 5s;
  background-image: linear-gradient(110deg, transparent 28%, rgba(63, 224, 208, .26) 44%, rgba(240, 196, 106, .26) 56%, transparent 72%), radial-gradient(circle at 50% 40%, #173a40, #181b25); background-size: 250% 100%, 100% 100%; background-repeat: no-repeat; }
.tile.r6::before { padding: 3px; background: conic-gradient(from var(--spin), #3fe0d0, #f0c46a 60deg, #b27bff 120deg, #3fe0d0 180deg, #f0c46a 240deg, #b27bff 300deg, #3fe0d0); filter: drop-shadow(0 0 4px #3fe0d0); opacity: .85; }
@keyframes glow6 {
  0%, 100% { border-color: #3fe0d0; box-shadow: 0 0 12px rgba(63, 224, 208, .6), inset 0 0 16px rgba(63, 224, 208, .45); }
  33% { border-color: #f0c46a; box-shadow: 0 0 16px rgba(240, 196, 106, .65), inset 0 0 18px rgba(240, 196, 106, .45); }
  66% { border-color: #b27bff; box-shadow: 0 0 16px rgba(178, 123, 255, .65), inset 0 0 18px rgba(178, 123, 255, .45); }
}

/* Уникальная: золото — две раскалённые искры, мощное свечение, блик */
.tile.r7 { --fx: glow7 2.4s ease-in-out infinite, sweep 4.6s ease-in-out infinite; --spin-t: 6s;
  background-image: linear-gradient(110deg, transparent 30%, rgba(255, 243, 196, .3) 50%, transparent 70%), radial-gradient(circle at 50% 40%, #4a3a16, #181b25); background-size: 250% 100%, 100% 100%; background-repeat: no-repeat; }
.tile.r7::before { padding: 3px; background: conic-gradient(from var(--spin), transparent 0deg, rgba(232, 194, 107, .55) 30deg, #fff6d0 60deg, transparent 95deg, transparent 180deg, rgba(232, 194, 107, .55) 210deg, #fff6d0 240deg, transparent 275deg); filter: drop-shadow(0 0 4px #e8c26b); }
@keyframes glow7 {
  0%, 100% { box-shadow: 0 0 10px rgba(232, 194, 107, .5), inset 0 0 14px rgba(232, 194, 107, .4); }
  50% { box-shadow: 0 0 24px rgba(232, 194, 107, .85), inset 0 0 22px rgba(232, 194, 107, .65); }
}

/* Окно предмета: рамка и имя по редкости */
.modal.rar-3 { border-color: #6b4aa8; box-shadow: 0 0 0 1px rgba(178, 123, 255, .25), 0 0 40px rgba(178, 123, 255, .18), 0 24px 60px rgba(0, 0, 0, .65); }
.modal.rar-4 { border-color: #a8641f; box-shadow: 0 0 0 1px rgba(255, 159, 61, .35), 0 0 50px rgba(255, 159, 61, .22), 0 24px 60px rgba(0, 0, 0, .65); }
.modal.rar-5 { border-color: #a82a36; box-shadow: 0 0 0 1px rgba(255, 77, 94, .4), 0 0 60px rgba(255, 77, 94, .28), 0 24px 60px rgba(0, 0, 0, .65); }
.modal.rar-6 { border-color: #2aa89c; box-shadow: 0 0 0 1px rgba(63, 224, 208, .45), 0 0 70px rgba(63, 224, 208, .3), 0 24px 60px rgba(0, 0, 0, .65); }
.rc3 { text-shadow: 0 0 10px rgba(178, 123, 255, .45); }
.rc4 { text-shadow: 0 0 12px rgba(255, 159, 61, .55); }
.rc5 { text-shadow: 0 0 14px rgba(255, 77, 94, .6); }
.item-name .rc6, .modal-head .rc6 {
  background: linear-gradient(90deg, #3fe0d0, #f0c46a, #b27bff, #3fe0d0); background-size: 200% 100%; background-repeat: repeat;
  -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; animation: flow 6s linear infinite;
}
/* Искры над легендарными и выше в окне предмета */
.item-head .tile { overflow: visible; }
.sparks { position: absolute; inset: 0; pointer-events: none; }
.sparks i { position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--rc); box-shadow: 0 0 6px var(--rc); animation: rise 1.8s ease-out infinite; }
.sparks i:nth-child(1) { left: 12%; }
.sparks i:nth-child(2) { left: 34%; animation-delay: .5s; }
.sparks i:nth-child(3) { left: 60%; animation-delay: 1s; }
.sparks i:nth-child(4) { left: 82%; animation-delay: 1.4s; }
/* Добыча высокой редкости на экране победы появляется со вспышкой */
@keyframes lootIn { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.loot-grid .tile.r3, .loot-grid .tile.r4, .loot-grid .tile.r5, .loot-grid .tile.r6, .loot-grid .tile.r7 { animation: lootIn .6s ease-out, var(--fx); }

/* ---------- Справка по боевым качествам ---------- */
.kv.help-row { width: 100%; background: none; border: 0; border-bottom: 1px dashed #262a38; color: inherit; text-align: left; cursor: pointer; font: inherit; font-size: 14px; }
.kv.help-row:hover, .kv.help-row:active { background: rgba(255, 255, 255, .04); }
.kv .chev { margin-left: 8px; color: var(--muted); font-style: normal; font-weight: 400; }
.formula { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: #c9cfdd; }
.formula li { margin-bottom: 4px; }
.calc { font-size: 13px; color: var(--accent-2); margin: 4px 0 0; }

/* ---------- Вход и регистрация ---------- */
.auth { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--bg); overflow-y: auto; }
.auth[hidden] { display: none; }
.auth-card { width: 100%; max-width: 343px; display: flex; flex-direction: column; gap: 12px; }
.auth-card .brand { justify-content: center; font-size: 20px; margin-bottom: 8px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card input { width: 100%; }
.auth-msg { min-height: 18px; margin: 0; font-size: 13px; color: var(--good); }
.auth-msg.bad { color: var(--bad); }
.auth-link { background: none; border: 0; color: var(--muted); font-size: 14px; padding: 8px; text-decoration: underline; cursor: pointer; }

/* Игроки на локации */
.player-list { display: flex; flex-direction: column; gap: 6px; }
.player { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.04); }
.player.me b { color: var(--accent, #e8c36a); }
.player.busy .meta { color: #e07a5f; }

/* Выдвижной чат */
.chat-fab { position: absolute; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: #181b24; color: #e8c36a; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,.5); cursor: pointer; }
.chat-badge, .chat-tab i { background: #e07a5f; color: #fff; font-style: normal; font-size: 11px; line-height: 16px; min-width: 16px; padding: 0 4px; border-radius: 8px; text-align: center; }
.chat-badge { position: absolute; top: -3px; right: -3px; }
.chat-badge[hidden], .chat-tab i[hidden] { display: none; }
.chat-panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 25; height: 52%; display: flex; flex-direction: column; background: #181b24; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.5); transform: translateY(105%); transition: transform .22s ease-out; }
#chat.open .chat-panel { transform: none; }
#chat.open .chat-fab { display: none; }
.chat-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.chat-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: #98a0b3; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.chat-tab.on { color: #e8c36a; border-color: #e8c36a; }
.chat-x { margin-left: auto; background: none; border: 0; color: #98a0b3; font-size: 24px; width: 40px; height: 36px; cursor: pointer; }
.chat-log { flex: 1; overflow-y: auto; padding: 8px 12px; font-size: 14px; }
.chat-msg { margin: 0 0 6px; word-break: break-word; color: #c9cfdc; }
.chat-msg b { color: #8fb6e8; }
.chat-msg.me b { color: #e8c36a; }
.chat-form { display: flex; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0e1015; color: #e6e9f2; font: inherit; font-size: 16px; }
.chat-form button { padding: 0 14px; border-radius: 8px; border: 0; background: #e8c36a; color: #1a1304; font: inherit; font-weight: 600; cursor: pointer; }

/* Список боёв на локации */
.battle-list { display: flex; flex-direction: column; gap: 6px; }
.battle-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.04); font-size: 14px; }
.battle-row.me b { color: var(--accent, #e8c36a); }
.battle-row .vs { color: #e07a5f; }

/* ---------- Экран входа ---------- */
.auth { background: radial-gradient(120% 60% at 50% 0%, #1c2030 0%, var(--bg) 60%); }
.auth-card { gap: 16px; }
.auth-hero { text-align: center; }
.auth-emblem { width: 84px; height: 84px; margin: 0 auto 12px; border-radius: 24px; display: grid; place-items: center; background: linear-gradient(160deg, var(--card-3), var(--card)); border: 1px solid var(--line); box-shadow: 0 0 0 1px rgba(217,164,65,.25), 0 8px 28px rgba(217,164,65,.18); }
.auth-emblem svg { width: 54px; height: 54px; }
.auth-hero h1 { margin: 0; font-size: 24px; letter-spacing: .02em; background: linear-gradient(180deg, var(--accent-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero p { margin: 6px 12px 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.auth-panel { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; }
.auth-tabs[hidden] { display: none; }
.auth-tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; min-height: 38px; border-radius: 7px; cursor: pointer; }
.auth-tabs button.on { background: var(--card-3); color: var(--accent-2); box-shadow: 0 0 0 1px rgba(217,164,65,.35) inset; }
.auth-panel form { display: flex; flex-direction: column; gap: 10px; }
.auth-field { display: flex; align-items: center; gap: 10px; padding: 0 12px; min-height: 48px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; color: var(--dim); }
.auth-field[hidden] { display: none; }
.auth-field:focus-within { border-color: var(--accent); color: var(--accent-2); box-shadow: 0 0 0 3px rgba(217,164,65,.15); }
.auth-field .ico { width: 20px; height: 20px; flex: none; }
.auth-field input { flex: 1; min-width: 0; width: auto; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 16px; padding: 12px 0; }
.auth-field input::placeholder { color: var(--dim); }
.auth-eye { border: 0; background: none; color: var(--muted); padding: 6px; display: grid; cursor: pointer; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.auth-tg { display: flex; justify-content: center; margin-top: 10px; min-height: 40px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-card input:-webkit-autofill { -webkit-text-fill-color: var(--text); box-shadow: 0 0 0 40px var(--bg-2) inset; }

.hist-log { max-height: 55vh; overflow-y: auto; font-size: 13px; }
.hist-log p { margin: 2px 0; }

/* ---------- Появление экранов и уважение к настройке «меньше движения» ---------- */
.screen:not([hidden]) { animation: fade .2s ease-out; }
.mob, .tile { transition: transform .08s, border-color .15s; }
.mob:active:not(:disabled) { transform: scale(.98); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}

/* снаряжение в карточке героя из боя */
.gear-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.gear-grid .slot-cell { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.gear-grid .slot-cell small { font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: .03em; text-align: center; }
.gear-grid .slot-cell .tile { width: 100%; cursor: pointer; }

/* стак ресурса в сумке: количество в углу */
.tile.stack { position: relative; }
.tile.stack .count { position: absolute; right: 3px; bottom: 2px; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; font-variant-numeric: tabular-nums; }

/* ---------- Свои поля: список, число с кнопками, флажки ---------- */
.csel { position: relative; display: block; min-width: 0; }
.csel select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.csel-face { display: block; font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 30px 9px 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.csel:active .csel-face, .csel-face:hover { border-color: var(--accent); }
.csel-arrow { position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
.market-tools .csel, .mf-range .csel { flex: 1; min-width: 0; }
.market-tools .csel-face, .mf-range .csel-face { padding: 6px 26px 6px 8px; font-size: 13px; }
.toggle .csel { min-width: 120px; }

.optpick { position: fixed; inset: 0; z-index: 70; display: flex; justify-content: center; align-items: flex-end; }
.optpick-back { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); animation: fade .2s; }
.optpick-sheet { position: relative; width: min(100%, 460px); max-height: 70vh; display: flex; flex-direction: column; background: #1d2130; border: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .5); animation: sheetUp .22s ease-out; padding-bottom: env(safe-area-inset-bottom); }
.optpick-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 8px 16px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.optpick-x { font-size: 22px; line-height: 1; }
.optpick-list { overflow-y: auto; padding: 0 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.pick-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 15px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.pick-opt:disabled { opacity: .4; }
.pick-opt.on { border-color: var(--accent); background: rgba(217, 164, 65, .14); color: var(--accent-2); font-weight: 700; }
.pick-mark { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.pick-opt.on .pick-mark { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 40%, transparent 45%); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.cnum { display: flex; align-items: stretch; gap: 4px; width: 100%; }
.cnum-field { flex: 1; min-width: 56px; display: flex; }
.cnum-field input { width: 100%; min-width: 0; text-align: center; font-variant-numeric: tabular-nums; padding: 9px 4px; -moz-appearance: textfield; }
.cnum-field input::-webkit-outer-spin-button, .cnum-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cnum-btn { flex: none; min-width: 36px; padding: 0 6px; font: inherit; font-size: 13px; font-weight: 700; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; touch-action: manipulation; user-select: none; }
.cnum-btn:active { background: rgba(217, 164, 65, .2); border-color: var(--accent); }
.cnum-btn.max { color: var(--accent-2); border-color: rgba(217, 164, 65, .5); }
.mf-range:has(.cnum) { flex-direction: column; align-items: stretch; }
.mf-range .cnum-btn { min-width: 32px; }

/* флажки и переключатели */
input[type="checkbox"], input[type="radio"] { -webkit-appearance: none; appearance: none; flex: none; width: 20px; height: 20px; margin: 0; border: 2px solid #3b4258; background: var(--card-2); display: inline-grid; place-content: center; cursor: pointer; transition: background .15s, border-color .15s; }
input[type="checkbox"] { border-radius: 6px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::after { content: ""; width: 5px; height: 10px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) scale(0); margin-top: -2px; transition: transform .12s; }
input[type="radio"]::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink); transform: scale(0); transition: transform .12s; }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after { transform: rotate(45deg) scale(1); }
input[type="radio"]:checked::after { transform: scale(1); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .4; }
.toggle input[type="checkbox"] { width: 42px; height: 24px; border-radius: 999px; place-content: unset; position: relative; }
.toggle input[type="checkbox"]::after { position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; margin: 0; border: 0; border-radius: 50%; background: var(--muted); transform: none; transition: transform .15s, background .15s; }
.toggle input[type="checkbox"]:checked::after { background: var(--accent-ink); transform: translateX(18px); }
input:focus-visible, .cnum-btn:focus-visible, .pick-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* рынок ресурсов: поля количества и цены */
.mat-field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.mat-form { padding-bottom: 10px; border-bottom: 1px dashed #262a38; margin-bottom: 12px; }
.mat-form .row img, .mat-form .row .ico { width: 28px; height: 28px; }
.bag-expand { padding: 10px 12px 0; justify-content: center; }
p.bag-expand { text-align: center; margin: 0; }
.tile .dur { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, .55); overflow: hidden; z-index: 2; }
.tile .dur i { display: block; height: 100%; background: #e8c547; }
.tile .dur.low i { background: #ff8a3d; }
.tile .dur.zero { background: var(--bad); }
.tile.broken > img { filter: grayscale(1) brightness(.55); }
.repair-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.repair-row { display: flex; align-items: center; gap: 10px; }
.repair-row .tile { width: 48px; flex: none; }
.repair-row .grow { flex: 1; min-width: 0; }
.prof-bar { margin: 6px 0 4px; }
.prof-bar .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.prof-bar .bar { height: 6px; border-radius: 3px; background: #151821; overflow: hidden; margin-top: 4px; }
.prof-bar .bar i { display: block; height: 100%; background: var(--accent-2); }

/* ---------- Справка по центру (ресурсы, термины) ---------- */
.sheet-wrap.centered { align-items: center; padding: 14px; }
.sheet-wrap.centered .sheet { max-width: 440px; border: 1px solid #3a4055; border-radius: 16px; padding: 14px 16px 16px; background: linear-gradient(180deg, #1d2130, #171a23); box-shadow: 0 0 0 1px rgba(217, 164, 65, .12), 0 24px 60px rgba(0, 0, 0, .65); animation: pop .16s ease-out; }
.sheet-wrap.centered .sheet-grip { display: none; }

/* Иконка чата: перенос долгим тапом */
.chat-fab { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chat-fab.moving { transform: scale(1.15); box-shadow: 0 0 0 3px rgba(232, 195, 106, .5), 0 6px 18px rgba(0, 0, 0, .6); }
.chat-item { display: inline; padding: 0 3px; border: 1px solid var(--line); border-radius: 6px; background: #0e1015; font: inherit; font-weight: 600; cursor: pointer; }
.chat-item.rc0 { color: #b8bfcc; }

/* ---------- Игроки на локации и обмен ---------- */
.player.tap { cursor: pointer; }
.player.tap:active { background: rgba(255, 255, 255, .09); }
.pc-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.pc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-bottom: 8px; }
.pc-stat { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, .04); }
.trade-side { margin-bottom: 10px; }
.trade-side.their.ok { box-shadow: 0 0 0 1px rgba(100, 200, 120, .6); border-radius: 10px; padding: 4px; }
.trade-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0; }
.trade-gold { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.trade-gold input, .trade-edit input { width: 110px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #0e1015; color: #e6e9f2; font: inherit; font-size: 16px; }
.trade-edit { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.trade-banner { position: absolute; left: 10px; right: 10px; bottom: calc(132px + env(safe-area-inset-bottom)); z-index: 60; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: #1d2130; border: 1px solid var(--accent, #e8c36a); box-shadow: 0 6px 22px rgba(0, 0, 0, .6); }
.trade-banner span { flex: 1; font-size: 14px; }

/* Счётчик кадров */
#fps { position: fixed; top: calc(2px + env(safe-area-inset-top)); right: 4px; z-index: 300; padding: 1px 6px; border-radius: 6px; font: 600 11px/16px ui-monospace, monospace; background: rgba(0, 0, 0, .55); color: #9fe39f; pointer-events: none; }
#fps.mid { color: #e8c36a; }
#fps.low { color: #ff7a7a; }

/* Кузница и сумки в окнах: десятки вещей сразу — вращающиеся рамки и свечение редких вещей не анимируем (роняли fps) */
.picker .tile, .picker .tile::before, .picker .tile::after, .modal-grid .tile, .modal-grid .tile::before { animation: none !important; }
.picker .tile::before, .modal-grid .tile::before { filter: none !important; }

/* Листание вкладок свайпом */
#hub-body { touch-action: pan-y; overflow-x: hidden; }
.tab.slide-l { animation: tabInL .24s cubic-bezier(.2, .8, .3, 1); }
.tab.slide-r { animation: tabInR .24s cubic-bezier(.2, .8, .3, 1); }
@keyframes tabInL { from { transform: translateX(46px); opacity: .25; } to { transform: none; opacity: 1; } }
@keyframes tabInR { from { transform: translateX(-46px); opacity: .25; } to { transform: none; opacity: 1; } }

/* Пока вкладка въезжает: рамки редких вещей стоят, слой готовится заранее — частое листание не роняет fps */
.tab.slide-l, .tab.slide-r { will-change: transform, opacity; }
.tab.slide-l .tile, .tab.slide-r .tile, .tab.slide-l .tile::before, .tab.slide-r .tile::before { animation-play-state: paused !important; }

/* Игра открыта на другом устройстве: окно поверх всего */
.frozen { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(8, 10, 14, .92); backdrop-filter: blur(4px); }
.frozen[hidden] { display: none; }
.frozen-card { max-width: 340px; text-align: center; background: var(--card, #1b1f27); border: 1px solid var(--line); border-radius: 14px; padding: 22px 18px; }
.frozen-card h2 { margin: 0 0 10px; font-size: 18px; }
.frozen-card p { margin: 0 0 14px; color: var(--dim); font-size: 14px; line-height: 1.4; }
.frozen-card .frozen-note { margin: 10px 0 0; font-size: 12px; }
