/* Premium table v3: final visual and responsive layer. */
:root {
    --v3-ink: #10232d;
    --v3-ink-2: #173746;
    --v3-felt: #147b69;
    --v3-felt-deep: #075245;
    --v3-gold: #e6bd67;
    --v3-gold-deep: #9d6b1d;
    --v3-red: #c8443d;
    --v3-paper: #fbfaf6;
    --v3-line: rgba(255, 255, 255, 0.2);
    --v3-shadow: 0 14px 32px rgba(8, 16, 20, 0.34);
}

html,
body {
    overscroll-behavior: none;
}

body {
    background:
        rgba(37, 24, 17, 0.34)
        url("/static/assets/walnut-table.webp") center / cover fixed;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
        "PingFang SC", "Microsoft YaHei", sans-serif;
}

.site-compliance {
    position: fixed;
    z-index: 100;
    right: 12px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 12px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.site-compliance a {
    color: inherit;
    text-decoration: none;
}

.site-compliance a:hover,
.site-compliance a:focus-visible {
    color: #fff8df;
    text-decoration: underline;
}

body.game-active .site-compliance {
    display: none;
}

button,
input {
    -webkit-tap-highlight-color: transparent;
}

.btn {
    border-radius: 7px;
    font-weight: 800;
    letter-spacing: 0;
}

.btn.primary {
    border-color: #d95b51;
    background: #c8443d;
    color: #fff;
}

.btn.primary:hover {
    background: #d24c44;
}

.btn.secondary {
    border-color: rgba(16, 35, 45, 0.18);
    background: #f6f2e8;
    color: #17332e;
}

.btn.warning {
    border-color: #f2d282;
    background: #b7832b;
    color: #fff7dc;
}

.btn.ghost {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(16, 35, 45, 0.68);
    color: #fff;
}

/* Authentication and lobby */
#auth,
#lobby,
#room {
    background:
        linear-gradient(rgba(22, 15, 11, 0.3), rgba(7, 20, 20, 0.62)),
        url("/static/assets/walnut-table.webp") center / cover;
}

.auth-shell,
.lobby-shell {
    width: min(1060px, calc(100vw - 32px));
    min-height: 100dvh;
    gap: 24px;
    padding-bottom: max(44px, calc(env(safe-area-inset-bottom) + 36px));
}

.auth-brand,
.brand-panel {
    min-height: 520px;
    border: 1px solid rgba(255, 226, 153, 0.28);
    border-radius: 8px;
    background:
        linear-gradient(rgba(6, 69, 59, 0.15), rgba(3, 35, 31, 0.76)),
        url("/static/assets/emerald-felt.webp") center / cover;
    box-shadow:
        inset 0 0 0 10px rgba(24, 22, 17, 0.3),
        0 24px 58px rgba(0, 0, 0, 0.34);
}

.auth-brand {
    display: grid;
    align-content: end;
    padding: 42px;
}

.auth-brand h1,
.brand-panel h1 {
    margin: 14px 0 10px;
    color: #fff8df;
    font-size: 52px;
    line-height: 1;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.auth-brand p,
.brand-panel p {
    color: rgba(255, 255, 255, 0.74);
}

.auth-card,
.lobby-card,
.room-shell {
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(10, 29, 28, 0.93);
    box-shadow: 0 24px 58px rgba(0, 0, 0, 0.34);
}

.auth-tabs,
.difficulty-control {
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.07);
}

.auth-tab,
.difficulty-control span {
    border-radius: 6px;
}

.difficulty-control {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.difficulty-control span {
    min-height: 58px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    padding: 8px 6px;
}

.difficulty-control b {
    font-size: 14px;
}

.difficulty-control small {
    color: rgba(255, 255, 255, 0.56);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
}

.difficulty-control input:checked + span small {
    color: rgba(24, 30, 28, 0.66);
}

.difficulty-note {
    margin: 8px 2px 0;
    color: rgba(255, 255, 255, 0.56);
    font-size: 12px;
    line-height: 1.5;
}

/* Game viewport */
body.game-active {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #26170f;
}

#game.active {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

#game .table-shell {
    position: relative !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-rows: 54px minmax(0, 1fr) 58px !important;
    gap: 0 !important;
    padding:
        max(0px, env(safe-area-inset-top))
        max(0px, env(safe-area-inset-right))
        max(0px, env(safe-area-inset-bottom))
        max(0px, env(safe-area-inset-left)) !important;
    background:
        rgba(30, 18, 11, 0.24)
        url("/static/assets/walnut-table.webp") center / cover !important;
    overflow: hidden !important;
}

#game .table-shell::before {
    display: none !important;
}

#game .game-hud {
    position: relative !important;
    inset: auto !important;
    z-index: 60;
    min-width: 0;
    display: grid !important;
    grid-template-columns: minmax(72px, 0.7fr) repeat(5, minmax(88px, 1fr)) 72px !important;
    gap: 2px !important;
    padding: 3px 6px !important;
    border-bottom: 1px solid rgba(255, 226, 153, 0.18);
    background: rgba(12, 24, 29, 0.96);
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.22);
}

#game .game-hud .hud-item,
#game .game-hud > .btn {
    min-width: 0 !important;
    min-height: 46px !important;
    height: 46px !important;
    margin: 0 !important;
    padding: 5px 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 5px !important;
    background: rgba(26, 55, 68, 0.68) !important;
    box-shadow: none !important;
}

#game .game-hud .trump-hud {
    border-color: rgba(230, 189, 103, 0.42) !important;
    background: rgba(88, 65, 26, 0.58) !important;
}

