:root {
  --felt-deep: #0a3c2f;
  --felt-mid: #0f5a45;
  --felt-light: #157a5c;
  --wood: #5c3a22;
  --wood-light: #7a5234;
  --ivory: #f3efe4;
  --ink: #1a1510;
  --gold: #d4a84b;
  --wan: #c0392b;
  --tong: #1f4e8c;
  --tiao: #1e7a46;
  --mist: rgba(243, 239, 228, 0.72);
  --shadow: rgba(0, 0, 0, 0.35);
  --radius-tile: 0.45rem;
  --font-brand: "Ma Shan Zheng", "ZCOOL XiaoWei", serif;
  --font-ui: "Noto Serif SC", "Songti SC", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  color: var(--ivory);
  background: #06261e;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  min-height: 100svh;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.is-playing {
  overflow: hidden;
  height: 100dvh;
  height: 100svh;
}

.felt-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(30, 120, 90, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 50% at 80% 90%, rgba(8, 40, 30, 0.8), transparent 50%),
    linear-gradient(160deg, #083528 0%, #0a3c2f 40%, #06261e 100%);
}

.felt-noise::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100dvh;
  min-height: 100svh;
  padding: 1.25rem;
  padding-top: max(1.25rem, env(safe-area-inset-top));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  padding-left: max(1.25rem, env(safe-area-inset-left));
}

body.is-playing .app {
  max-width: none;
  padding: 0;
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
}

body.is-playing .felt-noise {
  display: none;
}

.view {
  display: none;
  animation: fade-rise 0.55s ease both;
}

.view.is-active {
  display: block;
}

@keyframes fade-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— 首页 —— */
.hero {
  padding: clamp(3rem, 12vh, 6rem) 0.5rem 2rem;
  text-align: center;
}

.hero-brand {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(3.2rem, 12vw, 5.5rem);
  line-height: 1;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  animation: brand-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-title {
  margin: 0.6rem 0 0;
  font-size: clamp(1.15rem, 3.5vw, 1.55rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--mist);
}

.hero-sub {
  margin: 1rem auto 0;
  max-width: 22rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: rgba(243, 239, 228, 0.65);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 2rem;
  animation: fade-rise 0.7s 0.25s ease both;
}

@keyframes brand-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.home-rail {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2.5rem;
  animation: fade-rise 0.7s 0.4s ease both;
}

.stat-pill {
  min-width: 5.5rem;
  padding: 0.85rem 1.1rem;
  text-align: center;
  border: 1px solid rgba(212, 168, 75, 0.28);
  background: rgba(0, 0, 0, 0.2);
}

.stat-pill span {
  display: block;
  font-family: var(--font-brand);
  font-size: 1.75rem;
  color: var(--gold);
  line-height: 1;
}

.stat-pill small {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: rgba(243, 239, 228, 0.55);
}

/* —— 按钮 —— */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  padding: 0.85rem 1.6rem;
  min-height: 2.75rem;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #e0b85a, #c4922e);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(196, 146, 46, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--ivory);
  border: 1px solid rgba(243, 239, 228, 0.35);
}

.btn-icon,
.btn-text {
  appearance: none;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(243, 239, 228, 0.2);
  color: var(--ivory);
  cursor: pointer;
  font-family: inherit;
}

.btn-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  font-size: 1.1rem;
}

