/* =====================================================================
   JIA游 · 双人麻将  新拟态 UI
   目标：全移动端自适应 / 横屏体验 / 柔和立体质感 / 精致字形
   ===================================================================== */

:root {
  /* 新拟态基础色：低饱和度灰绿/暖灰 */
  --bg: #e8edf1;
  --bg-deep: #dfe5ea;
  --panel: #e8edf1;

  /* 新拟态阴影 */
  --shadow-light: rgba(255, 255, 255, 0.85);
  --shadow-dark: rgba(125, 135, 148, 0.32);
  --shadow-inner: rgba(125, 135, 148, 0.28);

  /* 功能色 */
  --gold: #d4a373;
  --gold-light: #e8c99a;
  --jade: #7fb069;
  --jade-light: #a8cf8d;
  --danger: #c96a6a;
  --danger-light: #e09a9a;
  --ink: #5b626e;
  --ink-dim: #8d95a0;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ============================== 屏幕切换 ============================== */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.24s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

.hidden {
  display: none !important;
}

/* ============================== 新拟态基础 ============================== */

.neumorphic {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
}

.neumorphic-inset {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: inset 4px 4px 8px var(--shadow-inner),
    inset -4px -4px 8px var(--shadow-light);
}

.neumorphic-pressed {
  box-shadow: inset 4px 4px 8px var(--shadow-inner),
    inset -4px -4px 8px var(--shadow-light);
}

/* ============================== 按钮 ============================== */

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 12px 22px;
  cursor: pointer;
  box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: inset 4px 4px 8px var(--shadow-inner),
    inset -4px -4px 8px var(--shadow-light);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  filter: grayscale(0.5);
}

.btn.primary {
  color: var(--jade);
  box-shadow: 6px 6px 12px rgba(80, 120, 70, 0.35), -6px -6px 12px rgba(255, 255, 255, 0.9);
}

.btn.primary:active {
  box-shadow: inset 4px 4px 8px rgba(80, 120, 70, 0.3),
    inset -4px -4px 8px rgba(255, 255, 255, 0.8);
}

.btn.accent {
  color: var(--gold);
  box-shadow: 6px 6px 12px rgba(160, 120, 70, 0.35), -6px -6px 12px rgba(255, 255, 255, 0.9);
}

.btn.accent:active {
  box-shadow: inset 4px 4px 8px rgba(160, 120, 70, 0.3),
    inset -4px -4px 8px rgba(255, 255, 255, 0.8);
}

.btn.link {
  box-shadow: none;
  color: var(--ink-dim);
  font-weight: 500;
}

.btn.wide {
  width: 100%;
}

.btn.icon {
  padding: 0;
  width: 40px;
  height: 36px;
  border-radius: 12px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.tiny {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 10px;
}

/* ============================== 大厅 ============================== */

.lobby-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: calc(20px + var(--safe-t)) 24px calc(20px + var(--safe-b));
  overflow-y: auto;
}

.brand {
  text-align: center;
}

.logo {
  margin: 0;
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 800;
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, #f5f7f9 0%, #c9d1d9 45%, #aab7c0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 12px rgba(125, 135, 148, 0.35));
}

.logo span {
  -webkit-text-fill-color: transparent;
}

.tagline {
  margin: 8px 0 0;
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

.lobby-panel {
  width: min(440px, 92vw);
  padding: 24px;
  border-radius: 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.16em;
}

input[type="text"] {
  width: 100%;
  background: var(--panel);
  border: none;
  border-radius: 14px;
  color: var(--ink);
  font-size: 16px;
  padding: 14px 16px;
  outline: none;
  font-family: inherit;
  box-shadow: inset 4px 4px 8px var(--shadow-inner),
    inset -4px -4px 8px var(--shadow-light);
}

input[type="text"]:focus {
  outline: 2px solid var(--jade-light);
}

input::placeholder {
  color: rgba(141, 149, 160, 0.5);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.join-row input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  text-align: center;
}

.footnote {
  margin: 0;
  font-size: 11px;
  color: rgba(141, 149, 160, 0.6);
  text-align: center;
  letter-spacing: 0.06em;
}

/* ============================== 房间 ============================== */

.room-wrap {
  width: 100%;
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-t)) calc(20px + var(--safe-r))
    calc(16px + var(--safe-b)) calc(20px + var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.room-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-code {
  flex: 1;
  text-align: center;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}

.room-code span {
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.16em;
}

.room-code strong {
  font-size: 26px;
  letter-spacing: 0.3em;
  color: var(--gold);
  font-weight: 800;
}

.seat-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 0;
}