#game .game-hud .hud-item span {
    margin: 0 0 1px !important;
    color: rgba(255, 255, 255, 0.58) !important;
    font-size: 10px !important;
    line-height: 1.05 !important;
}

#game .game-hud .hud-item strong {
    display: block;
    overflow: hidden;
    color: #fff !important;
    font-size: 15px !important;
    line-height: 1.1 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#game .game-hud > .btn {
    display: grid !important;
    place-items: center;
    color: #fff4d4 !important;
    font-size: 13px !important;
}

#game .table-felt {
    position: relative !important;
    inset: auto !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 8px !important;
    overflow: hidden !important;
    border: 8px solid rgba(44, 31, 24, 0.92) !important;
    border-radius: 8px !important;
    background:
        linear-gradient(rgba(10, 132, 111, 0.18), rgba(2, 61, 52, 0.18)),
        url("/static/assets/emerald-felt.webp") center / cover !important;
    box-shadow:
        inset 0 0 0 2px rgba(255, 235, 185, 0.14),
        inset 0 0 44px rgba(0, 31, 26, 0.42),
        0 12px 30px rgba(0, 0, 0, 0.28) !important;
}

#game .table-felt::before {
    inset: 10px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 5px !important;
}

#game .table-felt::after {
    left: 24% !important;
    right: 24% !important;
    top: 24% !important;
    bottom: 34% !important;
    border: 1px solid rgba(255, 255, 255, 0.09) !important;
    border-radius: 50% !important;
}

#game .board-menu-btn,
#game .voice-talk-button,
#game .card-tracker-toggle {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 !important;
    border: 1px solid rgba(255, 239, 198, 0.3) !important;
    border-radius: 7px !important;
    background: rgba(13, 37, 45, 0.9) !important;
    color: #fff1c7 !important;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24) !important;
}

#game .board-menu-btn {
    top: 8px !important;
    left: 8px !important;
}

#game .board-menu-btn span {
    width: 18px;
}

#game .side-tools {
    position: absolute !important;
    inset: auto 8px auto auto !important;
    z-index: 42 !important;
    top: 8px !important;
    right: 8px !important;
}

#game .voice-talk-button {
    position: relative !important;
    inset: auto !important;
    display: grid !important;
    place-items: center !important;
}

#game .voice-talk-label {
    font-size: 16px !important;
}

#game .voice-talk-icon {
    display: none !important;
}

#game .card-tracker-toggle {
    position: absolute !important;
    z-index: 42 !important;
    top: 8px !important;
    right: 54px !important;
    bottom: auto !important;
    overflow: hidden;
    font-size: 0 !important;
}

#game .card-tracker-toggle::before {
    content: "记";
    font-size: 16px;
    font-weight: 900;
}

#game .card-tracker-toggle.active {
    border-color: #f0cc78 !important;
    background: #9a6b21 !important;
}

#game .card-tracker-panel {
    position: absolute !important;
    z-index: 70 !important;
    top: 54px !important;
    right: 8px !important;
    bottom: auto !important;
    width: 250px !important;
    max-height: calc(100% - 64px) !important;
    padding: 8px !important;
    overflow: auto !important;
    border: 1px solid rgba(245, 215, 144, 0.38) !important;
    border-radius: 7px !important;
    background: rgba(9, 28, 34, 0.97) !important;
    box-shadow: var(--v3-shadow) !important;
}

#game .player-panel {
    z-index: 24 !important;
    width: 108px !important;
    min-width: 108px !important;
    max-width: 108px !important;
    height: 50px !important;
    min-height: 48px !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    padding: 5px 6px !important;
    overflow: visible !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    background: rgba(8, 34, 38, 0.9) !important;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22) !important;
}

#game .player-panel.active-turn {
    border-color: #f1cc73 !important;
    box-shadow:
        0 0 0 2px rgba(241, 204, 115, 0.22),
        0 8px 18px rgba(0, 0, 0, 0.26) !important;
}

#game .player-panel .avatar {
    width: 36px !important;
    height: 36px !important;
    flex: 0 0 36px !important;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.72);
    border-radius: 50% !important;
    background:
        url("/static/assets/player-avatar.webp") center / cover !important;
    color: transparent !important;
}

#game .player-panel strong {
    max-width: 58px !important;
    color: #fff !important;
    font-size: 12px !important;
}

#game .player-panel span {
    max-width: 58px !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 10px !important;
}

#game .player-panel .team-role {
    position: absolute !important;
    top: -9px !important;
    right: -5px !important;
    bottom: auto !important;
    left: auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 2px 5px !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    border-radius: 4px !important;
    background: #304a56 !important;
    color: #fff !important;
    font-size: 9px !important;
    line-height: 1.1 !important;
}

#game .player-panel .team-role::before,
#game .player-panel .team-role::after {
    display: none !important;
    content: none !important;
}

#game .player-panel .team-role.banker {
    border-color: #ffde91 !important;
    background: #c94a3d !important;
}

#game .opponent-top {
    top: 5px !important;
    right: auto !important;
    bottom: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
}

#game .opponent-left {
    top: 40% !important;
    right: auto !important;
    bottom: auto !important;
    left: 8px !important;
    transform: translateY(-50%) !important;
}

#game .opponent-right {
    top: 40% !important;
    right: 8px !important;
    bottom: auto !important;
    left: auto !important;
    transform: translateY(-50%) !important;
}

