#game-canvas-wrapper {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin: 20px auto 24px;
}

#game-canvas-area {
    display: block;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
    touch-action: manipulation;
}

.game-grid {
    display: grid;
    width: 100%;
    height: 100%;
    gap: clamp(3px, calc(22px / var(--knight-board-size, 5)), 8px);
    padding: clamp(3px, calc(18px / var(--knight-board-size, 5)), 7px);
}

.cell {
    position: relative;
    display: grid;
    min-width: 0;
    min-height: 0;
    background: transparent;
    line-height: 1;
    outline: none;
    place-items: center;
    transform: rotate(var(--knight-tile-rotation, 0deg));
    transform-origin: 50% 50%;
    user-select: none;
}

.cell.valid-move {
    cursor: pointer;
}

.cell.blocked-move {
    cursor: default;
}

.cell.valid-move:focus-visible {
    outline: 2px solid rgba(37, 63, 143, 0.72);
    outline-offset: 2px;
}

.cell.valid-move:hover {
    filter: saturate(1.08) brightness(1.02);
}

.cell.valid-move:active {
    transform: rotate(var(--knight-tile-rotation, 0deg)) translateY(1px);
}

.cell.valid-move::after {
    position: absolute;
    bottom: 13%;
    left: 13%;
    z-index: 2;
    width: clamp(6px, calc(34px / var(--knight-board-size, 5)), 10px);
    height: clamp(6px, calc(34px / var(--knight-board-size, 5)), 10px);
    background: rgba(255, 221, 49, 0.78);
    border-radius: 50%;
    box-shadow:
        0 0 0 1px rgba(255, 244, 143, 0.2),
        0.5px 0.5px 0 rgba(126, 99, 24, 0.14);
    content: "";
    pointer-events: none;
    transform: rotate(-8deg) scaleX(1.12);
}

.cell.risky-move::after {
    background: rgba(221, 82, 67, 0.82);
    box-shadow:
        0 0 0 1px rgba(255, 199, 189, 0.2),
        0.5px 0.5px 0 rgba(112, 34, 25, 0.15);
}

.cell.last-move {
    z-index: 2;
}

.cell.last-move .knight-tile-paper {
    filter: saturate(1.05);
}

.knight-tile-mark {
    position: relative;
    z-index: 1;
    display: grid;
    color: var(--knight-tile-number-color, var(--pen-blue));
    font-family: "Comic Sans MS", "Trebuchet MS", cursive;
    font-size: var(--knight-tile-font-size, 20px);
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1;
    opacity: 0.96;
    place-items: center;
    pointer-events: none;
    text-shadow:
        -1.2px -1.2px 0 color-mix(in srgb, var(--knight-tile-number-color, #253f8f) 38%, #ffffff),
        -0.6px -0.6px 0 color-mix(in srgb, var(--knight-tile-number-color, #253f8f) 48%, #ffffff),
        0.7px 0.7px 0 color-mix(in srgb, var(--knight-tile-number-color, #253f8f) 62%, #101b54),
        1.2px 1.2px 0 rgba(92, 73, 47, 0.12);
    text-transform: uppercase;
    transform: translateY(1px);
}

.knight-piece-icon {
    position: relative;
    z-index: 1;
    display: block;
    width: min(88%, 86px);
    max-width: 88%;
    max-height: 88%;
    height: auto;
    aspect-ratio: 22 / 31;
    pointer-events: none;
    transform: translateY(-2px);
}

.knight-current-step {
    position: absolute;
    bottom: 6%;
    left: 6%;
    z-index: 2;
    display: grid;
    min-width: 1.45em;
    min-height: 1.22em;
    padding: 0 0.16em;
    color: #ffeb3b;
    font-family: "Comic Sans MS", "Trebuchet MS", cursive;
    font-size: clamp(8px, calc(58px / var(--knight-board-size, 5)), 15px);
    font-weight: 700;
    line-height: 1;
    background: var(--pen-blue);
    border-radius: 1px;
    box-shadow: -0.5px 0.5px 0 rgba(255, 255, 255, 0.18);
    place-items: center;
    pointer-events: none;
    text-shadow:
        0.5px 0.5px 0 rgba(95, 74, 0, 0.4);
}