.seat-card {
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
}

.seat-card.empty {
  background: var(--panel);
  border: 2px dashed rgba(125, 135, 148, 0.25);
  color: rgba(141, 149, 160, 0.5);
}

.seat-card .avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  background: var(--panel);
  color: var(--gold);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}

.seat-card .name {
  font-size: 15px;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-card .badge {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.1em;
  box-shadow: 3px 3px 6px var(--shadow-inner), -3px -3px 6px var(--shadow-light);
}

.badge.ready {
  background: var(--panel);
  color: var(--jade);
}

.badge.wait {
  background: var(--panel);
  color: var(--ink-dim);
}

.badge.off {
  background: var(--panel);
  color: var(--danger);
}

.room-foot {
  display: flex;
  gap: 12px;
}

/* ============================== 牌桌 ============================== */

.table-root {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  gap: 0;
  background:
    radial-gradient(140% 100% at 50% 0%, rgba(255, 255, 255, 0.6) 0%, transparent 55%),
    var(--bg);
}

/* ---- 顶栏 ---- */

.tbl-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  min-height: 42px;
  background: var(--panel);
  border-bottom: 1px solid rgba(125, 135, 148, 0.12);
  box-shadow: 0 4px 10px var(--shadow-dark);
}

.hdr-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hdr-logo {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold);
  white-space: nowrap;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.hdr-room {
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.2em;
  white-space: nowrap;
}

.hdr-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 90px;
}

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(230px, 36vw);
}

.timer-bar {
  flex: 1;
  height: 7px;
  border-radius: 8px;
  background: rgba(125, 135, 148, 0.18);
  overflow: hidden;
}

.timer-bar i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--jade-light), var(--gold-light));
  transition: background 0.3s ease;
}

.timer-bar i.warn {
  background: linear-gradient(90deg, var(--gold-light), var(--danger-light));
}

#timer-text {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 30px;
  text-align: right;
}

.hdr-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  letter-spacing: 0.05em;
}

.scoreboard b {
  color: var(--gold);
  font-size: 15px;
}

.scoreboard .sb-opp b {
  color: var(--danger);
}

/* ---- 对家 ---- */

.opp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 2px;
  min-height: 48px;
}

.seat-tag {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  border: 1px solid rgba(125, 135, 148, 0.2);
  border-radius: 22px;
  padding: 2px 10px;
  white-space: nowrap;
  background: var(--panel);
  box-shadow: 3px 3px 6px var(--shadow-inner), -3px -3px 6px var(--shadow-light);
}

.seat-tag.dealer {
  color: var(--gold);
  border-color: rgba(212, 163, 115, 0.4);
}

