:root {
    color-scheme: dark;
    --felt: #252526;
    --felt-deep: #1e1e1e;
    --surface: #252526;
    --surface-soft: #2d2d30;
    --ink: #f3f3f3;
    --muted: #c4c4c4;
    --line: #7f8792;
    --accent: #0f766e;
    --accent-hover: #0c6962;
    --accent-soft: rgb(15 118 110 / 18%);
    --focus: #48cfc2;
    --menu-start: #292a2c;
    --menu-end: #1e1e1e;
    --menu-glow: rgb(15 118 110 / 18%);
    --control-border: rgb(255 255 255 / 30%);
    --success: #61cba5;
    --warning: #d5b875;
    --danger: #e58c91;
    --success-light: #176447;
    --warning-light: #705019;
    --danger-light: #a1283b;
    --status-ink: #17212b;
    --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: #788896;
    --accent: #0f766e;
    --accent-hover: #0c6962;
    --accent-soft: rgb(15 118 110 / 12%);
    --focus: #0f766e;
    --menu-start: #f8fbfd;
    --menu-end: #e3edf4;
    --menu-glow: rgb(55 148 255 / 14%);
    --control-border: rgb(23 33 43 / 28%);
    --status-ink: #fff;
    --shadow: 0 12px 32px rgb(22 45 66 / 14%);
}

:root[data-theme="light"] {
    --success: var(--success-light);
    --warning: var(--warning-light);
    --danger: var(--danger-light);
}

:root,
[data-color-preview] {
    --on-accent: #fff;
    --surface-hover: color-mix(in srgb, var(--ink) 6%, var(--surface-soft));
    --success-fill: var(--success-light);
    --success-hover: color-mix(in srgb, var(--success-fill) 85%, #000);
    --success-soft: color-mix(in srgb, var(--success) 18%, var(--surface));
    --success-glow: color-mix(in srgb, var(--success) 22%, transparent);
    --warning-soft: color-mix(in srgb, var(--warning) 18%, var(--surface));
    --warning-glow: color-mix(in srgb, var(--warning) 22%, transparent);
    --danger-soft: color-mix(in srgb, var(--danger) 12%, var(--surface));
    --on-success: #fff;
}

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: 10px;
    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: var(--on-accent);
    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);
    min-height: 44px;
    padding: 10px 18px;
    font-size: 1rem;
}

#mainMenu .quick-play {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    width: min(100%, 430px);
    text-align: center;
}

.quick-play > strong {
    color: var(--muted);
    font-size: 0.85rem;
}

#mainMenu #quickPlayButton {
    width: 100%;
    margin: 0;
}

#mainMenu #quickPlayButton:disabled {
    background: var(--surface-soft);
    color: var(--muted);
    box-shadow: none;
    transform: none;
}

.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;
}

.splash-footer {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transform: translateX(-50%);
}

.splash-footer .app-version {
    position: static;
    transform: none;
}

.leaderboard-link {
    color: var(--muted);
    font-size: 0.8rem;
    opacity: 0.68;
    text-decoration: underline;
}

#mainMenu {
    overflow-y: auto;
    align-content: safe center;
    padding-bottom: 76px;
}

#mainMenu .public-lobby-list {
    display: grid;
    gap: 8px;
    width: min(100%, 430px);
    max-height: 30vh;
    overflow-y: auto;
}

#mainMenu .public-lobby-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

#mainMenu button.public-lobby-random {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    min-width: 0;
    min-height: 36px;
    margin: 0;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
    opacity: 0.65;
}

#mainMenu button.public-lobby-random:hover {
    background: var(--surface-hover);
    opacity: 1;
}

#mainMenu button.public-lobby-random[hidden] {
    display: none;
}

#mainMenu .public-lobby-random > img {
    width: 20px;
    height: 20px;
}

[data-theme="dark"] .public-lobby-random > img {
    filter: invert(1);
}

#mainMenu .public-lobby-empty {
    color: var(--muted);
    font-size: 0.9rem;
}

#mainMenu button.public-lobby-entry {
    width: 100%;
    margin: 0;
    padding: 10px 16px;
    border-color: var(--line);
    background: transparent;
    color: var(--ink);
    box-shadow: none;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
}

#mainMenu button.public-lobby-entry:hover,
#mainMenu button.public-lobby-entry:active {
    border-color: var(--muted);
    background: var(--surface-soft);
    box-shadow: none;
    transform: none;
}

#mainMenu .public-lobby-error {
    min-height: 1em;
    color: var(--danger);
    font-size: 0.85rem;
}

.lobby-choice {
    display: block;
    margin: 8px 0;
    cursor: pointer;
}

.lobby-choice input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.lobby-choice span {
    display: grid;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--control-border);
    border-radius: 10px;
    text-align: left;
    transition: background-color 160ms ease, border-color 160ms ease;
}

.lobby-choice small {
    color: var(--muted);
}

.lobby-choice input:checked + span {
    background: var(--success-fill);
    border-color: var(--success);
    color: var(--on-success);
}

.lobby-choice input:checked + span small {
    color: rgb(255 255 255 / 82%);
}

.lobby-choice input:focus-visible + span {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

#dialogNewGame .dialog-footer {
    float: none;
    justify-content: center;
}

#dialogNewGame .dialog-footer > button {
    flex: 0 1 160px;
}

#mainMenu button.public-lobby-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

@media (max-width: 600px) {
    #mainMenu button.public-lobby-entry {
        flex-wrap: wrap;
        gap: 4px 10px;
    }
}

.public-lobby-entry__status {
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0.85;
}

.public-lobby-entry.is-running .public-lobby-entry__status {
    color: var(--warning);
}

button:hover {
    background: var(--accent-hover);
}

button:active {
    padding: 1vmin;
}

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

#playButton:active:not(:disabled),
#passButton:active:not(:disabled),
#exchangeActions > button:active:not(:disabled) {
    scale: 0.96;
    filter: brightness(1.12);
    transition: none;
}

@media (prefers-reduced-motion: reduce) {
    #playButton:active:not(:disabled),
    #passButton:active:not(:disabled),
    #exchangeActions > button:active:not(:disabled) {
        scale: 1;
    }
}

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

#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 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(--surface-hover);
}

#playerActions > #playButton:enabled,
#playerActions > #playButton:enabled:hover {
    background: var(--success-fill);
    border-color: var(--success);
    color: var(--on-success);
}

#playerActions > button {
    min-width: clamp(112px, 26vw, 180px);
    max-width: 46%;
}

#playerActions > button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

#playerActions > #passButton.pass-needs-action,
#playerActions > #passButton.pass-needs-action:hover {
    border-color: var(--warning);
    background: var(--warning);
    color: var(--status-ink);
    box-shadow: 0 0 0 3px var(--warning-glow), 0 5px 16px var(--warning-glow);
}

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

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

#gameTable {
    position: relative;
    overflow: auto;
    border: 1px solid var(--line);
    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 {
    flex: 0 0 auto;
    font-size: 16px;
    line-height: 1;
    white-space: nowrap;
}

.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: var(--on-accent);
    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;
}

#tableTurnHint {
    --guidance-opacity: 0.72;
    position: absolute;
    right: 48px;
    bottom: 12px;
    left: 48px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
    opacity: var(--guidance-opacity);
    text-align: center;
    pointer-events: none;
}

#tableTurnHint[hidden],
#exchangeActions[hidden] {
    display: none;
}

.exchange--offer {
    position: relative;
}

.exchange-offer__actions {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.exchange-sneaky-toggle[aria-pressed="true"] {
    background: var(--success-fill);
    border-color: var(--success);
    color: var(--on-success);
}

.exchange-sneaky-toggle[aria-pressed="true"]:hover {
    background: var(--success-hover);
}

/* Unregulated consent tick box: its own compact row above Force exchange and No exchange (initiator only). */
.exchange-offer__actions > .exchange-sneaky-check,
.exchange-offer__actions > .exchange-sneaky-check:hover {
    display: inline-flex;
    flex: 0 0 100%;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    margin: 0;
    padding: 2px 8px;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    color: var(--ink);
    font-size: 0.9rem;
}
.exchange-sneaky-check::before {
    content: "";
    display: grid;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    place-items: center;
    border: 2px solid var(--control-border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--on-success);
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
}
.exchange-sneaky-check[aria-checked="true"]::before {
    content: "✓";
    border-color: var(--success);
    background: var(--success);
}

#exchangeActions {
    position: relative;
    z-index: 40;
    grid-column: 1 / -1;
    grid-row: 5 / 6;
    align-self: center;
    justify-self: center;
    display: flex;
    justify-content: center;
    gap: 8px;
    max-width: 95%;
    width: min(90%, 480px);
    pointer-events: none;
}

