/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --germanium: #D9D7C7;
    --camel: #C3976A;
    --curry: #AC714A;
    --leather: #924A36;
    --maroon: #3A160E;
    --maroon-light: #5a2a1a;
    --maroon-dark: #1a0a05;
    --sand: #e8e0d0;
    --sand-light: #f0ead8;
    --text-dark: #2a1508;
    --text-light: #f5f0e8;
    --sidebar-width: 280px;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background-color: var(--sand-light);
    color: var(--text-dark);
    line-height: 1.7;
    min-height: 100vh;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--maroon-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--leather);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--curry);
}

/* ===== HEADER ===== */
.site-header {
    background: linear-gradient(135deg, var(--maroon-dark) 0%, var(--maroon) 50%, var(--leather) 100%);
    color: var(--germanium);
    padding: 1.5rem 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(58, 22, 14, 0.5);
    border-bottom: 3px solid var(--camel);
}

.site-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--maroon-dark) 0%, var(--maroon) 100%);
    color: var(--germanium);
    overflow-y: auto;
    z-index: 900;
    transition: transform 0.3s ease;
    border-right: 3px solid var(--camel);
    padding-top: 80px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 899;
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-nav .nav-section {
    border-bottom: 1px solid rgba(195, 151, 106, 0.2);
}

.sidebar-nav .nav-section:last-child {
    border-bottom: none;
}

.nav-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    color: var(--camel);
    font-size: 0.85rem;
    max-font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
    transition: all 0.2s ease;
    user-select: none;
}

.nav-section-title:hover {
    background: rgba(195, 151, 106, 0.15);
    color: var(--germanium);
}

.nav-section-title .icon {
    margin-right: 8px;
    font-size: 1rem;
}

.nav-section-title .arrow {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    display: inline-block;
}

.nav-section-title.collapsed .arrow {
    transform: rotate(-90deg);
}

.nav-section-title .section-icon {
    margin-right: 8px;
}

.nav-submenu {
    max-height: 800px;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.nav-submenu.collapsed {
    max-height: 0;
}

.nav-elem {
    display: block;
    padding: 0.5rem 1.2rem 0.5rem 2.8rem;
    color: var(--germanium);
    text-decoration: none;
    font-size: 0.82rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    opacity: 0.85;
}

.nav-elem:hover {
    background: rgba(195, 151, 106, 0.15);
    color: var(--camel);
    border-left-color: var(--camel);
    opacity: 1;
    padding-left: 3.2rem;
}

.nav-elem.active {
    color: var(--camel);
    border-left-color: var(--camel);
    opacity: 1;
    background: rgba(195, 151, 106, 0.1);
}

.sidebar-footer {
    padding: 1.5rem;
    text-align: center;
    color: var(--camel);
    font-size: 0.7rem;
    letter-spacing: 1px;
    opacity: 0.6;
    border-top: 1px solid rgba(195, 151, 106, 0.2);
    margin-top: 1rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 80px 2rem 4rem;
    max-width: 1200px;
    transition: margin-left 0.3s ease;
}

/* ===== HERO SECTION ===== */
.hero {
    background: linear-gradient(135deg, var(--maroon) 0%, var(--leather) 100%);
    color: var(--germanium);
    padding: 3rem 2.5rem;
    border-radius: 12px;
    margin-bottom: 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 2px solid var(--camel);
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23C3976A' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.hero > * {
    position: relative;
    z-index: 1;
}

.hero h2 {
    font-size: 2.2rem;
    color: var(--camel);
    margin-bottom: 1rem;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.hero p {
    font-size: 1.05rem;
    max-width: 700px;
    margin: 0 auto;
    opacity: 0.9;
    line-height: 1.8;
}

/* ===== SECTION STYLES ===== */
.section {
    margin-bottom: 3rem;
    scroll-margin-top: 80px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 3px solid var(--leather);
    position: relative;
}

.section-header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 80px;
    height: 3px;
    background: var(--camel);
}

.section-header .section-icon {
    font-size: 1.8rem;
}

.section-header h2 {
    font-size: 1.6rem;
    color: var(--maroon);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.section-content {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 15px rgba(58, 22, 14, 0.08);
    border: 1px solid rgba(146, 74, 54, 0.15);
}

.section-content h3 {
    font-size: 1.2rem;
    color: var(--leather);
    margin: 1.5rem 0 0.8rem;
    padding-left: 12px;
    border-left: 4px solid var(--camel);
}

.section-content h3:first-child {
    margin-top: 0;
}

.section-content p {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.section-content ul, .section-content ol {
    margin: 0.8rem 0 1rem 1.5rem;
}

.section-content li {
    margin-bottom: 0.5rem;
}

.section-content li::marker {
    color: var(--leather);
}

/* ===== INFO BOXES ===== */
.info-box {
    background: linear-gradient(135deg, var(--sand) 0%, var(--sand-light) 100%);
    border-left: 5px solid var(--camel);
    padding: 1.2rem 1.5rem;
    border-radius: 0 8px 8px 0;
    margin: 1.2rem 0;
}

.info-box.warning {
    border-left-color: var(--leather);
    background: linear-gradient(135deg, #f5e6d8 0%, #faf0e6 100%);
}

.info-box.tip {
    border-left-color: var(--curry);
    background: linear-gradient(135deg, #e8dcc8 0%, #f2ead8 100%);
}

.info-box strong {
    color: var(--leather);
}

/* ===== TABLES ===== */
.sectionTextContent table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2rem 0;
    font-size: 0.92rem;
}

.sectionTextContent table.table-bordered tbody tr:first-child {
    background: linear-gradient(135deg, var(--maroon) 0%, var(--leather) 100%);
    color: var(--germanium);
}

.sectionTextContent table.table-bordered tbody tr:first-child td {
    padding: 0.8rem 1rem;
    text-align: left;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.8rem;
}

.sectionTextContent td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(146, 74, 54, 0.12);
}

.sectionTextContent tbody tr {
    transition: background 0.2s ease;
}

.sectionTextContent tbody tr:hover {
    background: rgba(195, 151, 106, 0.1);
}

.sectionTextContent tbody tr:nth-child(even) {
    background: rgba(217, 215, 199, 0.3);
}

.sectionTextContent tbody tr:nth-child(even):hover {
    background: rgba(195, 151, 106, 0.12);
}

/* ===== GANG CARDS ===== */
.gangs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.gang-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 15px rgba(58, 22, 14, 0.1);
    border: 1px solid rgba(146, 74, 54, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gang-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(58, 22, 14, 0.15);
}

.gang-card-header {
    background: linear-gradient(135deg, var(--maroon) 0%, var(--leather) 100%);
    color: var(--camel);
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gang-card-header .gang-icon {
    font-size: 1.5rem;
}

.gang-card-header h3 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--camel);
    border: none;
    padding: 0;
    border-left: none;
}

.gang-card-body {
    padding: 1.2rem;
}

.gang-card-body p {
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
}

.gang-card-body .gang-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 0.8rem 0;
}

.gang-stat {
    background: var(--sand-light);
    padding: 0.4rem 0.6rem;
    border-radius: 5px;
    text-align: center;
    border: 1px solid rgba(146, 74, 54, 0.1);
}

.gang-stat .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--leather);
    letter-spacing: 1px;
}

