.guide-container,
.guide-container-inline {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    gap: 0;
    background: var(--bg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

#guide-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--bg);
    overflow: hidden;
}

.guide-header {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 2px solid var(--accent);
    padding: 15px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.guide-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
}

.guide-header h1 {
    margin: 0;
    font-size: 20px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.guide-header h1 i {
    flex-shrink: 0;
}

.guide-header h1 span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-back {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-back:hover {
    opacity: 0.9;
}

.btn-back:active {
    transform: scale(0.98);
}

/* Print button */
.btn-print {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-print:hover {
    opacity: 0.9;
}

.btn-print:active {
    transform: scale(0.98);
}

/* Hamburger menu button */
.btn-menu-toggle {
    display: none;
    padding: 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    transition: opacity 0.2s;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.btn-menu-toggle:hover {
    opacity: 0.9;
}

.btn-menu-toggle:active {
    transform: scale(0.98);
}

.guide-sidebar {
    background: #0f172a;
    overflow-y: auto;
    padding: 20px;
    border-left: 2px solid var(--accent);
    -webkit-overflow-scrolling: touch;
}

.guide-sidebar.mobile-hidden {
    display: none;
}

.guide-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.guide-nav li {
    margin: 5px 0;
}

.guide-nav a {
    display: block;
    padding: 12px 15px;
    color: var(--text);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
}

.guide-nav a:hover {
    background: rgba(59, 130, 246, 0.1);
}

.guide-nav a.active {
    background: var(--accent, #3b82f6);
    color: white;
    font-weight: bold;
}

.guide-main {
    overflow-y: auto;
    padding: 30px;
    background: var(--bg);
    -webkit-overflow-scrolling: touch;
}

.guide-breadcrumb {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
}

.guide-breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.2s;
}

.guide-breadcrumb a:hover {
    background: rgba(59, 130, 246, 0.1);
}

.guide-breadcrumb span {
    color: var(--text-secondary);
}

.guide-content {
    line-height: 1.8;
    color: var(--text);
}

.guide-section {
    margin-bottom: 40px;
}

.guide-section h2 {
    color: var(--accent);
    border-bottom: 3px solid var(--accent);
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 24px;
}

.guide-section h3 {
    color: var(--text);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: bold;
}

.guide-section h4 {
    color: var(--text);
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 18px;
}

.guide-section p {
    margin: 10px 0;
    text-align: justify;
}

.guide-table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
}


.guide-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    table-layout: auto;
}

.guide-table th,
.guide-table td {
    padding: 10px 8px;
    border: 1px solid var(--border);
    text-align: center;
    word-wrap: break-word;
    hyphens: auto;
}

.guide-table th {
    white-space: nowrap;
    font-size: 13px;
}

.guide-table td {
    white-space: normal;
    font-size: 13px;
}

/* Optimize column widths for mobile */
.guide-table th:first-child,
.guide-table td:first-child {
    min-width: 80px;
    max-width: 120px;
}

.guide-table th:nth-child(2),
.guide-table td:nth-child(2) {
    min-width: 70px;
    max-width: 100px;
}

.guide-table th:nth-child(n+3),
.guide-table td:nth-child(n+3) {
    min-width: 60px;
    max-width: 90px;
}

/* Navigation buttons */
.guide-section-nav {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
}

.guide-nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    flex: 1;
    justify-content: center;
}

.guide-nav-btn:hover {
    background: var(--accent);
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.guide-nav-btn.guide-nav-disabled {
    background: transparent;
    color: transparent;
    cursor: default;
    pointer-events: none;
}

.guide-nav-btn.guide-nav-prev {
    flex-direction: row-reverse;
}

/* Role abilities display */
.role-abilities {
    margin-top: 15px;
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 6px;
    border-right: 3px solid var(--accent);
    font-size: 14px;
    color: var(--text);
}

.role-abilities strong {
    color: var(--accent);
    margin-left: 8px;
}


.guide-table th {
    background: var(--accent);
    color: white;
    font-weight: bold;
}

.guide-table tr:nth-child(even) {
    background: rgba(0,0,0,0.02);
}

.role-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
    background: var(--bg-secondary);
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.role-card.mafia {
    border-color: var(--mafia-color);
    border-left-width: 5px;
}

.role-card.citizen {
    border-color: var(--citizen-color);
    border-left-width: 5px;
}

.role-card.independent {
    border-color: var(--indep-color);
    border-left-width: 5px;
}

.role-image {
    width: 150px;
    height: 150px;
    object-fit: contain;
    background: white;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid var(--border);
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
}

.role-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.role-content {
    flex: 1;
}

.role-content h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 20px;
}

.role-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.role-tag {
    padding: 4px 10px;
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent);
    border-radius: 12px;
    font-size: 12px;
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 30px;
}

.quick-link-card {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.quick-link-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: var(--accent);
}

.quick-link-card i {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 15px;
    display: block;
    text-align: center;
    width: 100%;
}

.quick-link-card h3 {
    margin: 0;
    font-size: 18px;
    text-align: center;
    width: 100%;
}

.subsection {
    margin: 20px 0;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-right: 4px solid var(--accent);
}

.subsection h4 {
    margin-top: 0;
    color: var(--accent);
}

.highlight {
    background: rgba(255, 255, 0, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Compact tables for playerCount section */
.guide-table-compact-wrapper {
    width: 100%;
}

.guide-table-compact-wrapper .guide-table-wrapper {
    overflow-x: hidden;
    width: 100%;
}

.guide-table-compact-wrapper .guide-table {
    table-layout: fixed;
    width: 100%;
}

.guide-table-compact-wrapper .guide-table th,
.guide-table-compact-wrapper .guide-table td {
    padding: 6px 4px;
    font-size: 11px;
}

.guide-table-compact-wrapper .guide-table {
    width: 100%;
}

.guide-table-compact-wrapper .guide-table th:first-child,
.guide-table-compact-wrapper .guide-table td:first-child {
    width: 25%;
}

.guide-table-compact-wrapper .guide-table th:nth-child(2),
.guide-table-compact-wrapper .guide-table td:nth-child(2) {
    width: 25%;
}

.guide-table-compact-wrapper .guide-table th:nth-child(3),
.guide-table-compact-wrapper .guide-table td:nth-child(3) {
    width: 25%;
}

.guide-table-compact-wrapper .guide-table th:nth-child(4),
.guide-table-compact-wrapper .guide-table td:nth-child(4) {
    width: 25%;
}

@media (max-width: 768px) {
    .guide-container,
    .guide-container-inline {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    
    .guide-header {
        padding: 12px 15px;
        top: 0;
    }
    
    .guide-header h1 {
        font-size: 16px;
        gap: 8px;
    }
    
    .guide-header h1 i {
        font-size: 18px;
    }
    
    .btn-back {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .btn-back span {
        display: none;
    }
    
    .btn-print span {
        display: none;
    }
    
    .btn-menu-toggle {
        display: flex;
    }
    
    
    .guide-sidebar {
        grid-column: 1;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 200;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -2px 0 8px rgba(0,0,0,0.2);
        border-left: 1px solid var(--border);
    }
    
    .guide-sidebar.mobile-visible {
        transform: translateX(0);
    }
    
    .guide-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
    }
    
    .guide-sidebar-overlay.mobile-visible {
        display: block;
    }
    
    .guide-main {
        grid-column: 1;
        padding: 20px 15px;
    }
    
    .guide-breadcrumb {
        margin-bottom: 15px;
        padding-bottom: 10px;
        font-size: 14px;
        flex-wrap: wrap;
    }
    
    .guide-section {
        margin-bottom: 30px;
    }
    
    .guide-section h2 {
        font-size: 20px;
        padding-bottom: 8px;
        margin-bottom: 15px;
    }
    
    .guide-section h3 {
        font-size: 18px;
        margin-top: 25px;
        margin-bottom: 12px;
    }
    
    .guide-section h4 {
        font-size: 16px;
        margin-top: 18px;
        margin-bottom: 8px;
    }
    
    .guide-section p {
        font-size: 14px;
        line-height: 1.7;
        text-align: right;
    }
    
    .guide-table-wrapper {
        margin: 15px -15px;
        border-radius: 0;
        overflow-x: hidden;
        width: calc(100% + 30px);
    }
    
    .guide-table {
        table-layout: fixed;
        width: 100%;
        max-width: 100%;
        min-width: unset;
    }
    
    .guide-table th {
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word;
        font-size: 10px;
        padding: 6px 3px;
        line-height: 1.3;
    }
    
    .guide-table td {
        white-space: normal;
        word-wrap: break-word;
        word-break: break-word;
        font-size: 10px;
        padding: 6px 3px;
        line-height: 1.3;
    }
    
    .role-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 15px;
        margin: 12px 0;
        gap: 15px;
    }
    
    .role-image {
        width: 120px;
        height: 120px;
    }
    
    .role-content {
        width: 100%;
    }
    
    .role-content h4 {
        font-size: 18px;
    }
    
    .quick-links {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        margin-top: 20px;
    }
    
    .guide-table-compact-wrapper .guide-table th,
    .guide-table-compact-wrapper .guide-table td {
        padding: 6px 3px;
        font-size: 11px;
    }
    
    .guide-table-compact-wrapper .guide-table {
        width: 100%;
    }
    
    .guide-table-compact-wrapper .guide-table th:first-child,
    .guide-table-compact-wrapper .guide-table td:first-child,
    .guide-table-compact-wrapper .guide-table th:nth-child(2),
    .guide-table-compact-wrapper .guide-table td:nth-child(2),
    .guide-table-compact-wrapper .guide-table th:nth-child(3),
    .guide-table-compact-wrapper .guide-table td:nth-child(3),
    .guide-table-compact-wrapper .guide-table th:nth-child(4),
    .guide-table-compact-wrapper .guide-table td:nth-child(4) {
        width: 25%;
    }
    
    .quick-link-card {
        padding: 15px 10px;
    }
    
    .quick-link-card i {
        font-size: 32px;
        margin-bottom: 8px;
    }
    
    .quick-link-card h3 {
        font-size: 13px;
    }
    
    .quick-link-card {
        padding: 20px 15px;
    }
    
    .quick-link-card i {
        font-size: 36px;
        margin-bottom: 10px;
    }
    
    .quick-link-card h3 {
        font-size: 15px;
    }
    
    .subsection {
        margin: 15px 0;
        padding: 12px;
        border-right-width: 3px;
    }
    
    .subsection h4 {
        font-size: 16px;
        margin-top: 0;
    }
    
    .role-tags {
        gap: 6px;
        justify-content: center;
    }
    
    .role-tag {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* Role Image Modal Styles */
.role-image-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.role-image-modal-close {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
}

.role-image-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.role-image-modal-close:active {
    transform: scale(0.95);
}

#role-image-modal-img {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    .role-image-modal-content {
        padding: 20px;
        max-width: 95vw;
    }
    
    .role-image-modal-close {
        top: 10px;
        left: 10px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    #role-image-modal-img {
        max-height: 60vh;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .guide-header h1 span {
        display: none;
    }
    
    .quick-links {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .quick-link-card {
        padding: 12px 8px;
    }
    
    .quick-link-card i {
        font-size: 28px;
        margin-bottom: 6px;
    }
    
    .quick-link-card h3 {
        font-size: 11px;
    }
    
    .guide-table {
        width: 100%;
        table-layout: fixed;
    }
    
    .guide-table th,
    .guide-table td {
        padding: 8px 6px;
        font-size: 12px;
        white-space: normal;
        word-break: break-word;
    }
    
    .guide-table th:first-child,
    .guide-table td:first-child {
        width: 30%;
        min-width: 0;
        max-width: 30%;
    }
    
    .guide-table th:nth-child(2),
    .guide-table td:nth-child(2) {
        width: 25%;
        min-width: 0;
        max-width: 25%;
    }
    
    .guide-table th:nth-child(3),
    .guide-table td:nth-child(3) {
        width: 25%;
        min-width: 0;
        max-width: 25%;
    }
    
    .guide-table th:nth-child(4),
    .guide-table td:nth-child(4) {
        width: 20%;
        min-width: 0;
        max-width: 20%;
    }
    
    /* For tables with more columns */
    .guide-table th:nth-child(n+5),
    .guide-table td:nth-child(n+5) {
        width: 16%;
        min-width: 0;
        max-width: 16%;
        font-size: 9px;
        padding: 5px 2px;
    }
    
    .guide-section-nav {
        flex-direction: column;
        gap: 10px;
        margin-top: 30px;
    }
    
    .guide-nav-btn {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .guide-main {
        padding: 15px 12px;
    }
}

/* Print Styles */
@media print {
    /* Hide non-printable elements */
    .guide-header,
    .guide-sidebar,
    .guide-breadcrumb,
    .guide-section-nav,
    .btn-print,
    .btn-back,
    .btn-menu-toggle,
    .quick-links,
    .role-image {
        display: none !important;
    }
    
    /* Reset layout for print */
    .guide-container,
    .guide-container-inline {
        display: block !important;
        position: static !important;
        height: auto !important;
        background: white !important;
    }
    
    .guide-main {
        padding: 20px !important;
        overflow: visible !important;
        background: white !important;
    }
    
    /* Page setup */
    @page {
        size: A4;
        margin: 2cm;
    }
    
    /* Typography for print */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt !important;
        line-height: 1.6 !important;
    }
    
    .guide-section {
        page-break-inside: avoid;
        margin-bottom: 30px;
    }
    
    .guide-section h1 {
        color: #000 !important;
        font-size: 24pt !important;
        margin-bottom: 15px;
        page-break-after: avoid;
    }
    
    .guide-section h2 {
        color: #000 !important;
        font-size: 18pt !important;
        border-bottom: 2px solid #000 !important;
        padding-bottom: 8px;
        margin-top: 25px;
        margin-bottom: 15px;
        page-break-after: avoid;
    }
    
    .guide-section h3 {
        color: #000 !important;
        font-size: 16pt !important;
        margin-top: 20px;
        margin-bottom: 12px;
        page-break-after: avoid;
    }
    
    .guide-section h4 {
        color: #000 !important;
        font-size: 14pt !important;
        margin-top: 15px;
        margin-bottom: 10px;
        page-break-after: avoid;
    }
    
    .guide-section p {
        color: #000 !important;
        margin: 8px 0;
        text-align: justify;
        orphans: 3;
        widows: 3;
    }
    
    /* Tables for print */
    .guide-table-wrapper {
        overflow: visible !important;
        margin: 15px 0;
        page-break-inside: avoid;
    }
    
    .guide-table {
        width: 100% !important;
        border-collapse: collapse;
        background: white !important;
        border: 1px solid #000 !important;
    }
    
    .guide-table th {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        padding: 8px !important;
        font-weight: bold;
        font-size: 11pt;
    }
    
    .guide-table td {
        border: 1px solid #000 !important;
        padding: 6px !important;
        color: #000 !important;
        font-size: 10pt;
    }
    
    .guide-table tr:nth-child(even) {
        background: #f9f9f9 !important;
    }
    
    /* Role cards for print */
    .role-card {
        border: 1px solid #000 !important;
        border-radius: 0 !important;
        padding: 15px !important;
        margin: 15px 0 !important;
        background: white !important;
        page-break-inside: avoid;
        display: block !important;
    }
    
    .role-card.mafia {
        border-left: 4px solid #000 !important;
    }
    
    .role-card.citizen {
        border-left: 4px solid #000 !important;
    }
    
    .role-card.independent {
        border-left: 4px solid #000 !important;
    }
    
    .role-content h4 {
        color: #000 !important;
        font-size: 14pt !important;
        margin-top: 0;
        margin-bottom: 10px;
    }
    
    .role-content {
        color: #000 !important;
    }
    
    .role-tags {
        margin-top: 8px;
    }
    
    .role-tag {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        padding: 3px 8px;
        font-size: 9pt;
    }
    
    .role-abilities {
        background: #f9f9f9 !important;
        border: 1px solid #000 !important;
        border-right: 3px solid #000 !important;
        color: #000 !important;
        padding: 10px;
        margin-top: 10px;
    }
    
    /* Subsections */
    .subsection {
        background: white !important;
        border: 1px solid #000 !important;
        border-right: 3px solid #000 !important;
        padding: 12px !important;
        margin: 15px 0;
        page-break-inside: avoid;
    }
    
    .subsection h4 {
        color: #000 !important;
        margin-top: 0;
    }
    
    /* Links */
    a {
        color: #000 !important;
        text-decoration: underline !important;
    }
    
    /* Avoid page breaks */
    .guide-section h2,
    .guide-section h3,
    .guide-section h4,
    .guide-table-wrapper,
    .role-card {
        page-break-after: avoid;
    }
}

