:root {
    color-scheme: dark;
    --ink: #f7f0dc;
    --muted: #b9b39f;
    --gold: #d8aa51;
    --gold-light: #f4d88d;
    --jade: #0c5b4c;
    --jade-deep: #06362f;
    --red: #c94b43;
    --panel: rgba(9, 27, 25, 0.88);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    background:
            radial-gradient(circle at 50% 15%, rgba(40, 127, 100, 0.28), transparent 34%),
            linear-gradient(135deg, #071a18, #020a09 70%);
}

button,
input,
select {
    font: inherit;
}

button {
    min-height: 42px;
    border: 1px solid rgba(216, 170, 81, 0.58);
    border-radius: 12px;
    padding: 9px 18px;
    color: var(--ink);
    background: linear-gradient(180deg, #295e52, #17473f);
    cursor: pointer;
    transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
    filter: brightness(1.12);
    transform: translateY(-1px);
}

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

button.primary {
    color: #241a08;
    font-weight: 800;
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
}

input,
select {
    width: 100%;
    margin-top: 8px;
    border: 1px solid rgba(244, 216, 141, 0.34);
    border-radius: 10px;
    padding: 11px 12px;
    color: var(--ink);
    outline: none;
    background: rgba(1, 12, 11, 0.72);
}

.hidden {
    display: none !important;
}

.app-shell {
    min-height: 100vh;
}

.panel {
    border: 1px solid rgba(216, 170, 81, 0.28);
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(16px);
    background: var(--panel);
}

.lobby {
    width: min(880px, calc(100% - 32px));
    margin: 5vh auto;
    border-radius: 24px;
    padding: 36px;
    text-align: center;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 72px;
    height: 96px;
    margin: 0 auto 18px;
    border: 3px solid var(--gold);
    border-radius: 10px;
    color: #161006;
    font: 900 54px/1 Georgia, serif;
    background: #f4ecd9;
    box-shadow: 0 12px 40px rgba(216, 170, 81, 0.24);
}

.eyebrow {
    margin: 0;
    color: var(--gold-light);
    font-size: 12px;
    letter-spacing: 0.24em;
}

.lobby h1 {
    margin: 8px 0 4px;
    font: 800 clamp(34px, 6vw, 56px)/1.1 "Microsoft YaHei", sans-serif;
    letter-spacing: 0.08em;
}

.subtitle {
    margin: 0 0 28px;
    color: var(--muted);
}

.lobby > label {
    display: block;
    max-width: 360px;
    margin: 0 auto 24px;
    color: var(--muted);
    text-align: left;
}

.lobby-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.lobby-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 22px;
    text-align: left;
    background: rgba(255, 255, 255, 0.035);
}

.lobby-card h2,
.lobby-card p {
    margin: 0;
}

.lobby-card p,
.lobby-card label {
    color: var(--muted);
    line-height: 1.65;
}

.join-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.join-row input {
    margin: 0;
}

.error-text {
    min-height: 24px;
    color: #ff958d;
}

.game {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.topbar {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 8px 22px;
    border-bottom: 1px solid rgba(216, 170, 81, 0.22);
    background: rgba(3, 17, 15, 0.82);
}

.mini-label {
    margin-right: 8px;
    color: var(--muted);
    font-size: 12px;
}

.network {
    color: #8be6bd;
    font-size: 13px;
}

.network::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
    background: currentColor;
}

.network.connecting {
    color: var(--gold-light);
}

.network.offline {
    color: #ff7f76;
}

.table-wrap {
    padding: 16px 16px 0;
    margin-right: 280px;
}

.table {
    position: relative;
    width: min(1020px, calc(100vw - 330px));
    min-width: 680px;
    height: min(58vh, 570px);
    margin: 0 auto;
    border: 10px solid #5a321d;
    border-radius: 42% / 18%;
    background:
            radial-gradient(circle at 50% 45%, rgba(29, 135, 103, 0.82), transparent 56%),
            linear-gradient(135deg, #0d6a56, var(--jade-deep));
    box-shadow:
            inset 0 0 90px rgba(0, 0, 0, 0.35),
            0 25px 70px rgba(0, 0, 0, 0.46);
}

.table::after {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(244, 216, 141, 0.18);
    border-radius: inherit;
    pointer-events: none;
}

.seat {
    position: absolute;
    z-index: 3;
    min-width: 130px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 9px 12px;
    text-align: center;
    background: rgba(3, 24, 21, 0.82);
}

.seat.active {
    border-color: var(--gold);
    box-shadow: 0 0 24px rgba(216, 170, 81, 0.45);
}

.seat .avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: -30px auto 5px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    color: #1d1508;
    font-weight: 900;
    background: var(--gold-light);
}

.seat .seat-name {
    font-weight: 700;
}

.seat .seat-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.seat-top {
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
}

.seat-bottom {
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
}

.seat-left {
    top: 50%;
    left: 24px;
    transform: translateY(-50%);
}

.seat-right {
    top: 50%;
    right: 24px;
    transform: translateY(-50%);
}

.center-board {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: 55%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.phase-badge {
    display: inline-block;
    border: 1px solid rgba(244, 216, 141, 0.55);
    border-radius: 99px;
    padding: 5px 13px;
    color: var(--gold-light);
    font-size: 12px;
    letter-spacing: 0.08em;
    background: rgba(0, 0, 0, 0.2);
}

.status-text {
    margin: 12px 0 8px;
    font-size: clamp(17px, 2.2vw, 25px);
    font-weight: 800;
}

.round-meta {
    color: rgba(255, 255, 255, 0.68);
    font-size: 13px;
}

.trick-area,
.public-buried > div {
    display: flex;
    min-height: 86px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.trick-group {
    display: flex;
    gap: 3px;
}

.trick-group small {
    align-self: center;
    margin-right: 3px;
    color: var(--gold-light);
}

.public-buried {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.public-buried > div {
    min-height: 56px;
    margin-top: 2px;
}

.hand-panel {
    position: fixed;
    right: 280px;
    bottom: 0;
    left: 0;
    z-index: 7;
    min-height: 190px;
    padding: 8px 18px 16px;
    text-align: center;
    background: linear-gradient(180deg, transparent, rgba(2, 11, 10, 0.92) 22%);
}

.selection-hint {
    min-height: 26px;
    color: var(--gold-light);
    font-size: 13px;
}

.hand {
    display: flex;
    height: 118px;
    align-items: flex-end;
    justify-content: center;
    padding: 0 40px;
}

.card {
    position: relative;
    display: inline-flex;
    flex: 0 0 70px;
    width: 70px;
    height: 100px;
    margin-left: -18px;
    border: 2px solid #d8d0bd;
    border-radius: 8px;
    padding: 7px;
    color: #171614;
    font: 900 21px/1 Georgia, serif;
    text-align: left;
    background: linear-gradient(145deg, #fffdf5, #e9e2d2);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
    cursor: pointer;
    user-select: none;
    transition: transform 120ms ease, border-color 120ms ease;
}

.card:first-child {
    margin-left: 0;
}

.card.red {
    color: #b72f34;
}

.card.selected {
    z-index: 4;
    border-color: var(--gold);
    transform: translateY(-18px);
}

.card.small {
    flex-basis: 39px;
    width: 39px;
    height: 56px;
    margin-left: -9px;
    border-width: 1px;
    padding: 3px;
    border-radius: 5px;
    font-size: 12px;
    cursor: default;
}

.card .suit {
    position: absolute;
    right: 7px;
    bottom: 5px;
    font-size: 28px;
}

.card.small .suit {
    right: 3px;
    bottom: 2px;
    font-size: 16px;
}

.controls {
    display: flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    flex-wrap: wrap;
}

.controls select {
    width: auto;
    min-width: 84px;
    margin: 0;
}

.event-panel {
    position: fixed;
    top: 72px;
    right: 12px;
    bottom: 12px;
    z-index: 6;
    width: 260px;
    border-radius: 16px;
    padding: 16px;
}

.event-panel h2 {
    margin: 0 0 12px;
    color: var(--gold-light);
    font-size: 15px;
}

.events {
    height: calc(100% - 34px);
    overflow: auto;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.events p {
    margin: 0;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.68);
}

.modal-card {
    width: min(460px, 100%);
    border-radius: 20px;
    padding: 28px;
    text-align: center;
}

.modal-card h2 {
    margin: 10px 0 18px;
    font-size: 30px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.score-plus {
    color: #82e6b9;
}

.score-minus {
    color: #ff9189;
}

.modal-card button {
    width: 100%;
    margin-top: 20px;
}

.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    z-index: 50;
    transform: translateX(-50%);
    border: 1px solid rgba(255, 143, 132, 0.55);
    border-radius: 12px;
    padding: 10px 18px;
    color: #ffe8e4;
    background: rgba(114, 26, 23, 0.94);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
}

@media (max-width: 980px) {
    .event-panel {
        display: none;
    }

    .table {
        width: calc(100vw - 24px);
        min-width: 640px;
    }

    .table-wrap {
        margin-right: 0;
    }

    .hand-panel {
        right: 0;
    }
}

@media (max-width: 720px) {
    .lobby {
        margin: 16px auto;
        padding: 24px 18px;
    }

    .lobby-grid {
        grid-template-columns: 1fr;
    }

    .game {
        min-width: 680px;
    }
}
