/* Metropolis from https://github.com/typehaus/metropolis (Unlicense). */
@font-face {
    font-family: "Chess Joker Metropolis";
    src: url("/game-plugins/chessjoker/1.0.4/fonts/Metropolis-Light.woff2") format("woff2");
    font-style: normal;
    font-weight: 300;
    font-display: swap;
}

@font-face {
    font-family: "Chess Joker Metropolis";
    src: url("/game-plugins/chessjoker/1.0.4/fonts/Metropolis-ExtraBold.woff2") format("woff2");
    font-style: normal;
    font-weight: 800;
    font-display: swap;
}

/* Game layout */
#content {
    container: cj-game-area / size;
    min-width: 0;
    min-height: 0;
}

#game {
    --cj-layout: desktop;
    --cj-cream: #f3e8cf;
    --cj-ink: #27231f;
    --cj-gold: #d3a747;
    color: var(--cj-ink);
    column-gap: .75rem;
    justify-content: center;
    min-height: 0;
    overflow: clip;
}

#playerData {
    display: flex;
    flex: 0 1 27.25rem;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    min-width: 0;
}

#playerData > .playerData {
    container-type: inline-size;
    flex: 0 0 auto;
}

#game #playerData > .playerData {
    border-style: solid;
    border-color: #000;
}

/* Textures extracted from board squares F6 (black) and B7 (white). */
#playerData > .playerData {
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

#playerData1 {
    background-image: url("/game-plugins/chessjoker/1.0.4/images/player-panel-black.webp");
}

#playerData0 {
    background-image: url("/game-plugins/chessjoker/1.0.4/images/player-panel-white.webp");
}

#playerData1 .playerDataBasic {
    color: #fff;
}

#board {
    align-self: stretch;
    display: block;
    flex: 0 0 auto;
    min-height: 0;
    min-width: 0;
    overflow: visible;
}

.chessJokerGame {
    box-sizing: border-box;
    container-type: inline-size;
    display: grid;
    gap: 1rem;
    grid-template-rows: minmax(0, 1fr);
    height: 100%;
    margin: 0 auto;
    min-height: 0;
    padding: 1rem;
    width: 100%;
}

.cjTable {
    align-items: center;
    display: flex;
    gap: 1rem;
    height: 100%;
    justify-content: center;
    min-height: 0;
}

/* The frame adds 3.5% of the board height on each side. */
.cjBoardWrap {
    aspect-ratio: 1;
    container-type: size;
    flex: 0 0 auto;
    height: calc(100% / 1.07);
    position: relative;
}

/* A solid backing avoids seams when zoom rounds the frame and board edges differently. */
.cjBoardWrap::before {
    background: #080706;
    border-radius: 2.5cqh;
    content: "";
    inset: -3.5cqh;
    pointer-events: none;
    position: absolute;
}

.cjBoard {
    background: #080706 url("/game-plugins/chessjoker/1.0.4/images/board.webp") center / 100% 100% no-repeat;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
    inset: 0;
    position: absolute;
    z-index: 1;
}

.cjRankLabels, .cjFileLabels {
    color: #fff;
    display: grid;
    font-size: 2.2cqh;
    font-weight: 700;
    position: absolute;
    text-shadow: 0 .15cqh .3cqh #000;
    z-index: 2;
}

.cjRankLabels {
    bottom: 0;
    grid-template-rows: repeat(8, 1fr);
    right: 100%;
    top: 0;
    width: 3.5cqh;
}

.cjFileLabels {
    grid-template-columns: repeat(8, 1fr);
    height: 3.5cqh;
    left: 0;
    right: 0;
    top: 100%;
}

.cjRankLabels span, .cjFileLabels span {
    align-items: center;
    display: flex;
    justify-content: center;
}

/* Squares, pieces and move highlights */
.cjSquare {
    align-items: center;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    min-height: 0;
    min-width: 0;
    position: relative;
    grid-row: var(--cj-row);
    grid-column: var(--cj-column);
}

.cjPiece {
    -webkit-user-drag: none;
    border-radius: 50%;
    cursor: default;
    display: block;
    height: 88%;
    object-fit: contain;
    position: relative;
    user-select: none;
    width: 88%;
    z-index: 1;
}

