#mainMenu {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: max(clamp(18px, 5vw, 56px), calc((100svh - 590px) / 2));
    padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
}
/* Nothing shrinks, so a taller menu scrolls instead of moving the logo and name. */
#mainMenu > * {
    flex: none;
}
#mainMenu > .splash-footer {
    position: static;
    margin-top: auto;
    padding-top: 16px;
    transform: none;
}
#mainMenu .game-logo {
    position: relative;
    padding-bottom: 2.4rem;
}
#mainMenu #splashPlayerName {
    position: absolute;
    top: calc(100% - 2.4rem);
    left: 5%;
    width: 90%;
}
#mainMenu[data-splash-pending],
#gameShell:has(> #mainMenu[data-splash-pending]) > :is(#settingsButton, .topbar-actions) {
    visibility: hidden;
}
#mainMenu[data-splash-pending] *,
#gameShell:has(> #mainMenu[data-splash-pending]) > :is(#settingsButton, .topbar-actions) {
    animation-play-state: paused !important;
}
.game-logo__neon {
    position: relative;
    width: min(92%, var(--neon-width, 620px), calc(28vh * var(--neon-scale, 4.4286)));
    margin: 0 auto;
    aspect-ratio: var(--neon-ratio, 620 / 140);
}
.neon-logo,
.neon-logo > svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.neon-logo text { font-kerning: normal; }

/* On light backgrounds, thicker tubes, a dimmer white core and a firmer shadow keep the sign legible. */
:root[data-theme="light"] .neon-logo__tubes * { stroke-width: 2.1; }
:root[data-theme="light"] .neon-logo__core { opacity: .45; }
:root[data-theme="light"] .neon-logo__shadow * { stroke-width: 3.6; }

@keyframes neon-logo-pulse { 0%, 100% { opacity: .78; } 50% { opacity: 1; } }
@keyframes neon-logo-flicker {
    0%, 86%, 89%, 92%, 100% { opacity: 1; }
    87%, 88% { opacity: .35; }
    90.5% { opacity: .6; }
}
/* An occasional full-sign double flash, as on a real neon sign. */
@keyframes neon-logo-flash {
    0%, 90%, 92%, 95%, 100% { opacity: 1; }
    91% { opacity: .45; }
    93.5% { opacity: .7; }
}
@keyframes neon-intro-back-card {
    0% { opacity: .12; }
    5%, 16% { opacity: .74; }
    9%, 22% { opacity: .59; }
    25%, 47% { opacity: .88; }
    42%, 63% { opacity: .7; }
    68%, 82%, 100% { opacity: 1; }
    78% { opacity: .825; }
}
@keyframes neon-intro-front-card {
    0% { opacity: .08; }
    11%, 26% { opacity: .79; }
    18%, 32% { opacity: .59; }
    38%, 64% { opacity: .925; }
    58% { opacity: .71; }
    69%, 90%, 100% { opacity: 1; }
    87% { opacity: .85; }
}
@keyframes neon-intro-main {
    0% { opacity: .15; }
    8% { opacity: .8; }
    17% { opacity: .71; }
    30% { opacity: .89; }
    46% { opacity: .79; }
    59% { opacity: .95; }
    74% { opacity: .875; }
    86%, 100% { opacity: 1; }
}
@keyframes neon-intro-sub {
    0% { opacity: .13; }
    11% { opacity: .78; }
    20% { opacity: .72; }
    33% { opacity: .88; }
    49% { opacity: .8; }
    62% { opacity: .94; }
    77% { opacity: .885; }
    89%, 100% { opacity: 1; }
}
@keyframes splash-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes splash-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: no-preference) {
    .neon-logo { animation: neon-logo-flash 11s steps(1, end) 4s infinite; }
    .neon-logo__glow,
    .neon-logo__halo { animation: neon-logo-pulse 3.2s ease-in-out infinite; }
    .neon-logo__flicker { animation: neon-logo-flicker 7s steps(1, end) infinite; }

    /* First visit: the UI fades in together while the sign keeps flickering. */
    #mainMenu.is-intro .neon-logo {
        animation: neon-logo-flash 11s steps(1, end) -505ms infinite;
    }
    #mainMenu.is-intro :is(.neon-logo__glow, .neon-logo__halo) {
        animation: neon-logo-pulse 3.2s ease-in-out 2500ms infinite backwards;
    }
    #mainMenu.is-intro .neon-logo__flicker {
        animation: neon-logo-flicker 7s steps(1, end) -545ms infinite;
    }
    #mainMenu.is-intro svg:not(.neon-logo__shadow) .neon-logo__back-card {
        animation: neon-intro-back-card 2500ms steps(1, end);
    }
    #mainMenu.is-intro svg:not(.neon-logo__shadow) .neon-logo__front-card {
        animation: neon-intro-front-card 2500ms steps(1, end);
    }
    #mainMenu.is-intro svg:not(.neon-logo__shadow) .neon-logo__main {
        animation: neon-intro-main 2500ms steps(1, end);
    }
    #mainMenu.is-intro svg:not(.neon-logo__shadow) .neon-logo__sub {
        animation: neon-intro-sub 2500ms steps(1, end);
    }
    #mainMenu.is-intro > :not(.game-logo, script),
    #mainMenu.is-intro #splashPlayerName,
    #gameShell:has(> #mainMenu.is-intro:not(.is-hidden)) > :is(#settingsButton, .topbar-actions) {
        animation: splash-fade-in 380ms ease-out 420ms both;
    }
    #mainMenu:not(.is-intro, .is-hidden) > :not(.splash-footer, script) {
        animation: splash-rise 260ms cubic-bezier(.2, .8, .25, 1) both;
    }
}

