* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    /* font-family: Arial, sans-serif; */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: #fff;
    color: #111;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

#quiz-section, #input-section {
    max-width: 800px;
    margin: 0 auto;
}

h1, h2 {
    text-align: center;
    margin-bottom: 20px;
    letter-spacing: -0.04em;
}

.input-prompt {
    text-align: center;
    margin-bottom: 20px;
}

.instruction {
    font-size: 1.2em;
    font-weight: bold;
    margin: 20px 0;
}

.question {
    margin-bottom: 20px;
}

.question p {
    margin-bottom: 10px;
    font-weight: bold;
}

.question-number {
    display: inline;
    font-weight: bold;
    padding-right: 10px;
}

.option-a {
    padding-left: 0;
}

.option-b {
    padding-left: 25px;
}

.question label {
    display: block;
    margin: 5px 0;
}

#code-form {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 30px;
}

.code-input {
    width: 100px;
    padding: 8px;
    font-size: 16px;
    text-align: center;
    text-transform: uppercase;
    border: 1px solid #ccc;
    border-radius: 4px;
}

button {
    padding: 10px 20px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button:hover {
    background-color: #555;
}

.error {
    color: red;
    text-align: center;
    margin-top: 10px;
}

.hidden {
    display: none;
}

#loading.hidden {
    display: none !important;
}

#loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.loader {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #333;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

#books-table {
    width: 100%;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f9f9f9;
}

img {
    max-width: 50px;
    height: auto;
    display: block;
}

td[data-label="Cover"] a {
    display: block;
    text-decoration: none;
}

td[data-label="Cover"] img {
    transition: opacity 0.2s ease;
}

td[data-label="Cover"] img:hover {
    opacity: 0.8;
    cursor: pointer;
}

td[data-label="Title"] a {
    color: #0066cc;
    text-decoration: underline;
}

td[data-label="Title"] a:hover {
    color: #003366;
}

/* === PAGINATION: FULLY FIXED FOR 18 PAGES === */
#pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    row-gap: 16px;
    margin: 30px 0 20px;
    padding: 0 10px;
}

#pagination button {
    width: 40px;
    height: 40px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #ccc;
    background: #fff;
    color: #333;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#pagination button:hover {
    background: #f0f0f0;
    border-color: #999;
}

#pagination button.active {
    background-color: #333;
    color: #fff;
    border-color: #333;
}

.question.error {
    border-left: 3px solid red;
    padding-left: 10px;
}

.code {
    font-size: 1.5em;
    font-weight: bold;
    display: inline-block;
    margin: 0 5px;
}