#exchangeActions > button {
    pointer-events: auto;
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    box-shadow: var(--shadow);
}

#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(--focus);
    background: var(--surface-soft);
}

.exchange-panel .exchange--waiting {
    border-color: var(--success);
    background: var(--success-soft);
    box-shadow: inset 4px 0 var(--success), 0 0 14px var(--success-glow);
}

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

.exchange-panel .exchange-player .exchange-player__emoji {
    font-size: 34px;
    line-height: 1;
}

.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;
    min-height: 174px;
    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: 84px;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    gap: 8px;
}

.exchange-preview > .exchange-selection__card {
    height: clamp(54px, 8vh, 76px);
    aspect-ratio: 2 / 3;
    width: auto;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
}

.exchange-selection__card > img,
.received-cards__card > img {
    display: block;
    width: 100%;
    height: 100%;
}

.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(--focus);
    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: pan-x;
    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: 100%;
    height: 100%;
    min-width: 0;
    max-width: none;
    border: 0;
    object-fit: fill;
    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;
}

@keyframes holo-shimmer {
    from { background-position: 0% 0%; }
    to { background-position: 200% 200%; }
}

[data-card-style="holo"] #playerHand .game-card::before,
.card-preview--holo::before {
    position: absolute;
    inset: 2px;
    z-index: 1;
    border-radius: 8px;
    background: linear-gradient(115deg, transparent 20%, rgb(255 90 170 / 32%) 32%, rgb(255 220 90 / 30%) 42%, rgb(90 255 170 / 30%) 52%, rgb(90 180 255 / 32%) 62%, rgb(190 90 255 / 30%) 72%, transparent 84%);
    background-size: 220% 220%;
    content: "";
    mix-blend-mode: color-dodge;
    opacity: 0.75;
    pointer-events: none;
    animation: holo-shimmer 4s linear infinite;
}

[data-card-style="gold"] #playerHand .game-card > img,
.card-preview--gold > img {
    box-shadow: 0 0 10px rgb(240 190 60 / 45%);
}

.setting-card-appearance {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(84px, auto);
    align-items: stretch;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    background: var(--surface-soft);
}

#cardAppearanceLocked {
    grid-column: 1 / -1;
    color: var(--muted);
}

.setting-card-appearance__controls {
    display: grid;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
    width: 100%;
    max-width: 210px;
}

.setting-card-appearance__button,
.setting-card-appearance__button:hover,
.setting-card-appearance__button:active,
.setting-card-appearance__button:focus {
    display: grid;
    align-content: center;
    gap: 2px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--control-border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    text-align: left;
    box-shadow: none;
    transform: none;
}

.setting-card-appearance__button strong {
    font-size: 0.84rem;
}

.setting-card-appearance__button small {
    overflow: hidden;
    color: var(--muted);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-appearance-preview {
    display: grid;
    place-items: center;
    min-width: 84px;
    padding: 4px;
}

.card-appearance-preview .card-preview {
    width: clamp(72px, 19vw, 92px);
    aspect-ratio: 2 / 3;
    overflow: visible;
    touch-action: none;
    cursor: grab;
    transform: perspective(600px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
    transition: transform 100ms ease-out;
}

.card-foil-option .card-preview {
    touch-action: none;
    cursor: grab;
    transform: perspective(600px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
    transition: transform 100ms ease-out;
}

.card-appearance-preview .card-preview > img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.secret-style-header {
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.card-style-list,
.color-theme-list {
    display: grid;
    grid-auto-rows: auto;
    gap: 10px;
}

[data-card-style="pixel"] #playerHand .game-card > img,
.card-preview--pixel > img {
    image-rendering: pixelated;
    border-radius: 0;
}

[data-card-style="neon"] #playerHand .game-card > img,
.card-preview--neon > img {
    box-shadow: 0 0 10px rgb(85 237 255 / 45%), 0 0 18px rgb(255 96 200 / 25%);
}

[data-card-style="parallax"] #playerHand .game-card::before,
.card-preview--parallax::before {
    position: absolute;
    inset: 2px;
    z-index: 1;
    border-radius: 8px;
    background: repeating-linear-gradient(135deg, transparent 0 18px, rgb(150 175 255 / 25%) 19px 20px, transparent 21px 38px);
    background-position: var(--pointer-x, 50%) var(--pointer-y, 50%);
    background-size: 200% 200%;
    content: "";
    pointer-events: none;
    mix-blend-mode: multiply;
}

.card-preview--parallax > img {
    transition: transform 180ms ease;
}

.card-style-option:hover .card-preview--parallax > img,
.card-style-option:focus-visible .card-preview--parallax > img {
    transform: perspective(300px) rotateY(-12deg) rotateX(5deg) scale(1.04);
}

.card-style-list .card-style-option,
.card-style-list .card-style-option:hover,
.card-style-list .card-style-option:active,
.card-style-list .card-style-option:focus,
.card-style-list .card-foil-option,
.card-style-list .card-foil-option:hover,
.card-style-list .card-foil-option:active,
.card-style-list .card-foil-option:focus,
.color-theme-list .color-theme-option,
.color-theme-list .color-theme-option:hover,
.color-theme-list .color-theme-option:active,
.color-theme-list .color-theme-option:focus {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
    transform: none;
}

.card-style-list .card-style-option__select[aria-pressed="true"],
.card-style-list .card-foil-option__select[aria-pressed="true"] {
    border-color: var(--success);
    background: var(--success-soft);
}

.card-style-list .card-foil-option.is-locked,
.card-style-list .card-style-option.is-locked {
    overflow: visible;
}

.card-foil-option.is-locked .card-foil-option__select,
.card-style-option.is-locked .card-style-option__select {
    filter: grayscale(1);
    opacity: 0.42;
    cursor: not-allowed;
}

.card-style-option.is-locked .card-style-option__select::after,
.card-foil-option.is-locked .card-foil-option__select::after {
    position: absolute;
    top: 50%;
    right: 4px;
    color: var(--danger);
    content: "×";
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    transform: translate(-50%, -55%);
}

.card-style-list .card-foil-option__select,
.card-style-list .card-style-option__select {
    position: relative;
    align-self: stretch;
    min-width: 100px;
    flex: 1;
    padding: 12px 24px 12px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
}

.card-style-option__unlock,
.card-foil-option__unlock {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: 50%;
    max-width: calc(100% - 12px);
    padding: 3px 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.68rem;
    text-align: center;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.card-foil-option__unlock[hidden],
.card-style-option__unlock[hidden] {
    display: none;
}

.unlock-progress {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 2px 12px;
    margin: 0;
    padding: 0 16px 10px;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.25;
}

#dialogCardFoil .color-theme-description {
    padding-inline: 16px;
}

.card-foil-option > strong,
.card-style-option__select > strong,
.card-style-option > strong {
    font-size: 0.8rem;
    white-space: nowrap;
}

.card-foil-option .card-preview,
.card-style-option .card-preview {
    width: clamp(30px, 10vw, 52px);
}

.card-style-list .card-foil-option .card-preview {
    width: clamp(64px, 18vw, 82px);
    flex: 0 0 auto;
}

.color-theme-list .color-theme-option[aria-pressed="true"] {
    border-color: var(--focus);
    background: var(--accent-soft);
}

.color-theme-preview {
    display: grid;
    flex: 0 0 auto;
    align-content: center;
    gap: 5px;
    width: 78px;
    height: 50px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        radial-gradient(ellipse at 50% 20%, var(--menu-glow), transparent 80%),
        var(--surface-soft);
}

.color-theme-preview > span {
    height: 10px;
    border-radius: 3px;
    background: var(--accent);
}

.color-theme-preview > span + span {
    background: linear-gradient(90deg,
        var(--success) 0 30%, transparent 30% 35%,
        var(--warning) 35% 65%, transparent 65% 70%,
        var(--danger) 70% 100%);
}

.color-theme-description {
    margin: 0;
    padding: 0 18px 12px;
    color: var(--muted);
    font-size: 0.85rem;
}

.card-style-list .card-style-option[hidden] {
    display: none;
}

.card-style-option[data-card-style="botanical"] { flex-wrap: wrap; }
.card-style-option .secret-style-header { flex-basis: 100%; text-align: left; }

.card-style-option__cards {
    display: flex;
    gap: 6px;
}

.card-preview {
    position: relative;
    display: block;
    width: 52px;
    overflow: hidden;
    border-radius: 8px;
}

.card-preview > img {
    display: block;
    width: 100%;
    height: auto;
}

@media (prefers-reduced-motion: reduce) {
    .card-preview--parallax > img {
        transition: none;
        transform: none !important;
    }

    [data-card-style="holo"] #playerHand .game-card::before,
    .card-preview--holo::before {
        animation: none;
    }
}

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

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

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

.game-card:hover:not(.is-selected) {
    background: transparent;
    box-shadow: none;
}

.game-card.is-selected {
    transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-19.8px) 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(-19.8px) 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(-19.8px) 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(.25,.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 {
    transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-19.8px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) rotate(var(--card-rotation, 0deg));
}

@media (hover: hover) and (pointer: fine) {
    .game-card:hover:not(.is-selected):not(.is-exchange-selected):not(.is-dragging) {
        transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-8px) 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 {
    filter: brightness(0.52) saturate(0.78);
}

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

.game-card.is-selected:focus-visible,
.game-card.is-exchange-selected:focus-visible {
    z-index: 1;
}

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

.game-card.is-selected:active {
    transform: perspective(900px) translateX(var(--card-offset, 0px)) translateY(-19.8px) 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));
}

.game-card.is-drag-source {
    opacity: 0;
    transition: none;
}

.card-drag-layer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    pointer-events: none;
}

.card-drag-layer > .game-card {
    position: absolute;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    opacity: 1;
    pointer-events: none;
    transform:
        perspective(900px)
        translate3d(var(--drag-offset-x, 0px), var(--drag-offset-y, 0px), 0)
        rotateX(var(--tilt-x, 0deg))
        rotateY(var(--tilt-y, 0deg))
        scale(var(--drag-scale, 1));
    transition: none;
}

.card-drag-layer > .game-card.is-returning {
    transition: transform 320ms cubic-bezier(.2,.8,.25,1);
    /* A card gliding back can be caught again for a retry. */
    pointer-events: auto;
    touch-action: none;
}

.card-drag-preview > img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    border: 0;
    object-fit: fill;
}

#gameTable.is-card-drop-target {
    outline: 2px solid var(--focus);
    outline-offset: -4px;
}

