:root {
    --elder-tile-width: clamp(48px, 5.96vw, 66px);
    --elder-tile-height: clamp(72px, 11.72vh, 96px);
    --ai-discard-width: clamp(42px, 4.88vw, 54px);
    --ai-discard-height: clamp(60px, 9.11vh, 76px);
    --public-discard-tile-width: clamp(38px, 4.39vw, 49px);
    --public-discard-tile-height: clamp(54px, 8.2vh, 68px);
    --recent-discard-tile-width: clamp(50px, 5.86vw, 64px);
    --recent-discard-tile-height: clamp(76px, 10.94vh, 92px);
    --font-normal: clamp(18px, 1.95vw, 22px);
    --font-key: clamp(25px, 2.73vw, 32px);
    --hand-tile-font: clamp(22px, 2.44vw, 28px);
    --ai-tile-font: clamp(17px, 1.95vw, 21px);
    --recent-discard-tile-font: clamp(21px, 2.34vw, 27px);
    --action-button-height: clamp(58px, 8.98vh, 76px);
    --action-button-min-width: clamp(106px, 11.72vw, 136px);
    --win-button-min-width: clamp(140px, 15.23vw, 170px);
    --hand-gap: clamp(2px, 0.35vw, 5px);
    --missing-suit-gap: clamp(10px, 1.56vw, 22px);
    --button-gap: clamp(8px, 1.37vw, 18px);
    --discard-gap: clamp(3px, 0.39vw, 5px);
    --table-edge-inset: clamp(6px, 0.98vw, 14px);
    --table-border-width: clamp(6px, 0.78vw, 10px);
    --player-panel-height: clamp(296px, 41.93vh, 326px);
    --player-panel-bottom: clamp(6px, 1.04vh, 10px);
    --player-panel-padding-x: clamp(8px, 1.17vw, 16px);
    --player-panel-padding-y: clamp(6px, 1.04vh, 10px);
    --player-discard-gap: clamp(5px, 0.78vh, 10px);
    --player-clearance: calc(var(--player-panel-height) + var(--player-panel-bottom) + var(--player-discard-gap));
    --hand-marker-clearance: clamp(34px, 5.21vh, 40px);
    --hand-area-height: calc(var(--elder-tile-height) + var(--hand-marker-clearance));
    --action-area-height: calc(var(--action-button-height) + 6px);
    --recent-discards-width: clamp(278px, 32vw, 350px);
    --recent-discards-height: clamp(118px, 17.19vh, 132px);
    --side-seat-width: clamp(126px, 13.2vw, 145px);
    --side-public-gap: clamp(12px, 1.37vw, 16px);
    --side-public-offset: calc(var(--table-edge-inset) + var(--side-seat-width) + var(--side-public-gap));
    --top-meld-area-height: clamp(62px, 8.85vh, 68px);
    --side-meld-area-height: clamp(128px, 18.75vh, 150px);
    --human-meld-area-height: clamp(66px, 9.38vh, 72px);
    --public-area-separation: clamp(10px, 1.17vw, 14px);
    --public-area-frame-extra: 34px;
    --top-public-area-height: calc(var(--public-discard-tile-height) + var(--top-meld-area-height) + var(--public-area-frame-extra));
    --side-public-area-height: calc(2 * var(--public-discard-tile-height) + var(--discard-gap) + var(--side-meld-area-height) + var(--public-area-frame-extra) + 2px);
    --human-public-area-height: calc(var(--public-discard-tile-height) + var(--public-area-frame-extra));
    --dingque-button-min-width: clamp(136px, 15.63vw, 180px);
    --dingque-button-height: clamp(70px, 10.68vh, 92px);
    --dingque-button-gap: clamp(14px, 2.15vw, 28px);
    --minimum-landscape-width: 760px;
    --minimum-landscape-height: 560px;
    --table-green: #0b563e;
    --table-green-dark: #073c2d;
    --cream: #fffdf2;
    --ink: #17201d;
    --gold: #f0c75e;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background: #173329;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: var(--font-normal);
    -webkit-text-size-adjust: 100%;
}

