body {
    font-family: Helvetica, Arial, sans-serif;
}

.board {
    display: grid;
    /* клетка = минимум 36px, максимум 100px, подстраивается под экран */
    grid-template-columns: repeat(var(--cols), clamp(36px, calc((100vw - 2rem) / var(--cols)), 100px));
    grid-auto-rows: clamp(36px, calc((100vw - 2rem) / var(--cols)), 100px);
    gap: 0;
    border: 3px solid #000;
    max-width: fit-content;
    margin-right: 50px; /* убрать на мобиле */
    width: fit-content;      /* было max-width */
        height: fit-content;     /* добавить */
        position: relative;
}

.board-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: 100% 100%;
    pointer-events: none;  /* клики проходят сквозь */
    z-index: 10;
}

.cell {
    position: relative;
    border: 1px solid dimgray;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: white;
    font-size: clamp(18px, calc((100vw - 2rem) / var(--cols) * 0.6), 66px);
}

.cell.black {
    background-color: black;
    cursor: default;
}

.cell .label {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: clamp(10px, calc((100vw - 2rem) / var(--cols) * 0.28), 33px);
    color: black;
}

.cell.black .label {
    color: white;
}

.cell .guess {
    text-align: center;
}

input.guess {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    text-align: center;
    font-size: clamp(18px, calc((100vw - 2rem) / var(--cols) * 0.6), 66px);
    text-transform: uppercase;
    cursor: text;
}

input.guess:focus,
input.guess:active {
    border: none;
    outline: none;
    box-shadow: none;
    background: transparent;
    font-size: clamp(18px, calc((100vw - 2rem) / var(--cols) * 0.6), 66px);
}

/* Layout */
.crosswordWrapper {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    gap: 1.5rem;
}
.currentWord {
    background-color: lightskyblue;
}

.revealed {
    color: blue;
}

@media (prefers-color-scheme: dark) {
    .cell {
        background-color: gray;
    }
    .currentWord {
        background-color: darkslateblue;
    }
    .revealed {
        color: aqua;
    }

}

.cell.circled {
    position: relative;
}

.cell.circled::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    border: 2px solid dimgray;
    pointer-events: none; /* чтобы не мешал кликам */
    box-sizing: border-box;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-clue-bar {
    display: none;
}

.wrap-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.wrap-group > button {
    width: auto;
    margin: 0;
    border-radius: var(--pico-border-radius);
}

/* Мобильный layout */
@media (max-width: 768px) {
    .crosswordWrapper {
        flex-direction: column;
        align-items: center;
    }

    .board {
        margin-right: 0;
    }

    #buttons {
        display: flex;
        gap: 0.5rem;
    }

    #buttons button {
        flex: 1;
    }
    input.guess {
            /* Предотвращает авто-зум на iOS */
            font-size: max(16px, clamp(18px, calc((100vw - 2rem) / var(--cols) * 0.6), 66px));
        }

        .current-clue-bar {
                display: block;
                width: 100vw;
                margin-left: calc(-1 * var(--pico-spacing, 1rem));
                padding: 0.75rem 1rem;
                background-color: lightskyblue;
                font-size: 0.9rem;
            }

            #clues .clue,
            #clues h3 {
                display: none;
            }
            @media (prefers-color-scheme: dark) {
                    .current-clue-bar {
                        background-color: darkslateblue;
                    }
                }
}