:root {
    color-scheme: dark;
    --felt: #252526;
    --felt-deep: #1e1e1e;
    --surface: #252526;
    --surface-soft: #2d2d30;
    --ink: #f3f3f3;
    --muted: #c4c4c4;
    --line: #535357;
    --accent: #075a9e;
    --accent-hover: #0b6fb8;
    --accent-soft: rgb(55 148 255 / 20%);
    --focus: #4fc1ff;
    --menu-start: #292a2c;
    --menu-end: #1e1e1e;
    --menu-glow: rgb(55 148 255 / 18%);
    --control-border: rgb(255 255 255 / 30%);
    --danger: #ffb4ab;
    --shadow: 0 12px 32px rgb(0 0 0 / 35%);
}

:root[data-theme="light"] {
    color-scheme: light;
    --felt: #e6edf2;
    --felt-deep: #f3f6f8;
    --surface: #ffffff;
    --surface-soft: #edf2f6;
    --ink: #17212b;
    --muted: #465564;
    --line: #aebdca;
    --accent: #005a9e;
    --accent-hover: #004778;
    --accent-soft: rgb(0 90 158 / 12%);
    --focus: #005a9e;
    --menu-start: #f8fbfd;
    --menu-end: #e3edf4;
    --menu-glow: rgb(55 148 255 / 14%);
    --control-border: rgb(23 33 43 / 28%);
    --danger: #a5140d;
    --shadow: 0 12px 32px rgb(22 45 66 / 14%);
}

html,
body {
    background: var(--felt-deep);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: clamp(14px, 1rem + 0.15vw, 18px);
    line-height: 1.45;
}

#gameShell {
    background:
        radial-gradient(ellipse at 48% 42%, var(--menu-glow), transparent 62%),
        linear-gradient(145deg, var(--felt), var(--felt-deep));
}

#mainMenu {
    align-content: center;
    justify-items: center;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 14px;
    padding: clamp(18px, 5vw, 56px);
    background:
        radial-gradient(ellipse at 50% 35%, var(--menu-glow), transparent 62%),
        linear-gradient(140deg, var(--menu-start), var(--menu-end));
    color: var(--ink);
}

.game-logo {
    width: min(100%, 760px);
    grid-row: auto;
}

.game-logo img {
    width: min(92%, 620px);
    max-height: 28vh;
    filter: drop-shadow(0 12px 22px rgb(0 0 0 / 23%));
}

#mainMenu button,
button {
    max-width: 100%;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 650;
    text-shadow: none;
    box-shadow: 0 4px 12px rgb(0 0 0 / 18%);
    transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

#mainMenu button {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
    width: min(100%, 430px);
    padding: 12px 22px;
}

.app-version {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    left: 50%;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    opacity: 0.68;
    transform: translateX(-50%);
    white-space: nowrap;
}

.app-version a {
    color: inherit;
    text-decoration: underline;
}

button:hover {
    background: var(--accent-hover);
    box-shadow: 0 8px 18px rgb(0 0 0 / 22%);
    transform: translateY(-1px);
}

button:active {
    padding: 1vmin;
    transform: translateY(1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

@keyframes settle-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#mainMenu:not(.is-hidden) .game-logo {
    animation: splash-logo-enter 480ms cubic-bezier(.2,.8,.25,1) both;
}

#mainMenu:not(.is-hidden) > button {
    animation: splash-action-enter 380ms cubic-bezier(.2,.8,.25,1) both;
}

#mainMenu:not(.is-hidden) > #BnHNySpill {
    animation-delay: 80ms;
}

#mainMenu:not(.is-hidden) > #BnHKobleSpill {
    animation-delay: 140ms;
}

#playerList > .player-summary,
#playerList .opponent-list > .player-summary {
    animation: settle-in 280ms cubic-bezier(.2,.8,.25,1) both;
}

#playerList > .player-summary:nth-child(2) { animation-delay: 25ms; }
#playerList > .player-summary:nth-child(3) { animation-delay: 50ms; }
#playerList > .player-summary:nth-child(4) { animation-delay: 75ms; }
#playerList > .player-summary:nth-child(5) { animation-delay: 100ms; }
#playerList .opponent-list > .player-summary:nth-child(1) { animation-delay: 55ms; }
#playerList .opponent-list > .player-summary:nth-child(2) { animation-delay: 95ms; }
#playerList .opponent-list > .player-summary:nth-child(3) { animation-delay: 135ms; }
#playerList .opponent-list > .player-summary:nth-child(4) { animation-delay: 175ms; }

@keyframes splash-logo-enter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes splash-action-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes lobby-menu-enter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes lobby-grid-enter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes game-surface-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

#gameMenu,
#playerActions {
    z-index: 1;
    align-content: center;
    color: var(--ink);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

#playerActions {
    position: relative;
}

#gameMenu > button,
#gameMenu .lobby-primary-action > button,
#playerActions > button {
    float: none !important;
    width: auto;
    min-width: 44px;
    min-height: 44px;
    height: auto;
    padding: 8px 12px;
    border: 1px solid var(--control-border);
    background: var(--surface-soft);
    color: var(--ink);
    box-shadow: 0 3px 10px rgb(0 0 0 / 18%);
}

#playerActions > br {
    display: none;
}

#playerActions #playerStatus {
    flex-basis: 100%;
}

#gameMenu > button:hover,
#gameMenu .lobby-primary-action > button:hover,
#playerActions > button:hover {
    background: var(--line);
}

#playerActions > #passButton.pass-needs-action,
#playerActions > #passButton.pass-needs-action:hover {
    border-color: #e4b51a;
    background: #f4cf43;
    color: #342a08;
    box-shadow: 0 0 0 3px rgb(244 207 67 / 24%), 0 5px 16px rgb(244 207 67 / 35%);
}