button {
    font: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

button:focus {
    outline: 4px solid #ffe493;
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-width: var(--minimum-landscape-width);
    min-height: var(--minimum-landscape-height);
    padding: var(--safe-area-top) var(--safe-area-right) var(--safe-area-bottom) var(--safe-area-left);
}

.mahjong-table {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background-color: var(--table-green);
    background-image: linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 24px 24px;
    border: var(--table-border-width) solid var(--table-green-dark);
    box-shadow: inset 0 0 0 2px #347a63;
}

.table-hud {
    position: absolute;
    z-index: 8;
    top: var(--table-edge-inset);
    right: var(--table-edge-inset);
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 3px;
    max-width: clamp(210px, 29vw, 340px);
    padding: clamp(5px, 0.78vh, 7px) clamp(8px, 0.98vw, 12px);
    border: 2px solid #cfe4da;
    border-radius: 8px;
    background: rgba(6, 49, 36, 0.92);
    text-align: right;
}

.table-hud strong {
    color: #fff1bd;
    font-size: clamp(17px, 1.86vw, 21px);
}

.table-hud span {
    color: #ffffff;
    font-size: clamp(15px, 1.56vw, 18px);
    font-weight: 700;
}

.seat {
    position: absolute;
    z-index: 2;
    min-width: clamp(112px, 12.5vw, 148px);
    padding: clamp(4px, 0.65vh, 6px) clamp(8px, 0.98vw, 12px);
    border: 2px solid #d6eadf;
    border-radius: 8px;
    background: #093f30;
    text-align: center;
}

.seat strong {
    display: block;
    font-size: clamp(19px, 2.05vw, 23px);
}

.seat span {
    display: block;
    margin-top: 1px;
    font-size: clamp(13px, 1.37vw, 16px);
    font-weight: 700;
    white-space: nowrap;
}

.seat .seat-score {
    color: #ffe28c;
    font-size: clamp(17px, 1.76vw, 20px);
}

.seat.is-hu {
    border: 4px solid var(--gold);
}

.seat-top {
    top: var(--table-edge-inset);
    left: 20%;
    transform: translateX(-50%);
}

.seat-left {
    top: 43%;
    left: var(--table-edge-inset);
    width: var(--side-seat-width);
    min-width: 0;
    transform: translateY(-50%);
}

.seat-right {
    top: 43%;
    right: var(--table-edge-inset);
    width: var(--side-seat-width);
    min-width: 0;
    transform: translateY(-50%);
}

.player-public-area {
    position: absolute;
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: clamp(4px, 0.49vw, 6px);
    border: 1px solid rgba(227, 244, 235, 0.45);
    border-radius: 7px;
    background: rgba(5, 52, 38, 0.52);
}

.public-area-heading {
    flex: 0 0 auto;
    min-height: 18px;
    text-align: center;
}

.player-public-area h2 {
    flex: 0 0 auto;
    margin: 0;
    color: #ffffff;
    font-size: clamp(14px, 1.46vw, 17px);
    text-align: center;
    white-space: nowrap;
}

.public-area-top {
    top: var(--table-edge-inset);
    left: 50%;
    width: calc(6 * var(--public-discard-tile-width) + 5 * var(--discard-gap) + 12px);
    height: var(--top-public-area-height);
    transform: translateX(-50%);
}

.public-area-top .meld-area {
    flex-basis: var(--top-meld-area-height);
}

.public-area-top .discard-grid {
    grid-template-columns: repeat(6, var(--public-discard-tile-width));
}

.public-area-left {
    top: calc(var(--table-edge-inset) + var(--top-public-area-height) + var(--public-area-separation));
    left: var(--side-public-offset);
    width: calc(3 * var(--public-discard-tile-width) + 2 * var(--discard-gap) + 12px);
    height: var(--side-public-area-height);
}

.public-area-right {
    top: calc(var(--table-edge-inset) + var(--top-public-area-height) + var(--public-area-separation));
    right: var(--side-public-offset);
    width: calc(3 * var(--public-discard-tile-width) + 2 * var(--discard-gap) + 12px);
    height: var(--side-public-area-height);
}

.player-public-area-side .meld-area {
    flex-basis: var(--side-meld-area-height);
}

.public-area-player {
    bottom: var(--player-clearance);
    left: 50%;
    width: calc(6 * var(--public-discard-tile-width) + 5 * var(--discard-gap) + 12px);
    height: var(--human-public-area-height);
    transform: translateX(-50%);
}

.discard-area {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding-top: 4px;
    cursor: pointer;
    touch-action: manipulation;
}

.discard-area:focus {
    outline: 3px solid #ffe493;
    outline-offset: -3px;
}

.discard-grid {
    display: grid;
    grid-template-columns: repeat(3, var(--public-discard-tile-width));
    gap: var(--discard-gap);
    align-content: start;
}

.discard-grid-wide {
    grid-template-columns: repeat(6, var(--public-discard-tile-width));
}

.meld-area {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(227, 244, 235, 0.32);
}

.meld-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: clamp(3px, 0.49vw, 6px);
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.meld-list:empty {
    display: none;
}

.player-public-area-side .meld-group {
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 0 2px;
    border-width: 2px;
}

.player-public-area-side .meld-type {
    min-width: 0;
    font-size: clamp(13px, 1.37vw, 15px);
    line-height: 1;
}

.player-public-area-side .meld-list,
.public-area-top .meld-list {
    display: grid;
    overflow: visible;
}

.player-public-area-side .meld-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
}