.cjKingInCheck::before {
    animation: cjCheckPulse 2s ease-in-out infinite;
    background: #e02020;
    box-shadow: inset 0 0 0 3px #b00000;
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

@keyframes cjCheckPulse {
    0%, 100% { opacity: .2; }
    50% { opacity: .75; }
}

.cjPublisherLogo {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    width: 8rem;
    visibility: hidden;
}

.cjPublisherLogo img {
    display: block;
    width: 100%;
    height: auto;
}

.cjCheckingPiece::before {
    animation: cjCheckingPiecePulse 2s ease-in-out infinite;
    background: #e24848;
    border: 2px solid #c43c3c;
    box-sizing: border-box;
    content: "";
    inset: 5%;
    pointer-events: none;
    position: absolute;
    z-index: 0;
}

@keyframes cjCheckingPiecePulse {
    0%, 100% { opacity: .12; }
    50% { opacity: .4; }
}

@media (prefers-reduced-motion: reduce) {
    .cjKingInCheck::before {
        animation: none;
        opacity: .5;
    }
    .cjCheckingPiece::before {
        animation: none;
        opacity: .28;
    }
}

.cjPieceColor0 {
    border: max(.0625rem, .12cqh) solid #aaa;
}

.cjPieceOpponent {
    transform: rotate(180deg);
}

.cjOuterSquare {
    display: none;
}

.cjOffboardLayer {
    position: fixed;
    inset: 0;
    z-index: 999;
    pointer-events: none;
    overflow: clip;
}

.cjExtendedBoard .cjOuterSquare {
    display: flex;
    position: absolute;
    grid-area: auto;
    visibility: hidden;
    pointer-events: auto;
}

.cjExtendedBoard .cjOuterSquare.cjDestination, .cjExtendedBoard .cjOuterSquare:has(.cjPiece) {
    visibility: visible;
}

.cjSelectable {
    cursor: pointer;
}

.cjSelectable::after, .cjDestination::after, .cjRemovable::after, .cjCapturedSquare::after {
    border-radius: 50%;
    content: "";
    inset: 34%;
    pointer-events: none;
    position: absolute;
}

.cjSelectable::after {
    background: transparent;
    box-shadow: 0 0 0 calc(var(--cj-square-size) * .035) #45d483cc;
    inset: 8%;
    z-index: 2;
}

.cjSelectable .cjPiece {
    cursor: pointer;
}

.cjSelectable.cjCardCheckOnly::after {
    box-shadow: 0 0 0 calc(var(--cj-square-size) * .035) #e87900;
}

.cjDestination {
    cursor: pointer;
}

.cjDestination::after {
    background: #45d483cc;
    box-shadow: 0 0 0 calc(var(--cj-square-size) * .02) #fff8;
    z-index: 2;
}

.cjCardCheckBlocked {
    cursor: not-allowed;
}

.cjCardCheckWarning {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M14 4Q16 1 18 4L30 26Q32 30 28 30H4Q0 30 2 26Z' fill='%23f59e0b' stroke='%237c3c00' stroke-width='1.5'/%3E%3Cpath d='M16 11v9' stroke='%232b1b00' stroke-width='3' stroke-linecap='round'/%3E%3Ccircle cx='16' cy='25' r='1.7' fill='%232b1b00'/%3E%3C/svg%3E") center / contain no-repeat;
    filter: drop-shadow(0 1px 2px #0008);
    height: 46%;
    position: absolute;
    width: 46%;
    z-index: 4;
}

.cjCardCheckMessage {
    align-items: flex-start;
    display: flex;
    gap: .75rem;
    text-align: left;
}

.cjCardCheckMessage .cjCardCheckWarning {
    flex: 0 0 2rem;
    height: 2rem;
    position: static;
    width: 2rem;
}

.cjCardCheckMessage p {
    margin: 0;
}

.cjCaptureDestination::after, .cjRemovable::after {
    background: transparent;
    box-shadow: 0 0 0 calc(var(--cj-square-size) * .035) #e24848ee;
    inset: 8%;
}

.cjCapturedSquare::after {
    background: #e2484866;
    inset: 6%;
    z-index: 2;
}

.cjDropHover::after {
    background: #45d483ee;
    inset: 22%;
}

.cjCaptureDestination.cjDropHover::after, .cjRemovable:hover::after {
    background: #e2484866;
    box-shadow: 0 0 0 calc(var(--cj-square-size) * .045) #e24848;
    inset: 8%;
}

.cjSwapDestination::after {
    background: transparent;
    box-shadow: 0 0 0 calc(var(--cj-square-size) * .035) #45d483cc;
    inset: 8%;
}

.cjSwapDestination.cjDropHover::after {
    background: #45d48366;
    box-shadow: 0 0 0 calc(var(--cj-square-size) * .045) #45d483;
    inset: 8%;
}

.cjSelectedSourcePiece, .cjCastlingSourcePiece {
    opacity: .35;
}

.cjCastlingPreviewPiece {
    opacity: .72;
    pointer-events: none;
    z-index: 3;
}

.cjHeldPiece {
    background: transparent !important;
    left: 0;
    top: 0;
    opacity: 1;
    pointer-events: none;
    position: fixed;
    z-index: 1100;
}

.cjHoldingPiece, .cjHoldingPiece .cjSquare {
    cursor: grabbing;
}

.cjPromotionChoice {
    border-radius: 50%;
    display: block;
    height: 5rem;
    object-fit: contain;
    width: 5rem;
}

.cjPromotionModal {
    pointer-events: none;
}

.cjPromotionModal .modal-dialog {
    pointer-events: auto;
}

#cjChooseAction .choicesDirect:has(.cjPromotionChoice) .choice {
    align-items: center;
    display: flex;
    justify-content: center;
    padding: .4rem;
}

/* Player panels */
.cjScore {
    font-size: 1.5em;
    font-weight: 700;
}

.cjEloOrange {
    color: #e87900;
}

.cjEloRed {
    color: #e02020;
}

#game .playerDataBasic {
    display: grid;
    font-size: 4.75cqw;
    grid-template-columns: 4em minmax(0, 1fr);
    column-gap: .5em;
    padding: .25em;
}