#game .kitty-cards {
    z-index: 26 !important;
    top: 8px !important;
    left: 56px !important;
    display: grid !important;
    justify-items: start !important;
    gap: 3px !important;
    transform: none !important;
}

#game .kitty-label,
#game .koupai-label {
    color: #fff0bd !important;
    font-size: 10px !important;
    line-height: 1 !important;
}

#game .hole-cards {
    gap: 2px !important;
}

#game .card-back {
    width: 27px !important;
    height: 39px !important;
    flex-basis: 27px !important;
    border-width: 1px !important;
    border-radius: 4px !important;
    background-size: 9px 9px, auto !important;
    box-shadow: 0 4px 9px rgba(0, 0, 0, 0.2) !important;
}

#game .koupai-cards {
    z-index: 29 !important;
    top: 8px !important;
    left: 176px !important;
    max-width: 142px !important;
    padding: 5px !important;
    gap: 3px !important;
    border-radius: 5px !important;
    background: rgba(7, 37, 37, 0.9) !important;
}

#game .koupai-card-list {
    gap: 2px !important;
}

#game .koupai-card-list .card.small,
#game .hole-cards .card.small {
    width: 27px !important;
    height: 39px !important;
    flex-basis: 27px !important;
    margin-left: -5px !important;
    padding: 3px !important;
    border-radius: 4px !important;
}

#game .koupai-card-list .card.small:first-child,
#game .hole-cards .card.small:first-child {
    margin-left: 0 !important;
}

#game .koupai-card-list .card.small .pip {
    display: none !important;
}

#game .center-play-area {
    z-index: 8 !important;
    inset: 0 118px 92px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    pointer-events: none;
}

#game .center-message {
    top: 64px !important;
    z-index: 16 !important;
    max-width: calc(100% - 18px) !important;
    min-height: 24px !important;
    padding: 4px 10px !important;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 5px !important;
    background: rgba(7, 48, 48, 0.76) !important;
    color: #fff3ca !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#game .trump-hint {
    top: 94px !important;
    z-index: 14 !important;
    max-width: calc(100% - 18px) !important;
    min-height: 20px !important;
    padding: 3px 8px !important;
    overflow: hidden;
    border-radius: 5px !important;
    background: rgba(8, 37, 40, 0.7) !important;
    font-size: 10px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#game .trump-hint strong {
    font-size: 11px !important;
}

#game .liangzhu-display {
    right: 0 !important;
    bottom: 2px !important;
    left: 0 !important;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.62) !important;
    font-size: 10px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#game .played-grid {
    top: 126px !important;
    left: 50% !important;
    width: min(620px, 100%) !important;
    height: 218px !important;
    transform: translateX(-50%) !important;
}

#game .played-slot {
    position: absolute !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    top: auto !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    min-width: 96px !important;
    min-height: 64px !important;
    gap: 3px !important;
    transform: none !important;
}

#game .played-slot.top {
    top: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
}

#game .played-slot.left {
    top: 48% !important;
    left: 0 !important;
    transform: translateY(-50%) !important;
}

#game .played-slot.right {
    top: 48% !important;
    right: 0 !important;
    transform: translateY(-50%) !important;
}

#game .played-slot.bottom {
    top: auto !important;
    bottom: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
}

#game .played-slot .card {
    width: 44px !important;
    height: 62px !important;
    flex-basis: 44px !important;
    margin-left: -13px !important;
    padding: 5px !important;
    border-radius: 4px !important;
}

#game .played-slot .card:first-child {
    margin-left: 0 !important;
}

#game .played-slot .card .corner {
    top: 3px !important;
    left: 3px !important;
    width: auto !important;
}

#game .played-slot .card .rank,
#game .played-slot .card .suit {
    font-size: 13px !important;
}

#game .played-slot .card .pip {
    right: 3px !important;
    bottom: 3px !important;
    display: block !important;
    font-size: 21px !important;
}

#game .played-slot .empty-zone {
    font-size: 10px !important;
}

#game .my-hand-area {
    z-index: 34 !important;
    right: 8px !important;
    bottom: 4px !important;
    left: 8px !important;
    height: 176px !important;
    min-height: 176px !important;
    display: block !important;
    padding: 20px 6px 3px !important;
    overflow: visible !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 6px !important;
    background: rgba(7, 31, 35, 0.82) !important;
    box-shadow: 0 -8px 22px rgba(0, 0, 0, 0.2) !important;
}

#game .my-info {
    position: absolute !important;
    z-index: 4 !important;
    top: 2px !important;
    right: 6px !important;
    bottom: auto !important;
    left: 6px !important;
    width: auto !important;
    height: 16px !important;
    min-height: 16px !important;
    gap: 6px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

#game .my-info::before,
#game .my-info::after {
    display: none !important;
}

#game .my-info > div:first-child {
    gap: 5px !important;
}

#game .my-info strong,
#game .my-info span {
    font-size: 10px !important;
    line-height: 1.1 !important;
}

#game .my-info .team-role,
#game .banker-badge {
    margin-top: 0 !important;
    padding: 1px 5px !important;
    border-radius: 4px !important;
    font-size: 9px !important;
}

#game .hand-prompt {
    max-height: 18px !important;
    padding: 2px 7px !important;
    overflow: hidden;
    border-radius: 4px !important;
    font-size: 9px !important;
    line-height: 1.15 !important;
    text-overflow: ellipsis;
    white-space: nowrap !important;
}