.public-area-top .meld-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
}

.public-area-top .meld-group {
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 0 2px;
    border-width: 2px;
}

.public-area-top .meld-type {
    min-width: 0;
}

.meld-group {
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 0;
    padding: 0 2px;
    border: 2px solid #f1d579;
    border-radius: 7px;
    background: #102f27;
    white-space: nowrap;
}

.meld-type {
    min-width: 0;
    color: #ffffff;
    font-size: clamp(14px, 1.46vw, 17px);
    line-height: 1;
}

.meld-meta {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: clamp(2px, 0.29vw, 4px);
    width: 100%;
    min-width: 0;
    line-height: 1;
}

.meld-tile {
    width: clamp(28px, 3.13vw, 34px);
    height: clamp(38px, 5.73vh, 46px);
    border-width: 2px;
    border-radius: 4px;
    font-size: clamp(13px, 1.46vw, 16px);
    box-shadow: 0 2px 0 #aaa58e;
}

.meld-count {
    color: #fff1bd;
    font-size: clamp(14px, 1.46vw, 17px);
    line-height: 1;
}

.meld-peng {
    border-style: solid;
}

.meld-ming-gang {
    border-color: #8fd7ff;
    border-style: double;
}

.meld-an-gang {
    border-color: #f4a6ca;
    border-style: dashed;
}

.meld-bu-gang {
    border-color: #b9ec9a;
    box-shadow: inset 0 0 0 2px #315b35;
}

.mahjong-tile {
    display: flex;
    position: relative;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 2px solid #c9c4ad;
    border-radius: 6px;
    background: var(--cream);
    box-shadow: 0 3px 0 #aaa58e;
    color: var(--ink);
    font-weight: 800;
    line-height: 1;
    text-align: center;
}

.tile-face {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
}

.tile-sprite-definitions {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.tile-text-fallback {
    pointer-events: none;
}

.discard-tile {
    width: var(--public-discard-tile-width);
    height: var(--public-discard-tile-height);
    font-size: var(--ai-tile-font);
}

.discard-tile.is-latest {
    border: 4px solid var(--gold);
    box-shadow: 0 0 0 2px #2e2410, 0 3px 0 #aaa58e;
}

.recent-discards-panel {
    position: absolute;
    z-index: 3;
    top: calc(var(--table-edge-inset) + var(--top-public-area-height) + var(--public-area-separation));
    left: 50%;
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    gap: clamp(4px, 0.65vh, 7px);
    width: var(--recent-discards-width);
    height: var(--recent-discards-height);
    padding: clamp(7px, 1.04vh, 10px);
    overflow: hidden;
    transform: translateX(-50%);
    border: 2px solid rgba(244, 212, 119, 0.72);
    border-radius: 12px;
    background: rgba(8, 62, 47, 0.86);
    text-align: center;
}

.recent-discards-panel h2 {
    margin: 0;
    color: #fff1bd;
    font-size: clamp(18px, 1.95vw, 22px);
}

.recent-discards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(5px, 0.78vw, 9px);
    width: 100%;
}

.recent-discard-card {
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.recent-discard-card strong {
    color: #ffffff;
    font-size: clamp(15px, 1.66vw, 19px);
    font-weight: 800;
    white-space: nowrap;
}

.recent-discard-tile {
    width: var(--recent-discard-tile-width);
    height: var(--recent-discard-tile-height);
    font-size: var(--recent-discard-tile-font);
}

.recent-discard-tile.is-current {
    border: 4px solid var(--gold);
    box-shadow: 0 0 0 2px #2e2410, 0 3px 0 #aaa58e;
}

.recent-discard-tile.is-empty {
    border-style: dashed;
    background: rgba(255, 253, 242, 0.78);
    color: #365148;
}

.player-panel {
    position: absolute;
    z-index: 5;
    right: var(--table-edge-inset);
    bottom: var(--player-panel-bottom);
    left: var(--table-edge-inset);
    height: var(--player-panel-height);
    display: grid;
    grid-template-rows: auto var(--human-meld-area-height) var(--hand-area-height) var(--action-area-height);
    padding: var(--player-panel-padding-y) var(--player-panel-padding-x);
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
}

.human-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: clamp(5px, 0.78vw, 9px);
    min-height: clamp(24px, 3.39vh, 28px);
    color: #ffffff;
    font-size: clamp(14px, 1.46vw, 17px);
    font-weight: 750;
}