/* Solid controls in every theme; card artwork retains its own rendering effects. */
button:not(.game-card) {
    background-image: none !important;
    box-shadow: none !important;
}

/* Top bar: the existing settings, log, rules and home buttons as flat tonal buttons. */
#settingsButton,
#homeButton,
#gameLogButton,
#rulesButton,
.game-menu-toggle {
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--ink);
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
#settingsButton:hover,
#homeButton:hover,
#gameLogButton:hover,
#rulesButton:hover,
.game-menu-toggle:hover {
    background: transparent;
    color: var(--ink);
    transform: none;
}
#settingsButton:active,
#homeButton:active,
#gameLogButton:active,
#rulesButton:active { transform: none; }

/* Button hierarchy: solid primary actions and quieter theme-coloured secondary actions. */
#mainMenu > #joinGameButton,
#gameMenu #inviteButton,
#gameMenu #lobbyMainMenuButton,
#gameMenu #mainMenuButton,
#gameMenu #leaveGameButton,
.dialog-footer > button {
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
    background-color: color-mix(in srgb, var(--accent) 16%, var(--surface));
    color: var(--ink);
}
#mainMenu > #joinGameButton:hover,
#gameMenu #inviteButton:hover,
#gameMenu #lobbyMainMenuButton:hover,
#gameMenu #mainMenuButton:hover,
#gameMenu #leaveGameButton:hover,
.dialog-footer > button:hover {
    background-color: color-mix(in srgb, var(--accent) 26%, var(--surface));
    color: var(--ink);
}

/* Layered surfaces. */
.dialog-window {
    border-color: color-mix(in srgb, var(--ink) 10%, transparent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 8%, transparent), 0 2px 6px rgb(0 0 0 / 20%), 0 28px 72px rgb(0 0 0 / 36%);
}
#playerList > div,
.setting-row {
    border-color: color-mix(in srgb, var(--ink) 11%, transparent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 7%, transparent), 0 1px 2px rgb(0 0 0 / 16%), 0 8px 20px rgb(0 0 0 / 12%);
}
.setting-row,
.setting-row:hover,
.setting-row:active,
.setting-row:focus {
    box-shadow: none;
}
.settings-category {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 750;
    letter-spacing: .1em;
    text-transform: uppercase;
}

/* Player seats keep their semantic turn, ready and passed colours from theme.css; no avatars. */

