.word-search-grid {
    display: grid;
    gap: 1px;
    border: 2px solid #000;
    margin: 0 auto;
    background-color: #000;
    width: 100%;
    grid-template-columns: repeat(var(--grid-size, 15), 1fr);
}

.page-wrapper {
    position: relative;
    flex-shrink: 0;
    margin-bottom: 2rem;
    transform-origin: top left;
}

.word-search-cell {
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    position: relative;
    aspect-ratio: 1/1;
    /* Calculate font size based on page width (approx 170mm printable area) divided by grid size */
    font-size: calc(170mm / var(--grid-size, 15) * 0.6);
}

.word-list {
    column-count: 3;
    column-gap: 2rem;
    margin-top: 2rem;
}

.word-item {
    break-inside: avoid;
    margin-bottom: 0.5rem;
    font-family: 'Comic Neue', cursive;
    font-size: 1.1rem;
}

.solution-highlight {
    background-color: rgba(255, 255, 0, 0.3);
    border-radius: 50%;
}

.cell-highlighted {
    background-color: #e0e0e0;
    color: #000;
    font-weight: 900;
}

.cell-dimmed {
    color: #ccc;
}

.icon-wrapper-sm {
    width: 32px;
    height: 32px;
}

.hidden {
    display: none;
}

/* Header Adjustments to save space */
.worksheet-header {
    margin-bottom: 1rem !important;
    padding-bottom: 0.5rem !important;
}

.worksheet-header h2 {
    margin-bottom: 0.25rem !important;
    font-size: 24pt !important;
}

.worksheet-header p {
    margin-bottom: 0 !important;
}

/* Watermark */
.worksheet-watermark {
    position: absolute;
    top: 10mm;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0.85;
    pointer-events: none;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.5rem;
    border-radius: 8px;
}

.worksheet-watermark img {
    height: 48px;
    width: auto;
}

.worksheet-watermark span {
    font-family: 'Quicksand', sans-serif;
    font-size: 18pt;
    color: #374151;
    font-weight: 700;
    letter-spacing: 0.5px;
}

@media print {
    .no-print, .worksheet-footer { display: none !important; }
    .preview-area { padding: 0; background: white; }
    .worksheet-page { 
        box-shadow: none; 
        margin: 0; 
        page-break-after: always;
        height: auto; /* Allow content to determine height */
        min-height: 100%; /* Ensure it fills the page */
        overflow: visible;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .worksheet-page:last-child {
        page-break-after: auto;
    }
    /* Removed .solution-page { page-break-before: always; } to prevent double page breaks */
    
    /* Ensure body doesn't add extra margins */
    body, html {
        margin: 0;
        padding: 0;
        height: auto;
    }
}
