/* ===== БАЗОВЫЕ НАСТРОЙКИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
    /* убираем общий скролл, используем внутренние */
}

body {
    background: #eef2f5;
    color: #1a2634;
    font-family: 'Share Tech Mono', monospace;
    line-height: 1.7;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.doc-wrapper {
    max-width: 1400px;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 2rem;
    background: #fcfdfd;
    border: 1px solid #cdd6df;
    border-radius: 8px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.03), 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 1.5rem;
}

/* ===== ОГЛАВЛЕНИЕ (ЛЕВАЯ КОЛОНКА) ===== */
.toc {
    background: #f4f7fa;
    border: 1px solid #d8e0e8;
    border-radius: 4px;
    padding: 1.2rem;
    overflow-y: auto;
    height: 100%;
    /* уникальный ползунок для оглавления */
    scrollbar-width: thin;
    scrollbar-color: #8fa0b3 #e9eef3;
}

.toc::-webkit-scrollbar {
    width: 8px;
}

.toc::-webkit-scrollbar-track {
    background: #e9eef3;
    border-radius: 4px;
}

.toc::-webkit-scrollbar-thumb {
    background: #8fa0b3;
    border-radius: 4px;
    border: 2px solid #e9eef3;
}

.toc::-webkit-scrollbar-thumb:hover {
    background: #6b7d91;
}

.toc h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    color: #0b2b3d;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 1.2rem;
    border-bottom: 2px solid #cbd5e0;
    padding-bottom: 0.6rem;
}

.toc ul {
    list-style: none;
}

.toc li {
    margin-bottom: 0.4rem;
}

.toc a {
    display: block;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
    color: #1f3a4b;
    text-decoration: none;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
    border-left: 3px solid transparent;
    transition: background 0.1s, color 0.1s;
}

.toc a:hover {
    background: #e2e8f0;
    color: #005a8c;
    border-left-color: #0077be;
}

.toc a .num {
    display: inline-block;
    width: 1.6rem;
    color: #6a7f96;
    font-size: 0.7rem;
    font-weight: bold;
}

/* ===== ОСНОВНОЙ КОНТЕНТ (ПРАВАЯ КОЛОНКА) ===== */
.content {
    overflow-y: auto;
    padding-right: 0.8rem;
    height: 100%;
    /* уникальный ползунок для основного контента */
    scrollbar-width: thin;
    scrollbar-color: #b0bec5 #f1f4f7;
}

.content::-webkit-scrollbar {
    width: 10px;
}

.content::-webkit-scrollbar-track {
    background: #f1f4f7;
    border-radius: 4px;
}

.content::-webkit-scrollbar-thumb {
    background: #b0bec5;
    border-radius: 4px;
    border: 2px solid #f1f4f7;
}

.content::-webkit-scrollbar-thumb:hover {
    background: #90a4ae;
}

h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: 2rem;
    color: #003153;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
    line-height: 1.2;
}

h1 .accent {
    color: #7c4d9e;
}

.doc-subhead {
    font-size: 0.85rem;
    color: #4f6b7e;
    border-bottom: 2px solid #dce4ec;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 0.05em;
}

.doc-subhead span {
    background: #eef3f8;
    padding: 0.2rem 0.8rem;
    border-radius: 2px;
    font-size: 0.7rem;
    color: #1f3a4b;
    border: 1px solid #cdd6df;
}

h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.1rem;
    color: #003153;
    margin: 2.2rem 0 1rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid #dce4ec;
    display: inline-block;
    letter-spacing: 0.04em;
}

h2 .emoji {
    margin-right: 0.3rem;
}

h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    color: #1f4a6b;
    margin: 1.5rem 0 0.6rem 0;
    letter-spacing: 0.02em;
}

h4 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: #003153;
    margin: 0 0 0.3rem 0;
    letter-spacing: 0.02em;
}

p {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    color: #1f2c3a;
    line-height: 1.8;
    margin-bottom: 0.7rem;
}

.text-muted {
    color: #5b7184;
    font-size: 0.8rem;
}

/* ===== СПОЙЛЕР ===== */
.spoiler {
    background: #2d2d2d;
    color: #2d2d2d;
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
    transition: color 0.2s;
    cursor: default;
}

.spoiler:hover {
    color: #ffd966;
    background: #2d2d2d;
}