/* Felt table: a static vignette and fine fibre texture, no animation. */
#gameTable {
    border-color: color-mix(in srgb, var(--ink) 9%, transparent);
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>"),
        radial-gradient(ellipse at 50% 45%, color-mix(in srgb, #fff 6%, var(--felt)), var(--felt) 58%, color-mix(in srgb, #000 28%, var(--felt)));
    box-shadow: inset 0 18px 60px rgb(0 0 0 / 26%), var(--shadow);
}
:root[data-theme="light"] #gameTable {
    background: radial-gradient(ellipse at 50% 45%, var(--surface), var(--felt) 62%, color-mix(in srgb, var(--accent) 10%, var(--felt)));
    box-shadow: inset 0 14px 40px rgb(0 0 0 / 7%), var(--shadow);
}

/* Segmented controls: one connected track with a filled selected option. */
.speed-options,
.turn-speed-options,
.play-input-options,
.card-style-scope-options,
.quick-play-options,
.language-options {
    gap: 3px;
    padding: 3px;
    border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
    border-radius: 12px;
    background: var(--felt-deep);
    box-shadow: none;
}
.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: 0;
}
.speed-option,
.animation-speed-option,
.play-input-option,
.card-style-scope-option,
#mainMenu .quick-play-option,
.language-option {
    border-radius: 9px !important;
    transition: background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}
.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(--accent);
    color: var(--on-accent);
    box-shadow: none;
    opacity: 1;
}

/* Switches use the theme accent. */
.setting-row[aria-pressed="true"] .setting-row__switch {
    border-color: var(--accent);
    background: var(--accent);
    opacity: 1;
}
.setting-row[aria-pressed="true"] .setting-row__switch > span { background: var(--on-accent); }

/* Tabular figures keep timers, codes and scores from shifting. */
.turn-countdown,
#gameIdDisplay,
.settings-game-id strong,
.player-summary__details,
.leaderboard-table td {
    font-variant-numeric: tabular-nums;
}

/* Theme-aware focus ring. */
:focus-visible,
button:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* Theme previews show the theme's accent and its two neon colours. */
.color-theme-preview {
    background:
        radial-gradient(ellipse at 50% 20%, color-mix(in srgb, var(--neon-a) 18%, transparent), transparent 80%),
        var(--felt-deep);
}
.color-theme-preview > span + span {
    background: linear-gradient(90deg, var(--neon-a) 0 48%, transparent 48% 52%, var(--neon-b) 52% 100%);
    box-shadow: none;
}

/* Flat AMOLED surfaces; keep neon, card depth and foil effects intact. */
:root[data-color-theme="amoled"] { --shadow: none; }

:root[data-color-theme="amoled"] :is(#gameShell, #mainMenu, #gameTable) {
    background: #000;
}

/* Override raised control states without changing their semantic fills or focus outlines. */
:root[data-color-theme="amoled"] :is(
    button, .dialog-window, .setting-row, .setting-row__switch, .setting-row__switch > span,
    #gameMenu, #gameTable, #playerList > div, .player-summary, .exchange,
    .speed-options, .turn-speed-options, .play-input-options,
    .card-style-scope-options, .quick-play-options, .language-options
) {
    background-image: none !important;
    box-shadow: none !important;
}

:root[data-color-theme="amoled"] :is(.dialog-window, .setting-row, #gameTable) {
    border-color: var(--line);
}

:root[data-color-theme="amoled"] :is(#settingsButton, #homeButton, #gameLogButton, #rulesButton, .game-menu-toggle) {
    background-color: transparent;
    transform: none;
}

:root[data-color-theme="amoled"] :is(#settingsButton, #homeButton, #gameLogButton, #rulesButton, .game-menu-toggle):hover {
    background-color: transparent;
}

:root[data-color-theme="amoled"] :is(#mainMenu, #gameMenu, #playerActions, .dialog-window) button:is(:hover, :active) {
    transform: none;
}

:root[data-color-theme="amoled"] .dialog-container { backdrop-filter: none; }

[data-color-preview="amoled"].color-theme-preview {
    background: #000;
}
[data-color-preview="amoled"].color-theme-preview > span + span {
    background: var(--neon-b);
    box-shadow: none;
}

