body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: #e0f7fa;
    color: #01579b;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: linear-gradient(45deg, #e3f2fd, #bbdefb);
}

.container {
    background: #fff;
    padding: 40px 60px;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    text-align: center;
    max-width: 960px;
    width: 100%;
    border: 5px solid #03a9f4;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    border-radius: 25px;
    border: 5px dashed #81d4fa;
    z-index: -1;
}

/* RESTORED COLORS for general application headers (e.g., wordlists.php) */
h1 {
    font-size: 2.8em;
    color: #039be5;
    text-shadow: 2px 2px #b3e5fc;
    margin-top: 0;
    margin-bottom: 20px;
}

h2, h3 {
    color: #0288d1;
    border-bottom: 2px dashed #039be5;
    padding-bottom: 5px;
    margin-top: 30px;
}

p.error { color: #d32f2f; font-weight: bold; }
p.ok { color: #388e3c; font-weight: bold; }

.navbar {
    background: #4fc3f7;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    gap: 15px;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.navbar a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1em;
    transition: transform 0.2s, color 0.2s;
}

.navbar a:hover {
    color: #e1f5fe;
    transform: translateY(-2px);
}

.btn, .btn-pdf {
    display: inline-block;
    background-color: #03a9f4;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    box-shadow: 0 5px 10px rgba(3, 169, 244, 0.3);
    transition: background-color 0.3s, transform 0.2s;
    text-decoration: none;
    margin: 8px 4px;
}

.btn:hover, .btn-pdf:hover {
    background-color: #0288d1;
    transform: translateY(-2px);
}

input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 2px solid #b3e5fc;
    border-radius: 12px;
    box-sizing: border-box;
    font-size: 1em;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
    border-color: #03a9f4;
    box-shadow: 0 0 8px rgba(3, 169, 244, 0.4);
    outline: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: #f0f8ff;
    border-radius: 10px;
    overflow: hidden;
}

th, td {
    border: 1px solid #b3e5fc;
    padding: 12px;
    text-align: center;
}

th {
    background: #81d4fa;
    color: #01579b;
    font-weight: bold;
}

.wordsearch-table {
    border-collapse: collapse;
    margin: 20px auto;
    background: #fff;
}

.wordsearch-table td {
    /* Thicker border for screen view */
    border: 2px solid #000;
    width: 30px;
    height: 30px;
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
    /* Increased font size for screen view */
    font-size: 18px;
    color: #000; /* Force black text on screen for print preview consistency */
    font-weight: bold; /* Bold letters on screen */
}

.wordsearch-table td.highlight-key {
    background-color: red;
    font-weight: 700;
    color: white !important;
}

.wordsearch-list {
    margin-top: 20px;
    text-align: center;
}

.wordsearch-list h3 {
    font-size: 1.5em;
    color: #0288d1;
    margin-bottom: 10px;
    border-bottom: none;
}

.wordsearch-list ul {
    list-style: none;
    padding: 0;
    margin: 0 auto;
    columns: 3;
    column-gap: 30px;
    max-width: 700px;
}

.wordsearch-list li {
    text-align: left;
    margin: 6px 0;
    font-size: 1.1em;
    font-weight: bold; /* Bold words on screen word list */
}

.grade-key {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 1em;
}

.grade-key th, .grade-key td {
    border: 1px solid #b3e5fc;
    padding: 10px;
}

.grade-key th {
    background-color: #e1f5fe;
    color: #01579b;
    font-weight: bold;
}

/* === PRINT MEDIA QUERY === */

@media print {
    body {
        background: none;
        padding: 0;
    }
    .container {
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 0;
        max-width: 100%;
    }
    .container::before {
        display: none;
    }
    /* Hide all buttons and navigation in print mode */
    .navbar, .btn, .btn-pdf, .pdf-buttons {
        display: none !important;
    }
    
    /* Global Print Color Override: Everything black and white */
    h1, h2, h3, p, li, th, td {
        color: #000 !important;
        text-shadow: none !important;
    }
    
    .wordsearch-table td {
        width: 0.8cm !important; 
        height: 0.8cm !important;
        font-size: 18pt !important; 
        border-color: #000 !important;
        border-width: 2px !important; 
        color: #000 !important;
        font-weight: bold !important;
    }
    
    /* FIX: Use Floats for reliable two-column display in Dompdf */
    .two-column-layout {
        width: 100% !important; 
        overflow: hidden; /* Contains the floats */
        display: block !important; 
        padding: 0 !important;
    }
    .column {
        width: 48% !important; /* Explicitly set column width */
        float: left !important; /* Use float for side-by-side */
        box-sizing: border-box;
        margin-right: 4% !important; /* Spacing between columns */
        padding: 0 !important;
    }
    .column:last-child {
        margin-right: 0 !important;
    }
    .column h2 {
        border-bottom: 2px solid #000;
        padding-bottom: 5px;
        margin-bottom: 10px;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        font-size: 1.3em !important; 
        margin-bottom: 12px;
        font-weight: bold !important; /* Bold words for print list */
    }
    .grade-key th, .grade-key td {
        border-color: #000;
    }

    /* Page Setup */
    @page {
        size: 8.5in 11in;
        margin: 0.5in;
    }
}


/* === PRINT PREVIEW AND WORKSHEET STYLING (Screen View) === */

body.print-page {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none;
    min-height: auto;
    display: block;
    font-size: 14pt;
    margin: 0;
    padding: 0;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 2.5em; 
    margin: 10px 0;
    color: #000 !important; 
    text-shadow: none;
}

.page-header p {
    font-size: 1.2em; 
    margin: 5px 0;
    color: #000;
}

.two-column-layout {
    /* Kept grid for modern screen viewing of the preview */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.two-column-layout ul {
    list-style: none;
    padding-left: 0;
}

.two-column-layout li {
    margin: 12px 0; 
    font-size: 1.2em; 
}

.section {
    margin-top: 40px;
}

.blank-line {
    display: inline-block;
    width: 90%;
    border-bottom: 2px dashed #000; 
}
@page {
    size: 8.5in 11in;
    margin: 0.5in; 
}

/* Worksheet Print Scaling (Dompdf compatibility for size) */
.wordsearch-table td {
  border: 1px solid #000 !important;
  width: 25px; height: 25px;
  font-size: 14pt;
  color: #000 !important;
}

.blank-line {
  border-bottom: 2px dashed #000 !important;
}