.board-room {
    --room-ink: #28254f;
    --room-muted: #534f70;
    --room-accent: #593db4;
    --room-wash: #efebf9;
    --room-border: #d9d3e8;
    --room-table: url("chess-table.87b1d512465d.webp");
    --room-friends: url("friends.66a9f634adc2.webp");
    --room-robot: url("robot.b9009247c359.webp");
    --room-local: #ece2fa;
    --room-ai: #dcecfb;
    --room-local-border: #a08bcf;
    --room-ai-border: #83a9cf;
    --room-ai-accent: #265c97;
    color: var(--room-ink);
    min-height: calc(100dvh - var(--main-nav-height, 72px));
    background: linear-gradient(144deg, var(--room-wash), #fcfaf8 90%);
    padding: clamp(1rem, 3vw, 2.75rem) clamp(.5rem, 2.8vw, 2rem) 1.5rem;
}
.board-room--janggi {
    --room-ink: #492d27;
    --room-muted: #6a4a42;
    --room-accent: #963b4c;
    --room-wash: #fbede5;
    --room-border: #e4d2c9;
    --room-table: url("janggi-table.2da5d0c7c063.webp");
    --room-friends: url("janggi-friends.a58e08e3dfd3.webp");
    --room-robot: url("janggi-robot.85374a6b5dc3.webp");
    --room-local: #f9e2e3;
    --room-ai: #e3efdc;
    --room-local-border: #c2878e;
    --room-ai-border: #82a88a;
    --room-ai-accent: #2e6742;
}
html[data-classroom-game="chess"] #classroom-play-toolbar { background: #f1ebfa; }
html[data-classroom-game="janggi"] #classroom-play-toolbar { background: #faf0e8; }
html[data-classroom-game="chess"] #classroom-play-toolbar h1,
html[data-classroom-game="janggi"] #classroom-play-toolbar h1 {
    border-radius: 999px;
    background: #473879;
    color: #fff;
    padding: .3rem .9rem;
    flex: 0 0 auto;
    margin-inline-end: auto;
    justify-self: start;
}
html[data-classroom-game="janggi"] #classroom-play-toolbar h1 { background: #8a4535; }