#splashPlayerName {
    cursor: pointer;
    text-decoration: none;
}
#splashPlayerName .splash-player-id {
    text-decoration: underline dotted;
    text-underline-offset: 4px;
}

#gameShell.game-active:not(.Lobby):not(.GameFinished) #playerList .player-summary.is-finished {
    --player-summary-opacity: .68;
    opacity: .68;
}

.player-pin-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.player-pin-row > #playerUsePin { flex: 0 0 155px; }
.player-pin-row > #playerPinFields { flex: 1; min-width: 0; }
#playerPinHint { display: block; color: var(--muted); }
#playerDefaultNameHint { display: block; margin-top: 4px; color: var(--muted); }
#playerDefaultNameHint[hidden] { display: none; }

.color-theme-list > .settings-category { margin: 16px 4px 4px; }

#playerList .is-reorderable {
    cursor: grab;
    touch-action: none;
    user-select: none;
}
#playerList .is-reordering { --player-summary-opacity: .65; opacity: .65; }
#playerList .is-reorder-target { outline: 2px dashed var(--focus); outline-offset: 2px; }

.play-guide { display: grid; gap: 16px; }
.play-guide section { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.play-guide h3 { margin: 0 0 12px; }
.play-guide p { margin-bottom: 0; }
.play-guide__cards, .play-guide__flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}
.play-guide__cards > span {
    display: grid;
    place-items: center;
    width: 44px;
    height: 62px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
}
.play-guide__flow > span, .play-guide__gesture { font-size: 1.6rem; text-align: center; }

#dialogRules .play-guide-shortcut {
    display: block;
    width: auto;
    min-height: 32px;
    margin: 0 auto 12px;
    padding: 4px 10px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.message-settings.is-enabled {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}
.message-settings { min-width: 0; }
.message-settings > button { width: 100%; margin-left: 0; margin-right: 0; }
.message-settings.is-enabled > .setting-row { border: 0; background: transparent; }
.message-settings > [hidden] { display: none; }
.leaderboard-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 18px 16px 12px;
}
.leaderboard-toolbar .dialog-title { grid-column: 2; padding: 0; }
.leaderboard-toolbar #leaderboardBotsToggleButton { justify-self: end; }
#leaderboardBotsToggleButton {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 28px;
    margin: 0;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    font-size: .75rem;
    font-weight: 400;
    opacity: .7;
}
#leaderboardBotsToggleButton[aria-pressed="true"] { color: var(--accent); opacity: 1; }
#leaderboardBotsToggleButton svg { width: 22px; height: 22px; }
#leaderboardBotsToggleButton[aria-pressed="true"] circle { transform: translateX(8px); }
#dialogLeaderboard .leaderboard-player-name,
#dialogLeaderboard .leaderboard-player-name:is(:hover, :active, :focus) {
    padding: 6px 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    transform: none;
    text-decoration: none;
}

.table-status-dock {
    position: absolute;
    z-index: 70;
    right: 8px;
    bottom: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}
.table-status-dock > #turnTimer {
    position: static;
    order: 2;
}
.table-status-dock > .table-card-pile__count {
    position: static;
    order: 1;
    display: inline-flex;
    align-items: center;
    width: auto;
    padding: 3px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: .7rem;
    font-weight: 400;
    line-height: 1.45;
    transform: none;
    box-shadow: none;
    font-variant-numeric: tabular-nums;
}
#gameTable:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible) > .table-status-dock {
    bottom: calc(var(--toast-stack-height) + 10px);
}
.table-status-dock > .table-card-pile__count[hidden] { display: none; }
.game-end-vote__choices button.has-waiting-player {
    border: 2px solid var(--warning);
    background: var(--warning-soft);
    color: var(--ink);
}
.lobby-waiting-hint { color: var(--warning); }

@media (orientation: landscape) and (max-height: 500px) {
    #gameTable:has(#gameToastRegion:not([hidden]) > .game-toast.is-visible) > .table-status-dock {
        top: 4px;
        bottom: auto;
    }
}
