:root {
  color-scheme: dark;
  --felt: #0c664f;
  --felt-deep: #064233;
  --jade: #39d395;
  --gold: #f3cb74;
  --ink: #17211e;
  --tile: #fff8e6;
  --tile-edge: #dcc991;
  --tile-shadow: rgba(10, 17, 12, 0.38);
  --panel: rgba(6, 34, 28, 0.78);
  --panel-strong: rgba(7, 45, 36, 0.94);
  --line: rgba(255, 255, 255, 0.16);
  --muted: rgba(235, 255, 247, 0.7);
  --danger: #ff6b66;
  --seat-w: min(68vw, 760px);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 1180px;
  margin: 0;
  min-height: 100vh;
  overflow: auto;
  background:
    radial-gradient(circle at 25% 10%, rgba(57, 211, 149, 0.22), transparent 28%),
    radial-gradient(circle at 80% 92%, rgba(243, 203, 116, 0.18), transparent 24%),
    linear-gradient(135deg, #10130f 0%, #183226 48%, #0a1411 100%);
  color: #f5fff9;
}

button {
  font: inherit;
}

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

.mahjong-table {
  position: relative;
  min-height: 900px;
  height: calc(100vh - 36px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  overflow: hidden;
  background:
    url("assets/table-felt.svg"),
    radial-gradient(ellipse at center, rgba(18, 131, 96, 0.88) 0%, rgba(8, 82, 63, 0.96) 58%, #06251f 100%);
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.52),
    0 28px 90px rgba(0, 0, 0, 0.55);
}

.table-ambient {
  position: absolute;
  inset: 86px 230px 160px 230px;
  border-radius: 999px;
  border: 14px solid rgba(255, 255, 255, 0.05);
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.topbar {
  position: absolute;
  z-index: 10;
  inset: 18px 18px auto 18px;
  display: grid;
  grid-template-columns: 260px 1fr auto;
  gap: 16px;
  align-items: center;
}

.brand,
.round-strip,
.top-actions,
.player-plate,
.side-panel,
.action-bar,
.center-console,
.result-card,
.rules-dialog {
  backdrop-filter: blur(18px);
}

.brand,
.round-strip,
.top-actions {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(4, 29, 24, 0.62);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 15px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(145deg, #f8e4a9, #b98a35);
  color: #1f2516;
  font-size: 26px;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 9px 20px rgba(0, 0, 0, 0.26);
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
  letter-spacing: 0;
}

.brand p,
.mini-label,
.round-strip span,
.player-plate span {
  color: var(--muted);
}

.brand p {
  margin-top: 2px;
  font-size: 12px;
}

.round-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 18px;
}

.round-strip span {
  white-space: nowrap;
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.primary-button,
.action-button,
.icon-button {
  border: 0;
  color: #08221b;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease;
}

.primary-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(145deg, #ffe7a2, #d89f32);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 10px 22px rgba(0, 0, 0, 0.25);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  font-weight: 900;
}

.primary-button:hover,
.action-button:hover,
.icon-button:hover,
.tile-button:hover {
  transform: translateY(-2px);
}

.primary-button:disabled,
.action-button:disabled {
  cursor: default;
  filter: grayscale(0.55);
  opacity: 0.48;
  transform: none;
}

.seat {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.seat-top {
  top: 112px;
  left: 50%;
  width: var(--seat-w);
  transform: translateX(-50%);
  flex-direction: column;
}

.seat-bottom {
  left: 50%;
  bottom: 18px;
  width: min(94vw, 1120px);
  transform: translateX(-50%);
  flex-direction: column;
}

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

.seat-right {
  top: 52%;
  right: 24px;
  transform: translateY(-50%);
  flex-direction: row-reverse;
}

.player-plate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 210px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(3, 24, 20, 0.72);
}

.player-plate strong {
  font-size: 15px;
}

.player-plate span {
  font-size: 12px;
}

@keyframes blink-name {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.turn-active {
  animation: blink-name 0.9s ease-in-out infinite;
  color: var(--gold) !important;
  text-shadow: 0 0 8px rgba(243, 203, 116, 0.45);
}

.human-plate {
  border-color: rgba(243, 203, 116, 0.55);
  box-shadow: 0 0 0 1px rgba(243, 203, 116, 0.12), 0 12px 30px rgba(0, 0, 0, 0.2);
}

.opponent-hand,
.human-hand,
.river,
.melds {
  display: flex;
  align-items: center;
  justify-content: center;
}

.opponent-hand {
  min-height: 36px;
}

.vertical-hand {
  width: 52px;
  min-height: 320px;
  flex-direction: column;
}

.human-hand {
  width: 100%;
  min-height: 108px;
  padding: 12px;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(255, 255, 255, 0.06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.melds {
  min-height: 44px;
  gap: 6px;
}

.human-melds {
  min-height: 38px;
}

.vertical-melds {
  flex-direction: column;
}

.meld-group {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.vertical-melds .meld-group {
  flex-direction: column;
}

.bonus-group {
  background: rgba(243, 203, 116, 0.22);
  box-shadow: 0 0 0 1px rgba(243, 203, 116, 0.32);
}

.bonus-reveal {
  outline: 2px solid rgba(243, 203, 116, 0.82);
  outline-offset: -3px;
}

.river {
  align-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(2, 24, 19, 0.28);
}

.river-top,
.river-bottom {
  width: min(58vw, 620px);
  min-height: 74px;
}

.river-left,
.river-right {
  width: 150px;
  min-height: 260px;
}

.center-console {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: grid;
  grid-template-columns: 104px 270px 104px;
  align-items: center;
  justify-items: center;
  gap: 22px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 30px;
  background: rgba(3, 31, 25, 0.62);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
}

.oracle-panel,
.discard-focus {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.status-orb {
  display: grid;
  place-items: center;
  width: 250px;
  min-height: 150px;
  padding: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.14), transparent 36%),
    linear-gradient(160deg, rgba(19, 110, 80, 0.95), rgba(5, 45, 37, 0.95));
  border: 1px solid rgba(243, 203, 116, 0.38);
  text-align: center;
  box-shadow:
    inset 0 0 28px rgba(255, 255, 255, 0.08),
    0 18px 38px rgba(0, 0, 0, 0.28);
}

.status-orb span {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.status-orb strong {
  display: block;
  max-width: 190px;
  margin-top: 8px;
  font-size: 18px;
  line-height: 1.35;
}

.side-panel {
  position: absolute;
  z-index: 4;
  right: 18px;
  top: 102px;
  width: 230px;
  max-height: 228px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

.panel-section {
  padding: 14px;
}

.panel-section h2 {
  margin-bottom: 8px;
  font-size: 15px;
}

.event-log {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 22px;
  color: rgba(245, 255, 249, 0.82);
  font-size: 12px;
  line-height: 1.45;
}

.event-log li::marker {
  color: var(--gold);
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid rgba(243, 203, 116, 0.24);
  border-radius: 18px;
  background: rgba(4, 30, 25, 0.72);
}

.action-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: linear-gradient(145deg, #f7fff9, #b9e9cf);
  font-weight: 800;
}

.action-button.warn {
  background: linear-gradient(145deg, #ffe7a2, #d69b2f);
}

.action-button.danger {
  background: linear-gradient(145deg, #ffd2ce, #ff7770);
}

.action-hint {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
}

.tile,
.tile-button,
.tile-back,
.tile-holder {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 64px;
  border-radius: 9px;
  border: 1px solid rgba(86, 58, 23, 0.24);
  user-select: none;
}

.tile,
.tile-button {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 18%),
    linear-gradient(155deg, #fff9e8 0%, #f5e4b6 58%, #d8b967 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.72),
    inset 0 -5px 0 rgba(107, 75, 24, 0.16),
    0 9px 16px var(--tile-shadow);
  color: var(--ink);
}

.tile.has-art,
.tile-button.has-art {
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.tile-art {
  display: block;
  width: 122%;
  height: 122%;
  object-fit: contain;
  pointer-events: none;
}

.tile-button {
  cursor: pointer;
  transform-origin: center bottom;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.tile-button.selected {
  transform: translateY(-16px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.72),
    inset 0 -5px 0 rgba(107, 75, 24, 0.16),
    0 18px 26px rgba(0, 0, 0, 0.34),
    0 0 0 3px rgba(243, 203, 116, 0.42);
}

.tile-button.drawn {
  margin-left: 12px;
}

.tile.small,
.river .tile,
.meld-group .tile {
  width: 31px;
  height: 43px;
  border-radius: 7px;
}

.tile.placeholder {
  opacity: 0.5;
}

.tile.placeholder::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(25, 35, 31, 0.32);
}

.tile-back {
  width: 32px;
  height: 45px;
  border-color: rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25% 50%, rgba(255, 255, 255, 0.12) 50% 75%, transparent 75%),
    linear-gradient(145deg, #176a57, #08362d);
  background-size: 12px 12px, auto;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 7px 13px rgba(0, 0, 0, 0.28);
}

.tile-holder {
  border: 0;
}

.vertical-hand .tile-back {
  margin-top: -24px;
}

.opponent-hand:not(.vertical-hand) .tile-back {
  margin-left: -16px;
}

.vertical-hand .tile.small {
  margin-top: -24px;
}

.opponent-hand:not(.vertical-hand) .tile.small {
  margin-left: -16px;
}

/* 局结束后亮牌，取消重叠以便看清 */
.opponent-hand.revealed {
  flex-wrap: wrap;
}

.opponent-hand.revealed .tile.small {
  margin-left: 2px;
}

.vertical-hand.revealed {
  min-height: auto;
  flex-wrap: wrap;
  flex-direction: row;
  width: auto;
  max-width: 220px;
}

.vertical-hand.revealed .tile.small {
  margin-top: 0;
  margin-left: 2px;
  margin-bottom: 2px;
}

.tile-face {
  display: grid;
  place-items: center;
  gap: 1px;
  line-height: 1;
}

.tile-rank {
  font-size: 24px;
  font-weight: 900;
}

.tile-sub {
  font-size: 11px;
  font-weight: 800;
}

.tile.small .tile-rank,
.river .tile-rank,
.meld-group .tile-rank {
  font-size: 16px;
}

.tile.small .tile-sub,
.river .tile-sub,
.meld-group .tile-sub {
  font-size: 8px;
}

.suit-m .tile-rank,
.suit-z .dragon-red {
  color: #b52522;
}

.suit-p .tile-rank {
  color: #1764a7;
}

.suit-s .tile-rank,
.dragon-green {
  color: #157a42;
}

.wind {
  color: #232a2b;
}

.deity,
.deity-tile {
  outline: 3px solid rgba(243, 203, 116, 0.62);
  outline-offset: -4px;
}

.deity::before,
.deity-tile::before {
  content: "得";
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe8a8, #d09025);
  color: #211d0a;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
}

.last-discard {
  animation: popTile 360ms ease both;
}

@keyframes popTile {
  0% {
    transform: scale(0.86);
    filter: brightness(1.4);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.rules-dialog {
  width: min(620px, calc(100vw - 40px));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  padding: 0;
  color: #f6fff9;
  background: var(--panel-strong);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.rules-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  font-size: 18px;
}

.rules-copy {
  display: grid;
  gap: 12px;
  padding: 18px;
  color: rgba(245, 255, 249, 0.84);
  line-height: 1.8;
}

.round-result {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.42);
}

.round-result.hidden {
  display: none;
}

.result-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(460px, calc(100vw - 48px));
  padding: 30px;
  border: 1px solid rgba(243, 203, 116, 0.5);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 0%, rgba(243, 203, 116, 0.18), transparent 48%),
    rgba(5, 32, 27, 0.94);
  text-align: center;
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.55);
}

.result-card h2 {
  font-size: 36px;
  color: var(--gold);
}

.result-card p {
  color: rgba(245, 255, 249, 0.82);
  line-height: 1.65;
}

@media (max-width: 1260px) {
  body {
    min-width: 1040px;
  }

  .side-panel {
    display: none;
  }

  .center-console {
    grid-template-columns: 90px 240px 90px;
    gap: 16px;
  }
}