.gang-stat .stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--maroon);
}

.gang-ability {
    background: linear-gradient(135deg, var(--sand) 0%, var(--sand-light) 100%);
    padding: 0.8rem;
    border-radius: 6px;
    margin-top: 0.8rem;
    border: 1px solid rgba(195, 151, 106, 0.3);
}

.gang-ability strong {
    color: var(--leather);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.gang-ability p {
    font-size: 0.85rem;
    margin-top: 0.3rem;
    margin-bottom: 0;
}

/* ===== MECHANIC CARDS ===== */
.mechanic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2rem;
    margin-top: 1rem;
}

.mechanic-card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(58, 22, 14, 0.08);
    border: 1px solid rgba(146, 74, 54, 0.12);
    border-top: 4px solid var(--leather);
}

.mechanic-card h4 {
    color: var(--maroon);
    font-size: 1.05rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mechanic-card p {
    font-size: 0.9rem;
}

/* ===== STAT BLOCK ===== */
.stat-block {
    background: linear-gradient(135deg, var(--maroon-dark) 0%, var(--maroon) 100%);
    color: var(--germanium);
    border-radius: 10px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border: 1px solid var(--camel);
}

.stat-block .stat-name {
    color: var(--camel);
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-block .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(195, 151, 106, 0.15);
    font-size: 0.9rem;
}

.stat-block .stat-row:last-child {
    border-bottom: none;
}

.stat-block .stat-label {
    color: var(--camel);
    opacity: 0.8;
}

.stat-block .stat-value {
    font-weight: bold;
    color: var(--germanium);
}

/* ===== TURN PHASE ===== */
.turn-phases {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.turn-phase {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: white;
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
    box-shadow: 0 2px 8px rgba(58, 22, 14, 0.06);
    border: 1px solid rgba(146, 74, 54, 0.1);
    transition: border-color 0.2s;
}

.turn-phase:hover {
    border-color: var(--camel);
}

.turn-phase-number {
    background: linear-gradient(135deg, var(--maroon) 0%, var(--leather) 100%);
    color: var(--camel);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.turn-phase-content h4 {
    color: var(--maroon);
    margin-bottom: 0.3rem;
}

.turn-phase-content p {
    font-size: 0.9rem;
    margin: 0;
}

/* ===== FOOTER ===== */
.site-footer {
    background: linear-gradient(135deg, var(--maroon-dark) 0%, var(--maroon) 100%);
    color: var(--germanium);
    text-align: center;
    padding: 2rem;
    margin-left: var(--sidebar-width);
    border-top: 3px solid var(--camel);
    transition: margin-left 0.3s ease;
}

.site-footer p {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ===== DECORATIVE DIVIDER ===== */
.divider {
    text-align: center;
    margin: 2rem 0;
    color: var(--camel);
    font-size: 1.2rem;
    letter-spacing: 8px;
    opacity: 0.5;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
        padding: 80px 1.5rem 3rem;
    }

    .site-footer {
        margin-left: 0;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .hamburger {
        display: flex;
    }

    .hero h2 {
        font-size: 1.6rem;
    }
    /* === SIDEBAR НА МОБИЛЬНЫХ === */
    .sidebar {
        transform: translateX(0) !important; /* Всегда видима */
        width: 240px; /* Чуть уже для мобильных */
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 900;
        padding-top: 70px; /* Учитываем высоту хедера */
        border-right: 2px solid var(--camel);
        /* Важно: разрешаем скролл внутри сайдбара */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Плавный скролл на iOS */
    }

    /* Убираем оверлей, так как сайдбар всегда открыт */
    .sidebar-overlay {
        display: none !important;
    }

    /* === MAIN CONTENT === */
    .main-content {
        margin-left: 240px; /* Отступ под ширину сайдбара */
        padding: 70px 1rem 2rem;
        width: calc(100% - 240px);
    }

    /* === FOOTER === */
    .site-footer {
        margin-left: 240px;
        width: calc(100% - 240px);
    }

    /* === HAMBURGER === */
    /* Опционально: скрываем кнопку, если она больше не нужна */
    .hamburger {
        display: none;
    }

    /* === УЛУЧШЕНИЯ ДЛЯ ТАЧА === */
    .nav-elem,
    .nav-section-title {
        min-height: 44px; /* Минимальная высота для удобного нажатия пальцем */
        display: flex;
        align-items: center;
    }

    .nav-elem {
        padding: 0.7rem 1rem 0.7rem 2.5rem;
        font-size: 0.9rem; /* Чуть крупнее текст */
    }

    .nav-section-title {
        padding: 0.9rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 600px) {
    .site-header {
        padding: 1rem;
    }

    .site-header h1 {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    .site-header .subtitle {
        font-size: 0.65rem;
    }

    .main-content {
        padding: 70px 1rem 2rem;
    }

    .hero {
        padding: 2rem 1.2rem;
    }

    .hero h2 {
        font-size: 1.3rem;
    }

    .hero p {
        font-size: 0.92rem;
    }

    .section-content {
        padding: 1.2rem;
    }

    .section-header h2 {
        font-size: 1.2rem;
    }

    .gangs-grid {
        grid-template-columns: 1fr;
    }

    .mechanic-grid {
        grid-template-columns: 1fr;
    }

    .rules-table {
        font-size: 0.82rem;
    }

    .rules-table th, .rules-table td {
        padding: 0.5rem 0.6rem;
    }

    .stat-block {
        padding: 1rem;
    }

    .stat-block .stat-row {
        font-size: 0.82rem;
    }

    .turn-phase {
        padding: 1rem;
    }

    .turn-phase-number {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }
}
@media (max-width: 500px) {
    /* === SIDEBAR НА ОЧЕНЬ МАЛЕНЬКИХ ЭКРАНАХ === */
    .sidebar {
        width: 100%; /* На очень узких экранах — на всю ширину */
        height: auto;
        position: relative; /* Не фиксирован, чтобы контент шёл после */
        padding-top: 60px;
        border-right: none;
        border-bottom: 3px solid var(--camel);
        max-height: 40vh; /* Ограничиваем высоту, чтобы можно было проскроллить */
    }
    .section-content h3{
        font-size: 8rem;
    }
    .sectionTextContent{
        font-size: 6rem;
    }

    /* === MAIN CONTENT === */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 60px 0.8rem 1.5rem;
    }

    /* === FOOTER === */
    .site-footer {
        margin-left: 0;
        width: 100%;
    }

    /* === УДОБСТВО НА МОБИЛЬНЫХ === */
    .nav-elem {
        padding: 0.8rem 1rem 0.8rem 2.2rem;
        font-size: 2rem;
        border-left-width: 4px;
    }

    .nav-section-title {
        font-size: 2rem;
        padding: 1rem;
    }

    /* Увеличиваем область нажатия для стрелочки */
    .nav-section-title .arrow {
        padding: 10px;
        margin: -10px 0;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section {
    animation: fadeIn 0.5s ease forwards;
}

/* ===== BACK TO TOP ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--maroon) 0%, var(--leather) 100%);
    color: var(--camel);
    border: 2px solid var(--camel);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    z-index: 800;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(58, 22, 14, 0.3);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(58, 22, 14, 0.4);
}

/* ===== TOOLTIP ===== */
.tooltip {
    position: relative;
    cursor: help;
    border-bottom: 1px dashed var(--leather);
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--maroon-dark);
    color: var(--germanium);
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    font-size: 0.78rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ===== WILD WEST DECORATIVE ELEMENTS ===== */
.western-border {
    border: 2px solid var(--camel);
    border-image: repeating-linear-gradient(
        45deg,
        var(--camel),
        var(--camel) 5px,
        transparent 5px,
        transparent 10px
    ) 10;
}

.asterism {
    text-align: center;
    color: var(--camel);
    font-size: 1.5rem;
    letter-spacing: 12px;
    margin: 1.5rem 0;
    opacity: 0.6;
}