#gameMenu > #gameMetadata {
    font-size: 0.82rem;
    text-align: center;
}

#gameTable,
#playerList,
#playerActions,
#playerHand {
    min-width: 0;
}

#gameTable {
    position: relative;
    overflow: auto;
    border: 1px solid rgb(255 255 255 / 12%);
    border-radius: 16px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}

#playerList {
    gap: 5px;
    overflow-y: auto;
    padding: 8px;
    color: var(--ink);
}

#playerList > div {
    flex: 0 0 auto;
    max-height: none;
    min-height: 42px;
    margin: 0;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    box-shadow: 0 2px 6px rgb(0 0 0 / 12%);
}

#playerList > div.is-my-turn {
    border-color: var(--focus);
    background: var(--accent-soft);
    box-shadow: inset 4px 0 var(--accent);
}

#playerList > div.is-finished {
    max-height: none;
    border-color: var(--line);
    background: var(--surface);
    color: var(--muted);
}

#playerList > div > button {
    min-height: 44px;
    padding: 8px 12px;
}

.player-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    font-size: 0.82rem;
    line-height: 1.2;
}

#playerList > div.player-summary.is-finished {
    border-color: var(--line);
    background: var(--surface);
}

.player-summary__name {
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-summary__details {
    display: inline-flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--muted);
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: center;
}

.player-summary__rank-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    object-fit: contain;
}

.player-summary__turn {
    display: inline-flex;
    min-height: 1.65em;
    align-items: center;
    justify-content: center;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
}

.player-summary__turn[aria-hidden="true"] {
    visibility: hidden;
}

.player-summary > button {
    min-height: 34px !important;
    padding: 5px 8px !important;
    font-size: 0.78rem;
}

#playerList > .player-summary,
#playerActions > span,
#gameTable .tips,
#gameTable .exchange-title,
#gameTable .trade-status {
    min-width: 0;
    overflow-wrap: anywhere;
}

#playerActions > span {
    max-width: 100%;
    line-height: 1.3;
}

#playerActions > #playerStatus.player-status--turn-hint {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
    opacity: 0.72;
    text-align: center;
}

#gameTable.exchange-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: clamp(8px, 1.5vw, 16px);
    overflow: auto;
}

.exchange-panel__heading {
    display: flex;
    min-width: 0;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 4px;
}

.exchange-panel__progress {
    color: var(--muted);
    font-size: 0.82rem;
    text-align: right;
}

.exchange-panel .exchange {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 4px 10px;
    margin: 0;
    padding: 8px 10px;
    border-color: var(--line);
    background: var(--surface);
    transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.exchange-panel .exchange--active {
    border-color: var(--accent);
    background: var(--surface-soft);
}

.exchange-panel .exchange--waiting {
    border-color: #35c46a;
    background: rgb(31 145 68 / 24%);
    box-shadow: inset 4px 0 #35c46a, 0 0 14px rgb(53 196 106 / 14%);
}

.exchange-panel .exchange-player {
    display: flex;
    align-items: center;
    justify-content: center;
}

.exchange-panel .exchange-player img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.exchange-panel .exchange--neutral .exchange-player {
    display: none;
}

.exchange-panel .exchange--neutral .exchange-title,
.exchange-panel .exchange--neutral .exchange-cards {
    grid-column: 1 / -1;
}

.exchange-panel .exchange-title {
    align-self: center;
    font-size: clamp(0.84rem, 2.2vw, 1rem);
    line-height: 1.3;
}

.exchange-panel .exchange-cards {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.exchange-panel .exchange-status {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 10px;
    color: var(--muted);
    font-size: 0.78rem;
}

.exchange-panel .exchange-cards button {
    min-height: 36px;
    padding: 6px 10px;
}

.exchange-selection {
    position: sticky;
    z-index: 2;
    bottom: 0;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 -6px 18px rgb(0 0 0 / 16%);
}

.exchange-selection__cards {
    display: flex;
    min-height: 42px;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.exchange-selection__card {
    height: clamp(54px, 8vh, 76px);
    width: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
    animation: exchange-card-arrive 220ms cubic-bezier(.2,.8,.25,1) both;
}

@keyframes exchange-card-arrive {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.exchange-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.exchange-received {
    position: static;
    margin-top: 0;
}

.game-card.is-received {
    box-shadow: 0 0 0 2px var(--accent, #f4cf43);
    border-radius: 8px;
}

.exchange-selection__empty {
    color: var(--muted);
    font-size: 0.84rem;
}

.exchange-selection__confirm {
    align-self: flex-end;
    min-height: 40px;
}

#playerHand > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

#playerHand {
    color: var(--ink);
}

#playerHand.card-hand {
    --hand-card-height: var(--shell-hand-card-height, clamp(88px, 21dvh, 156px));
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding: 22px 14px 6px;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

#playerHand.card-hand.is-hand-dragging,
.game-card.is-pressed {
    cursor: grabbing;
}

#playerHand.card-hand > .game-card:not(:last-child) {
    margin-right: calc(var(--hand-card-height) * -0.2667);
}

#playerHand.card-hand > .game-card {
    display: block;
    flex: 0 0 calc(var(--hand-card-height) * 2 / 3);
    width: calc(var(--hand-card-height) * 2 / 3);
    height: var(--hand-card-height);
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    box-shadow: none;
    text-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

#playerHand.card-hand > .game-card > img,
.cards-only-mode > #playerHand > .game-card > img {
    display: block;
    width: auto;
    height: clamp(88px, 21dvh, 156px);
    min-width: 0;
    max-width: none;
    object-fit: contain;
    border-radius: 8px;
    filter: drop-shadow(0 4px 8px rgb(0 0 0 / 24%));
}

#playerHand.card-hand.is-my-turn > .game-card > img {
    filter: none;
}

.game-card {
    position: relative;
    z-index: 1;
    overflow: hidden;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    isolation: isolate;
    transform-style: preserve-3d;
    transform: perspective(900px) translateX(var(--card-offset, 0px)) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
    transition: transform 180ms ease, filter 180ms ease, opacity 180ms ease;
}

.game-card img {
    border: 2px solid transparent;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.game-card::after {
    position: absolute;
    inset: 2px;
    border-radius: 8px;
    background: radial-gradient(circle at var(--pointer-x, 50%) var(--pointer-y, 50%), rgb(255 255 255 / 14%), transparent 42%);
    content: "";
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease;
    mix-blend-mode: normal;
}

.game-card.is-tilting::after {
    opacity: 1;
}

.game-card:disabled {
    cursor: default;
    opacity: 1;
    pointer-events: none;
}

#playerHand.card-hand:not(.is-my-turn) > .game-card > img {
    filter: grayscale(0.25) brightness(0.74);
}

.game-card.is-playable img {
    box-shadow: 0 4px 12px rgb(0 0 0 / 26%);
}

.game-card.is-mixable {
    z-index: 2;
    transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-5px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
}

.game-card:hover:not(.is-selected) {
    z-index: 2;
    background: transparent;
    box-shadow: none;
    transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-5px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
}

.game-card.is-selected {
    z-index: 3;
    transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-18px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
}

@keyframes hand-card-rise {
    from {
        transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(0) rotate(var(--card-rotation, 0deg));
    }
    to {
        transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-18px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
    }
}

.game-card.is-rising {
    animation: hand-card-rise 300ms cubic-bezier(.2,.8,.25,1) both;
}

@keyframes hand-card-lower {
    from {
        transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-18px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
    }
    to {
        transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(0) rotate(var(--card-rotation, 0deg));
    }
}

.game-card.is-lowering {
    animation: hand-card-lower 240ms cubic-bezier(.2,.8,.25,1) backwards;
}

.game-card.is-selected img,
.game-card.is-exchange-selected img {
    box-shadow: 0 10px 24px rgb(0 0 0 / 35%);
}

.game-card.is-exchange-selected {
    z-index: 3;
    transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-14px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
}

.game-card.is-unplayable {
    opacity: 1;
}

#playerHand.card-hand.is-my-turn > .game-card.is-unplayable > img {
    filter: brightness(0.52) saturate(0.78);
}