.human-summary > span {
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(3, 35, 26, 0.82);
}

.human-summary #human-score {
    color: #ffe28c;
    font-size: clamp(18px, 1.95vw, 22px);
}

.human-meld-list {
    align-items: center;
    flex-wrap: nowrap;
    width: clamp(292px, 34vw, 380px);
    height: 100%;
    margin: 0 auto;
    overflow: visible;
}

.human-meld-area {
    height: var(--human-meld-area-height);
    min-height: var(--human-meld-area-height);
    overflow: visible;
    padding: 0;
    border: 0;
}

.human-meld-list .meld-group {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 0;
    max-width: 84px;
    padding: 0 2px;
    border-width: 2px;
}

.human-meld-list .meld-type {
    min-width: 0;
}

.hand-layout {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: var(--hand-area-height);
    margin-top: 0;
}

.normal-hand,
.missing-hand {
    display: flex;
    align-items: flex-start;
    gap: var(--hand-gap);
}

.normal-hand {
    padding-top: clamp(15px, 2.21vh, 19px);
}

.hand-tile {
    width: var(--elder-tile-width);
    height: var(--elder-tile-height);
    padding: 0;
    font-size: var(--hand-tile-font);
    cursor: pointer;
    touch-action: manipulation;
    pointer-events: auto;
}

.hand-tile:disabled {
    opacity: 1;
    cursor: default;
}

.hand-tile:not(:disabled) {
    border-color: #fff0a8;
    box-shadow: 0 0 0 2px #234c3c, 0 3px 0 #aaa58e;
}

.hand-tile:not(:disabled):active {
    transform: translateY(3px);
}

.hand-tile.is-new {
    border-color: #a93423;
    outline: 2px solid #a93423;
    outline-offset: 1px;
    box-shadow: 0 0 0 1px rgba(255, 188, 151, 0.42), 0 3px 0 #8f8a76;
    animation: new-tile-border-breathe 2.4s ease-in-out infinite;
}

.hand-tile.is-new::before {
    content: "";
    position: absolute;
    top: -13px;
    left: 50%;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border-top: 10px solid #b53b27;
    border-right: 7px solid transparent;
    border-left: 7px solid transparent;
    pointer-events: none;
}

@keyframes new-tile-border-breathe {
    0%,
    100% {
        border-color: #a93423;
        outline-color: #a93423;
        box-shadow: 0 0 0 1px rgba(255, 188, 151, 0.42), 0 3px 0 #8f8a76;
    }

    50% {
        border-color: #e55b3f;
        outline-color: #e55b3f;
        box-shadow: 0 0 0 3px rgba(255, 204, 167, 0.58), 0 3px 0 #8f8a76;
    }
}

.missing-separator {
    flex: 0 0 var(--missing-suit-gap);
    height: var(--elder-tile-height);
    margin: clamp(15px, 2.21vh, 19px) clamp(5px, 0.78vw, 10px) 0;
    border-right: 3px dashed #ffe28c;
    border-left: 3px dashed #ffe28c;
}

.missing-hand-zone {
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 2px;
    padding-top: clamp(15px, 2.21vh, 19px);
}

.missing-zone-label {
    min-width: clamp(118px, 12.5vw, 148px);
    padding: 2px clamp(5px, 0.68vw, 8px);
    border-radius: 5px;
    background: #332600;
    color: #fff0a8;
    font-size: clamp(14px, 1.46vw, 17px);
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
}

.missing-tile {
    border-color: #d9b83d;
    background: #fff8d7;
}

.action-area {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--action-area-height);
    margin-top: 2px;
}

.action-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--button-gap);
}

.action-button {
    min-width: var(--action-button-min-width);
    height: var(--action-button-height);
    padding: clamp(5px, 0.78vh, 7px) clamp(12px, 1.76vw, 20px);
    border: 4px solid #ffffff;
    border-radius: 11px;
    background: #f3f0df;
    color: #17201d;
    font-size: clamp(27px, 3.03vw, 34px);
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 0 #2a372f;
    pointer-events: auto;
}