.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;
}

#mainMenu {
    position: relative;
}

.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;
    /* Closed dialogs hold over a hundred card previews; skip their style, layout, paint and animations. */
    content-visibility: hidden;
    transition: opacity 0.333s ease, visibility 0s linear 0.333s, content-visibility 0s linear 0.333s allow-discrete;
}

.dialog-container--visible {
    visibility: visible;
    content-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;
}

#playerUsePin {
    margin: 8px 0;
}

.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 {
    font-size: clamp(36px, 7vmin, 56px);
    line-height: 1;
}

.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: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.game-over__standing--self {
    border-color: var(--success);
    background: var(--success-soft);
    box-shadow: inset 4px 0 var(--success);
}

.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;
    min-width: 0;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

.game-over__rank > span {
    flex: 0 0 auto;
}

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

.game-over__standing-icon {
    flex: 0 0 auto;
    font-size: 1.1em;
    line-height: 1;
    white-space: nowrap;
}

.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: var(--on-accent);
    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;
}

.vote-choice {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.vote-choice small {
    font-size: 0.75rem;
}

.round-start-vote:not(.game-end-vote) .vote-choice > button {
    white-space: nowrap;
}

.player-summary__host {
    font-size: 0.7rem;
}

.player-summary__low-cards {
    animation: low-card-count-pulse 2.4s ease-in-out infinite;
}

@keyframes low-card-count-pulse {
    0%, 100% { color: var(--muted); }
    50% { color: var(--ink); }
}

@media (prefers-reduced-motion: reduce) {
    .player-summary__low-cards {
        animation: none;
    }
}

#gameMenu #readyButton[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--danger) 48%, var(--control-border));
    background: color-mix(in srgb, var(--danger) 16%, var(--surface-soft));
    color: var(--danger);
}

#gameMenu #readyButton[aria-pressed="true"]:hover {
    background: color-mix(in srgb, var(--danger) 23%, var(--surface-soft));
}

#gameShell.game-active.Lobby .lobby-primary-action:first-child {
    margin-bottom: 14px;
}

#addBotButton {
    -webkit-tap-highlight-color: transparent;
}

@media (hover: none) {
    #gameMenu #addBotButton:hover,
    #gameMenu #addBotButton:active {
        padding: 8px 12px;
        transform: none;
        background: var(--surface-soft);
        box-shadow: 0 3px 10px rgb(0 0 0 / 18%);
    }
}

.round-start-vote__choices button[aria-pressed="true"] {
    border-color: var(--success);
    background: var(--success-soft);
}

.game-end-vote__choices button[aria-pressed="true"] {
    border-color: var(--success);
    background: var(--success-soft);
}

.invite-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

#inviteChatButton { grid-column: 1 / -1; }

.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;
}

#dialogRules .dialog-window,
#dialogResults .dialog-window,
#dialogColorTheme .dialog-window,
#dialogSettings .dialog-window,
#dialogPlayGuide .dialog-window,
#dialogCardStyle .dialog-window,
#dialogCardFoil .dialog-window,
#dialogGameLog .dialog-window,
#dialogLeaderboard .dialog-window {
    display: flex;
    flex-direction: column;
    height: min(88dvh, 740px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

#dialogRules .dialog-title,
#dialogResults .dialog-title,
#dialogColorTheme .dialog-title,
#dialogSettings .dialog-title,
#dialogPlayGuide .dialog-title,
#dialogCardStyle .dialog-title,
#dialogCardFoil .dialog-title,
#dialogGameLog .dialog-title,
#dialogLeaderboard .dialog-title {
    flex: 0 0 auto;
    padding-bottom: 12px;
}

#dialogRules .rules-content,
#dialogResults .dialogBody,
#dialogColorTheme .dialogBody,
#dialogSettings .dialogBody,
#dialogPlayGuide .dialogBody,
#dialogCardStyle .dialogBody,
#dialogCardFoil .dialogBody,
#dialogGameLog .game-log,
#dialogLeaderboard .leaderboard-content {
    flex: 1 0 auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
    padding: 8px 16px 16px;
}

#dialogRules .dialog-footer,
#dialogResults .dialog-footer,
#dialogColorTheme .dialog-footer,
#dialogPlayGuide .dialog-footer,
#dialogGameLog .dialog-footer,
#dialogSettings .dialog-footer,
#dialogCardStyle .dialog-footer,
#dialogCardFoil .dialog-footer,
#dialogLeaderboard .dialog-footer {
    float: none;
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--surface);
    justify-content: center;
    border-top: 1px solid var(--line);
}

#dialogRules .dialog-footer > button,
#dialogResults .dialog-footer > button,
#dialogColorTheme .dialog-footer > button,
#dialogPlayGuide .dialog-footer > button,
#dialogGameLog .dialog-footer > button,
#dialogSettings .dialog-footer > button,
#dialogCardStyle .dialog-footer > button,
#dialogCardFoil .dialog-footer > button,
#dialogLeaderboard .dialog-footer > button {
    width: min(100%, 240px);
    flex: 0 1 auto;
}