.game-card:focus-visible {
    z-index: 4;
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.game-card:active {
    padding: 0;
    background: transparent;
}

.game-card.is-selected:active {
    transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-18px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
}

.game-card.is-dragging {
    z-index: 5;
    transition: none;
    transform:
        perspective(900px)
        translateX(calc(var(--card-offset, 0px) + var(--drag-offset-x, 0px)))
        translateY(calc(var(--drag-base-y, 0px) + var(--drag-offset-y, 0px)))
        scale(var(--drag-scale, 1))
        rotateX(var(--tilt-x, 0deg))
        rotateY(var(--tilt-y, 0deg))
        rotate(var(--card-rotation, 0deg));
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--player-color);
    color: #17191d;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
}

#mainMenu {
    position: relative;
}

.theme-toggle--menu {
    position: absolute;
    z-index: 2;
    top: calc(env(safe-area-inset-top) + 8px);
    right: calc(env(safe-area-inset-right) + 8px);
    grid-column: auto !important;
    grid-row: auto !important;
    width: auto !important;
    min-width: 72px;
    min-height: 40px;
    padding: 4px 8px !important;
    border-radius: 999px;
    background: var(--surface-soft);
    font-size: 0.82rem;
}

#mainMenu > .theme-toggle--menu {
    min-height: 40px;
    font-size: 0.82rem;
}

.theme-toggle__switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
    flex: 0 0 34px;
    border: 1px solid currentColor;
    border-radius: 999px;
    opacity: 0.82;
}

.theme-toggle__switch > span {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: currentColor;
    transition: transform 160ms ease;
}

:root[data-theme="dark"] .theme-toggle__switch > span {
    transform: translateX(14px);
}

.game-menu-toggle {
    position: fixed;
    z-index: 31;
    top: calc(env(safe-area-inset-top) + 8px);
    left: calc(env(safe-area-inset-left) + 8px);
    display: none;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    place-items: center;
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
}

#gameShell.game-active > .game-menu-toggle {
    display: grid;
}

.game-menu-toggle__icon,
.game-menu-toggle__icon::before,
.game-menu-toggle__icon::after {
    position: absolute;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    content: "";
    transition: transform 160ms ease, background-color 160ms ease;
}

.game-menu-toggle__icon::before {
    transform: translateY(-6px);
}

.game-menu-toggle__icon::after {
    transform: translateY(6px);
}

#gameShell.GameMenuOpen .game-menu-toggle__icon {
    background: transparent;
}

#gameShell.GameMenuOpen .game-menu-toggle__icon::before {
    transform: rotate(45deg);
}

#gameShell.GameMenuOpen .game-menu-toggle__icon::after {
    transform: rotate(-45deg);
}

#gameMenu {
    position: fixed;
    z-index: 30;
    top: calc(env(safe-area-inset-top) + 60px);
    left: calc(env(safe-area-inset-left) + 8px);
    display: none;
    width: min(22rem, calc(100vw - 16px));
    max-height: calc(100dvh - env(safe-area-inset-top) - 72px);
    overflow-x: hidden;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: left;
    overscroll-behavior: contain;
}

#gameShell.game-active.GameMenuOpen > #gameMenu {
    display: flex;
}

#gameMenu > button {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
}

#gameMenu #gameMetadata {
    width: 100%;
    text-align: left;
}