/* ===== КАРТОЧКИ ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.2rem;
    margin: 1.2rem 0 1rem 0;
}

.card {
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 1.2rem;
}

.card:hover {
    border-color: #b0c8dd;
}

.card .card-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: #005a8c;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.card .card-title .badge {
    font-size: 0.45rem;
    background: #e2e8f0;
    padding: 0.1rem 0.5rem;
    border-radius: 2px;
    color: #2d4a62;
    border: 1px solid #cbd5e0;
    font-family: 'Share Tech Mono', monospace;
}

.card p,
.card li {
    font-size: 0.85rem;
    color: #1f2c3a;
}

.card ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.card ul li {
    padding: 0.15rem 0 0.15rem 1rem;
    position: relative;
}

.card ul li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #0077be;
    opacity: 0.6;
}

/* ===== БОЕВОЙ ПОТОК ===== */
.combat-flow {
    background: #f2f7fc;
    border-left: 4px solid #0077be;
    border-radius: 2px;
    padding: 1rem 1.5rem;
    margin: 1rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.8rem;
    align-items: center;
}

.combat-flow .step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    color: #1f2c3a;
}

.combat-flow .step .num {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    color: #0077be;
    background: #e4ebf3;
    border-radius: 2px;
    padding: 0.1rem 0.5rem;
    border: 1px solid #cbd5e0;
}

.combat-flow .arrow {
    color: #6a7f96;
    font-size: 1.1rem;
}

.damage-ok {
    color: #2b7a3e;
}

.damage-fail {
    color: #b33c3c;
}

.crit-highlight {
    color: #b26b00;
}

/* ===== ЦИТАТА ===== */
.quote-block {
    background: #f2f7fc;
    border-left: 4px solid #7c4d9e;
    padding: 0.8rem 1.5rem;
    border-radius: 0 2px 2px 0;
    margin: 1rem 0;
}

.quote-block p {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1rem;
    color: #003153;
    margin: 0;
}

.quote-block .source {
    font-size: 0.75rem;
    color: #4f6b7e;
    margin-top: 0.1rem;
}

/* ===== ХАБ ===== */
.hub-features {
    list-style: none;
    padding: 0;
    margin: 0.6rem 0;
}

.hub-features li {
    padding: 0.3rem 0 0.3rem 1.6rem;
    position: relative;
    font-size: 0.85rem;
    color: #1f2c3a;
}

.hub-features li::before {
    content: "▹";
    position: absolute;
    left: 0;
    color: #0077be;
    font-size: 1.1rem;
}

/* ===== БИЛЕТЫ ===== */
.ticket-rules {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin: 1rem 0;
}

.rule-card {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 0.8rem 1.2rem;
}

.rule-card:hover {
    border-color: #b0c8dd;
}

.rule-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    line-height: 1.4;
}

.rule-card ul {
    list-style: none;
    padding: 0.1rem 0 0 0;
    margin: 0.2rem 0;
}

.rule-card ul li {
    padding: 0.05rem 0 0.05rem 1rem;
    position: relative;
    font-size: 0.85rem;
    color: #1f2c3a;
}

.rule-card ul li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #0077be;
}

/* ===== МАГАЗИН ===== */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.8rem;
    margin: 1rem 0;
}

.shop-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 0.7rem 1rem;
}

.shop-item:hover {
    border-color: #b0c8dd;
}

.shop-item .item-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
    line-height: 1.2;
}

.shop-item .price {
    color: #b26b00;
    font-weight: bold;
    font-size: 0.8rem;
}

/* ===== ПРОКАЧКА АНТИВИРУСА ===== */
.upgrade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.8rem;
    margin: 1rem 0;
}

.upgrade-card {
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 0.8rem 1rem;
}

.upgrade-card:hover {
    border-color: #b0c8dd;
}

.upgrade-card .upgrade-level {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: #005a8c;
    display: block;
    margin-bottom: 0.2rem;
    border-bottom: 1px solid #dce4ec;
    padding-bottom: 0.2rem;
}

.upgrade-card ul {
    list-style: none;
    padding: 0;
    margin: 0.1rem 0 0 0;
}

.upgrade-card ul li {
    padding: 0.1rem 0 0.1rem 1rem;
    position: relative;
    font-size: 0.8rem;
    color: #1f2c3a;
}

.upgrade-card ul li::before {
    content: "▹";
    position: absolute;
    left: 0;
    color: #0077be;
    font-size: 0.9rem;
}

/* ===== УЯЗВИМОСТИ ===== */
.vuln-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.2rem;
    margin: 1.2rem 0;
}

.vuln-detail {
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 1.2rem;
}

