.chess-page {
    --light-square: #eeeed2;
    --dark-square: #769656;
    --highlight: rgba(198, 202, 83, 0.75);

    --board-size: min(100vw - 2 * var(--gutter), 100svh - 11.5rem);

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--color-text);
    font: 400 1.25rem/1.55 "Zilla Slab", Rockwell, Georgia, serif;
}

.chess-page header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    width: var(--board-size);
}

.chess-page h1 {
    margin: 0;
    font-size: 1.75rem;
}

#board {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
    width: var(--board-size);
    height: var(--board-size);
    border: 2px solid var(--color-border);
}

.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    font-family: "DejaVu Sans", "Segoe UI Symbol", "Noto Sans Symbols 2", "Apple Symbols", serif;
    font-size: calc(var(--board-size) / 8 * 0.72);
    line-height: 1;
    cursor: pointer;
}

.square.light {
    background: var(--light-square);
}

.square.dark {
    background: var(--dark-square);
}

.square.white-piece {
    color: #fff;
    text-shadow: 0 0 2px #000, 0 0 1px #000, 0 0 1px #000;
}

.square.black-piece {
    color: #111;
    text-shadow: 0 0 2px #fff, 0 0 1px #fff;
}

.square.last-move {
    box-shadow: inset 0 0 0 100vmax rgba(198, 202, 83, 0.4);
}

.square.selected {
    box-shadow: inset 0 0 0 100vmax var(--highlight);
}

.square.in-check {
    box-shadow: inset 0 0 0 100vmax rgba(200, 40, 40, 0.75);
}

.square:focus-visible {
    z-index: 1;
    outline: 3px solid var(--color-accent);
    outline-offset: -3px;
}

.square.target::after,
.square.capture::after {
    content: "";
    position: absolute;
    border-radius: 50%;
}

.square.target::after {
    width: 28%;
    height: 28%;
    background: rgba(8, 8, 8, 0.45);
}

.square.capture::after {
    inset: 6%;
    border: calc(var(--board-size) / 8 * 0.08) solid rgba(8, 8, 8, 0.45);
}

.square[data-rank]::before,
.square[data-file]:not([data-rank])::before {
    position: absolute;
    top: 2px;
    left: 3px;
    color: #080808;
    font: 700 max(9px, calc(var(--board-size) / 8 * 0.16)) / 1 "Zilla Slab", Georgia, serif;
    text-shadow: none;
}

.square.dark[data-rank]::before,
.square.dark[data-file]:not([data-rank])::before {
    color: #efefef;
}

.square[data-rank]::before {
    content: attr(data-rank);
}

.square[data-file]:not([data-rank])::before {
    content: attr(data-file);
    top: auto;
    bottom: 2px;
    left: auto;
    right: 3px;
}

#status {
    min-height: 1.55em;
    margin: 0;
    text-align: center;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.controls button {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
}

.controls button:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.controls button:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

#promotion {
    padding: 0.5rem;
    border: 2px solid var(--color-border);
    background: var(--color-bg);
}

#promotion::backdrop {
    background: rgba(5, 7, 15, 0.6);
}

#promotion-choices {
    display: grid;
    grid-template-columns: repeat(4, calc(var(--board-size) / 8));
    grid-auto-rows: calc(var(--board-size) / 8);
    gap: 4px;
}