.dialog-container {
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgb(0 0 0 / 70%);
    backdrop-filter: blur(5px);
    visibility: hidden;
    transition: opacity 0.333s ease, visibility 0s linear 0.333s;
}

.dialog-container--visible {
    visibility: visible;
    transition-delay: 0s;
}

.dialog-window {
    position: relative;
    inset: auto;
    width: min(100%, 560px);
    min-width: 0;
    max-height: min(90dvh, 760px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 24px 72px rgb(0 0 0 / 34%);
    transform: translateY(18px);
}

.dialog-container--visible .dialog-window {
    transform: translateY(0);
}

.dialog-title {
    padding-top: 18px;
    color: var(--ink);
    font-size: 1.2rem;
    font-weight: 750;
}

.dialogBody {
    color: var(--muted);
    line-height: 1.55;
}

.dialogBody input,
.dialogBody select {
    width: 100%;
    min-height: 48px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
}

#joinGameError,
#playerNameError {
    color: var(--danger) !important;
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.dialog-footer > button {
    flex: 1 1 auto;
    width: auto;
    min-width: 44px;
    max-width: 100%;
    height: auto;
    min-height: 48px;
    padding: 8px 12px;
}

.dialog-footer > button[aria-label] {
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 10px;
}

.dialog-footer > button[aria-label] > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tips {
    padding: 12px;
    border-color: var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.game-over {
    display: flex;
    width: min(100%, 620px);
    max-height: 100%;
    flex-direction: column;
    gap: 10px;
    margin: auto;
    overflow-y: auto;
    text-align: left;
}

.game-over h2 {
    margin: 0;
    font-size: clamp(1.05rem, 3.5vmin, 1.45rem);
    text-align: left;
}

.game-over .round-start-vote {
    text-align: center;
}

.player-placement-result-icon {
    width: clamp(40px, 8vmin, 64px);
    height: clamp(40px, 8vmin, 64px);
    object-fit: contain;
}

.game-over__standings {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.game-over__standing {
    display: grid;
    grid-template-columns: clamp(7.5rem, 40%, 11rem) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.game-over__standing--self {
    border-color: #35c46a;
    background: rgb(31 145 68 / 20%);
    box-shadow: inset 4px 0 #35c46a;
}

.game-over__standing--enter {
    animation: game-over-row-enter 320ms cubic-bezier(.2,.8,.25,1) both;
}

@keyframes game-over-row-enter {
    from {
        opacity: 0;
        transform: translateX(-28px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.game-over__rank {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
    text-align: left;
    overflow-wrap: anywhere;
}

.game-over__rank-number {
    color: var(--muted);
    font-weight: 800;
}

.game-over__standing-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    object-fit: contain;
}

.game-over__name {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-weight: 750;
    text-align: left;
    overflow-wrap: anywhere;
}

.game-over__you {
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 750;
    line-height: 1.2;
}

.round-start-vote {
    display: flex;
    width: min(100%, 520px);
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 0 auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.round-start-vote__summary,
.round-start-vote__hint {
    color: var(--muted);
    font-size: 0.88rem;
    text-align: center;
}

.round-start-vote__choices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.round-start-vote__choices button[aria-pressed="true"] {
    border-color: #35c46a;
    background: rgb(31 145 68 / 30%);
}

.game-end-vote__choices button[aria-pressed="true"] {
    border-color: #35c46a;
    background: rgb(31 145 68 / 30%);
}

.invite-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.invite-actions button,
#inviteSmsButton {
    flex: 1 1 140px;
    min-height: 44px;
    padding: 9px 14px;
}

.invite-status {
    min-height: 1.5em;
    margin-top: 8px;
    color: var(--ink);
    font-weight: 650;
}

.dialog-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dialog-title-row .dialog-title {
    flex: 1 1 auto;
}

.dialog-close {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 7px 10px;
}

.game-log-dialog {
    display: flex;
    min-height: min(54dvh, 440px);
    flex-direction: column;
}

.game-log {
    display: flex;
    flex: 1 1 auto;
    min-height: 240px;
    max-height: min(60dvh, 500px);
    flex-direction: column;
    gap: 8px;
    padding: 14px 2px 2px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.game-log__entry {
    flex: 0 0 auto;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--ink);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.game-log__entry--enter {
    animation: game-log-entry-enter 260ms cubic-bezier(.2,.8,.25,1) both;
}

.game-log__empty {
    margin: auto;
    color: var(--muted);
    text-align: center;
}

@keyframes game-log-entry-enter {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .game-log__entry--enter {
        animation-duration: 1ms;
    }
}

.tips button {
    min-height: 44px;
    padding: 9px 14px;
}

.rules-credit {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}

#dialogRegler .dialog-footer {
    justify-content: center;
}

#dialogRegler .dialog-footer > button {
    width: min(100%, 240px);
    flex: 0 1 auto;
}

#gameTable.table-deck {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 36px 8px 44px;
}

.table-card-pile {
    --table-card-height: clamp(96px, 25vh, 190px);
    --table-card-width: calc(var(--table-card-height) * 2 / 3);
    position: relative;
    flex: 0 0 auto;
    width: calc(var(--table-card-width) + var(--pile-fan-width) + var(--pile-depth) + 10px);
    height: calc(var(--table-card-height) + var(--pile-depth) + 10px);
}

.table-pile-summary {
    position: absolute;
    z-index: 60;
    top: 50%;
    right: 8px;
    max-width: min(160px, 32%);
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 750;
    line-height: 1.3;
    text-align: left;
    overflow-wrap: anywhere;
    box-shadow: 0 3px 10px rgb(0 0 0 / 22%);
    transform: translateY(-50%);
    white-space: pre-line;
}

.table-play {
    position: absolute;
    inset: 0;
    z-index: var(--play-index);
}

.table-deck .table-play__card {
    position: absolute;
    top: var(--card-stack-offset, 0);
    left: var(--card-fan-offset, 0);
    z-index: var(--stack-index);
    display: block;
    width: var(--table-card-width);
    height: var(--table-card-height);
    max-width: none;
    border: 1px solid rgb(0 0 0 / 35%);
    border-radius: 8px;
    object-fit: fill;
    box-shadow: 0 3px 10px rgb(0 0 0 / 26%);
    transform: rotate(var(--pile-rotation, 0deg));
    transform-origin: center;
}

.table-card-pile__count {
    position: absolute;
    z-index: 60;
    top: 50%;
    left: calc(100% + 10px);
    max-width: min(180px, calc(50vw - 80px));
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 750;
    white-space: normal;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
    box-shadow: 0 3px 10px rgb(0 0 0 / 22%);
    transform: translateY(-50%);
}

.card-flight {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    border-radius: 8px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgb(0 0 0 / 28%));
}

.card-discard-flight {
    position: fixed;
    z-index: 150;
    pointer-events: none;
    border: 1px solid rgb(0 0 0 / 35%);
    border-radius: 8px;
    object-fit: fill;
    box-shadow: 0 3px 10px rgb(0 0 0 / 26%);
}

.game-toast {
    position: absolute;
    z-index: 200;
    top: 50%;
    left: 50%;
    width: min(420px, calc(100vw - 24px));
    padding: 12px 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    font-weight: 750;
    line-height: 1.3;
    text-align: center;
    overflow-wrap: anywhere;
    overflow: hidden;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, calc(-50% - 12px));
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
    pointer-events: auto;
    cursor: pointer;
    touch-action: manipulation;
}

.game-toast::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 4px;
    background: var(--toast-progress-gradient, linear-gradient(90deg, #17803d, #39a95f, #f4cf43));
    content: "";
    transform: scaleX(1);
    transform-origin: left center;
}

.game-toast.is-visible::after {
    animation: game-toast-progress var(--toast-duration, 3000ms) linear forwards;
}

@keyframes game-toast-progress {
    to {
        transform: scaleX(0);
    }
}

.game-toast.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
}

.game-toast__player {
    display: inline-block;
    max-width: 100%;
    margin: 0 0.08em;
    padding: 0.04em 0.34em;
    border-radius: 0.4em;
    background: var(--player-color);
    color: #17191d;
    white-space: nowrap;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > .game-menu-toggle {
    display: none;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu {
    position: relative;
    z-index: 2;
    top: auto;
    left: auto;
    grid-column: 1 / -1;
    grid-row: 1 / 2;
    display: flex;
    width: 100%;
    max-height: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 3px 8px;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    animation: game-surface-enter 360ms cubic-bezier(.2,.8,.25,1) both;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #playerList {
    animation: game-surface-enter 380ms 35ms cubic-bezier(.2,.8,.25,1) both;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameTable {
    animation: game-surface-enter 420ms 45ms cubic-bezier(.2,.8,.25,1) both;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #playerActions {
    animation: game-surface-enter 360ms 75ms cubic-bezier(.2,.8,.25,1) both;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #playerHand {
    animation: game-surface-enter 420ms 95ms cubic-bezier(.2,.8,.25,1) both;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > :not(#BnFInviterSpill):not(#autoSuggestionToggleButton):not(#BnFRegler):not(#BnFSpillogg):not(#BnPGiOpp) {
    display: none !important;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFInviterSpill,
#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #autoSuggestionToggleButton,
#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFRegler,
#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFSpillogg,
#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnPGiOpp {
    display: inline-flex;
    min-width: 0;
    min-height: 38px;
    margin: 0;
    padding: 6px clamp(7px, 1.6vw, 14px);
    flex: 0 1 auto;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    text-align: center;
    white-space: nowrap;
}

@media (min-width: 761px) and (orientation: landscape) {
    #gameShell.game-active {
        grid-template-columns: minmax(0, 1fr);
        --shell-hand-card-height: clamp(88px, 21dvh, 156px);
        grid-template-rows: 60px 64px minmax(0, 1fr) 64px calc(var(--shell-hand-card-height) + 34px);
    }

    #gameShell.game-active > #playerList {
        grid-column: 1 / -1;
        grid-row: 2 / 3;
        padding: 5px 8px;
    }

    #gameShell.game-active > #gameTable {
        grid-column: 1 / -1;
        grid-row: 3 / 4;
    }

    #gameShell.game-active > #playerActions {
        grid-column: 1 / -1;
        grid-row: 4 / 5;
    }

    #gameShell.game-active > #playerHand {
        grid-column: 1 / -1;
        grid-row: 5 / 6;
    }
}

@media (max-width: 760px) and (orientation: portrait) {
    #gameShell.game-active #playerHand.card-hand > .game-card > img,
    #gameShell.game-active.cards-only-mode > #playerHand > .game-card > img {
        height: var(--hand-card-height);
    }

    #gameShell.game-active {
        grid-template-columns: minmax(0, 1fr);
        --shell-hand-card-height: clamp(82px, 17dvh, 128px);
        grid-template-rows: 56px 60px minmax(0, 1fr) 60px calc(var(--shell-hand-card-height) + 34px);
    }

    #gameShell.game-active > #playerList {
        grid-column: 1 / -1;
        grid-row: 2 / 3;
        padding: 4px 6px;
    }

    #gameShell.game-active > #gameTable {
        grid-column: 1 / -1;
        grid-row: 3 / 4;
    }

    #gameShell.game-active > #playerActions {
        grid-column: 1 / -1;
        grid-row: 4 / 5;
    }

    #gameShell.game-active > #playerHand {
        grid-column: 1 / -1;
        grid-row: 5 / 6;
    }
}