.btn-text {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

/* —— 选关 —— */
.panel-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.panel-head h2 {
  margin: 0;
  flex: 1;
  font-size: 1.35rem;
  letter-spacing: 0.15em;
}

.panel-note {
  font-size: 0.75rem;
  color: rgba(243, 239, 228, 0.5);
  letter-spacing: 0.08em;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}

.level-card {
  position: relative;
  padding: 1rem 0.85rem;
  text-align: left;
  cursor: pointer;
  border: 1px solid rgba(243, 239, 228, 0.12);
  background: linear-gradient(160deg, rgba(21, 90, 70, 0.55), rgba(6, 38, 30, 0.7));
  color: inherit;
  font-family: inherit;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
}

.level-card::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% -20%;
  height: 70%;
  background: radial-gradient(circle, rgba(212, 168, 75, 0.18), transparent 65%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.level-card.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.level-card.is-cleared {
  border-color: rgba(212, 168, 75, 0.4);
}

.level-card .num {
  font-family: var(--font-brand);
  font-size: 1.6rem;
  color: var(--gold);
  line-height: 1;
}

.level-card .title {
  margin-top: 0.45rem;
  font-size: 0.92rem;
  font-weight: 700;
}

.level-card .theme {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: rgba(243, 239, 228, 0.5);
}

.level-card .stars {
  margin-top: 0.55rem;
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

/* —— 牌桌 —— */
.table-frame {
  border: 10px solid var(--wood);
  border-radius: 1.25rem;
  box-shadow:
    inset 0 0 0 3px var(--wood-light),
    0 20px 50px var(--shadow);
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.table-felt {
  padding: 0.65rem 0.65rem 0.85rem;
  background:
    radial-gradient(ellipse 90% 70% at 50% 40%, var(--felt-light), var(--felt-deep) 70%);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.table-4p {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: min(78dvh, 720px);
  flex: 1;
}

body.is-playing .table-4p {
  min-height: 0;
}

.play-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 2;
}

.level-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.level-no {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: rgba(243, 239, 228, 0.55);
}

.level-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.seat-head {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: rgba(243, 239, 228, 0.55);
}

.seat-que {
  color: var(--gold);
  border: 1px solid rgba(212, 168, 75, 0.35);
  padding: 0.1rem 0.4rem;
  font-size: 0.65rem;
}

.seat-backs,
.seat-river,
.seat-melds {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.18rem;
  max-width: 100%;
}

/* 牌河：真实麻将约每行 6 张 */
.seat-dui .seat-river,
.seat-me-river .seat-river {
  max-width: calc(6 * 2.35rem + 5 * 0.2rem);
  gap: 0.2rem;
}

.seat-melds {
  gap: 0.4rem;
}

.meld-group {
  display: flex;
  gap: 0.1rem;
  padding: 0.12rem;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0.2rem;
}

.seat-mid {
  flex: 1;
  display: grid;
  grid-template-columns: auto minmax(8rem, 1.3fr) auto;
  gap: 0.55rem;
  align-items: center;
  min-height: 12rem;
}

/* 左右两家：牌河竖着一溜，可滚动 */
.seat-shang,
.seat-xia {
  max-height: none;
  overflow: visible;
  justify-self: center;
  width: auto;
  min-width: 2.6rem;
}

.seat-shang .seat-backs,
.seat-xia .seat-backs,
.seat-shang .seat-melds,
.seat-xia .seat-melds {
  flex-direction: column;
  flex-wrap: nowrap;
  max-width: none;
  max-height: 5.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 0.12rem;
}

.seat-shang .seat-river,
.seat-xia .seat-river {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  max-width: none;
  max-height: min(48vh, 26rem);
  overflow-x: hidden;
  overflow-y: auto;
  gap: 0.12rem;
  padding: 0.15rem 0.1rem;
}

.seat-shang .seat-river .tile,
.seat-xia .seat-river .tile,
.seat-shang .seat-backs .tile,
.seat-xia .seat-backs .tile,
.seat-shang .seat-melds .tile,
.seat-xia .seat-melds .tile {
  flex-shrink: 0;
}

.wall-info {
  font-size: 0.75rem;
  color: rgba(243, 239, 228, 0.45);
  letter-spacing: 0.08em;
}

.wall-info.is-late {
  color: #f0c14a;
  font-weight: 700;
  letter-spacing: 0.12em;
  animation: pulse-glow 1.6s ease-in-out infinite;
}

.wall-info.is-critical {
  color: #ff8a65;
}

.table-heart {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-align: center;
  padding: 0.5rem;
}

.que-badge {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(212, 168, 75, 0.45);
  background: rgba(0, 0, 0, 0.28);
  letter-spacing: 0.18em;
  font-size: 0.85rem;
  color: var(--gold);
  animation: pulse-glow 2.4s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(212, 168, 75, 0);
  }
  50% {
    box-shadow: 0 0 18px 2px rgba(212, 168, 75, 0.25);
  }
}

.prompt {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(243, 239, 228, 0.75);
  letter-spacing: 0.04em;
  max-width: 14rem;
  line-height: 1.45;
}

.discard-slot {
  min-height: 3.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seat-me-river {
  margin-top: 0.15rem;
}

.hand-area {
  padding-top: 0.35rem;
  border-top: 1px solid rgba(243, 239, 228, 0.08);
  flex-shrink: 0;
}

.hand-label {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: rgba(243, 239, 228, 0.45);
  margin-bottom: 0.45rem;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 0.22rem;
  row-gap: 0.35rem;
  min-height: 5.2rem;
  overflow: visible;
  padding: 0.35rem 0.15rem 0.55rem;
}

.play-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.85rem;
  padding: 0 0.25rem;
  flex-shrink: 0;
}

.diff-stars {
  color: var(--gold);
  letter-spacing: 0.12em;
}

.theme-tag {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(243, 239, 228, 0.5);
}

/* —— 麻将牌（立体绿边实体感） —— */
.tile {
  --tile-w: clamp(2.6rem, 6.5vw, 3.4rem);
  --tile-h: calc(var(--tile-w) * 1.38);
  --rim: #1f6b45;
  --rim-dark: #0f3d28;
  position: relative;
  width: var(--tile-w);
  height: var(--tile-h);
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 0.28rem;
  background:
    linear-gradient(160deg, #fffcf3 0%, #f4ecda 48%, #e8dcc6 100%);
  box-shadow:
    2px 0 0 var(--rim),
    3px 2px 0 var(--rim-dark),
    0 3px 0 #c9bda6,
    0 8px 14px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 #fffef8;
  color: var(--ink);
  font-family: var(--font-ui);
  transform-origin: center bottom;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: deal-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.tile.no-anim,
.tile.tile-static {
  animation: none;
}

.tile::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12%;
  border-radius: 0 0 0.28rem 0.28rem;
  background: linear-gradient(180deg, transparent, rgba(31, 107, 69, 0.22));
  pointer-events: none;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(70, 55, 30, 0.14);
}

@media (hover: hover) and (pointer: fine) {
  .tile:hover:not(:disabled) {
    transform: translateY(-10px) rotate(-2deg);
    box-shadow:
      2px 0 0 var(--rim),
      3px 2px 0 var(--rim-dark),
      0 3px 0 #c9bda6,
      0 16px 26px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 #fffef8;
    z-index: 2;
  }

  .level-card:hover {
    transform: translateY(-3px);
    border-color: rgba(212, 168, 75, 0.45);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  }

  .level-card:hover::before {
    opacity: 1;
  }

  .btn-primary:hover {
    box-shadow: 0 10px 28px rgba(196, 146, 46, 0.5);
  }

  .btn-ghost:hover {
    background: rgba(243, 239, 228, 0.08);
  }
}

.tile:active:not(:disabled) {
  transform: translateY(-6px) scale(1.04);
  z-index: 2;
}

@media (hover: none) and (pointer: coarse) {
  .tile:active:not(:disabled) {
    transform: translateY(-4px) scale(1.03);
  }

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

.tile:disabled,
.tile.tile-static {
  cursor: default;
}

.tile .face {
  position: absolute;
  inset: 5% 8% 9% 6%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(90, 70, 40, 0.16);
  border-radius: 0.18rem;
  background: linear-gradient(180deg, #fffdf7, #f7f0e2);
  overflow: hidden;
}

.tile .tile-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.tile-sm {
  --tile-w: 1.85rem;
}

.tile-river {
  --tile-w: clamp(2.05rem, 4.8vw, 2.45rem);
}

.tile-xs {
  --tile-w: 1.35rem;
}

.tile-back {
  background:
    repeating-linear-gradient(
      135deg,
      #1a5c3c 0 3px,
      #164f34 3px 6px
    );
  box-shadow:
    2px 0 0 #0d3a26,
    0 2px 0 #0a2e1e,
    0 5px 10px rgba(0, 0, 0, 0.3);
  cursor: default;
}

.tile-back::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 40%, rgba(0, 0, 0, 0.2));
  height: 100%;
  border-radius: inherit;
}

.tile-back::after {
  inset: 12%;
  border-radius: 0.12rem;
  box-shadow: inset 0 0 0 1px rgba(212, 168, 75, 0.35);
  background: radial-gradient(circle at 50% 45%, rgba(212, 168, 75, 0.2), transparent 60%);
}

.tile.is-que {
  outline: 2px dashed rgba(192, 57, 43, 0.5);
  outline-offset: -3px;
}

.tile.is-discarding {
  animation: discard-fly 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
  z-index: 5;
}

.tile.is-wrong {
  animation: wrong-shake 0.45s ease;
}

.tile.in-slot {
  animation: land-slot 0.4s ease both;
  cursor: default;
  --tile-w: clamp(2.4rem, 6vw, 3rem);
}

@media (max-width: 640px) {
  .seat-mid {
    grid-template-columns: minmax(4.2rem, auto) 1fr minmax(4.2rem, auto);
    gap: 0.35rem;
    min-height: 7rem;
  }

  .seat-shang .seat-river,
  .seat-xia .seat-river {
    max-height: min(30vh, 14rem);
    gap: 0.16rem;
  }

  .seat-shang .seat-backs,
  .seat-xia .seat-backs {
    max-height: 4.2rem;
  }

  .seat-shang .seat-melds,
  .seat-xia .seat-melds {
    max-height: 6.5rem;
    gap: 0.25rem;
  }

  /* 牌河 / 副露：手机上加大到可读 */
  .tile-river {
    --tile-w: 2.2rem;
  }

  .tile-xs {
    --tile-w: 1.15rem;
  }

  .seat-dui .seat-river,
  .seat-me-river .seat-river {
    gap: 0.22rem;
    max-width: 100%;
  }

  .seat-dui .tile-river,
  .seat-me-river .tile-river,
  .seat-dui .seat-melds .tile,
  .seat-me-river .seat-melds .tile {
    --tile-w: 2.35rem;
  }

  .prompt {
    font-size: 0.7rem;
    max-width: 9.5rem;
  }

  .que-badge {
    font-size: 0.75rem;
    padding: 0.28rem 0.65rem;
    letter-spacing: 0.12em;
  }
}

@media (max-width: 520px) {
  .app {
    padding: 0.55rem;
    padding-top: max(0.55rem, env(safe-area-inset-top));
    padding-right: max(0.55rem, env(safe-area-inset-right));
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
    padding-left: max(0.55rem, env(safe-area-inset-left));
  }

  body.is-playing .app {
    padding: 0.35rem;
    padding-top: max(0.35rem, env(safe-area-inset-top));
    padding-right: max(0.35rem, env(safe-area-inset-right));
    padding-bottom: max(0.3rem, env(safe-area-inset-bottom));
    padding-left: max(0.35rem, env(safe-area-inset-left));
  }

  .hero {
    padding: clamp(2rem, 8vh, 4rem) 0.25rem 1.25rem;
  }

  .hero-brand {
    font-size: clamp(2.6rem, 14vw, 4rem);
  }

  .hero-title {
    letter-spacing: 0.12em;
    font-size: 1.05rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    margin-top: 1.5rem;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .home-rail {
    margin-top: 1.75rem;
    gap: 0.55rem;
  }

  .stat-pill {
    min-width: 4.8rem;
    padding: 0.7rem 0.75rem;
  }

  .level-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
  }

  .level-card {
    min-height: 5.5rem;
    padding: 0.85rem 0.7rem;
  }

  .table-frame {
    border-width: 5px;
    border-radius: 0.75rem;
  }

  .table-felt {
    padding: 0.35rem 0.3rem 0.4rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-4p {
    gap: 0.18rem;
    min-height: 0;
  }

  .play-topbar {
    gap: 0.45rem;
    flex-shrink: 0;
  }

  .btn-icon {
    width: 2.6rem;
    height: 2.6rem;
    flex-shrink: 0;
  }

  .btn-text {
    min-height: 2.4rem;
    padding: 0.45rem 0.75rem;
  }

  .level-name {
    font-size: 0.95rem;
  }

  .panel-note {
    display: none;
  }

  .seat-dui .seat-backs {
    display: none;
  }

  .seat-head {
    font-size: 0.62rem;
  }

  .seat-me-river .seat-head-me {
    display: none;
  }

  .seat-mid {
    flex: 1 1 auto;
    min-height: 0;
    align-items: start;
  }

  .wall-info {
    display: none;
  }

  .discard-slot {
    min-height: 2.8rem;
  }

  /* 对家 / 本家牌河与副露再放大一档 */
  .tile-river {
    --tile-w: 2.3rem;
  }

  .seat-dui .tile-river,
  .seat-me-river .tile-river,
  .seat-dui .seat-melds .tile,
  .seat-me-river .seat-melds .tile {
    --tile-w: 2.5rem;
  }

  .seat-shang .tile-river,
  .seat-xia .tile-river,
  .seat-shang .seat-melds .tile,
  .seat-xia .seat-melds .tile {
    --tile-w: 2.15rem;
  }

  .seat-dui .seat-river,
  .seat-me-river .seat-river {
    justify-content: center;
    gap: 0.2rem;
  }

  .seat-me-river {
    flex-shrink: 0;
    margin-top: 0.1rem;
  }

  .hand-label {
    font-size: 0.62rem;
    margin-bottom: 0.25rem;
  }

  .hand-area {
    flex-shrink: 0;
    padding-top: 0.4rem;
    margin-top: 0.1rem;
  }

  .hand {
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-end;
    gap: 0.16rem;
    row-gap: 0.28rem;
    min-height: 0;
    padding: 0.2rem 0 0.45rem;
    overflow: visible;
  }

  /* 手牌两行排完约 14 张，保证整副可见且可点 */
  .hand .tile {
    --tile-w: min(2.85rem, calc((100% - 1.2rem) / 7));
    flex-shrink: 0;
  }

  .play-footer {
    margin-top: 0.35rem;
  }

  .modal {
    padding: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    align-items: end;
  }

  .modal-card {
    width: 100%;
    padding: 1.4rem 1.1rem 1.2rem;
    border-radius: 1rem 1rem 0 0;
    max-height: min(88dvh, 36rem);
    overflow-y: auto;
  }

  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

/* 横屏手机：压缩纵向空间，手牌仍可操作 */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    padding: 1.25rem 0.5rem 0.75rem;
  }

  .home-rail {
    margin-top: 1rem;
  }

  body.is-playing .app {
    padding: 0.25rem;
  }

  .table-frame {
    border-width: 4px;
  }

  .seat-dui,
  .seat-me-river .seat-head {
    display: none;
  }

  .seat-mid {
    min-height: 5rem;
  }

  .seat-shang .seat-river,
  .seat-xia .seat-river {
    max-height: 5.5rem;
  }

  .prompt,
  .wall-info,
  .hand-label {
    display: none;
  }

  .hand {
    flex-wrap: wrap;
    justify-content: center;
    min-height: 0;
    padding-bottom: 0.25rem;
    gap: 0.12rem;
    row-gap: 0.18rem;
  }

  .hand .tile {
    --tile-w: min(2.4rem, calc((100% - 1rem) / 7));
  }

  .tile-river {
    --tile-w: 1.85rem;
  }

  .play-footer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes deal-in {
  from {
    opacity: 0;
    transform: translateY(28px) rotateX(40deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes discard-fly {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  60% {
    transform: translateY(-120px) scale(1.15) rotate(-8deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-90px) scale(0.3);
    opacity: 0;
  }
}

@keyframes land-slot {
  from {
    transform: translateY(-40px) scale(1.2);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes wrong-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px) rotate(-3deg);
  }
  40% {
    transform: translateX(6px) rotate(3deg);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

/* —— 弹层 —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(4, 20, 16, 0.72);
  backdrop-filter: blur(6px);
  animation: fade-rise 0.3s ease both;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(26rem, 100%);
  padding: 1.75rem 1.4rem 1.4rem;
  background: linear-gradient(165deg, #124a3a, #0a2e24);
  border: 1px solid rgba(212, 168, 75, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
  overflow: hidden;
}

.modal-sm {
  width: min(20rem, 100%);
}

.result-burst {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 50% 20%, rgba(212, 168, 75, 0.25), transparent 45%);
  pointer-events: none;
  animation: burst-spin 8s linear infinite;
}

@keyframes burst-spin {
  to {
    transform: rotate(360deg);
  }
}

.result-eyebrow {
  position: relative;
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.result-title {
  position: relative;
  margin: 0.5rem 0 0;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
}

.result-stats {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.result-stats span {
  display: block;
  min-width: 5rem;
  padding: 0.5rem 0.7rem;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.8rem;
  color: rgba(243, 239, 228, 0.8);
}

.result-explain {
  position: relative;
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: rgba(243, 239, 228, 0.78);
  text-align: left;
}

.modal-actions {
  position: relative;
  display: flex;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 1.35rem;
  flex-wrap: wrap;
}