.action-button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #2a372f;
}

.win-button {
    min-width: var(--win-button-min-width);
    background: #b82929;
    color: #ffffff;
    border-color: #fff1a8;
    box-shadow: 0 0 0 4px #4c0e0e, 0 4px 0 #2a372f;
}

.pass-button {
    border-color: #d6ded9;
    background: #e8ecea;
    color: #29342f;
}

.action-peng,
.action-ming-gang,
.action-an-gang,
.action-bu-gang {
    border-color: #fff2b0;
    background: #ffd86f;
    box-shadow: 0 0 0 2px #493a0d, 0 4px 0 #2a372f;
}

#table-status.is-hu-opportunity {
    padding: 4px 9px;
    border: 3px solid #fff1a8;
    border-radius: 7px;
    background: #9e2020;
    font-size: clamp(19px, 2.05vw, 23px);
}

.modal-backdrop {
    position: fixed;
    z-index: 20;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 3.13vh, 30px);
    background: rgba(0, 0, 0, 0.7);
}

.discard-history-dialog {
    width: min(760px, 92vw);
    max-height: calc(100vh - 32px);
    padding: clamp(18px, 2.86vh, 28px);
    overflow-y: auto;
    border: 4px solid #f0cb63;
    border-radius: 16px;
    background: #0c4a37;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.discard-history-dialog h2 {
    margin: 0;
    color: #fff1bd;
    font-size: clamp(30px, 3.32vw, 40px);
}

.discard-history-dialog p {
    margin: 7px 0 12px;
    font-size: clamp(18px, 1.95vw, 22px);
    font-weight: 750;
}

.discard-history-list {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(5px, 0.78vw, 9px);
    max-height: 50vh;
    padding: 8px;
    overflow-y: auto;
    border: 2px solid rgba(227, 244, 235, 0.55);
    border-radius: 10px;
    background: rgba(5, 43, 32, 0.72);
}

.discard-history-list .discard-tile {
    width: var(--recent-discard-tile-width);
    height: var(--recent-discard-tile-height);
}

.discard-history-close {
    min-width: clamp(150px, 17vw, 190px);
    min-height: clamp(58px, 8.33vh, 70px);
    margin-top: 14px;
    border: 4px solid #ffffff;
    border-radius: 11px;
    background: #f0c75e;
    color: #17201d;
    font-size: clamp(25px, 2.73vw, 31px);
    font-weight: 900;
    cursor: pointer;
}

.dingque-dialog {
    width: min(700px, 92vw);
    padding: clamp(22px, 3.65vh, 32px);
    border: 4px solid #f0cb63;
    border-radius: 16px;
    background: #0c4a37;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.dingque-dialog h2 {
    margin: 0;
    font-size: clamp(32px, 3.52vw, 40px);
}

.dingque-buttons {
    display: flex;
    justify-content: center;
    gap: var(--dingque-button-gap);
    margin-top: clamp(20px, 3.39vh, 30px);
}

.dingque-buttons button {
    min-width: var(--dingque-button-min-width);
    min-height: var(--dingque-button-height);
    border: 4px solid #ffffff;
    border-radius: 12px;
    background: #ffe291;
    color: #17201d;
    font-size: clamp(28px, 3.03vw, 34px);
    font-weight: 850;
    cursor: pointer;
}

.dingque-buttons button:active {
    background: #f2c956;
}

.end-game-dialog {
    width: min(660px, 92vw);
    max-height: calc(100vh - 32px);
    padding: clamp(22px, 3.65vh, 34px);
    overflow-y: auto;
    border: 4px solid #f0cb63;
    border-radius: 16px;
    background: #0c4a37;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.human-round-summary {
    width: min(520px, 84vw);
    margin: 10px auto 14px;
    padding: 10px 16px;
    border: 2px solid rgba(255, 241, 189, 0.72);
    border-radius: 10px;
    background: rgba(5, 43, 32, 0.78);
}

.human-round-summary h3 {
    margin: 0;
    color: #fff1bd;
    font-size: clamp(28px, 3.13vw, 36px);
}

.end-game-summary-lines p {
    margin: 5px 0;
    font-size: clamp(18px, 1.95vw, 22px);
}

.end-game-score-label {
    display: block;
    margin-top: 8px;
    color: #ffffff;
    font-size: clamp(17px, 1.86vw, 21px);
    font-weight: 800;
}