#game .my-hand {
    position: absolute !important;
    z-index: 2 !important;
    top: auto !important;
    right: 4px !important;
    bottom: 2px !important;
    left: 4px !important;
    width: auto !important;
    height: var(--hand-height) !important;
    min-height: var(--hand-height) !important;
    overflow: visible !important;
}

#game .my-hand .card {
    overflow: hidden !important;
    border: 1px solid #d4d8d5 !important;
    border-radius: 5px !important;
    background: #fbfaf6 !important;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.22) !important;
}

#game .my-hand .card.selected {
    z-index: 1000 !important;
    border-color: #efc75f !important;
    box-shadow:
        0 0 0 2px rgba(239, 199, 95, 0.32),
        0 8px 14px rgba(0, 0, 0, 0.26) !important;
}

#game .my-hand .card .corner {
    top: var(--hand-card-pad) !important;
    left: var(--hand-card-pad) !important;
    width: auto !important;
    max-width: 25px !important;
    justify-items: start !important;
    gap: 0 !important;
}

#game .my-hand .card .rank,
#game .my-hand .card .suit {
    width: auto !important;
    min-width: 0 !important;
    font-family: Georgia, "Times New Roman", serif !important;
    font-weight: 900 !important;
    line-height: 0.9 !important;
    text-align: left !important;
}

#game .my-hand .card:not(.joker-card) .rank {
    font-size: var(--hand-card-rank) !important;
    writing-mode: horizontal-tb !important;
}

#game .my-hand .card:not(.joker-card) .suit {
    font-size: var(--hand-card-suit) !important;
    writing-mode: horizontal-tb !important;
}

#game .my-hand .card .pip {
    right: 5px !important;
    bottom: 5px !important;
    font-size: 28px !important;
    opacity: 0.9 !important;
}

#game .my-hand .card.joker-card .rank {
    writing-mode: vertical-rl !important;
    text-orientation: upright !important;
}

#game .action-dock {
    position: relative !important;
    inset: auto !important;
    width: auto !important;
    bottom: auto !important;
    z-index: 64;
    min-width: 0;
    min-height: 58px !important;
    height: 58px !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 7px !important;
    padding: 6px 12px !important;
    padding-bottom: max(6px, env(safe-area-inset-bottom)) !important;
    background: rgba(10, 31, 39, 0.97) !important;
    box-shadow: 0 -8px 18px rgba(0, 0, 0, 0.24);
}

#game .action-dock .btn {
    min-width: 104px !important;
    width: auto !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 18px !important;
    font-size: 15px !important;
}

#game .action-dock .btn.primary {
    min-width: 126px !important;
}

body.game-active .toast {
    z-index: 200 !important;
    bottom: 220px !important;
    max-width: min(72vw, 520px) !important;
    padding: 7px 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px !important;
    background: rgba(5, 27, 31, 0.94) !important;
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.28);
    font-size: 12px !important;
    line-height: 1.2 !important;
    text-align: center;
}

.orientation-gate {
    z-index: 1000 !important;
    background:
        linear-gradient(rgba(6, 27, 28, 0.9), rgba(6, 27, 28, 0.96)),
        url("/static/assets/emerald-felt.webp") center / cover !important;
}

@media (orientation: landscape) and (max-height: 560px) {
    #game .table-shell {
        grid-template-rows: 48px minmax(0, 1fr) 52px !important;
    }

    #game .game-hud {
        grid-template-columns: repeat(4, minmax(82px, 1fr)) 64px !important;
        padding: 2px 5px !important;
    }

    #game .game-hud .hud-item,
    #game .game-hud > .btn {
        height: 44px !important;
        min-height: 44px !important;
    }

    #game .game-hud .hud-item:first-child,
    #game .game-hud .hud-item:nth-child(6) {
        display: none !important;
    }

    #game .table-felt {
        margin: 0 5px !important;
        border-width: 5px !important;
    }

    #game .center-play-area {
        inset: 0 116px 101px !important;
    }

    #game .center-message {
        top: 52px !important;
    }

    #game .trump-hint {
        top: 79px !important;
    }

    #game .played-grid {
        top: 104px !important;
        width: min(390px, 100%) !important;
        height: 100px !important;
    }

    #game .my-hand-area {
        height: 98px !important;
        min-height: 98px !important;
        padding-top: 18px !important;
    }

    #game .opponent-left,
    #game .opponent-right {
        top: 64px !important;
        transform: none !important;
    }

    #game .played-slot {
        min-width: 76px !important;
        min-height: 48px !important;
        gap: 2px !important;
    }

    #game .played-slot .card {
        width: 34px !important;
        height: 48px !important;
        flex-basis: 34px !important;
        margin-left: -10px !important;
        padding: 4px !important;
    }

    #game .played-slot .card .rank,
    #game .played-slot .card .suit {
        font-size: 11px !important;
    }

    #game .played-slot .card .pip {
        font-size: 17px !important;
    }

    #game .action-dock {
        min-height: 52px !important;
        height: 52px !important;
        padding: 4px 10px !important;
    }

    #game .action-dock .btn {
        height: 40px !important;
        min-height: 40px !important;
        min-width: 94px !important;
        padding: 0 14px !important;
        font-size: 14px !important;
    }
}

