:root {
  color-scheme: light;
  --bg: #f4efe3;
  --panel: #fff8ec;
  --panel-2: #efe5cf;
  --felt: #0f5a43;
  --felt-dark: #0a3f31;
  --tile: #fff8ea;
  --tile-edge: #d7c59b;
  --ink: #17352a;
  --muted: #6e7b72;
  --gold: #c9952c;
  --red: #c64f3f;
  --green: #1b8c62;
  --blue: #255f9f;
  --line: rgba(23, 53, 42, 0.14);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(244, 239, 227, 0.86), rgba(244, 239, 227, 0.98)),
    radial-gradient(circle at center, #d9eadf 0, var(--bg) 58%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f3ea;
  color: var(--ink);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: rgba(240, 189, 93, 0.6);
}

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

button.primary {
  border: 0;
  background: linear-gradient(135deg, #155b47, #d8a33a);
  color: white;
  font-weight: 700;
}

button.ghost {
  border: 1px solid rgba(23, 53, 42, 0.16);
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
}

button.ghost:hover {
  background: rgba(21, 91, 71, 0.1);
  color: var(--ink);
  border-color: rgba(21, 91, 71, 0.45);
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  grid-template-areas:
    "home home"
    "side table";
  min-height: 100vh;
}

body.game-view .app-shell {
  grid-template-areas: "side table";
}

.site-home {
  grid-area: home;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(520px, 1fr) auto auto;
  gap: 28px;
  padding: 22px clamp(20px, 5vw, 72px) 36px;
  background:
    linear-gradient(135deg, rgba(21, 91, 71, 0.12), transparent 34%),
    radial-gradient(circle at 82% 22%, rgba(201, 149, 44, 0.16), transparent 24%),
    linear-gradient(180deg, rgba(248, 243, 232, 0.98), rgba(240, 234, 221, 0.98));
  border-bottom: 1px solid var(--line);
}

.site-nav,
.nav-actions,
.hero-actions,
.feature-band,
.panel-title-row,
.manual-wallet,
.account-actions,
.wallet-line,
.credit-line,
.holding-line,
.record-row {
  display: flex;
  align-items: center;
}

.site-nav {
  justify-content: space-between;
  gap: 18px;
}

.nav-actions,
.hero-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.account-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(21, 91, 71, 0.2);
  border-radius: 999px;
  color: var(--green);
  background: rgba(21, 91, 71, 0.08);
  font-size: 13px;
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(300px, 0.75fr);
  align-items: center;
  gap: clamp(28px, 6vw, 86px);
}

.hero-copy {
  display: grid;
  gap: 18px;
  max-width: 680px;
}

.eyebrow {
  color: var(--gold);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.hero-copy h2 {
  color: #153a2d;
  font-size: clamp(42px, 7vw, 84px);
  line-height: 1;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 620px;
  color: #4f5f57;
  font-size: 17px;
  line-height: 1.8;
}

.hero-table {
  position: relative;
  min-height: 430px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(circle at center, rgba(26, 118, 82, 0.95), rgba(9, 48, 37, 0.96) 72%),
    #0b3f31;
  box-shadow: inset 0 0 0 12px rgba(0, 0, 0, 0.2), 0 30px 70px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.table-glow {
  position: absolute;
  inset: 18%;
  border: 1px dashed rgba(240, 189, 93, 0.35);
  border-radius: 999px;
}

.hero-tile {
  position: absolute;
  width: 108px;
  height: 152px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.hero-tile.wan {
  left: 20%;
  top: 34%;
  transform: rotate(-10deg);
}

.hero-tile.tong {
  left: 43%;
  top: 24%;
  transform: rotate(7deg);
}

.hero-tile.tiao {
  right: 18%;
  bottom: 24%;
  transform: rotate(13deg);
}

.hero-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.38));
}

.feature-band {
  justify-content: space-between;
  gap: 14px;
}