#dialogLeaderboard .dialog-title {
    text-align: center;
}

#dialogLeaderboard .dialog-window {
    position: relative;
}

.leaderboard-table-scroll {
    max-width: 100%;
    overflow: visible;
}

#dialogLeaderboard .leaderboard-content {
    display: block;
    overflow: visible;
}

.leaderboard-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 7px 4px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.leaderboard-table th:first-child,
.leaderboard-table td:first-child {
    text-align: left;
}

.leaderboard-table td:first-child {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-table th button {
    min-width: 0;
    min-height: 40px;
    margin: 0;
    padding: 4px 2px;
    font: inherit;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    white-space: nowrap;
}

.leaderboard-player-name {
    display: block;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 6px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font: inherit;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-player-id {
    position: absolute;
    z-index: 1;
    transform: translateY(-50%);
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
    text-align: center;
    pointer-events: none;
}

.leaderboard-table th[aria-sort="descending"] button,
.leaderboard-table th[aria-sort="ascending"] button {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 5px;
}

@media (max-width: 480px) {
    #dialogLeaderboard .leaderboard-content {
        padding-right: 6px;
        padding-left: 6px;
    }

    .leaderboard-table {
        font-size: 0.75rem;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 6px 2px;
    }

    .leaderboard-table td:first-child {
        max-width: clamp(64px, 22vw, 112px);
    }

    .leaderboard-table th button {
        font-size: 0.6875rem;
        padding: 4px 0;
    }
}

.rules-content section + section { margin-top: 16px; }
.rules-content h3 { margin: 0 0 6px; color: var(--ink); font-size: 1rem; }
.rules-content ul { margin: 0; padding-left: 20px; }
.rules-content li + li { margin-top: 6px; }
.rules-content p { margin: 0; }
.rules-content p + p { margin-top: 8px; }
.rules-player-box {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}
.rules-player-options { margin-bottom: 10px; }
.round-start-vote__hint { color: var(--muted); font-size: 0.72rem; text-align: center; }
.rules-content strong { color: var(--ink); }

.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__trick,
.settings-category {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.game-log__trick::after,
.settings-category::after {
    height: 1px;
    flex: 1 1 auto;
    background: var(--surface-hover);
    content: "";
}

.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;
}

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

.table-card-pile,
.table-play {
    --pile-fan-step: min(max(30px, min(48px, calc(var(--table-card-width) * 0.38))),
        max(0px, calc((var(--board-width, 100vw) - var(--table-card-width) - var(--pile-depth, 0px) - var(--pile-edge-space)) / max(1, var(--pile-fan-count, 0)))));
    --pile-fan-width: calc(var(--pile-fan-count, 0) * var(--pile-fan-step));
    --landing-space-x: clamp(0px, calc((var(--board-width, 0px) - var(--table-card-width) - var(--pile-fan-width) - var(--pile-depth) - 64px) / 2), var(--landing-limit-x));
    --landing-space-y: clamp(0px, calc((var(--board-height, 0px) - var(--table-card-height) - var(--pile-depth) - 64px) / 2), var(--landing-limit-y));
}

.table-card-pile {
    --table-card-height: clamp(96px, 25vh, 190px);
    --table-card-width: calc(var(--table-card-height) * 2 / 3);
    --pile-edge-space: max(128px, calc(var(--table-card-height) * 0.75));
    --landing-limit-x: 220px;
    --landing-limit-y: 130px;
    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);
}

@media (max-width: 600px) {
    .table-card-pile {
        --pile-edge-space: max(112px, calc(var(--table-card-height) * 0.75));
        --landing-limit-x: 150px;
        --landing-limit-y: 170px;
    }
}

.table-pile-summary {
    position: absolute;
    z-index: 60;
    bottom: 4px;
    left: 50%;
    width: min(440px, calc(100% - 20px));
    height: 40px;
    padding: 10px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font-size: clamp(0.7rem, 2.5vw, 0.85rem);
    font-weight: 750;
    line-height: 1.3;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: none;
    transform: translateX(-50%);
    white-space: nowrap;
}

#gameTable:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible) > :is(.table-pile-summary, #tableTurnHint) {
    opacity: 0;
    animation: none;
}

#gameTable:not(:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible)) > :is(.table-pile-summary, #tableTurnHint) {
    animation: table-guidance-fade-in 240ms ease 1s both;
}

@keyframes table-guidance-fade-in {
    from { opacity: 0; }
    to { opacity: var(--guidance-opacity, 1); }
}

.table-play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(var(--table-card-width) + var(--pile-fan-width) + var(--pile-depth) + 10px);
    height: calc(var(--table-card-height) + var(--pile-depth) + 10px);
    transform: translate(-50%, -50%);
    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: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgb(0 0 0 / 26%);
    transform: rotate(var(--pile-rotation, 0deg));
    transform-origin: center;
    isolation: isolate;
}

.table-deck .table-play__card > img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: inherit;
    object-fit: fill;
}

.table-play__beat-outline {
    position: absolute;
    inset: 0;
    z-index: 5;
    border-radius: inherit;
    box-shadow: inset 0 0 0 2px var(--accent);
    opacity: 0;
    pointer-events: none;
}

#gameTable:has(> .table-pile-summary--required:not([hidden])):not(:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible)) .table-play__beat-outline {
    animation: required-pile-pulse 3s ease-in-out infinite;
    animation-delay: 6s;
}

@keyframes required-pile-pulse {
    0%, 33.333%, 100% { opacity: 0; }
    16.667% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
    #gameTable .table-play__beat-outline {
        animation: none !important;
    }
}

.table-card-pile__count {
    position: absolute;
    z-index: 60;
    top: 50%;
    left: calc(100% + 10px);
    max-width: none;
    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: nowrap;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
    box-shadow: 0 3px 10px rgb(0 0 0 / 22%);
    transform: translateY(-50%);
}

.club-three-glint {
    --club-glint: var(--success);
    animation: club-three-glint 850ms ease-out;
}

.club-three-glint--loss {
    --club-glint: var(--danger);
}

@keyframes club-three-glint {
    0%, 100% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
    30% { filter: brightness(1.35) drop-shadow(0 0 20px var(--club-glint)); }
}

@media (prefers-reduced-motion: reduce) {
    .club-three-glint {
        animation-duration: 600ms !important;
    }
}

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

.card-flight > img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: fill;
}

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

.card-discard-flight > img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: inherit;
    object-fit: fill;
}

.game-toast {
    position: absolute;
    z-index: 200;
    top: 50%;
    left: 50%;
    width: min(520px, calc(100vw - 24px));
    height: clamp(50px, 9dvh, 76px);
    box-sizing: border-box;
    align-content: center;
    padding: 4px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font-size: clamp(0.78rem, 2.5vw, 0.95rem);
    font-weight: 750;
    line-height: 1.2;
    text-align: center;
    white-space: pre-line;
    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;
}

#playerActions > .game-toast {
    max-height: calc(100% - 10px);
}

#gameToastRegion {
    --board-toast-height: 40px;
    position: absolute;
    z-index: 65;
    bottom: 4px;
    left: 50%;
    width: min(440px, calc(100% - 20px));
    height: calc(var(--board-toast-height) * 2 + 6px);
    overflow: hidden;
    pointer-events: none;
    transform: translateX(-50%);
    border-radius: 10px;
}

#gameToastRegion[data-max-visible="1"] {
    height: var(--board-toast-height);
}

#gameToastRegion[hidden] {
    display: none;
}

#gameToastRegion > .game-toast {
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--board-toast-height);
    max-height: none;
    margin: 0;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: clamp(0.7rem, 2.5vw, 0.85rem);
    transform: none;
    transform-origin: center bottom;
    transition: visibility 120ms ease;
    pointer-events: none;
    cursor: default;
}

#gameToastRegion > .game-toast--archived {
    bottom: calc(var(--board-toast-height) + 6px);
}

#gameToastRegion > #GameToast.is-visible {
    pointer-events: auto;
    cursor: pointer;
}

.exchange-flight-target {
    opacity: 0;
    pointer-events: none;
}