#game .playerDataDetail {
    padding: 0 1.1875cqw 1.1875cqw;
}

#playerData .playerDataBasic > *, #playerData .basicDesc > * {
    padding-left: 0;
}

.playerDataBasic .basicDesc {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    display: flex;
    align-items: center;
    gap: .3em;
}

#playerData .playerData.startPlayer .playerInfoLogin {
    font-weight: normal;
}

.playerDataBasic .cjScore {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    margin: 0;
    white-space: nowrap;
}

.cjEloButton {
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    text-align: left;
}

.playerDataBasic .cjMaterial {
    grid-column: 2;
    grid-row: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .1em .3em;
    min-height: 1.5em;
    min-width: 0;
}

.cjMaterialGroup {
    display: flex;
    flex-wrap: wrap;
    max-width: 100%;
    padding-left: .45em;
}

.cjMaterialPiece {
    width: 1.5em;
    height: 1.5em;
    object-fit: contain;
    margin-left: -.45em;
}

.cjAvatar {
    border-radius: .75em;
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: center;
    height: 4em;
    object-fit: cover;
    width: 4em;
}

.cjCards {
    display: flex;
    gap: .75rem;
}

.cjCardSlot {
    min-width: 0;
    width: 100%;
}

/* Card artwork and shared states */
.cjCard {
    aspect-ratio: 7 / 5;
    border-radius: 2.5% / 3.5%;
    clip-path: inset(0 round 2.5% / 3.5%);
    container-type: inline-size;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.cjCardImage {
    -webkit-user-drag: none;
    display: block;
    height: 100%;
    object-fit: contain;
    user-select: none;
    width: 100%;
}

.cjCardHelp {
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
}

button.cjCardHelp:not(:disabled) {
    cursor: help;
}

.cjCardHelp img {
    display: block;
    width: 100%;
    height: 100%;
}

.cjCardHelp:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Match the artwork's text inset and type size in card-width units, on both halves. */
.cjCardText {
    align-items: flex-start;
    background: #000;
    box-sizing: border-box;
    color: #fff;
    display: flex;
    font-family: "Chess Joker Metropolis", Arial, sans-serif;
    font-size: var(--cj-card-fit-size, 5.2cqw);
    font-weight: 300;
    height: 34.6%;
    justify-content: center;
    left: 21.7%;
    letter-spacing: normal;
    line-height: 1.05;
    padding: 2.7cqw 3.3cqw 0;
    position: absolute;
    text-align: left;
    top: 0;
    width: 78.3%;
    border-top-right-radius: 2.5cqw;
}

.cjCardTextLayers {
    display: grid;
    width: 100%;
}

.cjCardTextContent {
    display: block;
    grid-area: 1 / 1;
    align-self: start;
    width: 100%;
}

.cjCardCheckOverlay {
    color: #ff6868;
    opacity: 0;
    pointer-events: none;
    user-select: none;
    visibility: hidden;
}

/* Keep the spacing, but expose and paint metadata only in the original layer. */
.cjCardCheckOverlay .cjCardMetadata {
    visibility: hidden;
}

.cjCheckingCard .cjCardCheckOverlay {
    visibility: visible;
    animation: cjCheckingCardPulse 2s ease-in-out infinite;
}

@keyframes cjCheckingCardPulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .cjCheckingCard .cjCardCheckOverlay {
        animation: none;
        opacity: 1;
    }
}