.vuln-detail:hover {
    border-color: #b0c8dd;
}

.vuln-detail h3 {
    margin-top: 0;
    font-size: 0.75rem;
    color: #003153;
}

.vuln-detail p {
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.vuln-detail p em {
    color: #1f4a6b;
}

/* ===== ЛОКАЦИИ ===== */
.location-card {
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 1.2rem 1.5rem;
    margin: 1.5rem 0;
}

.location-card:hover {
    border-color: #b0c8dd;
}

.location-card h3 {
    margin-top: 0;
    font-size: 0.85rem;
}

.location-meta {
    background: #eef3f8;
    padding: 0.3rem 0.6rem;
    border-radius: 2px;
    margin: 0.3rem 0 0.6rem 0;
    font-size: 0.8rem;
    color: #1f3a4b;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem;
}

.location-meta .meta-tag {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.45rem;
    color: #005a8c;
    background: #dce4ec;
    padding: 0.05rem 0.5rem;
    border-radius: 2px;
    border: 1px solid #cbd5e0;
}

.virus-list {
    list-style: none;
    padding: 0;
    margin: 0.3rem 0 0.5rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
}

.virus-list li {
    font-size: 0.8rem;
    color: #1f2c3a;
    background: #f4f6f9;
    padding: 0.05rem 0.6rem;
    border-radius: 2px;
    border: 1px solid #dce4ec;
}

.puzzle-block {
    background: #eaf1fa;
    border-left: 4px solid #0077be;
    padding: 0.6rem 1rem;
    border-radius: 0 2px 2px 0;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #1f2c3a;
}

.puzzle-block strong {
    color: #003153;
}

/* ===== ЖИТЕЛИ ===== */
.inhabitants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.inhabitant-card {
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 1rem 1.2rem;
}

.inhabitant-card:hover {
    border-color: #b0c8dd;
}

.inhabitant-card h4 {
    margin-top: 0;
    font-size: 0.65rem;
    color: #003153;
}

.inhabitant-card p {
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.inhabitant-card p strong {
    color: #1f4a6b;
}

/* ===== ТАБЛИЦА УЯЗВИМОСТЕЙ ===== */
.mapping-table {
    display: flex;
    flex-direction: column;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
    background: #f8fafc;
}

.mapping-row {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1.2fr;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid #dce4ec;
    align-items: center;
}

.mapping-row.header {
    background: #eef3f8;
    font-weight: bold;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.45rem;
    color: #003153;
    letter-spacing: 0.04em;
}

.mapping-row:last-child {
    border-bottom: none;
}

.mapping-row span {
    font-size: 0.75rem;
}

.mapping-row .vuln-tag {
    font-size: 0.6rem;
}

/* таблицы с одной колонкой уязвимости */
.mapping-table:has(.mapping-row:first-child .vuln-tag) .mapping-row {
    grid-template-columns: 2fr 1.2fr;
}

.mapping-table:has(.mapping-row:first-child .vuln-tag) .mapping-row.header {
    grid-template-columns: 2fr 1.2fr;
}

.vuln-tag {
    display: inline-block;
    padding: 0.05rem 0.5rem;
    border-radius: 2px;
    font-size: 0.6rem;
    font-weight: bold;
    text-align: center;
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 0.01em;
    margin: 0.05rem 0;
}

.vuln-tag.network {
    background: #d4e2f0;
    color: #003b6f;
}

.vuln-tag.malware {
    background: #fcd9d9;
    color: #8b2b2b;
}

.vuln-tag.crypto {
    background: #d9e8d9;
    color: #1d5c1d;
}

.vuln-tag.os {
    background: #e5d9f0;
    color: #4a2b7a;
}

/* ===== БОССЫ ===== */
.boss-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.boss-card {
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 1rem 1.2rem;
}

.boss-card:hover {
    border-color: #b0c8dd;
}

.boss-card .boss-name {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    color: #a1323a;
    display: block;
    margin-bottom: 0.2rem;
}

.boss-card .boss-desc {
    font-size: 0.75rem;
    color: #1f2c3a;
}

.boss-card .boss-mech {
    font-size: 0.65rem;
    color: #3a546a;
    border-top: 1px solid #dce4ec;
    padding-top: 0.4rem;
    margin-top: 0.4rem;
}

.boss-mb {
    border-color: #7c4d9e;
    background: #f4f0fa;
}

/* ===== МУЗЫКА ===== */
.music-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin: 0.8rem 0;
}

.music-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 2px;
    padding: 0.3rem 0.8rem;
    font-size: 0.7rem;
    color: #1f2c3a;
}