.game-toast::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 4px;
    background: var(--toast-progress-gradient, linear-gradient(90deg, var(--success-fill), var(--success), var(--warning)));
    content: "";
    transform: scaleX(1);
    transform-origin: left center;
}

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

body[data-message-timer-bar="off"] .game-toast::after {
    display: none;
    animation: none;
}

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

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

.game-toast.game-toast--leaving {
    position: fixed;
    z-index: 0;
    margin: 0;
    pointer-events: none;
    transform: none;
}

.game-toast--leaving::after {
    animation: none !important;
    transform: scaleX(0);
}

.game-toast.game-toast--leaving.is-leaving {
    opacity: 0;
    transform: none;
    transition:
        opacity var(--toast-leave-fade, 330ms) linear var(--toast-leave-fade-delay, 670ms),
        transform var(--toast-leave, 1000ms) ease-out;
}

.game-toast__player {
    display: inline-block;
    max-width: min(55vw, 260px);
    margin: 0 0.08em;
    padding: 0.04em 0.34em;
    border-radius: 0.4em;
    background: var(--player-color);
    color: #17191d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

.game-toast.game-toast--archived {
    position: fixed;
    z-index: 75;
    margin: 0;
    transform: none;
    pointer-events: none;
    animation: none;
}

.game-toast--archived::after {
    display: none;
}

#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(#inviteButton):not(#rulesButton):not(#gameLogButton):not(#leaveGameButton) {
    display: none !important;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #inviteButton,
#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #rulesButton,
#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #gameLogButton,
#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #leaveGameButton {
    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;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu,
#gameShell.game-active.GameFinished > #gameMenu {
    padding-inline: 56px;
}

#settingsButton,
#homeButton,
#gameLogButton,
#rulesButton {
    position: fixed;
    z-index: 32;
    top: calc(env(safe-area-inset-top) + 8px);
    left: calc(env(safe-area-inset-left) + 8px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
}

.topbar-actions {
    position: fixed;
    z-index: 32;
    top: calc(env(safe-area-inset-top) + 8px);
    right: calc(env(safe-area-inset-right) + 8px);
    display: flex;
    align-items: center;
    gap: 8px;
}

#gameShell .topbar-actions > button {
    position: static;
}
#homeButton[hidden], #gameLogButton[hidden], #rulesButton[hidden] { display: none; }
#homeButton svg, #gameLogButton svg, #rulesButton svg {
    display: block;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
}

#waitingPlayers {
    position: fixed;
    z-index: 32;
    top: calc(env(safe-area-inset-top) + 12px);
    left: calc(env(safe-area-inset-left) + 60px);
    max-width: calc(100vw - 230px - env(safe-area-inset-left) - env(safe-area-inset-right));
    color: var(--muted);
    font-size: 0.65rem;
    line-height: 1.3;
}

#splashPlayerName {
    color: var(--muted);
    font-size: 0.8rem;
    max-width: 90%;
    overflow-wrap: anywhere;
    white-space: normal;
    text-align: center;
}

.settings-list #changeNameButton { width: 100%; }

#spectatorJoinToast {
    pointer-events: none;
    cursor: default;
}

#spectatorJoinToast::after { display: none; }

.player-summary__name,
.game-over__name > span:first-child {
    display: block;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: none;
}

.player-summary__name[role="button"],
.game-over__name > span[role="button"] {
    cursor: pointer;
}

.expanded-player-name {
    position: fixed;
    z-index: 1000;
    max-width: min(280px, calc(100vw - 16px));
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--ink);
    box-shadow: var(--shadow);
    font-size: 1rem;
    white-space: normal;
    overflow-wrap: anywhere;
    pointer-events: none;
}

.turn-timer {
    position: absolute;
    z-index: 70;
    bottom: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
}

.turn-timer[hidden] {
    display: none;
}

.turn-timer > svg {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

.turn-countdown {
    color: var(--muted);
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
}

#gameTable .turn-timer > #extendTurnButton {
    min-width: 0;
    min-height: 24px;
    margin: 0 0 0 2px;
    padding: 2px 5px;
    border-color: color-mix(in srgb, var(--danger) 35%, var(--control-border));
    background: color-mix(in srgb, var(--danger) 12%, var(--surface-soft));
    color: var(--muted);
    box-shadow: none;
    font-size: 0.65rem;
    white-space: nowrap;
    animation: turn-extension-pulse 2.4s ease-in-out infinite;
}

@keyframes turn-extension-pulse {
    0%, 100% { opacity: 0.62; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    #gameTable .turn-timer > #extendTurnButton {
        animation: none;
    }
}

#reclaimSeatButton {
    position: relative;
    z-index: 40;
    grid-column: 1 / -1;
    grid-row: 5 / 6;
    align-self: center;
    justify-self: center;
    width: min(80%, 320px);
    min-height: 56px;
    margin: 0;
    padding: 14px 24px;
    font-size: 1.1rem;
    box-shadow: var(--shadow);
}

#playbackControls {
    position: absolute;
    top: 4px;
    right: 8px;
    width: 36px;
    height: 36px;
}

#fastForwardButton {
    position: absolute;
    right: 0;
    bottom: 0;
}

#fastForwardButton,
#autoSuggestionToggleButton,
#autoPassToggleButton {
    z-index: 70;
    display: grid;
    place-items: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    margin: 0;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    opacity: 0.65;
}

#fastForwardButton:hover,
#autoSuggestionToggleButton:hover,
#autoPassToggleButton:hover,
#fastForwardButton:active,
#autoSuggestionToggleButton:active,
#autoPassToggleButton:active {
    background: transparent;
    box-shadow: none;
    transform: none;
    filter: none;
    opacity: 1;
}

#fastForwardButton > svg {
    width: 20px;
    height: 20px;
}

#suggestionControls {
    position: absolute;
    top: 4px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

#autoSuggestionToggleButton,
#autoPassToggleButton {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: auto;
    font-size: 0.72rem;
    white-space: nowrap;
}

#autoSuggestionToggleButton > [aria-hidden],
#autoPassToggleButton > [aria-hidden] {
    width: 20px;
    height: 20px;
    font-size: 20px;
    line-height: 20px;
    text-align: center;
}

#autoSuggestionToggleButton[aria-pressed="false"] > .auto-suggestion-on,
#autoSuggestionToggleButton[aria-pressed="true"] > .auto-suggestion-off,
#autoPassToggleButton[aria-pressed="false"] > .auto-pass-on,
#autoPassToggleButton[aria-pressed="true"] > .auto-pass-off {
    display: none;
}

#autoSuggestionToggleButton[aria-pressed="true"] > .auto-suggestion-on,
#autoPassToggleButton[aria-pressed="true"] > .auto-pass-on {
    color: var(--success);
}

#fastForwardButton[hidden],
#fastForwardButton[aria-pressed="false"] > .normal-play-icon,
#fastForwardButton[aria-pressed="true"] > .fast-forward-icon {
    display: none;
}

#resumeGameButton[hidden],
#turnTimer[hidden],
#turnCountdown[hidden],
#extendTurnButton[hidden],
#reclaimSeatButton[hidden] {
    display: none;
}

.vote-choice {
    min-width: 0;
    flex: 1 1 120px;
    max-width: 100%;
}

.vote-choice .player-summary__name { width: 100%; text-align: center; }

.game-end-vote__choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    align-items: start;
}

.game-end-vote__choices .vote-choice > button {
    width: 100%;
    min-width: 0;
}

.received-cards-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgb(0 0 0 / 65%);
    pointer-events: auto;
}

.received-cards-overlay[hidden] { display: none; }

.received-cards__content {
    max-width: min(90vw, 500px);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    color: var(--ink);
    text-align: center;
    max-height: 90dvh;
    overflow-y: auto;
}

.received-cards__content > button { margin-top: 12px; }

.exchange-ready-hint {
    color: var(--muted);
    font-size: .8rem;
    text-align: center;
}

.received-cards__pile {
    display: flex;
    justify-content: center;
    padding: 16px 24px;
}