.cjCardMetadata {
    display: none;
}

.cjCardText strong {
    font-weight: 800;
}

.cjCardTextMirrored {
    border-top-left-radius: 2.5cqw;
    border-top-right-radius: 0;
    bottom: 0;
    top: auto;
    transform: rotate(180deg);
}

.cjCardTextMirrored.cjCardTextMimicked {
    border-bottom-right-radius: 2.5cqw;
    border-top-left-radius: 0;
    color: #45d483;
    transform: none;
}

.cjCardEmpty {
    align-items: center;
    background: rgb(243 232 207 / .72);
    border: .15rem dashed #6b6257;
    box-sizing: border-box;
    color: #6b6257;
    display: flex;
    font-family: "Chess Joker Metropolis", Arial, sans-serif;
    font-size: 5.2cqw;
    font-weight: 700;
    justify-content: center;
}

.cjCardToggle, .cjCardToggle .cjCardToggleButton {
    cursor: pointer;
}

.cjCardToggle .cjCardToggleButton, .cjCardUnavailable .cjCardToggleButton {
    border: 2px solid #45d483cc;
}

.cjCardToggleButton {
    align-items: center;
    background: #0008;
    border: .6cqw solid #fff;
    border-radius: 50%;
    box-shadow: 0 .5cqw 1.5cqw #0008;
    box-sizing: border-box;
    color: #fff;
    display: none;
    font: 700 8cqw / 1 Arial, sans-serif;
    height: 12cqw;
    justify-content: center;
    padding: 0;
    position: absolute;
    right: 3cqw;
    top: 50%;
    transform: translateY(-50%);
    width: 12cqw;
    z-index: 4;
}

.cjCardToggle .cjCardToggleButton, .cjCardActive .cjCardToggleButton {
    display: flex;
}

.cjCardActive .cjCardToggleButton {
    background: #237a49;
}

.cjCardActive .cjCardToggleButton::before {
    content: "\2713";
}

.cjCardToggle .cjCardToggleButton:focus-visible {
    border-color: var(--cj-gold);
}

.cjCardToggleButton:focus-visible {
    outline: 2px solid var(--cj-gold);
    outline-offset: 2px;
}

.cjCardUnavailable .cjCardToggleButton {
    border-color: #e87900;
}

/* Score pile */
.cjScoredCards {
    --cj-scored-card-width: clamp(10rem, 42vw, 17.5rem);
    align-items: center;
    display: flex;
    min-height: calc(var(--cj-scored-card-width) * 5 / 7);
    overflow-x: auto;
    padding: 1rem;
}

.cjScoredCard {
    aspect-ratio: 7 / 5;
    flex: 0 0 var(--cj-scored-card-width);
    position: relative;
    width: var(--cj-scored-card-width);
}

.cjScoredCard + .cjScoredCard {
    margin-left: clamp(-13.7rem, -32.9vw, -7.8rem);
}

.cjScoredCard > .cjCard {
    inset: 0;
    position: absolute;
}

.cjScoredCard:hover, .cjScoredCard:focus-visible {
    z-index: 1000 !important;
}

.cjScoredCardKnown .cjScoredCardBack {
    opacity: 1;
    transition: opacity .15s ease;
}

.cjScoredCardKnown:hover .cjScoredCardBack, .cjScoredCardKnown:focus-visible .cjScoredCardBack {
    opacity: 0;
}

.cjScoredCardKnown:focus-visible {
    outline: .2rem solid #d3a747;
    outline-offset: .15rem;
}

.cjNoScoredCards {
    margin: 1rem auto;
}

/* Draw pile */
.cjDeckPanel {
    box-sizing: border-box;
    container-type: size;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: .5em 0;
}

.cjDeck {
    width: max(0px, min(calc(100cqw - var(--cj-capture-width, 0px) - .25rem), 140cqh));
    max-width: 100%;
    flex: 0 1 auto;
}

