:root {
    --bg: #0c0e13;
    --bg2: #141822;
    --card: #171c27;
    --card2: #1d2432;
    --line: #262e3d;
    --text: #e8e6df;
    --muted: #8b93a4;
    --gold: #d9a441;
    --gold-dim: #a97f31;
    --gun: #d98b3f;
    --heal: #5bb56a;
    --spirit: #a06cd6;
    --danger: #d5604f;
    --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
    background: radial-gradient(1200px 600px at 50% -10%, #1a1410 0%, var(--bg) 55%) fixed;
    color: var(--text);
    padding-top: calc(env(safe-area-inset-top) + 96px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 70px);
    overscroll-behavior-y: contain;
}

/* --- Топбар --- */
#topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 20;
    padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
    background: linear-gradient(180deg, rgba(12,14,19,.98), rgba(12,14,19,.86) 70%, transparent);
    backdrop-filter: blur(8px);
}
#title {
    font-weight: 800; letter-spacing: 3px; font-size: 20px; color: var(--gold);
    text-shadow: 0 0 18px rgba(217,164,65,.35); margin-bottom: 8px;
}
#search {
    width: 100%; border: 1px solid var(--line); background: var(--bg2); color: var(--text);
    border-radius: 10px; padding: 10px 12px; font-size: 15px; outline: none;
}
#search:focus { border-color: var(--gold-dim); }

/* --- Таббар --- */
#tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: rgba(15,18,25,.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab {
    background: none; border: none; color: var(--muted);
    padding: 9px 0 8px; font-size: 11px; font-weight: 600;
    display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
}
.tab span { font-size: 19px; filter: grayscale(.4) opacity(.75); }
.tab.active { color: var(--gold); }
.tab.active span { filter: none; }

/* --- Общее --- */
#view { padding: 12px; max-width: 720px; margin: 0 auto; }
.loading, .empty { text-align: center; color: var(--muted); padding: 40px 0; }
.section-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 18px 4px 8px; }

/* --- Сетка героев --- */
.hero-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.hero-cell {
    position: relative; border-radius: var(--radius); overflow: hidden; cursor: pointer;
    aspect-ratio: 16/9; border: 1px solid var(--line); background: var(--card);
}
.hero-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-cell .name {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 10px 8px;
    font-weight: 700; font-size: 15px;
    background: linear-gradient(transparent, rgba(8,9,12,.92));
}
.hero-cell .role { position: absolute; top: 8px; left: 8px; font-size: 10px; color: var(--gold);
    background: rgba(8,9,12,.6); padding: 3px 7px; border-radius: 6px; }

/* --- Карточка (герой/предмет) --- */
.card-hero-img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.card-h1 { font-size: 22px; font-weight: 800; margin: 12px 2px 2px; }
.card-role { color: var(--gold); font-size: 13px; margin: 0 2px 6px; }
.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; }
.block h3 { margin: 0 0 8px; font-size: 14px; color: var(--gold-dim); }
.ability { margin: 10px 0; }
.ability b { color: var(--text); }
.ability p { margin: 3px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.tip { color: var(--muted); font-size: 14px; margin: 7px 0; padding-left: 14px; position: relative; line-height: 1.45; }
.tip::before { content: "•"; color: var(--gold); position: absolute; left: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.chip.hero { color: var(--danger); }
.link { color: var(--gold); text-decoration: none; }
.muted { color: var(--muted); font-size: 13px; }

/* --- Кнопки-строки --- */
.rowbtn {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 10px 12px; margin-top: 8px; color: var(--text); font-size: 15px; cursor: pointer; text-align: left;
}
.rowbtn .arrow { margin-left: auto; color: var(--muted); }

/* --- Билд-коллаж --- */
.collage { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; margin-top: 8px; }

/* --- Фильтры предметов --- */
.filters { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.fbtn { background: var(--card); border: 1px solid var(--line); color: var(--muted);
    border-radius: 20px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.fbtn.active { color: var(--bg); }
.fbtn.gun.active { background: var(--gun); border-color: var(--gun); }
.fbtn.heal.active { background: var(--heal); border-color: var(--heal); }
.fbtn.spirit.active { background: var(--spirit); border-color: var(--spirit); }
.fbtn.all.active { background: var(--gold); border-color: var(--gold); }
.tiers { display: flex; gap: 6px; margin-bottom: 12px; }
.tbtn { flex: 1; background: var(--card); border: 1px solid var(--line); color: var(--muted);
    border-radius: 8px; padding: 7px 0; font-size: 13px; cursor: pointer; text-align: center; }
.tbtn.active { color: var(--gold); border-color: var(--gold-dim); }

.item-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.item-cell { cursor: pointer; text-align: center; }
.item-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.item-cell .n { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.2;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.item-card-img { width: 128px; height: 128px; border-radius: 12px; border: 1px solid var(--line); display: block; margin: 0 auto; }
.cat-tag { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.cat-Weapon { background: rgba(217,139,63,.18); color: var(--gun); }
.cat-Vitality { background: rgba(91,181,106,.18); color: var(--heal); }
.cat-Spirit { background: rgba(160,108,214,.18); color: var(--spirit); }
.statline { color: var(--text); font-size: 14px; margin: 5px 0; }
.statline b { color: var(--gold); }

/* --- Тир-лист --- */
.tier-row { display: flex; align-items: center; gap: 10px; background: var(--card);
    border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-top: 7px; }
.tier-rank { font-weight: 800; color: var(--gold); width: 26px; }
.tier-name { flex: 1; font-weight: 600; }
.tier-wr { color: var(--heal); font-weight: 700; }
.tier-pr { color: var(--muted); font-size: 12px; width: 64px; text-align: right; }

/* --- Патчи --- */
.patch { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px; margin-top: 10px; }
.patch h3 { margin: 0 0 6px; color: var(--gold); font-size: 15px; }
.patch .body { color: var(--muted); font-size: 14px; line-height: 1.5; white-space: pre-line; }

.backbtn { display: inline-flex; align-items: center; gap: 6px; color: var(--gold);
    background: none; border: none; font-size: 15px; cursor: pointer; padding: 4px 0; margin-bottom: 6px; }