.received-cards__pile > .received-cards__card {
    width: clamp(72px, 20vw, 130px);
    aspect-ratio: 2 / 3;
    flex: 0 0 auto;
    margin-left: -22px;
    border-radius: 8px;
    box-shadow: 0 5px 18px rgb(0 0 0 / 35%);
    transform: rotate(var(--received-angle));
    animation: received-card-enter 300ms ease-out both;
    animation-delay: calc(var(--received-index) * 70ms);
}

.game-over__name > span:first-child { flex: 1 1 auto; }
.game-over__you { flex: 0 0 auto; }

@keyframes received-card-enter {
    from { opacity: 0; transform: translateY(40px) rotate(var(--received-angle)); }
    to { opacity: 1; transform: translateY(0) rotate(var(--received-angle)); }
}

@media (prefers-reduced-motion: reduce) {
    .received-cards__card { animation: none; }
    #gameTable:not(:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible)) > :is(.table-pile-summary, #tableTurnHint) {
        animation: none;
        opacity: var(--guidance-opacity, 1);
    }
}

#settingsButton:hover {
    background: var(--surface);
}

#settingsButton .settings-gear {
    width: 24px;
    height: 24px;
    transition: transform 300ms ease;
}

#settingsButton:hover .settings-gear {
    transform: rotate(60deg);
}

#gameShell.game-active > .game-menu-toggle {
    left: calc(env(safe-area-inset-left) + 60px);
}

.copyable-game-id {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.copy-toast {
    position: fixed;
    z-index: 1100;
    bottom: calc(env(safe-area-inset-bottom) + 24px);
    left: 50%;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.copy-toast.is-visible {
    opacity: 0.95;
    transform: translate(-50%, 0);
}

.settings-list {
    display: grid;
    gap: 8px;
}

.settings-category {
    margin: 12px 0 4px;
}

.settings-game-id {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
    letter-spacing: 0.08em;
}

.settings-game-id strong {
    color: var(--ink);
    font-size: 1.05rem;
    letter-spacing: 0.14em;
}

.setting-row__text strong {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.setting-row,
.setting-row:hover,
.setting-row:active,
.setting-row:focus {
    background: var(--surface-soft);
    color: var(--ink);
    box-shadow: none;
    transform: none;
}

.setting-row:active {
    padding: 12px 14px;
}

.setting-row {
    display: flex;
    width: 100%;
    max-width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--ink);
    text-align: left;
}

.setting-row__text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.setting-row__text small {
    color: var(--muted);
    font-weight: 500;
}

.setting-row__switch {
    position: relative;
    flex: 0 0 40px;
    width: 40px;
    height: 22px;
    border: 1px solid currentColor;
    border-radius: 999px;
    opacity: 0.6;
}

.setting-row__switch > span {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: currentColor;
    transition: transform 160ms ease, background-color 160ms ease;
}

.setting-row[aria-pressed="true"] .setting-row__switch {
    border-color: var(--success);
    opacity: 1;
}

.setting-row[aria-pressed="true"] .setting-row__switch > span {
    background: var(--success);
    transform: translateX(18px);
}

.setting-speed,
.setting-turn-speed,
.setting-play-input,
.setting-card-style-scope,
.setting-language {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    cursor: default;
}

.card-style-list > .setting-card-style-scope {
    grid-column: 1 / -1;
}

.speed-options,
.turn-speed-options,
.play-input-options,
.card-style-scope-options,
.quick-play-options,
.language-options {
    display: flex;
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.speed-option,
.speed-option:hover,
.speed-option:active,
.speed-option:focus,
.animation-speed-option,
.animation-speed-option:hover,
.animation-speed-option:active,
.animation-speed-option:focus,
.play-input-option,
.play-input-option:hover,
.play-input-option:active,
.play-input-option:focus,
.card-style-scope-option,
.card-style-scope-option:hover,
.card-style-scope-option:active,
.card-style-scope-option:focus,
#mainMenu .quick-play-option,
.language-option,
.language-option:hover,
.language-option:active,
.language-option:focus {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    padding: 8px 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
    transform: none;
    font-size: 0.9rem;
    opacity: 0.7;
}

.speed-option + .speed-option,
.animation-speed-option + .animation-speed-option,
.play-input-option + .play-input-option,
.card-style-scope-option + .card-style-scope-option,
.quick-play-option + .quick-play-option,
.language-option + .language-option {
    border-left: 1px solid var(--line);
}

.speed-option[aria-pressed="true"],
.speed-option[aria-pressed="true"]:hover,
.animation-speed-option[aria-pressed="true"],
.animation-speed-option[aria-pressed="true"]:hover,
.play-input-option[aria-pressed="true"],
.play-input-option[aria-pressed="true"]:hover,
.card-style-scope-option[aria-pressed="true"],
.card-style-scope-option[aria-pressed="true"]:hover,
#mainMenu .quick-play-option[aria-pressed="true"],
.language-option[aria-pressed="true"],
.language-option[aria-pressed="true"]:hover {
    background: var(--success-soft);
    box-shadow: inset 0 -3px 0 var(--success);
    opacity: 1;
    font-weight: 700;
}

@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) 132px calc(var(--shell-hand-card-height) + 98px);
    }

    #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 (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) calc(124px - var(--mobile-table-extra-space, 0px)) calc(var(--shell-hand-card-height) + 62px);
    }

    #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) calc(124px - var(--mobile-table-extra-space, 0px)) calc(var(--shell-hand-card-height) + 46px);
    }

    #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 (max-width: 760px) and (min-height: 501px) {
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #playerActions {
        padding-top: 76px;
    }
}

@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) calc(132px - var(--mobile-table-extra-space, 0px)) calc(var(--shell-hand-card-height) + 32px);
    }

    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #inviteButton,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #rulesButton,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #gameLogButton,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #leaveGameButton {
        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 > #playerStatus {
        grid-column: 1 / -1;
        grid-row: 2 / 3;
    }

    #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);
    /* The seats keep their height; the lobby scrolls when the rules panel grows. */
    grid-template-rows: 60px auto max(180px, min(42dvh, 360px)) auto auto auto;
    align-content: start;
    gap: 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    overflow-y: auto;
}

#gameShell.game-active.Lobby > #playerList {
    grid-column: 1 / -1;
    grid-row: 3 / 4;
    display: grid;
    width: min(calc(100% - 24px), 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: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: auto;
    animation: lobby-grid-enter 460ms 45ms cubic-bezier(.2,.8,.25,1) both;
}

#lobbyCapacity { display: none; }
#gameShell.game-active.Lobby > #lobbyCapacity:not([hidden]) {
    display: block;
    grid-column: 1 / -1;
    grid-row: 4 / 5;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}

#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,
#gameShell.game-active.Lobby > #playerList .lobby-empty-seat {
    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 .lobby-empty-seat {
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.8rem;
    opacity: 0.45;
}

#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 > #lobbyMainMenuButton,
#gameShell.game-active.GameFinished > #gameMenu > #changeNameButton,
#gameShell.game-active.GameFinished > #gameMenu > #joinAsPlayerButton,
#gameShell.game-active.GameFinished > #gameMenu > #leaveGameButton,
#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 {
    display: contents;
}

#gameShell.game-active.Lobby > #gameMenu > button {
    grid-column: 1 / -1;
    grid-row: 2 / 3;
    width: min(100%, 360px);
    margin: 0;
    justify-self: center;
    justify-content: center;
    text-align: center;
}

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

#gameShell.game-active.Lobby > #gameMenu > .lobby-primary-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    grid-column: 1 / -1;
    grid-row: 6 / 7;
    width: min(calc(100% - 24px), 360px);
    margin: 4px 0 0;
    justify-self: center;
}

#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 > #gameMenu #gameMetadata {
    display: flex !important;
    position: fixed;
    z-index: 31;
    top: calc(env(safe-area-inset-top) + 8px);
    left: 50%;
    transform: translateX(-50%);
    height: 44px;
    width: max-content;
    max-width: calc(100vw - 240px);
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

#gameShell.game-active.Lobby #gameMetadata > br,
#gameShell.game-active.Lobby #gameStatusText { display: none; }