html:has(.board-room--entry) #classroom-play-toolbar [data-play-action="reset"] { display: none; }
.board-room--entry { display: grid; align-content: center; }
.board-picker {
    width: min(100%, 68rem);
    margin-inline: auto;
    display: grid;
    grid-template-columns: 36% minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--room-border);
    border-radius: clamp(1rem, 2.5vw, 2rem);
    background: #ffffff8c;
    box-shadow: 0 20px 52px #35264116;
}
.board-picker-art {
    background: var(--room-table) center / cover no-repeat;
    min-block-size: 31rem;
}
.board-picker-body {
    align-self: center;
    padding: clamp(1.25rem, 4vw, 3.4rem);
    min-width: 0;
    text-align: center;
}
.board-picker-body h2 {
    margin: 0 0 clamp(1.1rem, 4vw, 2.5rem);
    font-size: clamp(1.75rem, 4.8vw, 3.65rem);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -.055em;
    word-break: keep-all;
}
.board-picker-options, .board-level-form fieldset {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(.65rem, 2vw, 1.3rem);
}
.board-mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .65rem;
    padding: clamp(.75rem, 2vw, 1.6rem) .5rem;
    min-width: 0;
    color: var(--room-ink);
    background: linear-gradient(#fff9, transparent 65%), var(--room-local);
    border: 1px solid var(--room-local-border);
    border-radius: clamp(.85rem, 2vw, 1.55rem);
    box-shadow: inset 0 0 0 2px #fffc, 0 8px 16px #38234914;
    text-decoration: none;
    word-break: keep-all;
    transition: transform .16s ease, box-shadow .16s ease;
}
.board-mode-card--computer {
    background: linear-gradient(#fff9, transparent 65%), var(--room-ai);
    border-color: var(--room-ai-border);
}
.board-mode-card:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 2px #fffc, 0 12px 22px #38234928; }
.board-mode-card strong { font-size: clamp(1rem, 2.8vw, 2.05rem); letter-spacing: -.045em; line-height: 1.25; }
.board-mode-card > span:not([aria-hidden]) { font-size: clamp(.75rem, 1.6vw, 1rem); line-height: 1.4; }
.board-mode-art {
    width: min(100%, 12rem);
    aspect-ratio: 1.6;
    background: var(--room-friends) center / contain no-repeat;
}
.board-mode-card--computer .board-mode-art { background-image: var(--room-robot); width: min(100%, 9.6rem); aspect-ratio: 1.28; }
.board-mode-arrow {
    display: inline-grid;
    place-items: center;
    background: var(--room-accent);
    border: 2px solid #fffc;
    color: white;
    border-radius: 99px;
    min-width: 3.25rem;
    min-height: 2.1rem;
    margin-top: auto;
    font-size: 1.25rem;
    font-weight: 800;
}
.board-mode-card--computer .board-mode-arrow { background: var(--room-ai-accent); }
.board-picker-back { display: inline-block; margin-bottom: 1rem; color: var(--room-muted); font-weight: 700; }
.board-level-form { max-width: 29rem; margin: auto; }
.board-level-form fieldset { border: 0; padding: 0; margin: 0 0 1.4rem; }
.board-level-form label { position: relative; }
.board-level-form input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.board-level-form label span {
    display: grid;
    place-items: center;
    padding: .5rem;
    min-height: 3.2rem;
    background: #fff;
    border: 1px solid var(--room-border);
    border-radius: .8rem;
    font-weight: 800;
    cursor: pointer;
}
.board-level-form input:checked + span { background: var(--room-local); border: 2px solid var(--room-accent); }
.board-level-form input:focus-visible + span { outline: 3px solid var(--room-accent); outline-offset: 3px; }

.board-table {
    container-type: inline-size;
    margin-inline: auto;
    width: min(100%, 70rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(12.5rem, 34.5%);
    grid-template-rows: auto auto 1fr auto auto;
    align-items: start;
    column-gap: clamp(1.1rem, 3vw, 3rem);
    row-gap: .85rem;
    --table-height: max(24rem, calc(100dvh - var(--main-nav-height, 72px) - 5rem));
}
.board-match-meta { grid-area: 1 / 2; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.board-match-meta h1 { font-size: 1.4rem; font-weight: 900; }
.board-match-meta > :is(a, span) {
    display: inline-block;
    padding: .38rem .65rem;
    border: 1px solid var(--room-border);
    border-radius: 99px;
    color: var(--room-muted);
    background: #ffffffb5;
    font-size: .875rem;
    font-weight: 750;
}
.board-match-meta a:hover { border-color: var(--room-accent); text-decoration: underline; }
.board-status-card, .board-history {
    background: #fffc;
    border: 1px solid var(--room-border);
    border-radius: 1rem;
    box-shadow: 0 5px 14px #38234913;
}
.board-status-card {
    grid-area: 2 / 2;
    padding: .85rem 1rem;
    border-inline-start: 4px solid var(--room-accent);
    background: linear-gradient(130deg, #fff, var(--room-local));
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    font-weight: 900;
    line-height: 1.3;
}
.board-status-detail, .board-ai-message {
    margin-top: .25rem;
    color: var(--room-muted);
    font-size: .875rem;
    font-weight: 650;
}
.board-ai-message.error { color: #9f232c; }
.board-match-board { grid-area: 1 / 1 / 5; width: min(100%, var(--table-height)); margin-inline: auto; }
.board-room--janggi .board-match-board { width: min(100%, calc(var(--table-height) * .9)); }
.board-history { grid-area: 3 / 2; align-self: stretch; overflow: hidden; max-height: 21rem; }
.board-history summary {
    padding: .75rem 1rem;
    cursor: pointer;
    font-weight: 850;
}
.board-history[open] summary { border-bottom: 1px solid var(--room-border); }
.board-history .move-history, .janggi-history {
    overflow: auto;
    max-height: min(36vh, 19rem);
    min-height: 4rem;
    padding: .75rem 1rem;
    color: var(--room-muted);
    font-size: .875rem;
}
.board-history .move-item { padding: .38rem 0; border-bottom: 1px solid var(--room-border); font-variant-numeric: tabular-nums; }
.janggi-history { white-space: pre-wrap; line-height: 1.95; }
.board-match-tools { grid-area: 4 / 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.board-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 2.75rem;
    border: 1px solid var(--room-border, #d9d3e8);
    border-radius: .75rem;
    background: #fff;
    padding: .4rem .65rem;
    color: var(--room-ink, #28254f);
    font-size: .88rem;
    font-weight: 800;
    text-align: center;
    word-break: keep-all;
    cursor: pointer;
}
.board-button:hover:not(:disabled) { border-color: var(--room-accent, #593db4); }
.board-button:disabled { opacity: .56; cursor: default; }
.board-button--accent { background: var(--room-accent); border-color: var(--room-accent); color: #fff; }
.board-credit { grid-area: 5 / 1 / 6 / -1; justify-self: end; color: var(--room-muted); font-size: .875rem; text-decoration: underline; }
.board-room :is(a, button, summary):focus-visible { outline: 3px solid var(--room-accent); outline-offset: 2px; }
.board-room [hidden] { display: none !important; }

.chess-board-frame {
    padding: clamp(3px, .65vw, 8px);
    background: #674329 url("chess-dark.b940e83806b7.webp") center / 80px;
    border: 1px solid #64472f;
    border-radius: .65rem;
    box-shadow: 0 8px 20px #4932233a;
}
#myBoard { width: 100%; }
#myBoard .board-b72b1 { border: 1px solid #51351e; }
#myBoard .white-1e1d7 { background: #f2dbbc url("chess-light.a3f2034c33be.webp") center / cover; color: #4b3627; }
#myBoard .black-3c85d { background: #b5845b url("chess-dark.b940e83806b7.webp") center / cover; color: #231b19; }
#myBoard .notation-322f9 { font-size: clamp(.55rem, 1vw, .9rem); font-weight: 800; }
#myBoard img { user-select: none; }
#myBoard .square-55d63:focus-visible { outline: 3px solid #39238f; outline-offset: -3px; z-index: 1; }
#myBoard .highlight-selected, #janggiBoard .selected { box-shadow: inset 0 0 0 3px #5136a2; background-color: #c9b0e8a0; }
#myBoard .highlight-hint::after, #janggiBoard .hint::after {
    content: "";
    position: absolute;
    inset: 39%;
    border-radius: 50%;
    background: #493284b0;
    pointer-events: none;
}
#myBoard .highlight-attack, #janggiBoard .hint:has(.janggi-piece) { box-shadow: inset 0 0 0 3px #a32f42; }
#myBoard .last-move:not(.highlight-selected, .highlight-attack), #janggiBoard .last-move:not(.selected, .hint) { box-shadow: inset 0 0 0 3px #b17217; }

.board-janggi-surface {
    isolation: isolate;
    position: relative;
    background: #efd29b url("janggi-wood.8e8e350d59ff.webp") center / cover;
    border: 3px solid #794c2b;
    border-radius: .65rem;
    box-shadow: 0 8px 20px #63371d3a;
    overflow: hidden;
}
.janggi-board-overlay { position: absolute; width: 100%; height: 100%; inset: 0; fill: none; stroke: #684427; stroke-width: .024; pointer-events: none; }
.janggi-board { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); position: relative; }
.janggi-board.flipped, .janggi-board.flipped .janggi-piece { transform: rotate(180deg); }
.janggi-cell {
    display: grid;
    place-items: center;
    min-width: 0;
    padding: 0;
    aspect-ratio: 1;
    border: 0;
    background: transparent;
    position: relative;
    container-type: inline-size;
    cursor: pointer;
}
#janggiBoard .janggi-cell:focus-visible { outline-offset: -3px; z-index: 1; }
#janggiBoard .janggi-piece {
    --piece-ink: #861627;
    --piece-face: url("janggi-cho.251cdccb019c.webp");
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 1px;
    height: 90%;
    width: 90%;
    padding: 0;
    position: absolute;
    color: var(--piece-ink);
    background: var(--piece-face) center / contain no-repeat;
    filter: drop-shadow(0 1px 1px #4027124a);
}
#janggiBoard .piece-blue {
    --piece-ink: #134829;
    --piece-face: url("janggi-han.fa4f133f2979.webp");
}
.piece-side-badge { display: none; }
.piece-glyph {
    position: relative;
    font: 800 clamp(12px, 46cqi, 34px)/1 "AppleMyungjo", "Batang", "Noto Serif CJK KR", serif;
}
#janggiBoard .piece-name { position: relative; font-size: clamp(7px, 17cqi, 12px); line-height: 1; font-weight: 900; }
#turnIndicator.is-blue { color: #174f31; }
#turnIndicator.is-red { color: #812838; }

.board-result-dialog {
    width: min(calc(100% - 2rem), 27rem);
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 1.25rem;
    background: transparent;
}
.board-result-dialog::backdrop { background: #21162669; }
.board-result-card {
    padding: 1.5rem;
    border-radius: 1.25rem;
    background: #fffaf7;
    color: #492d27;
    text-align: center;
}
.board-result-icon { font-size: 2.5rem; }
.board-result-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1rem; }
.result-title { font-size: 1.55rem; font-weight: 900; }
.result-desc { margin: .65rem 0 1rem; }
.toast {
    display: none;
    position: fixed;
    inset: auto 1rem 1rem;
    width: fit-content;
    max-width: calc(100% - 2rem);
    margin-inline: auto;
    background: #36231d;
    color: #fff;
    border-radius: .65rem;
    padding: .65rem 1rem;
    z-index: 99;
}
.toast.show { display: block; }
.toast-title { font-weight: 900; }
.board-result-button {
    border: 1px solid #d7ccec;
    border-radius: .75rem;
    min-height: 2.75rem;
    padding: .45rem 1rem;
    font-weight: 800;
}
.board-result-button--primary { background: #593db4; color: #fff; }

@media (min-width: 701px) {
    html[data-classroom-playing] .service-shell.board-room--entry {
        padding: 0 !important;
        align-content: stretch;
    }
    .board-picker {
        width: min(100%, 96rem);
        min-height: calc(100dvh - var(--main-nav-height, 72px));
        grid-template-columns: 36.7% minmax(0, 1fr);
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }
    .board-picker-body { padding: 1.5rem clamp(1rem, 4.4vw, 3.1rem) 1.5rem .1rem; }
    .board-mode-card { min-height: clamp(15rem, 33.8vw, 24.4rem); justify-content: center; gap: .8rem; }
    .board-mode-arrow { margin-top: .3rem; }
    .board-mode-card > span:not([aria-hidden]) { font-size: clamp(.85rem, 1.6vw, 1.18rem); }
    .board-room--chess .board-match-board { width: min(100%, calc(var(--table-height) - 2rem)); }
    .board-room--janggi .board-match-board { width: min(100%, calc((var(--table-height) + 1.6rem) * .9)); }
    .board-status-card { min-height: 4.7rem; align-content: center; }
}

@media (max-width: 700px) {
    .board-picker { grid-template-columns: minmax(0, 1fr); max-width: 33rem; }
    .board-mode-art { width: min(100%, 7rem); }
    .board-mode-card--computer .board-mode-art { width: min(100%, 5.6rem); }
    .board-picker-art { min-block-size: 0; height: clamp(7rem, 28vw, 12rem); background-position: center 54%; }
    .board-table { grid-template: auto / minmax(0, 1fr); width: min(100%, 32rem); gap: .55rem; }
    .board-table > * { grid-area: auto; }
    .board-match-meta { grid-row: 1; }
    .board-status-card { grid-row: 2; padding: .55rem .75rem; }
    .board-match-board { grid-row: 3; }
    .board-room--janggi .board-match-board { width: 100%; max-width: 29rem; }
    .board-match-tools { grid-row: 4; }
    .board-history { grid-row: 5; }
    .board-credit { grid-row: 6; }
}
@media (prefers-reduced-motion: reduce) {
    .board-mode-card { transition: none; }
}
