html, body {
    margin: 0;
    height: 100%;
    font-family: system-ui, "Segoe UI", sans-serif;
    font-size: 14px;
    color: #222;
    background: #f3f3f3;
}

button {
    font: inherit;
    color: inherit;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Menu bar */

.menubar {
    position: relative;
    z-index: 20;
    display: flex;
    background: #fff;
    border-bottom: 1px solid #ccc;
}

.menu {
    position: relative;
}

.menu-title {
    padding: 0.4rem 0.75rem;
    background: none;
    border: 0;
    cursor: pointer;
}

    .menu-title:hover, .menu-title.open {
        background: #e5f1fb;
    }

.menu-items {
    position: absolute;
    top: 100%;
    left: 0;
    display: flex;
    flex-direction: column;
    min-width: 15rem;
    padding: 0.25rem 0;
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

    .menu-items button {
        display: grid;
        grid-template-columns: 1.25rem 1fr auto;
        gap: 0.5rem;
        padding: 0.35rem 0.75rem;
        text-align: left;
        background: none;
        border: 0;
        cursor: pointer;
    }

        .menu-items button:hover:not(:disabled) {
            background: #e5f1fb;
        }

        .menu-items button:disabled {
            color: #999;
            cursor: default;
        }

.shortcut {
    color: #666;
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10;
}

/* Board and analysis */

.content {
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: flex-start;
    gap: 12px;
    min-height: 0;
    padding: 12px;
    overflow: auto;
    container-type: size;
}

/* The board fills the height, or the width left beside the analysis panel (240px + 12px gap). */
.board-area {
    flex: none;
    width: min(100cqh, 100cqw - 252px);
}

.content.without-analysis .board-area {
    width: min(100cqh, 100cqw);
}

.board {
    display: grid;
    grid-template-columns: 1.25rem repeat(8, 1fr);
    grid-template-rows: 1.25rem repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1;
}

.coordinate {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #333;
}

.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    background: #1e7a3c;
    border: 1px solid #0b3d1c;
    cursor: pointer;
}

    .square:hover {
        background: #23893f;
    }

    .square:focus-visible {
        outline: none;
        border-color: yellow;
        box-shadow: inset 0 0 0 1px yellow;
    }

.disc {
    position: absolute;
    inset: 10%;
    border: 1px solid #222;
    border-radius: 50%;
}

    .disc.black {
        background: #000;
    }

    .disc.white {
        background: #fff;
    }

.hint, .last {
    position: absolute;
    aspect-ratio: 1;
    border-radius: 50%;
}

.hint {
    width: 24%;
    background: rgba(0, 0, 0, 0.33);
}

.last {
    width: 20%;
    background: #e03030;
}

.analysis {
    flex: none;
    box-sizing: border-box;
    width: 240px;
    /* Beside the board: level with the squares, below the a–h row (the board's first grid row). */
    margin-top: 1.25rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
}

    .analysis h2 {
        margin: 0 0 0.5rem;
        font-size: 1rem;
    }

    .analysis dl {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 0.2rem 0.75rem;
        margin: 0;
    }

    .analysis dt {
        color: #555;
    }

    .analysis dd {
        margin: 0;
    }

.statusbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    padding: 0.3rem 0.75rem;
    background: #fff;
    border-top: 1px solid #ccc;
}

    .statusbar .clock {
        margin-left: auto;
    }

@media (max-width: 700px) {
    .content {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
    }

    .board-area, .content.without-analysis .board-area {
        width: min(100cqw, 100cqh);
    }

    .analysis {
        align-self: stretch;
        width: auto;
        margin-top: 0;
    }
}

/* Dialogs */

.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
}

.dialog {
    min-width: 18rem;
    max-width: min(90vw, 34rem);
    padding: 1rem 1.25rem;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

    .dialog h2 {
        margin: 0 0 0.75rem;
        font-size: 1.1rem;
    }

.dialog-message {
    white-space: pre-line;
}

.dialog-heading {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* About box: the picture beside the text, the title and buttons across the top and bottom. */
.dialog-with-picture {
    display: grid;
    grid-template-columns: 11rem minmax(0, 1fr);
    column-gap: 1.25rem;
    max-width: min(92vw, 40rem);
}

    .dialog-with-picture h2, .dialog-with-picture .dialog-buttons {
        grid-column: 1 / -1;
    }

.dialog-picture {
    margin: 0;
}

    .dialog-picture img {
        display: block;
        width: 100%;
        aspect-ratio: 1;
        object-fit: cover;
        border: 1px solid #ccc;
        border-radius: 6px;
    }

    .dialog-picture figcaption {
        margin-top: 0.5rem;
        font-size: 0.85rem;
        color: #555;
    }

.dialog-body p {
    margin: 0.6rem 0 0;
    line-height: 1.45;
}

    .dialog-body p:first-child {
        margin-top: 0;
    }

@media (max-width: 520px) {
    .dialog-with-picture {
        grid-template-columns: 1fr;
    }

    .dialog-picture {
        width: 9rem;
        margin-bottom: 0.75rem;
    }
}

.dialog-text {
    box-sizing: border-box;
    width: 100%;
    padding: 0.3rem 0.4rem;
    font: inherit;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

    .dialog-buttons button {
        min-width: 5rem;
        padding: 0.3rem 0.8rem;
    }

        .dialog-buttons button.default {
            font-weight: 600;
        }

.settings {
    display: grid;
    grid-template-columns: auto 12rem 6rem;
    gap: 0.5rem 0.75rem;
    align-items: center;
    margin: 0;
    padding: 0;
    border: 0;
}

    .settings legend {
        margin-bottom: 0.75rem;
        padding: 0;
    }

/* From the Blazor template */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1e7a3c;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }
