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 (as in Stello.Web) */

.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;
        }

        .menu-items button.separator-before {
            margin-top: 0.25rem;
            border-top: 1px solid #ddd;
            padding-top: 0.5rem;
        }

.shortcut {
    color: #666;
}

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

/* Board and panels */

.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 is 7 cells wide and 7 high (preview row and 6 rows) plus the numbers; it fills the height or the width beside the panels. */
.board-area {
    flex: none;
    width: min(100cqh - 2rem, 100cqw - 252px);
}

.board {
    --red-face: #d32f2f;
    --yellow-face: #fbc02d;
    --red-shadow: none;
    --yellow-shadow: none;
    --disc-border: 2px solid rgba(0, 0, 0, 0.25);
    --face: #1565c0;
    --hole: #e8eef6;
    width: 100%;
}

.columns, .numbers {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.columns {
    position: relative;
}

/* Behind the six rows, below the preview row (1/7 of the height). */
.face {
    position: absolute;
    inset: calc(100% / 7) 0 0 0;
    background: var(--face);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.board.wood .face {
    background: var(--wood) center / cover;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.board.golden-oak {
    --wood: url(../textures/wood-golden-oak.jpg);
    --hole: #f4ead9;
}

.board.reddish-wood {
    --wood: url(../textures/wood-reddish.jpg);
    --hole: #f6e2c8;
}

.board.discs-3d {
    --red-face: radial-gradient(circle at 35% 30%, #ff8a80 0%, #e53935 35%, #b71c1c 80%);
    --yellow-face: radial-gradient(circle at 35% 30%, #fff59d 0%, #fdd835 35%, #f9a825 85%);
    --red-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.4);
    --yellow-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.4);
    --disc-border: 0;
}

.column {
    position: relative;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}

    .column:focus-visible {
        outline: 3px solid #ffd54f;
        outline-offset: -3px;
        border-radius: 6px;
    }

.preview, .cell {
    position: relative;
    display: block;
    aspect-ratio: 1;
}

/* The disc that would be dropped, above the column under the mouse. */
.column:hover .preview.red::after, .column:hover .preview.yellow::after {
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 50%;
    opacity: 0.8;
}

.column:hover .preview.red::after {
    background: var(--red-face);
}

.column:hover .preview.yellow::after {
    background: var(--yellow-face);
}

.cell::before {
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 50%;
    background: var(--hole);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
}

.column:hover:has(.preview:not(.none)) .cell::before {
    filter: brightness(1.06);
}

.disc {
    position: absolute;
    inset: 10%;
    border: var(--disc-border);
    border-radius: 50%;
    box-sizing: border-box;
}

    .disc.red {
        background: var(--red-face);
        box-shadow: var(--red-shadow);
    }

    .disc.yellow {
        background: var(--yellow-face);
        box-shadow: var(--yellow-shadow);
    }

    /* From the preview row down to the cell; one cell is 125% of a disc. */
    .disc.falling {
        animation-name: fall;
        animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
        animation-fill-mode: both;
    }

@keyframes fall {
    from {
        transform: translateY(calc(var(--fall) * -125%));
    }

    to {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .disc {
        animation: none !important;
    }
}

.winning {
    position: absolute;
    inset: 4%;
    border: 4px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}

.last {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16%;
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.75);
}

.numbers span {
    padding-top: 0.3rem;
    text-align: center;
    color: #333;
}

.side-panels {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 12px;
    width: 240px;
    /* Level with the top of the board face, below the preview row. */
    margin-top: calc(min(100cqh - 2rem, 100cqw - 252px) / 7);
}

.panel {
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
}

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

.status p {
    margin: 0.2rem 0 0;
}

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

.analysis dt {
    color: #555;
}

.analysis dd {
    margin: 0;
}

    .analysis dd.line {
        overflow-wrap: anywhere;
    }

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

    .board-area {
        width: min(100cqw, 100cqh - 2rem);
    }

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

/* Dialogs (as in Stello.Web) */

.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, 36rem);
    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;
    }

.settings-note {
    grid-column: 1 / -1;
    max-width: 30rem;
    margin: 0.75rem 0 0;
    color: #555;
}

/* 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: #1565c0;
            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");
    }