.feature-band article {
  display: grid;
  gap: 6px;
  min-height: 96px;
  flex: 1;
  padding: 18px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.feature-band strong {
  color: #17352a;
}

.feature-band span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.rules-section {
  display: grid;
  grid-template-columns: minmax(240px, 0.45fr) minmax(0, 1fr);
  gap: clamp(18px, 4vw, 42px);
  align-items: start;
  padding: 22px 0 6px;
  border-top: 1px solid var(--line);
}

.rules-heading {
  display: grid;
  gap: 10px;
}

.rules-heading h2 {
  color: #153a2d;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.1;
}

.rules-heading p {
  color: #4f5f57;
  font-size: 15px;
  line-height: 1.8;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.rules-grid article {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  border: 1px solid rgba(23, 53, 42, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.rules-grid strong {
  color: #153a2d;
  font-size: 18px;
}

.rules-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.side-panel {
  grid-area: side;
  border-right: 1px solid var(--line);
  background: rgba(252, 248, 239, 0.96);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.table-wrap {
  grid-area: table;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #155b47, #d8a33a);
  color: white;
  font-size: 26px;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.16);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}

.brand p,
.hint {
  margin-top: 4px;
  color: #66756c;
  font-size: 13px;
}

.panel-block {
  display: grid;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.panel-title-row {
  justify-content: space-between;
}

.account-auth,
.account-card {
  display: grid;
  gap: 10px;
}

.auth-fields {
  display: grid;
  gap: 8px;
}

.auth-actions {
  margin: 0;
}

.manual-wallet,
.account-actions {
  gap: 8px;
}

.manual-wallet input,
.account-actions input {
  min-width: 0;
}

.manual-wallet button,
.account-actions button {
  flex: 0 0 auto;
  padding: 0 12px;
}

.account-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.wallet-line,
.credit-line,
.holding-line,
.record-row {
  justify-content: space-between;
  gap: 10px;
}

.wallet-line span,
.credit-line span,
.holding-line span {
  color: var(--muted);
  font-size: 13px;
}

.wallet-line strong {
  color: #163d2f;
  font-size: 13px;
  min-width: 0;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.credit-line strong {
  color: var(--green);
  font-size: 24px;
}

.account-records {
  display: grid;
  gap: 6px;
  max-height: 116px;
  overflow: auto;
}

.record-row {
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(21, 91, 71, 0.06);
  color: var(--muted);
  font-size: 12px;
}

.record-row strong {
  color: var(--green);
}

.record-row span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.record-row small {
  color: #819488;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 190px;
}

.admin-toolbar {
  display: flex;
  gap: 8px;
}

.admin-toolbar select {
  flex: 1;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  background: #fffdf8;
  color: var(--ink);
}

.admin-request-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.admin-request-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(201, 149, 44, 0.22);
  border-radius: 8px;
  background: rgba(201, 149, 44, 0.06);
}

.admin-request-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-request-main strong {
  color: #305546;
}

.admin-request-main span,
.admin-request-main small {
  color: var(--muted);
  font-size: 12px;
}

.admin-request-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.admin-request-actions button.approve {
  background: #1b8c62;
  border-color: #1b8c62;
}

.admin-request-actions button.decline {
  background: #c64f3f;
  border-color: #c64f3f;
}

.admin-request-actions button.approve,
.admin-request-actions button.decline {
  color: #fff;
}

.admin-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(244, 239, 227, 0.94), rgba(244, 239, 227, 1)),
    radial-gradient(circle at 18% 12%, rgba(21, 91, 71, 0.16), transparent 28%),
    radial-gradient(circle at 86% 20%, rgba(201, 149, 44, 0.15), transparent 24%);
}

.admin-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
  display: grid;
  gap: 18px;
}

.admin-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 0;
}

.admin-back {
  order: 2;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.7);
}