/* iPhone 15 / 15 Pro Max Safari and standalone landscape. */
@media (orientation: landscape) and (max-height: 430px) and (max-width: 940px) {
    #game .table-shell {
        grid-template-rows: 44px minmax(0, 1fr) 48px !important;
    }

    #game .game-hud {
        grid-template-columns: repeat(4, minmax(70px, 1fr)) 58px !important;
        padding: 2px 4px !important;
    }

    #game .game-hud .hud-item,
    #game .game-hud > .btn {
        height: 40px !important;
        min-height: 40px !important;
        padding: 4px 6px !important;
    }

    #game .game-hud .hud-item span {
        font-size: 9px !important;
    }

    #game .game-hud .hud-item strong {
        font-size: 13px !important;
    }

    #game .table-felt {
        margin: 0 3px !important;
        border-width: 4px !important;
    }

    #game .board-menu-btn,
    #game .voice-talk-button,
    #game .card-tracker-toggle {
        width: 34px !important;
        min-width: 34px !important;
        height: 34px !important;
        min-height: 34px !important;
    }

    #game .card-tracker-toggle {
        right: 48px !important;
    }

    #game .side-tools {
        right: 8px !important;
    }

    #game .player-panel {
        width: 94px !important;
        min-width: 94px !important;
        max-width: 94px !important;
        height: 42px !important;
        min-height: 42px !important;
        padding: 4px 5px !important;
    }

    #game .player-panel .avatar {
        width: 31px !important;
        height: 31px !important;
        flex-basis: 31px !important;
    }

    #game .player-panel strong {
        max-width: 50px !important;
        font-size: 11px !important;
    }

    #game .player-panel span {
        max-width: 50px !important;
        font-size: 9px !important;
    }

    #game .opponent-top {
        top: 4px !important;
    }

    #game .opponent-left,
    #game .opponent-right {
        top: 60px !important;
        transform: none !important;
    }

    #game .kitty-cards {
        top: 5px !important;
        left: 48px !important;
    }

    #game .koupai-cards {
        top: 5px !important;
        left: 161px !important;
    }

    #game .center-play-area {
        inset: 0 101px 95px !important;
    }

    #game .center-message {
        top: 48px !important;
        min-height: 20px !important;
        padding: 3px 8px !important;
        font-size: 11px !important;
    }

    #game .trump-hint {
        top: 71px !important;
        min-height: 18px !important;
        padding: 2px 6px !important;
    }

    #game .trump-sub {
        display: none !important;
    }

    #game .played-grid {
        top: 93px !important;
        width: min(350px, 100%) !important;
        height: 84px !important;
    }

    #game .played-slot {
        min-width: 68px !important;
        min-height: 42px !important;
    }

    #game .played-slot .card {
        width: 31px !important;
        height: 43px !important;
        flex-basis: 31px !important;
        margin-left: -9px !important;
    }

    #game .my-hand-area {
        right: 4px !important;
        bottom: 2px !important;
        left: 4px !important;
        height: 92px !important;
        min-height: 92px !important;
        padding: 16px 3px 1px !important;
    }

    #game .my-info {
        top: 1px !important;
        right: 4px !important;
        bottom: auto !important;
        left: 4px !important;
        height: 14px !important;
        min-height: 14px !important;
        padding: 0 !important;
    }

    #game .my-info strong,
    #game .my-info span {
        font-size: 9px !important;
    }

    #game .hand-prompt {
        max-width: 64% !important;
        font-size: 8px !important;
    }

    #game .my-hand .card .pip {
        display: none !important;
    }

    #game .action-dock {
        min-height: 48px !important;
        height: 48px !important;
        gap: 5px !important;
        padding: 3px 8px !important;
    }

    #game .action-dock .btn {
        min-width: 84px !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 12px !important;
        font-size: 13px !important;
    }

    #game .action-dock .btn.primary {
        min-width: 104px !important;
    }

    #game .card-tracker-panel {
        top: 46px !important;
        width: 224px !important;
        max-height: calc(100% - 52px) !important;
    }
}

/*
 * Safari can expose a wider CSS viewport than the nominal iPhone preset when
 * page zoom or "request desktop website" is active. Keep every interactive
 * region in a fixed vertical band for all short landscape viewports.
 */
