:root {
  --felt: #2e9b57;
  --felt-deep: #1a7a40;
  --ivory: #fff6de;
  --wan: #cc1a1a;
  --pin: #1a4db8;
  --sou: #1a8a32;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Microsoft YaHei", "SimHei", sans-serif;
  color: #fff8e0;
  min-height: 100%;
}
body.ingame {
  overflow: hidden;
  height: 100dvh;
}
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(#3a2a18, #1a120c);
}
#app { position: relative; z-index: 1; min-height: 100%; }

.plaza-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 28px 8vw 8px;
  gap: 16px;
  flex-wrap: wrap;
}
.plaza-bar h1 {
  margin: 0;
  font-size: 2rem;
  color: #ffe082;
  text-shadow: 0 2px 0 #7a4a10;
}
.plaza-user { display: flex; align-items: center; gap: 10px; }
.game-grid {
  padding: 8px 8vw 40px;
  max-width: 1100px;
}
.game-cat h2 {
  margin: 18px 0 10px;
  font-size: 1.1rem;
  color: #ffd54a;
  letter-spacing: 2px;
}
.game-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.game-card {
  position: relative;
  background: linear-gradient(#3d6a2e, #234a1c);
  border: 3px solid #e0b445;
  border-radius: 10px;
  min-height: 160px;
  padding: 18px 16px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
  text-align: left;
}
.game-card:hover { filter: brightness(1.08); }
.game-card h3 { margin: 0 0 8px; color: #ffe082; font-size: 1.25rem; }
.game-card p { margin: 0; color: #d8f0c8; font-size: 0.9rem; }
.game-card .soon {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #8a5a10;
  color: #ffe082;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
}
.auth-card { text-align: left; min-width: 0; width: min(360px, calc(100vw - 32px)); }
.auth-card label { display: block; margin: 10px 0 4px; font-size: 0.85rem; }
.auth-card input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 4px;
  border: 2px solid #c9a227;
  background: #fffdf4;
  color: #333;
}

.panel {
  max-width: 440px;
  width: calc(100% - 24px);
  margin: 24px auto;
  padding: 20px 18px 16px;
  background: linear-gradient(#3d6a2e, #234a1c);
  border: 3px solid #e0b445;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  box-sizing: border-box;
}
.hall-page {
  min-height: 100dvh;
  background: linear-gradient(#3d6a2e, #1e4a18);
  padding: 10px 16px 24px;
  box-sizing: border-box;
}
.hall-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
}
.hall-bar button {
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
}
#hello-user {
  font-size: 13px;
  color: #fffde7;
}
.hall-card {
  max-width: 340px;
  margin: 28px auto 0;
  padding: 18px 16px 14px;
  background: rgba(0, 0, 0, .18);
  border: 2px solid #e0b445;
  border-radius: 8px;
}
.brand { text-align: center; }
.brand-tiles img { height: 88px; width: auto; }
.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #ffe082;
  text-shadow: 0 2px 0 #7a4a10;
}
.sub { color: #d8f0c8; margin: 6px 0 0; font-size: 0.85rem; }
.panel label { display: block; margin: 12px 0 6px; font-size: 0.85rem; }
.panel input, .join-row input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 4px;
  border: 2px solid #c9a227;
  background: #fffdf4;
  color: #333;
  font-size: 0.95rem;
}
.row { display: flex; gap: 8px; margin-top: 10px; justify-content: center; flex-wrap: wrap; }
#play-box { margin-top: 14px; }
.play-main { text-align: center; }
.join-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.join-row input { flex: 1; min-width: 0; width: auto; }
button {
  cursor: pointer;
  border: 2px solid #fff3c0;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 14px;
  background: linear-gradient(#ffe082, #e0a020);
  color: #5a2a00;
  font-weight: 800;
  box-shadow: 0 2px 0 #8a5a10;
}
button.ghost {
  background: linear-gradient(#8bc34a, #4caf50);
  color: #fff;
  border-color: #dcedc8;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.row.tabs button { flex: 1; }
.hidden { display: none !important; }

.lobby-seats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.lobby-seats div {
  background: rgba(0,0,0,.25);
  padding: 14px 10px;
  border-radius: 6px;
  border: 1px solid #c9a227;
  text-align: center;
}
.lobby-seats .empty { color: #c5e1a5; }

/* QQ 棋牌桌 */
.table-wrap {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  background: #1c7a40;
}
#orient {
  position: relative;
  min-height: 100%;
  min-height: 100dvh;
}
#orient.force-land {
  position: fixed;
  top: 0;
  left: 100vw;
  left: 100dvw;
  width: 100vh;
  width: 100dvh;
  height: 100vw;
  height: 100dvw;
  min-height: 0;
  overflow: auto;
  transform: rotate(90deg);
  transform-origin: 0 0;
  z-index: 1;
}
#orient.force-land .table-wrap {
  position: absolute;
  inset: 0;
  height: 100%;
}
#orient.force-land .hall-page {
  min-height: 100%;
}
#orient.force-land .overlay {
  position: absolute;
}
#orient.force-land .plaza-bar { padding: 12px 24px 4px; }
#orient.force-land .plaza-bar h1 { font-size: 1.35rem; }
#orient.force-land .game-grid { padding: 4px 24px 16px; }
#orient.force-land .game-card { min-height: 88px; padding: 10px 12px; }
#orient.force-land .overlay .card { padding: 16px 18px; max-width: 90%; }
.qq-desk {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #1c7a40;
}
.qq-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #1c7a40;
}
.qq-bar {
  flex: 0 0 auto;
  min-height: 32px;
  height: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 4px 12px;
  background: linear-gradient(#5aa03a, #2e7d32);
  border-bottom: 2px solid #e0b445;
  font-size: 13px;
  color: #fffde7;
}
.qq-bar button {
  margin-left: auto;
  padding: 2px 10px;
  font-size: 13px;
  box-shadow: none;
}
.qq-felt {
  position: relative;
  flex: 1;
  min-height: 560px;
  margin: 8px;
  border: 14px solid #a05a28;
  border-radius: 10px;
  background:
    radial-gradient(ellipse at 50% 42%, #48b86a 0%, #2e9b57 45%, #1c7a40 100%);
  box-shadow: inset 0 0 80px rgba(0,0,0,.18), 0 0 0 3px #6b3a14;
}

.player-tag {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(40, 24, 8, .72);
  border: 1px solid #e0b445;
  border-radius: 4px;
  padding: 4px 8px 4px 4px;
}
.av-face {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: linear-gradient(#90caf9, #1565c0);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 2px solid #ffe082;
}
.av-meta { display: flex; flex-direction: column; line-height: 1.2; }
.av-name { font-size: 12px; color: #fffde7; }
.av-score { font-size: 12px; color: #ffe082; font-family: Tahoma, sans-serif; }
.av-opp { top: 10px; left: 50%; transform: translateX(-50%); }
.av-left { left: 10px; top: 42%; }
.av-right { right: 10px; top: 42%; }
.player-tag.turn { box-shadow: 0 0 0 2px #ffe082, 0 0 10px #ffeb3b; }

.qq-wall {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}
.qq-wall.top {
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
}
.qq-wall.left {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
}
.qq-wall.right {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
}
.qq-wall.left .stands,
.qq-wall.right .stands {
  flex-direction: column;
}
.stands { display: flex; gap: 1px; }
.stand {
  width: 18px;
  height: 24px;
  background:
    linear-gradient(#3dce6a, #1f9a45);
  border: 1px solid #0d5c28;
  border-radius: 2px;
  box-shadow: 0 5px 0 #fff4d6, 0 6px 0 #c2b48a;
  flex: 0 0 auto;
}
.qq-wall.left .stand,
.qq-wall.right .stand {
  width: 24px;
  height: 16px;
  box-shadow: 5px 0 0 #fff4d6, 6px 0 0 #c2b48a;
}

.qq-center {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(52%, 460px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.qq-mid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.discards {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  max-width: 210px;
}
.rot-180 { transform: rotate(180deg); }
.rot-90 { transform: rotate(90deg); max-width: 150px; }
.rot-270 { transform: rotate(-90deg); max-width: 150px; }

.remain {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3d8c50, #0e3d22);
  border: 4px solid #e0b445;
  box-shadow: inset 0 0 12px #000, 0 4px 0 #6b3a14;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fffde7;
}
.remain span { font-size: 12px; }
.remain strong { font-size: 26px; color: #ffe082; line-height: 1; }
.remain em { font-style: normal; font-size: 12px; color: #b2ff59; }

.qq-self {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  z-index: 5;
}
.self-hand {
  display: flex;
  align-items: flex-end;
}
.self-hand .mj { margin-left: -8px; }
.self-hand .mj:first-child { margin-left: 0; }
.self-melds { display: flex; gap: 4px; margin-right: 8px; }

.actions {
  position: absolute;
  left: auto;
  right: 3%;
  bottom: 22%;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.actions button {
  pointer-events: auto;
  width: 76px;
  height: 76px;
  border-radius: 12px;
  padding: 0;
  font-size: 28px;
  line-height: 76px;
  font-weight: 900;
  box-shadow: 0 4px 0 #6b3a14, 0 6px 16px rgba(0,0,0,.35);
}
.actions button.hu {
  background: linear-gradient(#ff6b5b, #d32f2f);
  color: #fff;
  border-color: #ffcdd2;
}
.actions button.peng {
  background: linear-gradient(#ffb74d, #ef6c00);
  color: #fff;
}
.actions button.gang {
  background: linear-gradient(#ce93d8, #7b1fa2);
  color: #fff;
}
.end-bar {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 22;
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.end-bar button {
  pointer-events: auto;
  background: rgba(20, 40, 20, .35);
  border: 1px solid rgba(255, 253, 231, .55);
  color: #fffde7;
  box-shadow: none;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 6px;
}
.end-bar button:hover {
  background: rgba(255, 255, 255, .22);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  pointer-events: auto;
}
.overlay .card {
  background: linear-gradient(#3d6a2e, #234a1c);
  border: 3px solid #e0b445;
  padding: 24px;
  border-radius: 8px;
  text-align: center;
  min-width: 260px;
}

/* QQ 麻将牌：厚象牙 + 绿背 */
.mj {
  --w: 50px;
  --h: 72px;
  width: var(--w);
  height: var(--h);
  position: relative;
  border-radius: 8px;
  background:
    linear-gradient(#ffffff 0 82%, #2fa24c 82% 100%);
  box-shadow: 3px 6px 10px rgba(0, 40, 0, .28);
  user-select: none;
  flex: 0 0 auto;
  z-index: 1;
}
.mj::before {
  content: "";
  position: absolute;
  inset: 2px 2px 12px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(255,255,255,.7), transparent 42%);
  pointer-events: none;
}
.face.char {
  flex-direction: column;
  line-height: 0.9;
  font-weight: 900;
  font-family: "KaiTi", "STKaiti", "SimSun", serif;
}
.face.char b { font-size: 24px; font-style: normal; color: #111; }
.face.char i { font-size: 24px; font-style: normal; color: #d01216; }
.mj.mini { --w: 24px; --h: 34px; box-shadow: 1px 2px 0 #d5c79e, 1px 5px 0 #e7d7b0; }
.self-hand .mj.clickable { cursor: pointer; }
.self-hand .mj.clickable:hover,
.self-hand .mj.selected {
  transform: translateY(-14px);
  z-index: 3;
}

.mj .face {
  position: absolute;
  inset: 6px 4px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mj.mini .face { inset: 2px 2px 6px; }
.mj.mini .face.char b { font-size: 11px; }
.mj.mini .face.char i { font-size: 10px; }

.bai {
  width: 78%;
  height: 70%;
  border: 2px solid #1a8a32;
  color: #1a8a32;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 22px;
  font-family: "KaiTi", "SimSun", serif;
}
.mj.mini .bai { font-size: 10px; border-width: 1px; }

.pin { display: grid; width: 100%; height: 100%; place-items: center; }
.pin i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #7eb0ff, var(--pin) 60%, #0b2a80);
}
.mj.mini .pin i { width: 4px; height: 4px; }
.pin.p1 { grid-template: 1fr / 1fr; }
.pin.p2 { grid-template: 1fr 1fr / 1fr; }
.pin.p3 { grid-template: 1fr 1fr 1fr / 1fr; }
.pin.p4 { grid-template: 1fr 1fr / 1fr 1fr; }
.pin.p5 { grid-template: 1fr 1fr 1fr / 1fr 1fr; }
.pin.p5 i:nth-child(3) { grid-column: 1 / 3; }
.pin.p6 { grid-template: 1fr 1fr 1fr / 1fr 1fr; }
.pin.p7 { grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr; }
.pin.p8 { grid-template: repeat(4, 1fr) / 1fr 1fr; }
.pin.p9 { grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr; }

.sou {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
}
.sou i {
  width: 7px;
  height: 70%;
  border-radius: 3px;
  background: linear-gradient(90deg, #9be6a8, var(--sou));
  position: relative;
}
.sou i::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 14%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: #cc1a1a;
}
.mj.mini .sou i { width: 3px; }
.sou.s1 i { width: 9px; height: 78%; }
.sou.s4, .sou.s6, .sou.s8, .sou.s9 { display: grid; }
.sou.s4 { grid-template: 1fr 1fr / 1fr 1fr; }
.sou.s6 { grid-template: 1fr 1fr 1fr / 1fr 1fr; }
.sou.s8 { grid-template: 1fr 1fr / 1fr 1fr 1fr 1fr; }
.sou.s9 { grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr; }
.sou.s4 i, .sou.s6 i, .sou.s8 i, .sou.s9 i { height: 78%; width: 5px; }

.mj.back {
  background: linear-gradient(#3dce6a, #1f9a45);
  box-shadow: 0 6px 0 #fff4d6, 0 7px 0 #c2b48a;
}
.mj.back::before { border-color: rgba(255,255,255,.2); }

.meld-group { display: flex; gap: 1px; }

@media (max-width: 900px) {
  .mj { --w: 38px; --h: 54px; }
  .stand { width: 14px; height: 18px; }
  .self-hand .mj { margin-left: -6px; }
  .qq-bar { font-size: 12px; gap: 6px 10px; }
  .actions button {
    width: 64px;
    height: 64px;
    font-size: 24px;
    line-height: 64px;
  }
  .plaza-bar { padding: 16px 16px 4px; }
  .plaza-bar h1 { font-size: 1.45rem; }
  .game-grid { padding: 4px 16px 24px; }
  .game-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .game-card { min-height: 120px; padding: 14px 12px; }
  .panel {
    width: calc(100% - 20px);
    margin: 16px auto;
    min-height: 0;
  }
  .hall-card { margin-top: 20px; }
  .brand h1 { font-size: 1.35rem; }
}