.admin-login-panel,
.admin-summary,
.admin-page .admin-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 236, 0.9);
  box-shadow: 0 18px 40px rgba(23, 53, 42, 0.08);
}

.admin-login-panel {
  width: min(430px, 100%);
}

.admin-dashboard {
  display: grid;
  gap: 18px;
}

.admin-page .admin-request-list {
  max-height: 58vh;
}

.admin-page .admin-request-row {
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.66);
}

.admin-page .admin-request-main span,
.admin-page .admin-request-main small {
  font-size: 13px;
}

.profile-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 0 6px;
}

.profile-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.profile-copy strong {
  font-size: 18px;
  color: #17352a;
}

.profile-copy span {
  color: var(--green);
  font-weight: 700;
}

.profile-copy small {
  color: var(--muted);
}

.profile-avatar,
.seat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fffaf1;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}

.profile-avatar {
  font-size: 18px;
}

.seat-avatar {
  width: 34px;
  height: 34px;
  font-size: 14px;
}

.avatar-jade { background: linear-gradient(135deg, #185d48, #3ca06e); }
.avatar-amber { background: linear-gradient(135deg, #ac6a16, #d8a33a); }
.avatar-crimson { background: linear-gradient(135deg, #93302d, #da6556); }
.avatar-azure { background: linear-gradient(135deg, #255f9f, #69a3e1); }
.avatar-plum { background: linear-gradient(135deg, #6d4a9d, #b271d1); }
.avatar-ivory { background: linear-gradient(135deg, #8d8d7f, #d9d1b8); color: #17352a; }
.avatar-ink { background: linear-gradient(135deg, #1f2c36, #41546a); }
.avatar-gold { background: linear-gradient(135deg, #9b6a17, #f0ca63); color: #17352a; }

.seat-main,
.player-name-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-subline {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.account-tools {
  flex-wrap: wrap;
}

.account-tools button {
  flex: 1;
  min-width: 0;
}

.modal-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.profile-modal-card,
.ledger-modal-card,
.funds-modal-card {
  width: min(760px, calc(100vw - 32px));
  color: #17352a;
}

.profile-modal-body,
.funds-panel {
  display: grid;
  gap: 14px;
}

.profile-preview {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(21, 91, 71, 0.08);
}

.profile-preview-copy {
  display: grid;
  gap: 4px;
}

.profile-preview-copy strong {
  font-size: 20px;
}

.profile-preview-copy span {
  color: var(--green);
  font-weight: 700;
}

.profile-preview-copy small {
  color: var(--muted);
}

.avatar-pick {
  display: grid;
  gap: 10px;
}

.avatar-pick-label {
  color: var(--muted);
  font-size: 14px;
}

.avatar-preset-list {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.avatar-choice {
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(23, 53, 42, 0.18);
  background: #fffaf1;
  color: #17352a;
  font-weight: 700;
}

.avatar-choice.selected {
  border-color: rgba(21, 91, 71, 0.8);
  box-shadow: inset 0 0 0 2px rgba(21, 91, 71, 0.12);
}

.ledger-summary,
.funds-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ledger-summary > div,
.funds-metrics > div {
  padding: 14px;
  border-radius: 10px;
  background: rgba(21, 91, 71, 0.08);
}

.ledger-summary span,
.funds-metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.ledger-summary strong,
.funds-metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  color: #17352a;
}

.ledger-tabs,
.funds-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ledger-tabs button,
.funds-tabs button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: #f7f3ea;
}

.ledger-tabs button.active,
.funds-tabs button.active {
  background: #155b47;
  color: #fff;
}

.ledger-list {
  display: grid;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
}

.ledger-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 53, 42, 0.08);
}

.ledger-row strong {
  color: #17352a;
}

.ledger-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.ledger-row-right {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.ledger-row-right .pos {
  color: var(--green);
}

.ledger-row-right .neg {
  color: var(--red);
}

.funds-hint,
.funds-notice {
  color: var(--muted);
  line-height: 1.6;
}

.funds-recharge-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid rgba(201, 149, 44, 0.18);
  background: rgba(201, 149, 44, 0.08);
}

.funds-recharge-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.funds-recharge-label {
  color: #17352a;
  font-size: 14px;
  font-weight: 700;
}

.funds-copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  gap: 8px;
}

.funds-copy-row input {
  min-width: 0;
  font-size: 13px;
}

.copy-btn {
  padding: 0 10px;
  white-space: nowrap;
}

.funds-copy-tip {
  color: #7a5d14;
  font-size: 13px;
}

.funds-notice {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(201, 149, 44, 0.12);
  color: #7a5d14;
}

.consent-banner {
  margin-top: 4px;
  padding: 10px 12px;
  background: rgba(255, 196, 0, 0.12);
  border: 1px solid rgba(255, 196, 0, 0.45);
  border-radius: 8px;
  font-size: 13px;
  color: #ffe7b0;
  display: grid;
  gap: 8px;
}
.consent-banner .consent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.consent-banner .consent-tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}
.consent-banner .consent-tag.ok {
  background: rgba(120, 220, 120, 0.18);
  color: #b5f1b5;
}
.consent-banner .consent-tag.need {
  background: rgba(255, 196, 0, 0.18);
  color: #ffd57a;
}
.consent-banner .consent-actions {
  display: flex;
  gap: 8px;
}
.consent-banner button {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
}
.consent-banner button.approve {
  background: #2f9e44;
  color: #fff;
}
.consent-banner button.decline {
  background: #c92a2a;
  color: #fff;
}

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

.base-score-field {
  display: grid;
  gap: 7px;
}

.base-score-field > span {
  font-size: 13px;
  color: var(--muted);
}

.base-score-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.base-score-option {
  min-height: 34px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.base-score-option.active {
  background: #155b47;
  color: #fff;
  box-shadow: 0 6px 14px rgba(21, 91, 71, 0.18);
}

.room-list-block {
  display: grid;
  gap: 10px;
}

.room-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-list-head h2 {
  font-size: 15px;
  color: var(--gold);
}

button.small {
  min-height: 30px;
  padding: 4px 12px;
  font-size: 13px;
}

.room-list {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow-y: auto;
}

.room-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.room-list-row .meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.room-list-row .code {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 1px;
}

.room-list-row .sub {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-list-row .right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.tag.waiting {
  color: #8fe3a0;
  border-color: rgba(143, 227, 160, 0.5);
}

.tag.playing {
  color: #e3c08f;
  border-color: rgba(227, 192, 143, 0.5);
}

.tag.base-score {
  color: var(--gold);
  border-color: rgba(201, 149, 44, 0.45);
  background: rgba(201, 149, 44, 0.08);
  font-weight: 700;
}

.room-list-empty,
.room-list .empty {
  font-size: 13px;
  color: var(--muted);
}

.room-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
}

.room-title strong {
  color: var(--gold);
  font-size: 28px;
  letter-spacing: 2px;
}

.room-base-score {
  margin-top: -6px;
  font-size: 13px;
  color: var(--muted);
}

.seat-list,
#scoreList {
  display: grid;
  gap: 8px;
}

.seat,
.score-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.score-row strong {
  color: var(--gold);
}

.table-wrap {
  padding: 22px;
  min-width: 0;
}

.mahjong-table {
  position: relative;
  min-height: calc(100vh - 44px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 30%),
    radial-gradient(circle at center, var(--felt) 0, var(--felt-dark) 68%);
  box-shadow: inset 0 0 0 8px rgba(0, 0, 0, 0.18);
}

.center-board {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(330px, 44%);
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(6, 22, 17, 0.78);
  backdrop-filter: blur(4px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
}

.round-info,
.last-discard {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.last-discard strong {
  color: var(--gold);
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
}

.action-bar button {
  padding: 0 14px;
}

.action-status {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  color: var(--gold);
  font-weight: 700;
}

.confirm-action {
  min-width: 132px;
  padding: 0 18px;
  box-shadow: 0 8px 22px rgba(217, 70, 69, 0.24);
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #d8e2d5;
  font-size: 13px;
}

.log-list-side {
  max-height: 240px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.opponent {
  position: absolute;
  display: grid;
  gap: 8px;
  min-width: 210px;
  max-width: 360px;
  z-index: 2;
}

.opponent.top {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 50%);
}

.opponent.left {
  top: 42%;
  left: 18px;
  width: min(360px, 28%);
}

.opponent.right {
  top: 42%;
  right: 18px;
  width: min(360px, 28%);
}

.player-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: white;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.badge.turn {
  background: rgba(240, 189, 93, 0.18);
  color: var(--gold);
}

.badge.win {
  background: rgba(79, 193, 136, 0.2);
  color: #86e0b2;
}

.badge.ready {
  background: rgba(79, 193, 136, 0.22);
  color: #9df0c1;
}

.mini-hand,
.meld-row,
.discard-row,
.hand-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.discard-row {
  min-height: 54px;
  max-height: 112px;
  align-content: flex-start;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(2, 14, 11, 0.28);
  overflow: hidden;
}

.back-tile {
  width: 28px;
  height: 42px;
  border-radius: 5px;
  background: url("/assets/majiang/pai.gif") center / contain no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}

.tile {
  width: 45px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #1a1b18;
  font-weight: 900;
  line-height: 1;
  box-shadow: none;
  user-select: none;
  padding: 0;
  overflow: visible;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.26));
}

.tile.small {
  width: 32px;
  height: 46px;
  border-radius: 5px;
  font-size: 13px;
}

.meld {
  display: inline-flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0;
  padding: 2px 6px 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  margin-right: 4px;
  position: relative;
}

.meld > .tile.small {
  margin-left: -8px;
}

.meld > .tile.small:first-child {
  margin-left: 0;
}

.meld > .tile.small {
  width: 26px;
  height: 38px;
}

.meld.gang {
  border: 1px solid rgba(240, 189, 93, 0.45);
  background: rgba(240, 189, 93, 0.08);
  padding-right: 14px;
}

.meld.gang::after {
  content: '杠';
  position: absolute;
  right: -2px;
  top: -8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.4);
  padding: 1px 4px;
  border-radius: 4px;
}

.tile.selected {
  transform: translateY(-12px);
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 8px;
}

.tile.disabled {
  opacity: 0.44;
}

.tile-fallback {
  display: none;
}

.self-area {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(6, 22, 17, 0.6);
  backdrop-filter: blur(4px);
  z-index: 3;
}

.bottom-stack {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 22px;
  display: grid;
  gap: 10px;
}

.bottom-stack .action-bar {
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(6, 22, 17, 0.7);
  backdrop-filter: blur(4px);
}

.self-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.self-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.self-tools button {
  padding: 0 14px;
}

.trustee-toggle {
  border: 1px solid rgba(21, 91, 71, 0.45);
  background: rgba(21, 91, 71, 0.08);
  color: var(--green);
  font-weight: 600;
}

.trustee-toggle.active {
  border-color: rgba(21, 91, 71, 0.75);
  background: rgba(21, 91, 71, 0.16);
  color: var(--ink);
}

.hand-row.trustee .tile {
  filter: grayscale(0.5);
  opacity: 0.55;
  cursor: default;
}

.hand-row {
  min-height: 74px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 24px;
  top: 20px;
  z-index: 10;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #d94645;
  color: white;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}

.round-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 29, 24, 0.42);
  backdrop-filter: blur(4px);
}

.round-modal-card {
  width: min(520px, calc(100vw - 40px));
  background: linear-gradient(180deg, #fffaf0 0%, #f4ead4 100%);
  border: 1px solid rgba(201, 149, 44, 0.3);
  border-radius: 18px;
  padding: 22px 26px 24px;
  color: #17352a;
  box-shadow: 0 24px 60px rgba(32, 40, 33, 0.28);
}

.round-modal-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 700;
  color: #17352a;
  margin-bottom: 14px;
}

.round-modal-card .icon-close {
  width: 28px;
  height: 28px;
  line-height: 1;
  font-size: 22px;
  padding: 0;
  border-radius: 50%;
  background: rgba(23, 53, 42, 0.08);
  border-color: transparent;
}

.round-modal-body {
  display: grid;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

.round-modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(23, 53, 42, 0.06);
}

.round-modal-row .name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.round-modal-row .name small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.round-modal-row .delta {
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.round-modal-row .delta.pos {
  color: var(--green);
}

.round-modal-row .delta.neg {
  color: var(--red);
}

.round-modal-row .delta.zero {
  color: var(--muted);
}

.round-modal-row.winner {
  border-color: rgba(201, 149, 44, 0.45);
  background: rgba(201, 149, 44, 0.08);
}

.round-modal-card footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.round-modal-card footer button {
  padding: 0 18px;
}

.round-modal-empty {
  text-align: center;
  color: #9ab4a6;
  padding: 16px 0;
}

.round-modal-cleanup {
  margin: 4px 0 0;
  font-size: 12px;
  color: #a07818;
  text-align: center;
  min-height: 16px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "home"
      "side"
      "table";
  }

  body.game-view .app-shell {
    grid-template-areas:
      "side"
      "table";
  }

  .site-home {
    min-height: auto;
    padding: 18px 16px 24px;
  }

  .site-nav,
  .hero-section,
  .feature-band,
  .rules-section {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .hero-copy h2 {
    font-size: 42px;
  }

  .hero-table {
    min-height: 300px;
  }

  .hero-tile {
    width: 80px;
    height: 112px;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .table-wrap {
    padding: 10px;
  }

  .mahjong-table {
    min-height: 760px;
  }

  .center-board {
    top: 47%;
    transform: translate(-50%, -50%);
    width: min(320px, calc(100% - 24px));
  }

  .opponent.top {
    top: 12px;
  }

  .opponent.left,
  .opponent.right {
    top: 104px;
    max-width: calc(50% - 24px);
    width: calc(50% - 24px);
  }

  .tile {
    width: 36px;
    height: 52px;
    font-size: 14px;
  }

  .discard-row {
    max-height: 84px;
    min-height: 44px;
  }
}

/* ===== 移动端横屏优化 ===== */
.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at center, #1a2b21 0, var(--bg) 60%);
  color: var(--ink);
}

.rotate-hint .rotate-icon {
  width: 56px;
  height: 94px;
  border: 4px solid var(--gold);
  border-radius: 12px;
  position: relative;
  animation: rotate-phone 1.8s ease-in-out infinite;
}

.rotate-hint .rotate-icon::after {
  content: "\21BB";
  position: absolute;
  right: -24px;
  bottom: -12px;
  font-size: 26px;
  color: var(--gold);
}

@keyframes rotate-phone {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}

.rotate-hint .rotate-text {
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
}

.rotate-hint .dismiss {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  min-height: auto;
  padding: 0;
}

/* 用户主动选择竖屏查看，或结算弹窗打开时，不再遮挡 */
body.rotate-dismissed .rotate-hint {
  display: none !important;
}

body.round-open .rotate-hint {
  display: none !important;
}

/* 手机牌局：直接使用横屏牌桌，隐藏侧边栏，紧凑布局 */
@media (max-width: 820px) {
  body.in-game .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "table";
  }

  body.in-game .side-panel {
    display: none;
  }

  body.in-game .table-wrap {
    padding: 0;
    height: 100vh;
    overflow: hidden;
  }

  body.in-game .mahjong-table {
    min-height: 100vh;
    height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.in-game .center-board {
    top: 35%;
    width: min(280px, 38%);
    padding: 6px 12px;
    gap: 4px;
  }

  body.in-game .round-info,
  body.in-game .last-discard {
    font-size: 12px;
    gap: 6px;
  }

  body.in-game .opponent {
    max-width: 30vw;
    gap: 4px;
    z-index: 4;
  }

  body.in-game .opponent.top {
    top: 8px;
  }

  body.in-game .opponent.left,
  body.in-game .opponent.right {
    top: 28%;
  }

  body.in-game .player-name {
    font-size: 12px;
  }

  body.in-game .badge {
    font-size: 10px;
    min-height: 20px;
    padding: 1px 6px;
  }

  body.in-game .mini-hand {
    flex-wrap: nowrap;
    gap: 2px;
  }

  body.in-game .back-tile {
    width: 14px;
    height: 20px;
    border-radius: 2px;
  }

  body.in-game .tile.small {
    width: 20px;
    height: 28px;
    border-radius: 3px;
  }

  body.in-game .discard-row {
    min-height: 34px;
    max-height: 62px;
    padding: 3px;
    gap: 2px;
  }

  body.in-game .meld > .tile.small {
    width: 16px;
    height: 22px;
  }

  body.in-game .meld {
    padding: 1px 4px 2px;
    margin-right: 3px;
  }

  body.in-game .bottom-stack {
    left: 10px;
    right: 10px;
    bottom: 4px;
    gap: 4px;
    z-index: 3;
  }

  /* 操作栏：紧凑居中，避免横跨遮挡左右两家的弃牌河 */
  body.in-game .bottom-stack .action-bar {
    justify-self: center;
    width: fit-content;
    max-width: min(320px, 45vw);
    min-height: 34px;
    padding: 6px 10px;
  }

  body.in-game .self-area {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 6px 10px;
    gap: 4px;
  }

  body.in-game .self-meta {
    grid-column: 2;
    grid-row: 3;
    gap: 8px;
    align-items: center;
    align-self: center;
  }

  body.in-game .self-meta > .player-name,
  body.in-game .self-meta .player-name-left,
  body.in-game .self-area > .player-subline {
    display: none;
  }

  body.in-game .self-area > .meld-row,
  body.in-game .self-area > .discard-row {
    grid-column: 1 / 3;
  }

  body.in-game .self-area > .hand-row {
    grid-column: 1;
    grid-row: 3;
  }

  body.in-game .self-tools {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    justify-items: stretch;
    min-width: 74px;
  }

  body.in-game .self-tools .badge {
    min-height: 24px;
    justify-content: center;
    padding: 1px 5px;
    font-size: 10px;
  }

  body.in-game .self-tools .badge:not(:first-child) {
    display: none;
  }

  body.in-game .self-tools button {
    min-height: 28px;
    padding: 0 8px;
    font-size: 11px;
  }

  body.in-game .hand-row {
    min-height: 48px;
  }

  body.in-game .tile {
    width: 34px;
    height: 48px;
  }

  body.in-game .tile.small {
    font-size: 11px;
  }
}

/* 手机竖屏拿着时，强制把牌桌旋成横屏画面 */
@media (orientation: portrait) and (max-width: 820px) {
  body.in-game {
    width: 100vw;
    min-height: 100vh;
    overflow: hidden;
  }

  body.in-game .app-shell {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
  }

  body.in-game .table-wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vh;
    width: 100dvh;
    height: 100vw;
    padding: 0;
    overflow: hidden;
    transform: rotate(90deg) translateY(-100%);
    transform-origin: top left;
  }

  body.in-game .mahjong-table {
    width: 100%;
    height: 100%;
    min-height: 100%;
  }

  body.in-game .toast {
    top: 12px;
    right: 12px;
    max-width: 280px;
  }
}