.music-item .icon {
    font-size: 0.9rem;
    opacity: 0.7;
}

.music-item .label {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.4rem;
    color: #4f6b7e;
    letter-spacing: 0.04em;
    margin-right: 0.1rem;
}

.boss-theme {
    grid-column: 1 / -1;
    justify-content: center;
    border-color: #7c4d9e;
    background: #f4f0fa;
}

/* ===== БАДЖИ КОМИКСОВ ===== */
.comic-badge {
    display: inline-block;
    background: #edf2f9;
    border: 1px solid #cdd6df;
    border-radius: 2px;
    padding: 0.1rem 0.8rem;
    font-size: 0.5rem;
    font-family: 'Press Start 2P', monospace;
    color: #1f3a4b;
    letter-spacing: 0.04em;
}

/* ===== ПЕРСОНАЖИ ===== */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.char-card {
    background: #f8fafc;
    border: 1px solid #dce4ec;
    border-radius: 4px;
    padding: 1rem 1.2rem;
}

.char-card:hover {
    border-color: #b0c8dd;
}

.char-card .char-name {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    color: #005a8c;
    display: block;
    margin-bottom: 0.1rem;
}

.char-card .char-role {
    font-size: 0.65rem;
    color: #4f6b7e;
    display: block;
    margin-bottom: 0.2rem;
}

.char-card .char-desc {
    font-size: 0.75rem;
    color: #1f2c3a;
}

.char-card .speech-effect {
    font-size: 0.65rem;
    color: #4f6b7e;
    border-top: 1px solid #dce4ec;
    padding-top: 0.3rem;
    margin-top: 0.4rem;
}

/* ===== СВОДКА ===== */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.summary-grid>div {
    background: #f8fafc;
    border-radius: 2px;
    padding: 0.5rem 0.8rem;
    border: 1px solid #dce4ec;
}

.summary-label {
    display: block;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.45rem;
    color: #005a8c;
    margin-bottom: 0.1rem;
}

.summary-value {
    font-size: 0.75rem;
    color: #1f2c3a;
}

/* ===== РАЗДЕЛИТЕЛИ ===== */
.divider {
    height: 2px;
    background: #dce4ec;
    margin: 2rem 0;
}

/* ===== ФУТЕР ===== */
.footer {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid #dce4ec;
    text-align: center;
    font-size: 0.65rem;
    color: #6a7f96;
    letter-spacing: 0.05em;
    font-family: 'Share Tech Mono', monospace;
}

.footer span {
    color: #003153;
    opacity: 0.3;
}

/* ===== АДАПТИВ ===== */
@media (max-width: 900px) {
    .doc-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
    }

    .toc {
        height: auto;
        max-height: 40vh;
        overflow-y: auto;
    }

    .content {
        height: auto;
    }

    .toc ul {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem 0.6rem;
    }

    .toc li {
        margin-bottom: 0;
    }

    .toc a {
        padding: 0.2rem 0.6rem;
        border-left: none;
        border-bottom: 2px solid transparent;
        font-size: 0.8rem;
    }

    .toc a:hover {
        border-left-color: transparent;
        border-bottom-color: #0077be;
        background: transparent;
    }

    .toc a .num {
        width: auto;
        margin-right: 0.3rem;
    }

    .mapping-row {
        grid-template-columns: 1fr;
        gap: 0.2rem;
        padding: 0.5rem 0.8rem;
    }

    .mapping-row.header {
        display: none;
    }

    .rule-card {
        flex-direction: column;
        align-items: stretch;
    }

    .inhabitants-grid,
    .shop-grid,
    .upgrade-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    body {
        padding: 0.8rem;
    }

    .doc-wrapper {
        padding: 0.8rem;
    }

    h1 {
        font-size: 1.4rem;
    }

    .card-grid,
    .boss-grid,
    .char-grid,
    .vuln-detail-grid,
    .inhabitants-grid,
    .shop-grid,
    .upgrade-grid {
        grid-template-columns: 1fr;
    }

    .combat-flow {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }

    .combat-flow .arrow {
        transform: rotate(90deg);
        align-self: center;
    }

    .music-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .location-card {
        padding: 0.8rem;
    }
}

@media (max-width: 450px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .location-card h3 {
        font-size: 0.7rem;
    }

    .virus-list li {
        font-size: 0.7rem;
        padding: 0.05rem 0.5rem;
    }
}