/* === MOBILE STYLES === */
@media (max-width: 600px) {
    #code-form {
        flex-direction: column;
        align-items: center;
        margin-bottom: 10px;
    }

    .code-input {
        width: 150px;
    }

    .instruction {
        font-size: 1.4em;
    }

    .question {
        margin-bottom: 30px;
    }

    .question-number {
        font-size: 1.2em;
        padding-right: 15px;
    }

    .option-a, .option-b {
        font-size: 1.2em;
    }

    .option-b {
        padding-left: 30px;
    }

    .radio-group {
        background: #f9f9f9;
        border-radius: 8px;
        padding: 10px;
        margin-top: 10px;
    }

    .question label {
        font-size: 1.2em;
        margin: 10px 0;
        display: flex;
        align-items: center;
    }

    .question input[type="radio"] {
        width: 20px;
        height: 20px;
        margin-right: 10px;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead {
        display: none;
    }

    .card {
        border-top: 1px solid #d9d9d9;
        border-bottom: 1px solid #d9d9d9;
        padding: 14px 16px;
        background: #fff;
        color: #111;
        line-height: 1.4;
    }

    .rank-score-row {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        margin-bottom: 10px;
        font-size: 18px;
    }

    .rank-score-row .rank,
    .rank-score-row .score {
        white-space: nowrap;
        color: #222;
    }

    .rank-score-row .rank b,
    .rank-score-row .score b {
        font-weight: 700;
    }

    .content-row {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 14px;
    }

    .text-col {
        flex: 1 1 auto;
        min-width: 0;
    }

    .title-author-block {
        margin: 0;
    }

    .title-author-block .title {
        display: block;
        font-weight: 800;
        font-size: 22px;
        letter-spacing: 0.2px;
        margin: 0 0 2px 0;
    }

    .title-author-block .title a {
        color: #0066cc;
        text-decoration: underline;
    }

    .title-author-block .title a:hover {
        color: #003366;
    }

    .title-author-block .author {
        display: block;
        font-weight: 700;
        font-size: 20px;
        margin: 0 0 0.5em 0;
    }

    .description {
        margin: 0;
        font-size: 18px;
        color: #222;
    }

    .cover-col {
        flex: 0 0 auto;
    }

    .cover-col .book-cover {
        display: block;
        width: 120px;
        max-width: 40vw;
        height: auto;
        border: 0;
        object-fit: cover;
        object-position: center;
        margin-top: 0;
    }

    /* MOBILE PAGINATION: 3 ROWS OF 6 */
    #pagination {
        gap: 8px;
        row-gap: 14px;
        justify-content: center;
        margin: 30px 0 20px;
        padding: 0 5px;
    }

    #pagination button {
        flex: 0 0 calc(16.666% - 8px);
        margin: 0;
        width: auto;
        min-width: 40px;
        height: 40px;
        font-size: 16px;
        border-radius: 6px;
        border: 1px solid #ccc;
        background: #fff;
        color: #333;
    }

    #pagination button:hover {
        background: #f0f0f0;
        border-color: #999;
    }

    #pagination button.active {
        background-color: #333;
        color: #fff;
        border-color: #333;
    }

    .container, #quiz-section, #input-section {
        padding: 10px;
        max-width: 100%;
    }

    .input-prompt {
        text-align: left;
    }
}

/* === TINY SCREENS (e.g. iPhone SE) === */
@media (max-width: 380px) {
    .cover-col .book-cover {
        width: 100px;
    }
    .title-author-block .title {
        font-size: 20px;
    }
    .title-author-block .author {
        font-size: 18px;
    }
    .rank-score-row {
        font-size: 16px;
    }
    .description {
        font-size: 16px;
    }

    #pagination button {
        font-size: 15px;
        height: 38px;
    }
}

/* New author input styles (May, 19 2026) */

/* .autocomplete-wrapper {
    max-width: 500px;
    margin: 20px auto;
}

#author-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.1em;
    border: 2px solid #ccc;
    border-radius: 6px;
}

*/

.button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 15px;
}

.button-group button {
    padding: 12px 28px;
    font-size: 1.1em;
}

.author-count {
    text-align: center;
    color: #555;
    margin-top: 10px;
    font-size: 0.95em;
}

.highlight {
    color: #0066cc;
    font-weight: bold;
}

/* Keep all your existing mobile + pagination styles */

/* Custom Autocomplete */
.autocomplete-wrapper {
    position: relative;
    max-width: 520px;
    margin: 20px auto;
}

#author-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.1em;
    border: 2px solid #ccc;
    border-radius: 6px;
    background: white;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #0066cc;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background-color: #f0f8ff;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

#intro-text {
    max-width: 520px;           /* roughly 50% on most desktops */
    margin: 0 auto 35px auto;
    text-align: left;
    font-size: 1.05em;
    line-height: 1.55;
    color: #333;
}

/* Book Title Links */
td[data-label="Title"] a,
.title a {
    color: #0066cc;           /* Nice blue */
    font-weight: bold;
    text-decoration: none;    /* Remove underline */
    transition: color 0.2s ease;
}

td[data-label="Title"] a:hover,
.title a:hover {
    color: #003366;           /* Darker blue on hover */
    text-decoration: underline; /* Optional subtle underline on hover */
}