.cjLastTurnCaptures {
    align-content: center;
    justify-content: center;
    display: grid;
    flex: 1 1 0;
    min-width: 0;
    margin-right: .25rem;
    height: 100%;
    overflow: hidden;
}

.cjLastTurnCaptures:empty {
    visibility: hidden;
}

.cjCapturedToken {
    display: block;
    position: relative;
    min-width: 0;
    min-height: 0;
}

.cjCapturedToken::before, .cjCapturedToken::after {
    background: #e02020;
    border-radius: 2px;
    content: "";
    height: max(2px, 6%);
    left: 10%;
    pointer-events: none;
    position: absolute;
    top: 50%;
    width: 80%;
    transform: translateY(-50%) rotate(45deg);
}

.cjCapturedToken::after {
    transform: translateY(-50%) rotate(-45deg);
}

.cjLastTurnPiece {
    box-sizing: border-box;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.cjDeckCount {
    align-items: center;
    background: #fff;
    border-radius: 50%;
    bottom: 2cqw;
    box-sizing: border-box;
    box-shadow: inset -.1em -.1em .3em 0 #666, 0 0 .2em .1em #1f1f1f;
    color: #000;
    display: flex;
    font-size: 7.5cqw;
    font-weight: 700;
    height: 2.75em;
    justify-content: center;
    position: absolute;
    right: 2cqw;
    width: 2.75em;
}

/* Portrait screens and landscape phones */
@media (orientation: portrait), (max-width: 43.75em), (orientation: landscape) and (max-height: 32em) and (max-width: 64em) {
    /* The framework applies its saved desktop minimum width inline. */
    #gamePage {
        min-width: 0 !important;
        scrollbar-width: none;
    }

    #gamePage::-webkit-scrollbar {
        display: none;
    }

    body.fw22.noPanel #gamePage {
        grid-template-columns: minmax(0, 1fr) 0 0;
    }

    body.fw22:not(.noPanel) #gamePage {
        grid-template-columns: 100% 0 100%;
        overflow-x: auto;
    }

    #panelHandle {
        display: none;
    }

    body.fw22:not(.noPanel) #panel {
        min-width: 0;
        overflow-x: auto;
    }

    #content {
        min-width: 0;
    }

    #header {
        height: auto;
        min-height: 38px;
        flex-wrap: wrap;
        row-gap: .2rem;
        padding-block: .2rem;
    }

    #headerButtons {
        max-width: 100%;
        margin-left: auto;
    }
}