/* Lobby: the game ID opens the invite; a small hint sits under it. */
.game-id-invite-hint { display: none; }
#gameShell.game-active.Lobby > #gameMenu #gameMetadata { flex-direction: column; gap: 3px; line-height: 1; }
#gameShell.game-active.Lobby #gameIdDisplay { font-size: 125%; text-underline-offset: 2px; }
#gameShell.game-active.Lobby .game-id-invite-hint {
    display: block;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
}

#gameShell.game-active.Lobby #startGameButton {
    background: var(--success-fill);
    border-color: var(--success);
    color: var(--on-success);
}

#gameShell.game-active.Lobby #startGameButton:hover {
    background: var(--success-hover);
}

#gameShell.game-active.Lobby #gameMenu #addBotButton.is-full,
#gameShell.game-active.Lobby #gameMenu #addBotButton.is-full:hover {
    border-color: var(--danger);
    background: var(--danger-light);
    color: #fff;
    box-shadow: none;
    opacity: 1;
    cursor: default;
    transform: none;
}

#gameShell.game-active.Lobby #startGameButton.is-waiting,
#gameShell.game-active.Lobby #startGameButton.is-waiting:hover {
    border-color: var(--control-border);
    background: var(--surface-soft);
    color: var(--ink);
    box-shadow: none;
    opacity: 1;
    cursor: default;
    transform: none;
}

#gameShell.game-active.Lobby #gameMenu.waiting-for-players #addBotButton {
    border-color: var(--success);
    background: var(--success-fill);
    color: var(--on-success);
    box-shadow: 0 0 0 3px var(--success-glow), 0 5px 16px var(--success-glow);
}

#gameShell.game-active.Lobby #gameMenu.waiting-for-players #addBotButton:hover {
    background: var(--success-hover);
}

@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.Lobby > #playerList .player-summary.player-summary--ready,
#gameShell.game-active #playerList .is-current-turn {
    border-color: var(--success);
    background: var(--success-soft);
    box-shadow: inset 4px 0 var(--success), 0 0 14px var(--success-glow);
}

#gameShell.game-active #playerList .player-summary--passed {
    border-color: var(--warning);
    background: var(--warning-soft);
    box-shadow: inset 4px 0 var(--warning), 0 0 14px var(--warning-glow);
}

#gameShell.game-active #playerList .player-summary__turn {
    background: var(--success-fill);
    color: var(--on-success);
}

.shuffle-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    background: rgb(0 0 0 / 45%);
}

.shuffle-stack {
    position: relative;
    width: clamp(70px, 16vmin, 110px);
    aspect-ratio: 5 / 7;
}

.shuffle-card {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background: var(--surface-soft);
    border: 3px solid var(--accent-hover);
    box-shadow: 0 3px 10px rgb(0 0 0 / 35%);
    animation: shuffle-card-riffle 0.775s ease-in-out infinite;
    animation-delay: calc(var(--shuffle-index) * 0.07s);
}

.shuffle-label {
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 750;
    box-shadow: 0 3px 12px rgb(0 0 0 / 35%);
}

@keyframes shuffle-card-riffle {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(calc(-1 * clamp(30px, 8vmin, 60px))) rotate(-8deg); }
    75% { transform: translateX(clamp(30px, 8vmin, 60px)) rotate(8deg); }
}

#gameShell.game-active #playerList .player-summary--pulse-turn,
#gameShell.game-active #playerList .player-summary--pulse-passed,
#gameShell.game-active #playerList .player-summary--starter-flash {
    position: relative;
}

/* Flash with an overlay so the block's own entry animation is never replayed. */
#gameShell.game-active #playerList .player-summary--pulse-turn::after,
#gameShell.game-active #playerList .player-summary--pulse-passed::after,
#gameShell.game-active #playerList .player-summary--starter-flash::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
}

#gameShell.game-active #playerList .player-summary--pulse-turn::after {
    background: var(--success);
    animation: attention-flash 0.9s ease-in-out 1;
}

#gameShell.game-active #playerList .player-summary--pulse-passed::after {
    background: var(--warning);
    animation: attention-flash 0.9s ease-in-out 1;
}

#gameShell.game-active #playerList .player-summary--pulse-turn {
    --attention-color: var(--success);
}

#gameShell.game-active #playerList .player-summary--pulse-passed {
    --attention-color: var(--warning);
}

#gameShell.game-active #playerList .player-summary--pulse-turn::after,
#gameShell.game-active #playerList .player-summary--pulse-passed::after {
    box-shadow: inset 0 0 0 2px var(--attention-color), 0 0 16px var(--attention-color);
}

@keyframes attention-flash {
    0%, 100% { opacity: 0; }
    45% { opacity: 0.32; }
}

#gameShell.game-active #playerList .player-summary--starter-flash::after {
    background: var(--success-glow);
    animation: soft-flash 0.63s ease-in-out 3;
}

@keyframes soft-flash {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .shuffle-card,
    #gameShell.game-active #playerList .player-summary--pulse-turn::after,
    #gameShell.game-active #playerList .player-summary--pulse-passed::after,
    #gameShell.game-active #playerList .player-summary--starter-flash::after {
        animation: none;
    }

    .shuffle-card:nth-child(odd) { transform: rotate(-5deg); }
    .shuffle-card:nth-child(even) { transform: rotate(5deg); }
}

#playerHand.is-dealing-wait .game-card {
    visibility: hidden;
}

#playerHand.is-dealing-in > .game-card {
    animation: hand-deal-in 520ms cubic-bezier(.2,.8,.25,1) backwards;
    animation-delay: calc(var(--deal-index, 0) * 45ms);
}

@keyframes hand-deal-in {
    from {
        opacity: 0;
        translate: -48px -34px;
        rotate: -8deg;
    }
    to {
        opacity: 1;
        translate: 0 0;
        rotate: 0deg;
    }
}

#gameShell.game-active #playerList .player-summary--passed .player-summary__turn {
    background: var(--warning);
    color: var(--status-ink);
}

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

#gameShell.game-active:not(.Lobby):not(.GameFinished) > #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: var(--warning);
    background: var(--warning-soft);
    color: var(--ink);
    box-shadow: inset 4px 0 var(--warning), 0 0 14px var(--warning-glow);
}

#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):not(.GameFinished) > #playerActions {
    padding-top: calc(80px - var(--mobile-table-extra-space, 0px));
}

@media (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
    #gameShell.game-active:not(.Lobby):not(.GameFinished) {
        --mobile-table-extra-space: calc(var(--mobile-pass-button-height, 44px) * 0.7);
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    #gameShell.game-active:not(.Lobby):not(.GameFinished) {
        --mobile-pass-button-height: 36px;
    }
}

#gameShell.GameFinished #suggestionControls {
    display: none;
}

#gameShell.game-active:not(.Lobby) > #playerActions > button {
    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;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
}

#playerStatus:empty { display: none; }

@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:hover:not(.is-selected):not(.is-exchange-selected):not(.is-dragging) {
        transform: translateX(var(--card-offset, 0px)) rotate(var(--card-rotation, 0deg));
    }

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

    .card-drag-layer > .game-card {
        transform: translate3d(var(--drag-offset-x, 0px), var(--drag-offset-y, 0px), 0);
        transition: 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;
}

#playerActions > #playButton {
    order: -1;
}

#playerActions > #playButton:not([hidden]) {
    display: inline-flex;
}

#playerActions > #playButton[hidden],
.setting-row[hidden] {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #playerActions > #playerStatus {
        flex: 0 0 100%;
    }
}

