/* Crossword — centered grid + horizontal words at bottom */

:root {
    --highlight-green: #4caf50;
}

body.crossword-page {
    margin: 0;
    min-height: 100vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    background-color: #fffcfa;
    color: #260b00;
    font-family: "Adobe Jenson Pro", Georgia, "Times New Roman", serif;
}

body.crossword-page .page-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
    overflow: auto;
    background-color: #fffcfa;
    color: #260b00;
    /* Tighter bottom than default top-nav page — less empty space below words */
    padding-bottom: 10px !important;
    /* Sit closer to top nav than default poem pages */
    padding-top: 108px !important;
}

/* Column: crossword centered on top, word strip at bottom */
body.crossword-page .game-wrapper {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 0;
    gap: 0;
    padding: 0;
}

body.crossword-page .crossword-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    margin-top: 0;
    /* Space between grid and “Words to find” strip */
    margin-bottom: 32px;
}

.grid-container {
    position: relative;
    --grid-gap: 14px;
    width: var(--grid-width, 600px);
    height: var(--grid-height, 450px);
    max-width: 100%;
    user-select: none;
    touch-action: none;
    border: none;
    background: transparent;
    flex-shrink: 0;
}

#selection-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* 12 columns × 9 rows — matches JS gridCols/gridRows */
#crossword-grid {
    display: grid;
    grid-template-columns: repeat(12, var(--cell-size, 45px));
    grid-template-rows: repeat(9, var(--cell-size, 45px));
    width: 100%;
    height: 100%;
    gap: var(--grid-gap, 14px);
    background: transparent;
}

.cell {
    width: var(--cell-size, 45px);
    height: var(--cell-size, 45px);
    background: #fff;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Courier New", Courier, monospace;
    font-weight: 900;
    font-size: calc(var(--cell-size, 45px) * 0.42);
    color: #1a1a1a;
    position: relative;
    z-index: 2;
}

.cell.is-found {
    color: #fff;
    transition: color 0.2s;
}

/* Bottom: horizontal word list — tight to bottom of poem area */
body.crossword-page .word-list {
    width: 100%;
    max-width: 100%;
    flex-shrink: 0;
    padding: 14px 20px 6px;
    box-sizing: border-box;
    border-top: 1px solid rgba(38, 11, 0, 0.12);
    background: rgba(255, 252, 250, 0.96);
}

.word-list h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 12px;
    color: #260b00;
    text-align: center;
}

#words-to-find {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 20px;
    row-gap: 12px;
}

.word-item {
    padding: 6px 10px;
    color: #5c4033;
    font-size: 0.85rem;
    text-transform: uppercase;
    transition: color 0.4s;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.word-item.found-text {
    color: var(--highlight-green);
    text-decoration: line-through;
}

@media (max-width: 860px) {
    body.crossword-page .page-main {
        padding-bottom: 8px !important;
        padding-top: 160px !important;
    }

    body.crossword-page .crossword-main {
        margin-bottom: 24px;
    }
}

@media (max-width: 520px) {
    #words-to-find {
        gap: 8px 12px;
    }

    .word-item {
        font-size: 0.75rem;
    }
}