/* Use the space left by the sidebar, rather than the window's orientation. */
@container cj-game-area (max-aspect-ratio: 3/2) or (max-width: 43.75em) or ((max-height: 32em) and (max-width: 64em)) {
    #game {
        box-sizing: border-box;
        display: grid;
        flex: 1 0 100%;
        align-items: stretch;
        gap: .4rem;
        padding: .4rem 0;
        overflow: visible;
    }

    #game #playerData > .playerData {
        box-sizing: border-box;
        border-width: 2px;
        order: 0;
    }

    .cjDeckPanel {
        display: none;
    }

    #board {
        order: 1;
        width: 100%;
        height: 100%;
        aspect-ratio: auto;
        align-self: stretch;
    }

    .chessJokerGame {
        display: block;
        padding: 0;
        height: 100%;
    }

    .cjTable {
        container-type: size;
        gap: 0;
        width: 100%;
        height: 100%;
    }

    .cjBoardWrap {
        --cj-mobile-board-size: min(100cqw, 100cqh);
        width: var(--cj-mobile-board-size);
        height: auto;
        aspect-ratio: 1;
    }

    .cjBoardWrap::before {
        inset: 0;
        border-radius: 0;
    }

    /* Reserve only occupied/playable side columns; vertical squares may overlap the UI. */
    .cjOuterLeft .cjBoardWrap, .cjOuterRight .cjBoardWrap {
        --cj-mobile-board-size: min(calc(100cqw * 8 / 9), 100cqh);
    }

    .cjOuterLeft .cjBoardWrap {
        margin-left: calc(var(--cj-mobile-board-size) / 8);
    }

    .cjOuterRight .cjBoardWrap {
        margin-right: calc(var(--cj-mobile-board-size) / 8);
    }

    .cjOuterLeft.cjOuterRight .cjBoardWrap {
        --cj-mobile-board-size: min(80cqw, 100cqh);
    }

    .cjRankLabels, .cjFileLabels {
        font-size: 2.5cqw;
        line-height: 1;
        pointer-events: none;
    }

    .cjRankLabels {
        left: 0;
        right: auto;
        width: 3.5cqh;
    }

    .cjFileLabels {
        top: auto;
        bottom: 0;
        height: 3.5cqh;
    }

    .cjRankLabels span {
        align-items: flex-start;
        justify-content: flex-start;
        padding: .6cqh;
    }

    .cjFileLabels span {
        align-items: flex-end;
        justify-content: flex-end;
        padding: .6cqh;
    }

    .cjRankLabels span:nth-child(odd), .cjFileLabels span:nth-child(even) {
        color: #27231f;
    }

    .cjRankLabels span:nth-child(even), .cjFileLabels span:nth-child(odd) {
        color: #fff;
    }

    #game .playerDataBasic {
        font-size: .875rem;
        grid-template-columns: 2.5rem minmax(0, 1fr) auto;
        align-items: center;
        gap: .1rem .4rem;
        padding: .35rem .5rem;
    }

    .cjAvatar {
        width: 2.5rem;
        height: 2.5rem;
        grid-row: 1 / 3;
        border-radius: .4rem;
    }

    .playerDataBasic .basicDesc {
        align-self: center;
        min-width: 0;
        flex-wrap: wrap;
        overflow-wrap: anywhere;
    }

    .playerDataBasic .cjScore {
        grid-column: 3;
        grid-row: 1 / 3;
        align-self: center;
        font-size: 1rem;
        min-height: 2.75rem;
    }

    .playerDataBasic .cjMaterial {
        grid-column: 2;
        grid-row: 2;
    }

    #game.cjCompactPlayers .cjAvatar {
        display: none;
    }

    #game.cjCompactPlayers .playerDataBasic {
        grid-template-columns: fit-content(40%) minmax(0, 1fr) auto;
        padding-block: .25rem;
    }

    .cjCompactPlayers .playerDataBasic .basicDesc {
        grid-column: 1;
    }

    .cjCompactPlayers .playerDataBasic .cjScore {
        grid-column: 3;
        grid-row: 1;
        min-height: 0;
    }

    .cjCompactPlayers .playerDataBasic .cjMaterial {
        grid-column: 2;
        grid-row: 1;
    }

    #game .playerDataDetail {
        padding: 0 .4rem .4rem;
    }

    .cjTextCard {
        --cj-card-font-size: .875rem;
        --cj-card-line-height: 1.35;
        --cj-card-metadata-height: calc(.75rem * 1.575);
        --cj-card-circle-size: calc(3 * var(--cj-card-font-size) * var(--cj-card-line-height) - var(--cj-card-metadata-height) - 2px);
        --cj-card-padding-y: .6rem;
        --cj-card-padding-x: .7rem;
        box-sizing: border-box;
        aspect-ratio: auto;
        min-height: calc(3 * var(--cj-card-font-size) * var(--cj-card-line-height) + 2 * var(--cj-card-padding-y));
        background: #181818;
        border-radius: .4rem;
        clip-path: none;
        container-type: normal;
    }

    :where(.cjTextCard) .cjCardImage {
        display: none;
    }

    :where(.cjTextCard) .cjCardText {
        position: static;
        display: block;
        width: auto;
        height: auto;
        padding: var(--cj-card-padding-y) var(--cj-card-padding-x);
        border-radius: 0;
        background: transparent;
        font-size: var(--cj-card-font-size);
        line-height: var(--cj-card-line-height);
    }

    .cjTextCard .cjCardToggleButton {
        width: var(--cj-card-circle-size);
        height: var(--cj-card-circle-size);
        font-size: calc(var(--cj-card-circle-size) * .7);
        border-width: 1.5px;
        right: var(--cj-card-padding-x);
        top: var(--cj-card-padding-y);
        transform: none;
    }

    :where(.cjTextCard) .cjCardTextMirrored {
        display: none;
    }

    :where(.cjTextCard) .cjCardTextMirrored.cjCardTextMimicked {
        display: block;
        border-top: 1px solid #49705a;
        border-radius: 0;
        margin: 0 .7rem;
        padding: .5rem 0 .6rem;
        transform: none;
    }

    :where(.cjTextCard) .cjCardTextContent {
        display: flow-root;
    }

    /* Reserve only the circle's height, letting later lines use the full width. */
    .cjTextCard > .cjCardText:not(.cjCardTextMirrored) .cjCardTextContent::before {
        content: "";
        float: right;
        width: calc(var(--cj-card-circle-size) + .7rem);
        height: calc(var(--cj-card-circle-size) + 2px);
    }

    :where(.cjTextCard) .cjCardMetadata {
        display: block;
        float: right;
        margin-left: .7rem;
        color: var(--cj-cream, #f3e8cf);
        font-size: .75rem;
        line-height: var(--cj-card-metadata-height);
        text-align: right;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    /* Reserve the final line's metadata width; its visible copy stays at the bottom. */
    :where(.cjTextCard) .cjCardMetadata::after {
        content: attr(data-label);
        visibility: hidden;
    }

    .cjTextCard:has(.cjCardHelp) .cjCardMetadata::after {
        padding-right: calc(1.5rem + .25em);
    }

    :where(.cjTextCard) .cjCardMetadata > span {
        position: absolute;
        right: var(--cj-card-padding-x);
        top: auto;
        bottom: var(--cj-card-padding-y);
    }

    .cjTextCard:has(.cjCardHelp) .cjCardMetadata > span {
        right: calc(var(--cj-card-padding-x) + 1.5rem + .25em);
    }

    .cjTextCard .cjCardHelp {
        font-size: 1.5rem;
        width: 1em;
        height: 1em;
        right: var(--cj-card-padding-x);
        bottom: calc(var(--cj-card-padding-y) + (var(--cj-card-metadata-height) - 1em) / 2);
    }

    .cjTextCard.cjCardEmpty {
        font-size: .875rem;
        padding: .6rem;
    }

}

/* Short, wide game areas keep the board beside compact player panels. */
@container cj-game-area (aspect-ratio > 3/2) and (max-height: 32em) and (max-width: 64em) {
    #game {
        --cj-layout: landscape;
        grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
        grid-template-rows: minmax(0, 1fr);
    }

    #board {
        grid-column: 1;
        grid-row: 1;
    }

    #playerData {
        display: flex;
        grid-column: 2;
        grid-row: 1;
        min-height: 0;
        margin: 0;
        gap: .4rem;
        overflow-y: auto;
        padding-right: .4rem;
    }

    #game #playerData > .playerData {
        width: 100%;
        margin-inline: 0;
    }

}