.end-game-human-score {
    display: block;
    margin-top: 1px;
    font-size: clamp(38px, 4.3vw, 50px);
    line-height: 1.05;
}

.score-positive,
.final-score-row strong.score-positive {
    color: #ffe28c;
}

.score-negative,
.final-score-row strong.score-negative {
    color: #ffc5b6;
}

.score-zero,
.final-score-row strong.score-zero {
    color: #ffffff;
}

.settlement-details {
    width: min(560px, 84vw);
    margin: 12px auto;
    padding: 10px;
    border: 2px solid rgba(255, 226, 140, 0.72);
    border-radius: 10px;
    background: rgba(5, 43, 32, 0.72);
    text-align: left;
}

.settlement-details > h3 {
    margin: 0 0 8px;
    color: #fff1bd;
    text-align: center;
}

.settlement-detail-group + .settlement-detail-group {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid rgba(255, 255, 255, 0.28);
}

.settlement-detail-group h4 {
    margin: 0 0 5px;
    color: #ffe28c;
    font-size: clamp(20px, 2.15vw, 25px);
}

.settlement-detail-row {
    display: grid;
    grid-template-columns: minmax(54px, auto) 1fr;
    gap: 9px;
    padding: 4px 0;
    font-size: clamp(17px, 1.86vw, 21px);
    line-height: 1.25;
}

.settlement-detail-row strong {
    color: #ffffff;
}

.settlement-detail-empty {
    margin: 5px 0 !important;
    color: #ffffff;
    font-size: clamp(17px, 1.86vw, 21px) !important;
}

.end-game-dialog h2 {
    margin: 0;
    color: #fff1bd;
    font-size: clamp(34px, 3.71vw, 44px);
}

.end-game-dialog p {
    margin: clamp(8px, 1.3vh, 12px) 0;
    font-size: clamp(20px, 2.15vw, 25px);
    font-weight: 750;
}

.final-score-list {
    width: min(360px, 80vw);
    margin: clamp(14px, 2.08vh, 20px) auto;
}

.final-score-row {
    display: flex;
    justify-content: space-between;
    padding: clamp(6px, 0.91vh, 9px) clamp(12px, 1.56vw, 18px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    font-size: clamp(22px, 2.44vw, 28px);
}

.final-score-row strong {
    color: #ffe28c;
}

.end-game-note {
    color: #ffffff;
}

.table-hud .session-restart-button {
    min-height: 44px;
    margin-top: 3px;
    padding: 5px 12px;
    border: 2px solid #d6e5de;
    border-radius: 7px;
    background: #274f42;
    color: #ffffff;
    font-size: clamp(14px, 1.46vw, 17px);
    font-weight: 750;
    cursor: pointer;
}

.end-game-dialog {
    max-height: calc(100vh - 24px);
    overflow-y: auto;
}

.end-game-dialog h3 {
    margin: clamp(9px, 1.3vh, 12px) 0 0;
    color: #ffffff;
    font-size: clamp(21px, 2.34vw, 27px);
}

.session-total-summary {
    width: min(390px, 82vw);
    margin: clamp(8px, 1.3vh, 12px) auto;
    padding: clamp(7px, 1.04vh, 10px) clamp(12px, 1.56vw, 18px);
    border: 2px solid rgba(255, 226, 140, 0.72);
    border-radius: 9px;
    background: rgba(5, 43, 32, 0.72);
}

.session-total-summary p {
    margin: 4px 0;
    font-size: clamp(18px, 1.95vw, 22px);
}

#human-cumulative-score {
    color: #ffe28c;
}

.end-game-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(12px, 1.76vw, 20px);
    margin-top: clamp(12px, 1.82vh, 17px);
}

.next-hand-button,
.end-restart-button {
    min-height: clamp(58px, 8.33vh, 70px);
    padding: 8px clamp(20px, 2.73vw, 30px);
    border-radius: 11px;
    font-size: clamp(24px, 2.73vw, 31px);
    font-weight: 900;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    .hand-tile.is-new {
        animation: none;
    }
}

.next-hand-button {
    min-width: clamp(170px, 19.53vw, 220px);
    border: 4px solid #fff1a8;
    background: #f0c75e;
    color: #17201d;
    box-shadow: 0 4px 0 #2a372f;
}

.end-restart-button {
    min-width: clamp(120px, 13.67vw, 150px);
    border: 3px solid #d6ded9;
    background: #e8ecea;
    color: #29342f;
    font-size: clamp(18px, 2.05vw, 23px);
}