/* 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 {
        width: min(100%, 980px);
        margin: 0 auto;
        box-shadow: 0 0 0 1px rgb(255 255 255 / 6%), 0 0 60px rgb(0 0 0 / 35%);
    }

    #gameShell.game-active:not(.Lobby):not(.GameFinished) {
        --shell-hand-card-height: clamp(96px, 17dvh, 132px);
        grid-template-rows: 60px 56px minmax(0, 1fr) 132px calc(var(--shell-hand-card-height) + 98px);
    }

    #gameShell > #settingsButton {
        left: calc(max(0px, (100vw - 980px) / 2) + 8px);
    }

    #gameShell > .topbar-actions {
        right: calc(max(0px, (100vw - 980px) / 2) + 8px);
        display: grid;
        grid-template-columns: repeat(3, 44px);
    }

    #gameShell > .topbar-actions > button {
        grid-row: 1;
    }

    #gameLogButton {
        grid-column: 1;
    }

    #rulesButton {
        grid-column: 2;
    }

    #homeButton {
        grid-column: 3;
    }

    #gameShell > #waitingPlayers {
        left: calc(max(0px, (100vw - 980px) / 2) + 60px);
        max-width: 750px;
    }

    #gameToastRegion {
        --board-toast-height: 48px;
    }

    #gameShell #gameTable:has(#gameToastRegion) {
        --toast-stack-height: 102px;
    }

    #gameShell #gameTable:has(#gameToastRegion[data-max-visible="1"]) {
        --toast-stack-height: 48px;
    }

    #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 > #inviteButton,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #rulesButton,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #gameLogButton,
    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #gameMenu > #leaveGameButton {
        min-height: 34px;
        font-size: 0.8rem;
    }
}

@media (min-width: 900px) and (min-height: 560px) and (orientation: landscape) and (hover: hover) and (pointer: fine) {
    #gameShell.game-active:not(.Lobby):not(.GameFinished) {
        grid-template-rows: 60px clamp(76px, 10dvh, 100px) minmax(0, 1fr) 132px calc(var(--shell-hand-card-height) + 98px);
    }

    #gameShell.game-active:not(.Lobby):not(.GameFinished) > #playerList .player-summary {
        padding: 6px 8px;
        gap: 4px;
    }
}

#gameTable:has(#gameToastRegion) {
    --toast-stack-height: 86px;
}

#gameTable:has(#gameToastRegion[data-max-visible="1"]) {
    --toast-stack-height: 40px;
}

#gameTable:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible) > :is(#turnTimer, #tableTurnHint) {
    bottom: calc(var(--toast-stack-height) + 10px);
}

@media (orientation: landscape) and (max-height: 500px) {
    .table-pile-summary {
        height: 30px;
        padding: 5px 10px;
    }

    #gameTable:has(#gameToastRegion) #gameToastRegion {
        --board-toast-height: 30px;
    }

    /* Too low for two lines: run them together instead of clipping both. */
    #gameToastRegion > .game-toast {
        white-space: normal;
    }

    #gameTable:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible) > :is(#turnTimer, #tableTurnHint) {
        top: 4px;
        bottom: auto;
    }

    #gameTable:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible) > #tableTurnHint {
        left: 4px;
        right: 52%;
    }
}

/* Custom rules: lobby panel between the seats and the actions. */
#customRulesPanel { display: none; }
#gameShell.game-active.Lobby > #customRulesPanel:not([hidden]) {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 5 / 6;
    justify-self: center;
    width: min(calc(100% - 24px), 760px);
    gap: 8px;
    padding: 10px 12px 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
}
/* A quiet "Rules" label on the left; the host's Edit link on the right. */
.custom-rules-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 24px;
}
.custom-rules-panel__title {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}
#gameShell.game-active.Lobby > #customRulesPanel.is-empty {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
#gameShell #customRulesPanel.is-empty > button.custom-rules-edit { justify-self: center; }
/* Edit link: small, borderless, dotted underline like the game ID. */
#gameShell button.custom-rules-edit,
#gameShell button.custom-rules-edit:hover,
#gameShell button.custom-rules-edit:active {
    width: auto;
    min-width: 0;
    min-height: 24px;
    margin: 0;
    padding: 0 2px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    transform: none;
}
#gameShell button.custom-rules-edit:hover { color: var(--ink); }
.custom-rules-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}
#gameShell button.custom-rule-chip,
#gameShell button.custom-rule-chip:hover,
#gameShell button.custom-rule-chip:active {
    display: inline-flex;
    width: auto;
    min-width: 0;
    min-height: 32px;
    margin: 0;
    padding: 3px 12px;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
    border-radius: 12px;
    background: color-mix(in srgb, var(--accent) 14%, var(--surface-soft));
    box-shadow: none;
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 650;
    text-align: center;
    white-space: nowrap;
    transform: none;
}
#gameShell button.custom-rule-chip:hover { background: color-mix(in srgb, var(--accent) 26%, var(--surface-soft)); }
#gameShell button.custom-rule-chip[aria-expanded="true"] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}
.custom-rules-explain {
    padding: 10px 12px;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    background: var(--surface-soft);
    text-align: left;
}
.custom-rules-explain > strong { display: block; margin-bottom: 4px; }
.custom-rules-explain > p {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}
.custom-rules-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}

/* Public lobby list: "Custom rules · N" beside the host. */
.public-lobby-entry__name {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
}
.public-lobby-entry__rules {
    padding: 1px 8px;
    border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}
.public-lobby-entry__rules[hidden] { display: none; }
/* Rows grow when the name, badge and status wrap, instead of spilling over the border. */
#mainMenu .public-lobby-list { grid-auto-rows: max-content; }
#mainMenu button.public-lobby-entry { min-height: max-content; }

/* Host editor: long-dialog layout that shrinks to its content. */
#dialogCustomRules .dialog-window {
    display: flex;
    flex-direction: column;
    max-height: min(88dvh, 740px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
#dialogCustomRules .dialog-title { flex: 0 0 auto; padding-bottom: 12px; }
#dialogCustomRules .dialogBody {
    flex: 1 0 auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
    padding: 8px 16px 16px;
    align-content: start;
}
#dialogCustomRules .dialog-footer {
    float: none;
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 2;
    align-items: center;
    border-top: 1px solid var(--line);
    background: var(--surface);
}
#dialogCustomRules .dialog-footer > button { flex: 0 1 auto; white-space: nowrap; }
#dialogCustomRules .speed-option { flex: 1 1 0; min-width: 0; padding-inline: 4px; font-size: 0.85rem; white-space: nowrap; }
#dialogCustomRules .message-settings { display: grid; gap: 0; }
#dialogCustomRules .custom-rules-pick-group { gap: 6px; }
#dialogCustomRules .custom-rules-pick-group > .setting-row {
    border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
    background: color-mix(in srgb, var(--ink) 4%, transparent);
}
.custom-rules-pick-one {
    padding: 4px 12px 2px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 750;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.custom-rules-preset-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: 32px;
}
#dialogCustomRules button.custom-rules-save-preset,
#dialogCustomRules button.custom-rules-save-preset:hover,
#dialogCustomRules button.custom-rules-save-preset:active {
    width: auto;
    min-width: 0;
    min-height: 32px;
    margin: 0;
    padding: 4px 12px;
    border: 1px solid var(--control-border);
    border-radius: 9px;
    background: transparent;
    box-shadow: none;
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    transform: none;
}
#dialogCustomRules button.custom-rules-save-preset:hover:not(:disabled) { background: var(--surface-hover); }
#dialogCustomRules button.custom-rules-save-preset:disabled { opacity: 0.5; cursor: default; }
.custom-rules-preset-status {
    color: var(--muted);
    font-size: 0.8rem;
}
.custom-rules-editor__count {
    margin-right: auto;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

/* Join confirmation list. */
.custom-rules-list {
    display: grid;
    gap: 6px;
    margin: 8px 0;
    padding: 0;
    list-style: none;
}
.custom-rules-list > li {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    background: var(--surface-soft);
    text-align: left;
}
.custom-rules-list small { color: var(--muted); line-height: 1.4; }
#customRulesSection[hidden] { display: none; }

/* Lobby: content scrolling up blurs and fades away under the top bar instead of colliding with it. */
#gameShell.game-active.Lobby::before {
    content: "";
    position: fixed;
    z-index: 30;
    top: 0;
    left: 50%;
    width: min(100%, 980px);
    height: calc(env(safe-area-inset-top) + 72px);
    transform: translateX(-50%);
    background: linear-gradient(var(--felt) 40%, transparent);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    -webkit-mask-image: linear-gradient(#000 50%, transparent);
    mask-image: linear-gradient(#000 50%, transparent);
    pointer-events: none;
}
