/* Main Layout */
.bingo-settings {
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #333;
}

#wordList {
    width: 100%;
    height: 150px;
    padding: 0.8rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
}

#wordList:focus {
    border-color: #4a90e2;
    outline: none;
}

.settings-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-item select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.action-buttons {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .settings-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .action-buttons {
        margin-left: 0;
        align-items: stretch;
    }

    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}
.btn-warning:hover {
    background-color: #e67e22;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}
.btn-danger:hover {
    background-color: #c0392b;
}


/* Bingo Grid */
.bingo-wrapper {
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    text-align: center;
    margin-bottom: 2rem;
}

.bingo-grid {
    display: grid;
    gap: 5px;
    margin: 0 auto;
    max-width: 600px;
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 4px solid #333;
    background-color: #333;
    padding: 5px;
}

.bingo-cell {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s, color 0.2s;
    user-select: none;
    overflow: hidden;
    word-break: break-all;
}

.bingo-cell-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
    font-weight: bold;
    line-height: 1.2;
}

.bingo-cell.active {
    background-color: #ffeb3b;
    color: #000;
}

.bingo-cell.active::after {
    content: "●";
    position: absolute;
    font-size: 4rem;
    color: rgba(255, 0, 0, 0.6);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.bingo-cell.free {
    font-weight: 900;
    color: #e74c3c;
    background-color: #ffebee;
}

.bingo-cell:hover:not(.active) {
    background-color: #f5f5f5;
}

/* Grid sizes classes will be added via JS or defined here */
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }


/* Instructions Style (Copied from timer.css/lottery.css for consistency) */
.instructions {
    background: var(--gray-lighter);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-large);
    margin-bottom: var(--spacing-xl);
}

.instructions h3 {
    font-size: 1.3em;
    color: var(--gray-darkest);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.instructions h3 i {
    color: var(--primary-color);
}

.instructions ol {
    margin-left: var(--spacing-xl);
    line-height: 1.8;
}

.instructions li {
    margin-bottom: var(--spacing-sm);
    color: var(--gray-darker);
}

.instructions li strong {
    color: var(--primary-color);
    font-weight: 600;
}

.instructions .note {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: rgba(30, 95, 140, 0.1);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--border-radius-small);
    color: var(--gray-darker);
}

.instructions .note i {
    color: var(--warning-color);
}


/* Print Styles */
@media print {
    /* Hide everything that is not the bingo wrapper or essential */
    body * {
        visibility: hidden;
    }
    
    .site-wrapper {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .container {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    /* Specifically hide ads and valid non-print elements */
    .ad-left, .ad-right, .ad-horizontal, 
    .site-header, header, footer,
    .no-print, .class-mode-toggle,
    .instructions,
    iframe {
        display: none !important;
    }

    /* Show only the bingo wrapper */
    .bingo-wrapper, .bingo-wrapper * {
        visibility: visible;
    }

    .bingo-wrapper {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: none;
    }

    .bingo-grid {
        max-width: 90vw; /* Use most of the page width */
        margin: 2rem auto;
        border-width: 2px;
    }
    
    .bingo-cell {
        border: 1px solid #333; /* Ensure borders print nicely */
    }

    /* Ensure background colors print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Force page background to be white */
    html, body, .site-wrapper, .container, .bingo-wrapper {
        background-color: #ffffff !important;
        background-image: none !important;
    }
    
    /* Ink-saving white background for print */
    .bingo-grid {
        background-color: #ffffff !important;
        border: 4px solid #000000 !important;
        gap: 0 !important; /* Remove gap, use borders */
    }

    .bingo-cell {
        background-color: #fff !important;
        border: 1px solid #000 !important; /* Add distinct borders */
        color: #000 !important;
    }
    
    .bingo-cell.free {
        background-color: #eee !important; /* Light gray for FREE is okay, or keep white */
        color: #000 !important;
        font-weight: bold !important;
        border: 1px solid #000 !important;
    }
    
    /* Hide active markers if any */
    .bingo-cell.active {
        background-color: #fff !important;
        color: #000 !important;
    }
    .bingo-cell.active::after {
        display: none !important;
    }
}

/* Export Mode (mimics print styles for html2canvas) */
body.export-mode .bingo-grid {
    background-color: #fff !important;
    border: 4px solid #000 !important;
    gap: 0 !important;
}

body.export-mode .bingo-cell {
    background-color: #fff !important;
    border: 1px solid #000 !important;
    color: #000 !important;
}

body.export-mode .bingo-cell.free {
    background-color: #eee !important;
    color: #000 !important;
    font-weight: bold !important;
    border: 1px solid #000 !important;
}

body.export-mode .bingo-cell.active {
    background-color: #fff !important;
    color: #000 !important;
}
body.export-mode .bingo-cell.active::after {
    display: none !important;
}

/* Bulk Control */
.bulk-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8f9fa;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #ddd;
}

#sheetCount {
    width: 60px;
    padding: 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    text-align: right;
}

.unit {
    font-size: 0.9rem;
    color: #666;
}

/* Loading Modal */
.loading-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loadingText {
    font-size: 1.1rem;
    color: #333;
    font-weight: bold;
}

/* PDF Group (Unified Button) */
/* PDF Group (Unified Button) */
.pdf-group {
    display: flex;
    background-color: #e74c3c; /* Match danger button color */
    border-radius: 4px;
    align-items: center;
    padding-right: 0.5rem; /* Changed to right padding */
    overflow: hidden;
}

.pdf-group .sheet-input {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: white;
    font-size: 0.9rem;
    margin-left: 0.3rem; /* Left margin for spacing from button */
    margin-right: 0;
}

.pdf-group #sheetCount {
    width: 50px;
    padding: 0.2rem;
    border: none;
    border-radius: 3px;
    font-size: 1rem;
    text-align: right;
    background: rgba(255, 255, 255, 0.9);
    color: black;
}

.pdf-group #savePdfBtn {
    border-radius: 0; 
    margin: 0;
    height: 100%;
    border-right: 1px solid rgba(255, 255, 255, 0.3); /* Right border instead of left */
    border-left: none;
}

/* Hide old bulk control styles if conflict */
.bulk-control { display: none !important; }