/* Phone controls; larger portrait screens keep the standard button labels. */
@media (max-width: 43.75em), (orientation: landscape) and (max-height: 32em) and (max-width: 64em) {
    /* Turn labels and replay controls change during a move. Keep one row and
       let text shrink so the header cannot resize the board. */
    #header {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
        grid-template-rows: 2.75rem;
        column-gap: .4rem;
    }

    #gameIcons { grid-column: 1; grid-row: 1; }
    #gameTitle { grid-column: 2; grid-row: 1; margin-left: 0; }

    #infoOnTurn {
        grid-column: 3;
        grid-row: 1;
        min-width: 0;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: right;
    }

    #headerButtons {
        grid-column: 4;
        grid-row: 1;
        justify-self: end;
        margin: 0;
        white-space: nowrap;
    }

    #animButtonsAnchor {
        width: auto;
        white-space: nowrap;
    }

    #btnClosePanel, #btnOpenPanel {
        margin-left: .25rem;
    }

    /* Transient live-animation controls must not add a second footer row. */
    #buttons {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        overflow-x: auto;
    }

    #buttons .btnGrp {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    #buttons #btnGrp_player { margin-left: auto; }
    #buttons #btns_end { display: none; }

    /* Keep button names available to screen readers while showing only icons. */
    #buttons button:has(.shaded-circle) > span:not(.shaded-circle) {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }

    #buttons button > .shaded-circle {
        margin-right: 0 !important;
    }
}
.cjCardTooltip {
    --bs-tooltip-max-width: min(34rem, calc(100vw - 1rem));
}

.cjCardTooltip .tooltip-inner {
    padding: .75rem 1rem;
    text-align: left;
}

.cjCardTooltip .cjCardHelpHeading {
    display: block;
    margin-bottom: .25rem;
    font-weight: bold;
}

.cjCardTooltip ul {
    margin: 0 0 .5rem;
    padding-left: 1.1rem;
}

.cjCardTooltip li + li {
    margin-top: .25rem;
}

.cjCardTooltip ul:last-child {
    margin-bottom: 0;
}