@media (max-width: 760px) and (orientation: landscape) {
    #gameShell.game-active #playerHand.card-hand > .game-card > img,
    #gameShell.game-active.cards-only-mode > #playerHand > .game-card > img {
        height: var(--hand-card-height);
    }

    #gameShell.game-active {
        grid-template-columns: minmax(0, 1fr);
        --shell-hand-card-height: clamp(72px, 23dvh, 116px);
        grid-template-rows: 56px 52px minmax(0, 1fr) 52px calc(var(--shell-hand-card-height) + 34px);
    }

    #gameShell.game-active > #playerList {
        grid-column: 1 / -1;
        grid-row: 2 / 3;
        padding: 3px 6px;
    }

    #gameShell.game-active > #gameTable {
        grid-column: 1 / -1;
        grid-row: 3 / 4;
    }

    #gameShell.game-active > #playerActions {
        grid-column: 1 / -1;
        grid-row: 4 / 5;
    }

    #gameShell.game-active > #playerHand {
        grid-column: 1 / -1;
        grid-row: 5 / 6;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    #gameShell.game-active {
        --shell-hand-card-height: clamp(54px, 18vh, 76px);
        grid-template-rows: 40px 36px minmax(58px, 1fr) 44px calc(var(--shell-hand-card-height) + 24px);
    }

    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFInviterSpill,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFRegler,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFSpillogg,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnPGiOpp {
        min-height: 32px;
        padding-top: 4px;
        padding-bottom: 4px;
    }

    #gameTable.table-deck {
        padding: 4px;
    }

    .table-card-pile {
        --table-card-height: clamp(40px, 15vh, 64px);
        width: calc(var(--table-card-width) + var(--pile-fan-width) + var(--pile-depth) + 10px);
        height: calc(var(--table-card-height) + var(--pile-depth) + 10px);
    }

    #gameShell.game-active #playerHand.card-hand > .game-card > img,
    #gameShell.game-active.cards-only-mode > #playerHand > .game-card > img {
        height: var(--hand-card-height);
    }

    #gameShell.game-active > #playerActions {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        gap: 2px;
        padding: 2px;
    }

    #gameShell.game-active > #playerActions > #passButton,
    #gameShell.game-active > #playerActions > #passButton_Off {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        min-height: 36px;
        padding: 4px 8px;
    }

    #gameShell.game-active > #playerActions > #exchangePrompt {
        grid-column: 1 / -1;
        grid-row: 2 / 3;
    }

    #gameShell.game-active > #playerActions > #playerStatus {
        display: none;
    }

    #gameShell.game-active > #playerActions > br {
        display: none;
    }

    #gameShell.game-active > #playerList {
        gap: 2px;
        padding: 2px 4px;
    }

    #gameShell.game-active > #playerList > .player-summary--self {
        min-height: 30px;
        padding: 2px 6px;
    }

    #gameShell.game-active #playerList .opponent-list {
        gap: 2px;
    }

    #gameShell.game-active #playerList .opponent-list > .player-summary {
        min-height: 28px;
        padding: 2px 4px;
        font-size: 0.66rem;
        line-height: 1.1;
    }

    #gameShell.game-active #playerList .opponent-list .player-summary__details {
        font-size: 0.62rem;
    }

    #gameShell.game-active #playerList .opponent-list .player-summary__turn {
        padding: 2px 5px;
        font-size: 0.6rem;
    }
}