.opp-hand {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.opp-melds,
.my-melds {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.meld {
  display: flex;
  gap: 2px;
}

/* ============================== 牌（新拟态） ============================== */

:root {
  --tile-w: 44px;
  --tile-h: calc(var(--tile-w) * 1.4);
  --tile-w-sm: calc(var(--tile-w) * 0.62);
  --tile-h-sm: calc(var(--tile-h) * 0.62);
  --tile-w-xs: calc(var(--tile-w) * 0.46);
  --tile-h-xs: calc(var(--tile-h) * 0.46);
}

.tile {
  width: var(--tile-w);
  height: var(--tile-h);
  border-radius: calc(var(--tile-w) * 0.16);
  background: var(--panel);
  border: none;
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  position: relative;
  flex: 0 0 auto;
  display: block;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

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

.tile-sm {
  width: var(--tile-w-sm);
  height: var(--tile-h-sm);
  border-radius: calc(var(--tile-w-sm) * 0.16);
  box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

.tile-xs {
  width: var(--tile-w-xs);
  height: var(--tile-h-xs);
  border-radius: calc(var(--tile-w-xs) * 0.17);
  box-shadow: 2px 2px 4px var(--shadow-dark), -2px -2px 4px var(--shadow-light);
}

.tile-back {
  background: var(--panel);
  border: none;
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}

.tile-back::after {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 24%;
  border: 1.5px solid rgba(125, 135, 148, 0.35);
  background: var(--panel);
  box-shadow: inset 3px 3px 6px rgba(125, 135, 148, 0.25),
    inset -3px -3px 6px rgba(255, 255, 255, 0.8);
}

.tile.wild {
  box-shadow: 5px 5px 12px rgba(212, 163, 115, 0.45), -5px -5px 12px rgba(255, 255, 255, 0.9);
}

.tile.playable {
  cursor: pointer;
}

.tile.playable:active {
  transform: translateY(-5px) scale(1.03);
}

.tile.raised {
  transform: translateY(-7px);
  box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
}

.tile.just {
  animation: tileIn 0.3s ease-out;
}

@keyframes tileIn {
  from {
    transform: translateY(-14px) scale(0.92);
    opacity: 0.5;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.hand-gap {
  width: calc(var(--tile-w) * 0.34);
  flex: 0 0 auto;
}

/* ---- 中央区域 ---- */

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 4px 12px;
  min-height: 0;
}

.discard-column {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  min-height: 0;
}

.discard-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  background: var(--panel);
  border-radius: 16px;
  padding: 4px 8px 6px;
  box-shadow: inset 3px 3px 6px var(--shadow-inner), inset -3px -3px 6px var(--shadow-light);
}

.discard-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
  flex: 0 0 auto;
}

.discard-zone {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.discard-zone::-webkit-scrollbar {
  display: none;
}

.discard-zone .tile.highlight {
  outline: 3px solid var(--jade);
  outline-offset: 1px;
  box-shadow: 0 0 10px rgba(127, 176, 105, 0.5);
}

.info-column {
  width: clamp(72px, 12vw, 104px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 0;
}

.wall-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  border-radius: 14px;
  background: var(--panel);
  border: none;
  box-shadow: inset 3px 3px 6px var(--shadow-inner),
    inset -3px -3px 6px var(--shadow-light);
}

.wall-num {
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.wall-label {
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 0.18em;
}

.turn-badge {
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 4px;
  border-radius: 12px;
  letter-spacing: 0.1em;
  background: var(--panel);
  color: var(--ink-dim);
  box-shadow: 4px 4px 8px var(--shadow-inner), -4px -4px 8px var(--shadow-light);
}

.turn-badge.mine {
  color: var(--jade);
  box-shadow: inset 3px 3px 6px rgba(127, 176, 105, 0.2),
    inset -3px -3px 6px rgba(255, 255, 255, 0.7);
}

.turn-badge.theirs {
  color: var(--gold);
  box-shadow: inset 3px 3px 6px rgba(212, 163, 115, 0.2),
    inset -3px -3px 6px rgba(255, 255, 255, 0.7);
}

.log-box {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  font-size: 10px;
  line-height: 1.4;
  color: rgba(141, 149, 160, 0.75);
  padding: 2px;
}

.log-box div {
  animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- 我的牌 ---- */

.me-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 4px 12px calc(6px + var(--safe-b));
  min-height: calc(var(--tile-h) + 20px);
}

.my-hand {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex-wrap: nowrap;
  justify-content: center;
}

/* ---- 操作按钮 ---- */

.action-layer {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tile-h) + 26px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 20;
  pointer-events: none;
}

.action-layer .act-btn {
  pointer-events: auto;
  appearance: none;
  border: none;
  border-radius: 16px;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #06231a;
  background: var(--panel);
  box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
  cursor: pointer;
  font-family: inherit;
  animation: popIn 0.22s cubic-bezier(0.2, 1.4, 0.5, 1);
  white-space: nowrap;
}

.action-layer .act-btn.win {
  color: #3a2400;
  box-shadow: 6px 6px 14px rgba(212, 163, 115, 0.5), -6px -6px 14px rgba(255, 255, 255, 0.9);
  animation: popIn 0.22s cubic-bezier(0.2, 1.4, 0.5, 1), glow 1.6s ease-in-out infinite alternate;
}

.action-layer .act-btn.pass {
  color: var(--ink-dim);
  box-shadow: 4px 4px 8px var(--shadow-inner), -4px -4px 8px var(--shadow-light);
}

.action-layer .act-btn:active {
  transform: scale(0.94);
  box-shadow: inset 4px 4px 8px var(--shadow-inner),
    inset -4px -4px 8px var(--shadow-light);
}

@keyframes popIn {
  from {
    transform: translateY(10px) scale(0.85);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes glow {
  from {
    box-shadow: 6px 6px 14px rgba(212, 163, 115, 0.4), -6px -6px 14px rgba(255, 255, 255, 0.8);
  }
  to {
    box-shadow: 6px 6px 22px rgba(212, 163, 115, 0.8), -6px -6px 22px rgba(255, 255, 255, 0.9);
  }
}

.status-layer {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--gold);
  text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.9), -2px -2px 4px rgba(125, 135, 148, 0.3);
}

.status-layer.show {
  display: flex;
  animation: popIn 0.6s cubic-bezier(0.2, 1.4, 0.5, 1);
}

/* ============================== 遮罩 ============================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(14px + var(--safe-t)) calc(14px + var(--safe-r))
    calc(14px + var(--safe-b)) calc(14px + var(--safe-l));
  background: rgba(125, 135, 148, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.overlay.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: min(440px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: none;
  border-radius: 28px;
  padding: 24px;
  box-shadow: 20px 20px 40px var(--shadow-dark), -20px -20px 40px var(--shadow-light);
  text-align: center;
}

.modal h2 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.modal p {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--ink-dim);
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.result-body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  text-align: left;
}

.result-body .fan-line {
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  color: var(--gold);
  margin: 10px 0 6px;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.result-body .pat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}

.pat {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 22px;
  background: var(--panel);
  border: none;
  color: var(--gold);
  box-shadow: 3px 3px 6px var(--shadow-inner), -3px -3px 6px var(--shadow-light);
}

.result-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  padding: 12px 0;
}

.rules-modal {
  text-align: left;
  width: min(600px, 94vw);
}

.rules-body {
  font-size: 14px;
  line-height: 1.8;
  color: #5b626e;
  max-height: 58vh;
  overflow-y: auto;
  padding-right: 6px;
}

.rules-body h3 {
  font-size: 14px;
  margin: 16px 0 6px;
  color: var(--gold);
  letter-spacing: 0.14em;
}

.rules-body h3:first-child {
  margin-top: 0;
}

.rules-body ul {
  margin: 0;
  padding-left: 20px;
}

.rules-body li {
  margin: 4px 0;
}

.rules-body b {
  color: var(--jade);
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20% + var(--safe-b));
  transform: translateX(-50%) translateY(16px);
  background: var(--panel);
  border: none;
  color: var(--ink);
  font-size: 14px;
  padding: 12px 22px;
  border-radius: 26px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- 横屏提示 ---- */

.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #cfd6dd;
  color: var(--ink-dim);
  text-align: center;
  padding: 28px;
}

.rotate-hint.show {
  display: flex;
}

.rotate-icon {
  font-size: 52px;
  color: var(--gold);
  animation: spinHint 2.4s ease-in-out infinite;
}

@keyframes spinHint {
  0%,
  40% {
    transform: rotate(0deg);
  }
  60%,
  100% {
    transform: rotate(90deg);
  }
}

/* ============================== 自适应 ============================== */

@media (max-width: 760px) {
  .hdr-logo {
    font-size: 14px;
  }
  .log-box {
    display: none;
  }
  .info-column {
    width: 68px;
  }
  .lobby-wrap {
    justify-content: flex-start;
    padding-top: calc(24px + var(--safe-t));
  }
  .logo {
    font-size: 36px;
  }
  .lobby-panel {
    padding: 18px;
    gap: 12px;
  }
}

@media (max-height: 400px) {
  .tbl-header {
    min-height: 36px;
    padding: 4px 10px;
  }
  .opp-row {
    min-height: 38px;
    padding: 3px 10px 0;
  }
  .me-row {
    padding: 2px 10px calc(3px + var(--safe-b));
  }
  .modal h2 {
    font-size: 19px;
  }
  .modal {
    padding: 18px;
  }
  .result-body .fan-line {
    font-size: 24px;
    margin: 6px 0 4px;
  }
  .tagline {
    display: none;
  }
}

@media (max-height: 320px) {
  .log-box {
    display: none;
  }
}

@media (min-aspect-ratio: 16/9) and (min-width: 900px) {
  :root {
    --tile-w: 54px;
  }
}