@media (orientation: landscape) and (max-width: 1280px) and (max-height: 620px) {
    #game .table-shell {
        grid-template-rows: 44px minmax(0, 1fr) 44px !important;
    }

    #game .game-hud {
        grid-template-columns: repeat(4, minmax(74px, 1fr)) 64px !important;
        padding: 2px 4px !important;
    }

    #game .game-hud .hud-item,
    #game .game-hud > .btn {
        height: 40px !important;
        min-height: 40px !important;
        padding: 3px 6px !important;
    }

    #game .game-hud .hud-item span {
        font-size: 9px !important;
    }

    #game .game-hud .hud-item strong {
        font-size: 13px !important;
    }

    #game .table-felt {
        margin: 0 3px !important;
        border-width: 4px !important;
    }

    #game .board-menu-btn,
    #game .voice-talk-button,
    #game .card-tracker-toggle {
        top: 7px !important;
        bottom: auto !important;
        width: 34px !important;
        min-width: 34px !important;
        max-width: 34px !important;
        height: 34px !important;
        min-height: 34px !important;
        max-height: 34px !important;
        margin: 0 !important;
        transform: none !important;
    }

    #game .board-menu-btn {
        right: auto !important;
        left: 7px !important;
    }

    #game .side-tools {
        top: 7px !important;
        right: 7px !important;
        bottom: auto !important;
        left: auto !important;
        width: 34px !important;
        height: 34px !important;
        margin: 0 !important;
        transform: none !important;
    }

    #game .voice-talk-button {
        right: auto !important;
        left: auto !important;
    }

    #game .card-tracker-toggle {
        right: 49px !important;
        left: auto !important;
    }

    #game .player-panel {
        width: 98px !important;
        min-width: 98px !important;
        max-width: 98px !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 4px 5px !important;
        gap: 5px !important;
    }

    #game .player-panel .avatar {
        width: 32px !important;
        height: 32px !important;
        flex-basis: 32px !important;
    }

    #game .player-panel strong {
        max-width: 52px !important;
        font-size: 11px !important;
        line-height: 1.05 !important;
    }

    #game .player-panel span {
        max-width: 52px !important;
        font-size: 9px !important;
        line-height: 1.05 !important;
    }

    #game .player-panel .team-role {
        top: -7px !important;
        right: 2px !important;
        bottom: auto !important;
        left: auto !important;
        padding: 2px 5px !important;
        font-size: 9px !important;
    }

    #game .opponent-top {
        top: 12px !important;
    }

    #game .opponent-left,
    #game .opponent-right {
        top: 72px !important;
        transform: none !important;
    }

    #game .kitty-cards {
        top: 7px !important;
        left: 49px !important;
    }

    #game .koupai-cards {
        top: 7px !important;
        left: 163px !important;
    }

    #game .center-play-area {
        inset: 0 104px 82px !important;
    }

    #game .center-message {
        top: 58px !important;
        min-height: 19px !important;
        padding: 3px 8px !important;
        font-size: 10px !important;
    }

    #game .trump-hint {
        top: 80px !important;
        min-height: 17px !important;
        padding: 2px 6px !important;
        font-size: 9px !important;
    }

    #game .trump-sub {
        display: none !important;
    }

    #game .played-grid {
        top: 101px !important;
        width: min(340px, 100%) !important;
        height: 72px !important;
    }

    #game .played-slot {
        min-width: 66px !important;
        min-height: 42px !important;
    }

    #game .played-slot .card {
        width: 31px !important;
        height: 43px !important;
        flex-basis: 31px !important;
        margin-left: -9px !important;
        padding: 3px !important;
    }

    #game .played-slot .card .rank,
    #game .played-slot .card .suit {
        font-size: 11px !important;
    }

    #game .played-slot .card .pip {
        font-size: 16px !important;
    }

    #game .my-hand-area {
        right: 4px !important;
        bottom: 3px !important;
        left: 4px !important;
        height: 78px !important;
        min-height: 78px !important;
        padding: 15px 3px 1px !important;
    }

    #game .my-info {
        top: 1px !important;
        right: 4px !important;
        bottom: auto !important;
        left: 4px !important;
        height: 13px !important;
        min-height: 13px !important;
        padding: 0 !important;
    }

    #game .my-info strong,
    #game .my-info span {
        font-size: 9px !important;
    }

    #game .hand-prompt {
        max-width: 60% !important;
        max-height: 13px !important;
        padding: 1px 5px !important;
        font-size: 8px !important;
    }

    #game .my-hand .card .pip {
        display: none !important;
    }

    #game .action-dock {
        min-height: 44px !important;
        height: 44px !important;
        gap: 5px !important;
        padding: 3px 8px !important;
        padding-bottom: max(3px, env(safe-area-inset-bottom)) !important;
    }

    #game .action-dock .btn {
        min-width: 82px !important;
        height: 36px !important;
        min-height: 36px !important;
        padding: 0 11px !important;
        font-size: 13px !important;
    }

    #game .action-dock .btn.primary {
        min-width: 102px !important;
    }

    #game .card-tracker-panel {
        top: 47px !important;
        right: 7px !important;
        width: 220px !important;
        max-height: calc(100% - 54px) !important;
    }
}

@media (orientation: landscape) and (max-height: 350px) {
    #game .table-shell {
        grid-template-rows: 40px minmax(0, 1fr) 44px !important;
    }

    #game .game-hud .hud-item,
    #game .game-hud > .btn {
        height: 36px !important;
        min-height: 36px !important;
    }

    #game .trump-hint {
        display: none !important;
    }

    #game .center-message {
        top: 35px !important;
    }

    #game .played-grid {
        top: 59px !important;
        height: 75px !important;
    }

    #game .my-hand-area {
        height: 68px !important;
        min-height: 68px !important;
    }
}

/*
 * Final short-landscape collision guard. These declarations intentionally
 * sit after all legacy landscape breakpoints so Safari page zoom cannot
 * restore viewport-based played-card coordinates.
 */