@media (max-width: 420px) {
    .table-card-pile {
        --table-card-height: clamp(92px, 23vh, 148px);
    }

}

#gameShell.game-active.Lobby {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(80px, 30dvh);
}

#gameShell.game-active.Lobby > #playerList {
    grid-column: 1 / -1;
    grid-row: 2 / 3;
    display: grid;
    width: min(100%, 760px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-rows: minmax(0, 1fr);
    align-content: stretch;
    justify-self: center;
    gap: 8px;
    padding: 8px;
    overflow: auto;
    animation: lobby-grid-enter 460ms 45ms cubic-bezier(.2,.8,.25,1) both;
}

#gameShell.game-active.Lobby > #playerList[data-player-count="1"] {
    grid-template-columns: minmax(0, 360px);
    grid-template-rows: minmax(0, 1fr);
    justify-content: center;
}

#gameShell.game-active.Lobby > #playerList[data-player-count="2"] {
    grid-template-rows: minmax(0, 1fr);
}

#gameShell.game-active.Lobby > #playerList > .opponent-list {
    display: contents;
}

#gameShell.game-active.Lobby > #playerList .opponent-seat-0,
#gameShell.game-active.Lobby > #playerList .opponent-seat-1,
#gameShell.game-active.Lobby > #playerList .opponent-seat-2,
#gameShell.game-active.Lobby > #playerList .opponent-seat-3,
#gameShell.game-active.Lobby > #playerList .opponent-seat-4 {
    grid-column: auto;
    grid-row: auto;
}

#gameShell.game-active.Lobby > #playerList .player-summary.lobby-grid-last-player {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 360px);
}

#gameShell.game-active.Lobby > #playerList .player-summary {
    display: flex;
    min-width: 0;
    min-height: 0;
    width: auto;
    height: 100%;
    margin: 0;
    padding: 6px;
    flex: initial;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    grid-column: auto;
    grid-row: auto;
    overflow: hidden;
}

#gameShell.game-active.Lobby > #playerList[data-player-count="1"] .player-summary {
    justify-self: center;
    width: min(100%, 360px);
}

#gameShell.game-active.Lobby > #playerList .player-summary__name {
    max-width: 100%;
    padding: 2px 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--player-color, #cfd4dc);
    color: #17191d;
    font-weight: 800;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#gameShell.game-active.Lobby > #gameTable,