@media (orientation: landscape) and (max-width: 1280px) and (max-height: 620px) {
    #game .table-shell {
        grid-template-rows: 44px minmax(0, 1fr) 0 !important;
    }

    #game .table-felt {
        overflow: hidden !important;
    }

    body.game-active .toast {
        right: auto !important;
        bottom: clamp(112px, 24vh, 146px) !important;
        left: 50% !important;
        width: max-content !important;
        max-width: min(72vw, 440px) !important;
        padding: 5px 9px !important;
        font-size: 10px !important;
        transform: translateX(-50%) !important;
    }

    #game .played-grid {
        position: absolute !important;
        top: clamp(88px, 22vh, 112px) !important;
        right: auto !important;
        bottom: auto !important;
        left: 50% !important;
        width: min(58vw, 560px) !important;
        height: 104px !important;
        margin: 0 !important;
        transform: translateX(-50%) !important;
    }

    #game .played-slot.top {
        top: 0 !important;
        right: auto !important;
        bottom: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    #game .played-slot.left {
        top: 50% !important;
        right: auto !important;
        bottom: auto !important;
        left: 0 !important;
        transform: translateY(-50%) !important;
    }

    #game .played-slot.right {
        top: 50% !important;
        right: 0 !important;
        bottom: auto !important;
        left: auto !important;
        transform: translateY(-50%) !important;
    }

    #game .played-slot.bottom {
        top: auto !important;
        right: auto !important;
        bottom: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    #game .my-hand-area {
        right: max(4px, env(safe-area-inset-right)) !important;
        bottom: max(4px, env(safe-area-inset-bottom)) !important;
        left: max(4px, env(safe-area-inset-left)) !important;
        height: 78px !important;
        min-height: 78px !important;
        padding: 0 3px 1px !important;
    }

    #game.has-action-buttons .my-hand-area,
    #game:has(.action-dock .btn:not([hidden])) .my-hand-area {
        right: max(238px, calc(env(safe-area-inset-right) + 238px)) !important;
    }

    #game .my-info {
        top: auto !important;
        right: 4px !important;
        bottom: calc(var(--hand-stack-height, 74px) + 4px) !important;
        left: 4px !important;
        height: 17px !important;
        min-height: 17px !important;
        padding: 1px 7px !important;
        overflow: hidden !important;
        border: 1px solid rgba(255, 238, 185, 0.22) !important;
        border-radius: 4px !important;
        background: rgba(6, 35, 39, 0.94) !important;
    }

    #game .my-info > div:first-child {
        min-width: max-content !important;
        flex-shrink: 0 !important;
    }

    #game .my-info strong,
    #game .my-info span {
        font-size: 9px !important;
        line-height: 1 !important;
        white-space: nowrap !important;
    }

    #game .hand-prompt {
        min-width: 0 !important;
        max-width: 54% !important;
    }

    #game .action-dock {
        position: absolute !important;
        z-index: 70 !important;
        right: max(6px, env(safe-area-inset-right)) !important;
        bottom: max(5px, env(safe-area-inset-bottom)) !important;
        left: auto !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 230px !important;
        min-height: 38px !important;
        height: 38px !important;
        gap: 4px !important;
        padding: 1px !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    #game .action-dock .btn {
        min-width: 68px !important;
        height: 36px !important;
        min-height: 36px !important;
        padding: 0 8px !important;
        font-size: 12px !important;
    }

    #game .action-dock .btn.primary {
        min-width: 82px !important;
    }

}

@media (orientation: portrait) and (max-width: 900px) {
    body.game-active .orientation-gate {
        display: grid !important;
    }

    body.game-active #game {
        visibility: hidden;
    }

    .orientation-phone {
        border-radius: 7px !important;
    }
}

@media (max-width: 720px) {
    .auth-shell,
    .lobby-shell {
        width: min(100% - 24px, 460px);
        grid-template-columns: 1fr;
        align-content: center;
        padding: 20px 0;
    }

    .auth-brand,
    .brand-panel {
        min-height: 180px;
        padding: 24px;
    }

    .auth-brand h1,
    .brand-panel h1 {
        font-size: 38px;
    }

    .auth-card,
    .lobby-card {
        padding: 20px;
    }
}

/* Stable Safari landscape geometry: card faces and play slots never reflow. */
#game .my-hand .card:not(.joker-card) .rank,
#game .my-hand .card:not(.joker-card) .suit,
#game .my-hand .card.long-rank:not(.joker-card) .rank {
    font-size: var(--hand-card-rank, 16px) !important;
    line-height: 0.92 !important;
}

@media (orientation: landscape) and (max-width: 1400px) and (max-height: 700px) {
    #game {
        --hand-action-lane: clamp(238px, 19vw, 300px);
    }

    #game.screen.active .my-hand-area,
    #game.screen.active.has-action-buttons .my-hand-area,
    #game.screen.active:has(.action-dock .btn:not([hidden])) .my-hand-area {
        right: calc(env(safe-area-inset-right) + var(--hand-action-lane)) !important;
    }

    #game .center-play-area {
        inset:
            0
            max(92px, 8vw)
            calc(var(--hand-stack-height, 84px) + 38px) !important;
        overflow: visible !important;
    }

    #game .played-grid {
        position: absolute !important;
        top: clamp(90px, 22vh, 124px) !important;
        right: auto !important;
        bottom: 8px !important;
        left: 50% !important;
        width: min(58vw, 760px) !important;
        height: auto !important;
        margin: 0 !important;
        transform: translateX(-50%) !important;
    }

    #game .played-slot.top {
        top: 0 !important;
        right: auto !important;
        bottom: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    #game .played-slot.left {
        top: 50% !important;
        right: auto !important;
        bottom: auto !important;
        left: 0 !important;
        transform: translateY(-50%) !important;
    }

    #game .played-slot.right {
        top: 50% !important;
        right: 0 !important;
        bottom: auto !important;
        left: auto !important;
        transform: translateY(-50%) !important;
    }

    #game .played-slot.bottom {
        top: auto !important;
        right: auto !important;
        bottom: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    body.game-active .toast {
        top: auto !important;
        right: max(6px, env(safe-area-inset-right)) !important;
        bottom: max(47px, calc(env(safe-area-inset-bottom) + 42px)) !important;
        left: auto !important;
        width: max-content !important;
        max-width: min(230px, 27vw) !important;
        transform: none !important;
    }
}

/* Annotated landscape fixes: stable player text, independent tools and clear play lanes. */
#game .player-panel > .player-meta {
    display: grid !important;
    grid-template-rows: auto auto !important;
    align-content: center !important;
    justify-items: start !important;
    flex: 1 1 auto !important;
    gap: 2px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    overflow: hidden !important;
}