#gameShell.game-active.Lobby > #playerActions,
#gameShell.game-active.Lobby > #playerHand {
    display: none;
}

#gameShell.game-active.GameFinished {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(40px, 60px) minmax(0, 1fr) auto;
}

#gameShell.game-active.GameFinished > #playerList,
#gameShell.game-active.GameFinished > #playerHand {
    display: none;
}

#gameShell.game-active.GameFinished > #gameTable {
    grid-column: 1 / -1;
    grid-row: 2 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 32px);
}

#gameShell.game-active.GameFinished > #playerActions {
    grid-column: 1 / -1;
    grid-row: 3 / 4;
}

/* Finished round: same top button bar as during play instead of the dropdown menu. */
#gameShell.game-active.GameFinished > .game-menu-toggle {
    display: none;
}

#gameShell.game-active.GameFinished > #gameMenu {
    position: relative;
    z-index: 2;
    top: auto;
    left: auto;
    grid-column: 1 / -1;
    grid-row: 1 / 2;
    display: flex;
    width: 100%;
    max-height: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 3px 8px;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    animation: game-surface-enter 360ms cubic-bezier(.2,.8,.25,1) both;
}

#gameShell.game-active.GameFinished > #gameMenu > #gameMetadata,
#gameShell.game-active.GameFinished > #gameMenu > #BnFKobleSpill,
#gameShell.game-active.GameFinished > #gameMenu > #BnPByttNavn,
#gameShell.game-active.GameFinished > #gameMenu > #BnPNySpiller,
#gameShell.game-active.GameFinished > #gameMenu > #BnPGiOpp,
#gameShell.game-active.GameFinished > #gameMenu .lobby-wait-hint {
    display: none !important;
}

#gameShell.game-active.GameFinished > #gameMenu > .lobby-primary-actions,
#gameShell.game-active.GameFinished > #gameMenu .lobby-primary-action {
    display: contents;
}

#gameShell.game-active.GameFinished > #gameMenu button {
    width: auto;
    min-width: 0;
    min-height: 38px;
    margin: 0;
    padding: 6px clamp(7px, 1.6vw, 14px);
    flex: 0 1 auto;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    text-align: center;
    white-space: nowrap;
}

#gameShell.game-active.Lobby > .game-menu-toggle {
    display: none;
}

#gameShell.game-active.Lobby > #gameMenu {
    position: relative;
    z-index: 1;
    top: auto;
    left: auto;
    grid-column: 1 / -1;
    grid-row: 1 / 2;
    display: flex;
    width: 100%;
    max-height: 100%;
    align-items: center;
    justify-content: flex-start;
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 16px;
    gap: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    text-align: center;
    animation: lobby-menu-enter 420ms cubic-bezier(.2,.8,.25,1) both;
}

#gameShell.game-active.Lobby > #gameMenu > button {
    order: 1;
    width: min(100%, 360px);
    margin: 0;
    justify-content: center;
    text-align: center;
}

#gameShell.game-active.Lobby > #gameMenu > #BnFHovedmeny {
    display: none;
}

#gameShell.game-active.Lobby > #gameMenu > .lobby-primary-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    order: 2;
    width: min(100%, 360px);
    flex: 0 0 auto;
    margin: 36px auto 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

#gameShell.game-active.Lobby .lobby-primary-action {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
}

#gameShell.game-active.Lobby .lobby-primary-action > button {
    width: 100%;
    min-width: 0;
    margin: 0;
    justify-content: center;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
}

#gameShell.game-active.Lobby .lobby-wait-hint {
    align-self: center;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.2;
}

#gameShell.game-active.Lobby .lobby-wait-hint[hidden] {
    display: none;
}

#gameShell.game-active.Lobby > #gameMenu #gameMetadata {
    order: -1;
    width: min(100%, 360px);
    flex: 0 0 auto;
    margin: 0 auto 12px;
    font-size: clamp(1rem, 3vmin, 1.35rem);
    font-weight: 700;
    overflow-wrap: anywhere;
    text-align: center;
}

#gameShell.game-active.Lobby #startGameButton {
    background: #17803d;
    border-color: #39a95f;
    color: #fff;
}

#gameShell.game-active.Lobby #startGameButton:hover {
    background: #1c9948;
}

#gameShell.game-active.Lobby #gameMenu.waiting-for-players #BnFNyAutoSpiller {
    border-color: #39a95f;
    background: #17803d;
    color: #fff;
    box-shadow: 0 0 0 3px rgb(23 128 61 / 24%), 0 5px 16px rgb(23 128 61 / 35%);
}

#gameShell.game-active.Lobby #gameMenu.waiting-for-players #BnFNyAutoSpiller:hover {
    background: #1c9948;
}

@media (max-width: 360px) {
    #gameShell.game-active.Lobby > #gameMenu > .lobby-primary-actions {
        grid-template-columns: minmax(0, 1fr);
        width: min(100%, 360px);
    }
}

#gameShell.game-active #playerList {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    overflow-x: hidden;
    overflow-y: auto;
}

#gameShell.game-active #playerList > .player-summary--self {
    display: flex;
    flex-wrap: wrap;
    flex: 0 0 auto;
    width: min(100%, 360px);
    align-self: center;
    justify-content: center;
    text-align: center;
}

#gameShell.game-active #playerList > .player-summary--self .player-summary__details {
    text-align: center;
}

#gameShell.game-active #playerList .opponent-list {
    display: grid;
    width: min(100%, 560px);
    flex: 0 0 auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    gap: 5px;
    margin: 0 auto;
}

#gameShell.game-active #playerList .opponent-list:empty {
    display: none;
}

#gameShell.game-active #playerList .opponent-list > .player-summary {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 36px;
    margin: 0;
    padding: 4px;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.72rem;
    text-align: center;
}