#game .player-panel > .player-meta > strong,
#game .player-panel > .player-meta > .player-card-count {
    position: static !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    overflow: hidden !important;
    line-height: 1.05 !important;
    text-align: left !important;
    white-space: nowrap !important;
}

#game .player-panel > .player-meta > strong {
    text-overflow: ellipsis !important;
}

#game .player-panel > .player-meta > .player-card-count {
    text-overflow: clip !important;
}

#game .side-tools.table-tools {
    position: absolute !important;
    inset: 8px 8px auto auto !important;
    z-index: 72 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 14px !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    transform: none !important;
}

#game .side-tools.table-tools > .card-tracker-toggle,
#game .side-tools.table-tools > .voice-talk-button {
    position: relative !important;
    inset: auto !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    transform: none !important;
}

#game .center-play-area {
    z-index: 30 !important;
    isolation: isolate;
    overflow: visible !important;
}

#game .played-grid {
    z-index: 31 !important;
    overflow: visible !important;
    pointer-events: none;
}

#game .played-slot {
    z-index: 32 !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
}

#game .played-slot.has-cards > .empty-zone {
    display: none !important;
}

@media (orientation: landscape) and (max-width: 1400px) and (max-height: 700px) {
    #game .my-hand-area {
        bottom: 3px !important;
    }
}

/* Keep the compact landscape table stable across desktop-mode Safari widths. */
@media (orientation: landscape) and (min-width: 1281px) and (max-width: 1400px) and (max-height: 700px) {
    #game .table-shell {
        grid-template-rows: 54px minmax(0, 1fr) 0 !important;
    }

    #game.screen.active .my-hand-area,
    #game.screen.active.has-action-buttons .my-hand-area,
    #game.screen.active:has(.action-dock .btn:not([hidden])) .my-hand-area {
        left: calc(max(5vw, calc(env(safe-area-inset-left) + 8px)) - 16px) !important;
        right: calc(max(5vw, calc(env(safe-area-inset-right) + 8px)) - 16px) !important;
        bottom: max(42px, calc(env(safe-area-inset-bottom) + 42px)) !important;
    }

    #game .center-play-area {
        inset:
            0
            max(92px, 8vw)
            calc(var(--hand-stack-height, 84px) + 96px) !important;
    }

    #game .played-grid {
        top: 136px !important;
        right: auto !important;
        bottom: auto !important;
        left: 50% !important;
        width: min(57vw, 778px) !important;
        height: 175px !important;
        transform: translateX(-50%) !important;
    }

    #game .played-slot.top {
        top: 0 !important;
        right: auto !important;
        bottom: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    #game .played-slot.left {
        top: 52% !important;
        right: auto !important;
        bottom: auto !important;
        left: 0 !important;
        transform: translateY(-50%) !important;
    }

    #game .played-slot.right {
        top: 52% !important;
        right: 0 !important;
        bottom: auto !important;
        left: auto !important;
        transform: translateY(-50%) !important;
    }

    #game .played-slot.bottom {
        top: auto !important;
        right: auto !important;
        bottom: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    #game .action-dock {
        position: absolute !important;
        z-index: 70 !important;
        right: max(6px, env(safe-area-inset-right)) !important;
        bottom: max(5px, env(safe-area-inset-bottom)) !important;
        left: auto !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 230px !important;
        min-height: 38px !important;
        height: 38px !important;
        gap: 4px !important;
        padding: 1px !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    #game .action-dock .btn {
        width: auto !important;
        min-width: 68px !important;
        height: 36px !important;
        min-height: 36px !important;
        padding: 0 8px !important;
        font-size: 12px !important;
    }

    #game .action-dock .btn.primary {
        min-width: 82px !important;
    }
}

/* Match the marked play positions on iPhone landscape, independent of hand state. */
@media (orientation: landscape) and (max-width: 940px) and (max-height: 430px) {
    #game .center-play-area {
        inset: 0 101px 0 !important;
    }

    #game .played-grid {
        top: 78px !important;
        right: auto !important;
        bottom: auto !important;
        left: 50% !important;
        width: 54vw !important;
        height: 112px !important;
        transform: translateX(-50%) !important;
    }

    #game .played-slot.left,
    #game .played-slot.right {
        top: 42% !important;
    }
}

@media (orientation: landscape) and (min-width: 1281px) and (max-width: 1400px) and (max-height: 700px) {
    body.game-active .toast {
        top: 120px !important;
        right: max(12px, env(safe-area-inset-right)) !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
    }
}

/* Standalone iOS reports side/bottom safe areas that must not shift the hand off-center. */
@media (orientation: landscape) and (max-width: 940px) and (max-height: 430px) {
    body.standalone-app #game.screen.active .my-hand-area,
    body.standalone-app #game.screen.active.has-action-buttons .my-hand-area,
    body.standalone-app #game.screen.active:has(.action-dock .btn:not([hidden])) .my-hand-area {
        left: 4vw !important;
        right: 4vw !important;
        bottom: max(40px, calc(env(safe-area-inset-bottom) + 19px)) !important;
    }

    body.standalone-app #game.screen.active .my-hand {
        bottom: 4px !important;
    }

    body.standalone-app #game.screen.active .played-slot.bottom {
        bottom: 2px !important;
    }

    body.standalone-app #game.screen.active .action-dock {
        bottom: 5px !important;
        min-height: 36px !important;
        height: 36px !important;
    }

    body.standalone-app #game.screen.active .action-dock .btn {
        height: 32px !important;
        min-height: 32px !important;
    }
}