#gameShell.game-active #playerList .opponent-list .player-summary__name {
    width: fit-content;
    max-width: 100%;
    text-align: center;
}

#gameShell.game-active #playerList .opponent-list .player-summary__details {
    width: 100%;
    text-align: center;
}

#gameShell.game-active #playerList .opponent-list .player-summary__turn {
    align-self: center;
}

#gameShell.game-active #playerList .opponent-seat-0 { grid-column: 2; grid-row: 1; }
#gameShell.game-active #playerList .opponent-seat-1 { grid-column: 1; grid-row: 1; }
#gameShell.game-active #playerList .opponent-seat-2 { grid-column: 1; grid-row: 2; }
#gameShell.game-active #playerList .opponent-seat-3 { grid-column: 2; grid-row: 2; }
#gameShell.game-active #playerList .opponent-seat-4 { grid-column: 1; grid-row: 3; }

#gameShell.game-active #playerList .is-current-turn {
    border-color: #35c46a;
    background: rgb(31 145 68 / 30%);
    box-shadow: inset 4px 0 #35c46a, 0 0 14px rgb(53 196 106 / 22%);
}

#gameShell.game-active #playerList .player-summary--passed {
    border-color: #c5ad61;
    background: rgb(197 173 97 / 22%);
    box-shadow: inset 4px 0 #c5ad61, 0 0 14px rgb(197 173 97 / 14%);
}

#gameShell.game-active #playerList .player-summary__turn {
    background: #17803d;
}

#gameShell.game-active #playerList .player-summary--passed .player-summary__turn {
    background: #d8c783;
    color: #342a08;
}

#gameShell.game-active #playerList .player-summary--self .player-summary__name {
    text-align: center;
}

#gameShell.game-active:not(.Lobby) > #playerList {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    gap: 4px;
    overflow: hidden;
}

#gameShell.game-active:not(.Lobby) > #playerList .opponent-list,
#gameShell.game-active:not(.Lobby) > #playerList .opponent-list:empty {
    display: contents;
}

#gameShell.game-active:not(.Lobby) > #playerList .player-summary,
#gameShell.game-active:not(.Lobby) > #playerList .opponent-list > .player-summary {
    width: auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    margin: 0;
    padding: 2px 3px;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 1px;
    overflow: hidden;
    font-size: 0.68rem;
    line-height: 1.1;
    grid-column: auto;
    grid-row: auto;
}

#gameShell.game-active:not(.Lobby) > #playerList .player-summary__name {
    max-width: 100%;
    padding: 1px 6px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--player-color, #cfd4dc);
    color: #17191d;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#gameShell.game-active:not(.Lobby) > #playerList .player-summary__details {
    max-width: 100%;
    overflow: hidden;
    font-size: 0.6rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#gameShell.game-active:not(.Lobby) > #playerList .player-summary.player-summary--passed {
    border-color: #c5ad61;
    background: rgb(197 173 97 / 22%);
    color: var(--ink);
    box-shadow: inset 4px 0 #c5ad61, 0 0 14px rgb(197 173 97 / 14%);
}

#gameShell.game-active:not(.Lobby) > #playerActions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    overflow: hidden;
}

#gameShell.game-active:not(.Lobby) > #playerActions > button,
#gameShell.game-active:not(.Lobby) > #playerActions > #exchangePrompt {
    flex: 0 1 auto;
    text-align: center;
}

#gameShell.game-active:not(.Lobby) > #playerActions > br {
    display: none;
}

#gameShell.game-active:not(.Lobby) > #playerActions > #playerStatus {
    min-width: 0;
    flex: 0 1 auto;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (orientation: landscape) and (max-height: 600px) {
    #gameShell.game-active.Lobby > #gameMenu {
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }

    .game-card,
    .game-card:hover,
    .game-card.is-mixable,
    .game-card.is-selected,
    .game-card.is-exchange-selected,
    .game-card:active {
        transform: translateX(var(--card-offset, 0px)) rotate(var(--card-rotation, 0deg));
    }

    .game-card::after {
        display: none;
    }
}

/* Finished player: the status message fills the whole hand area. */
#playerHand.card-hand.hand-finished {
    align-items: center;
    justify-content: center;
    gap: 12px;
    overflow: hidden;
    padding: 8px 14px;
    text-align: center;
    cursor: default;
}

#playerHand.card-hand.hand-finished > span {
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
    font-size: 1.15rem;
}

#playerHand.card-hand.hand-finished > img {
    flex: 0 0 auto;
    width: auto;
    height: clamp(36px, 40%, 72px);
}

/* Keep the hand centered while it fits; it scrolls from the left edge once it overflows. */
#playerHand.card-hand {
    justify-content: safe center;
}

/* Desktop: a compact, centered play area instead of a stretched full-window layout. */
@media (min-width: 900px) and (min-height: 560px) and (orientation: landscape) and (pointer: fine) {
    body {
        font-size: 15px;
    }

    #gameShell.game-active:not(.Lobby):not(.GameFinished) {
        width: min(100%, 980px);
        margin: 0 auto;
        --shell-hand-card-height: clamp(96px, 17dvh, 132px);
        grid-template-rows: 44px 56px minmax(0, 1fr) 48px calc(var(--shell-hand-card-height) + 34px);
        box-shadow: 0 0 0 1px rgb(255 255 255 / 6%), 0 0 60px rgb(0 0 0 / 35%);
    }

    #gameShell.game-active #playerHand.card-hand > .game-card > img,
    #gameShell.game-active.cards-only-mode > #playerHand > .game-card > img {
        height: var(--shell-hand-card-height);
    }

    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFInviterSpill,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #autoSuggestionToggleButton,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFRegler,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnFSpillogg,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #BnPGiOpp {
        min-height: 34px;
        font-size: 0.8rem;
    }
}
