/* style.css — 双人雀神 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: #0d2418; color: #f3ecd8; user-select: none;
}
.screen { position: fixed; inset: 0; }

/* ---------- 大厅 ---------- */
.lobby-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255, 236, 180, .18), transparent 60%),
    linear-gradient(180deg, #14382a 0%, #0d2418 55%, #081710 100%);
}
.lobby-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 26px 26px;
}
.lobby-panel {
  position: relative; z-index: 2; width: min(420px, 92vw);
  margin: 8vh auto 0; padding: 34px 30px 26px;
  background: linear-gradient(170deg, rgba(24, 52, 38, .92), rgba(14, 32, 22, .95));
  border: 1px solid rgba(214, 178, 94, .35); border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
  backdrop-filter: blur(6px);
}
.lobby-logo { text-align: center; margin-bottom: 22px; }
.logo-tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 62px; height: 80px; border-radius: 9px; margin-bottom: 10px;
  background: linear-gradient(160deg, #fdf6e0, #eadfb8);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .45), inset 0 -3px 0 rgba(120, 90, 40, .25);
  color: #b3271d; font-size: 34px; font-weight: 800; font-family: KaiTi, STKaiti, serif;
}
.lobby-logo h1 {
  font-size: 30px; letter-spacing: 8px; color: #f0d28a; font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.subtitle { margin-top: 6px; font-size: 13px; color: #9db8a5; letter-spacing: 2px; }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.mode-btn {
  padding: 12px 8px; border-radius: 12px; border: 1px solid rgba(214, 178, 94, .3);
  background: rgba(255, 255, 255, .04); color: #cfe0d2; cursor: pointer; font-size: 15px; font-weight: 700;
  transition: all .18s ease;
}
.mode-btn small { display: block; margin-top: 4px; font-size: 11px; font-weight: 400; color: #8ba693; }
.mode-btn.active {
  border-color: #e7c56a; background: linear-gradient(160deg, rgba(231, 197, 106, .18), rgba(231, 197, 106, .06));
  color: #f4dc9a; box-shadow: inset 0 0 0 1px rgba(231, 197, 106, .25);
}
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: #9db8a5; margin-bottom: 6px; letter-spacing: 1px; }
.field input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid rgba(214, 178, 94, .3);
  background: rgba(0, 0, 0, .28); color: #f3ecd8; font-size: 16px; outline: none;
}
.field input:focus { border-color: #e7c56a; }
.lobby-btns { display: grid; gap: 10px; margin-top: 18px; }
.big-btn {
  padding: 13px 18px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 16px; font-weight: 700; letter-spacing: 2px; transition: transform .12s ease, filter .15s ease;
}
.big-btn:active { transform: scale(.97); }
.big-btn.primary {
  background: linear-gradient(180deg, #d8a53c, #b0761f); color: #fff8e8;
  box-shadow: 0 5px 14px rgba(176, 118, 31, .4), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.big-btn.ghost {
  background: transparent; border: 1px solid rgba(214, 178, 94, .4); color: #e6d5a3;
}
.big-btn.ghost:hover { background: rgba(214, 178, 94, .1); }
.lobby-tip { margin-top: 16px; font-size: 12px; color: #7e9884; text-align: center; line-height: 1.6; }

/* ---------- 等待房 ---------- */
.wait-panel { text-align: center; }
.wait-panel h2 { color: #f0d28a; font-size: 22px; margin-bottom: 8px; letter-spacing: 2px; }
.wait-panel h2 b { font-size: 30px; letter-spacing: 6px; color: #fff3cf; cursor: pointer; }
.wait-tip { color: #9db8a5; font-size: 13px; margin-bottom: 22px; }
.seat-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 24px; }
.seat-card { width: 120px; padding: 18px 10px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(214, 178, 94, .25); font-size: 14px; }
.vs { font-size: 22px; font-weight: 800; color: #e7c56a; }
.seat-avatar {
  width: 52px; height: 52px; margin: 0 auto 8px; border-radius: 50%;
  background: linear-gradient(160deg, #2f6f4d, #1c4530); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #f0d28a; font-size: 18px; border: 2px solid rgba(214, 178, 94, .4);
}
.wait-panel .big-btn { width: 100%; margin-bottom: 10px; }

/* ---------- 牌桌 ---------- */
.scene { position: absolute; inset: 0; overflow: hidden; }
.mountains {
  position: absolute; inset: 0;
  background:
    radial-gradient(900px 320px at 20% 0%, rgba(184, 220, 190, .35), transparent 70%),
    radial-gradient(900px 360px at 85% 0%, rgba(150, 200, 170, .3), transparent 70%),
    linear-gradient(180deg, #9ec9a8 0%, #7fb08e 26%, #55896a 46%, #2e5c44 72%, #1d4030 100%);
}
.mountains::before {
  content: ""; position: absolute; left: -5%; right: -5%; top: 2%; height: 34%;
  background:
    radial-gradient(60% 90% at 22% 100%, rgba(38, 84, 58, .75), transparent 68%),
    radial-gradient(52% 80% at 52% 100%, rgba(52, 106, 74, .65), transparent 66%),
    radial-gradient(58% 86% at 82% 100%, rgba(30, 70, 48, .8), transparent 70%);
  filter: blur(2px);
}
.mountains::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(10, 30, 20, .35) 100%);
}

.table-felt {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: 7%; bottom: 0; width: min(1000px, 100vw);
  background:
    radial-gradient(120% 90% at 50% 10%, #2c7a52 0%, #1f5d3c 48%, #16452c 100%);
  border-radius: 46px 46px 0 0;
  border: 14px solid transparent;
  border-image: linear-gradient(180deg, #a97b3f, #7c5122) 1;
  box-shadow: inset 0 14px 40px rgba(0, 0, 0, .38), 0 -8px 30px rgba(0, 0, 0, .3);
}
.table-rim {
  position: absolute; inset: -14px; border-radius: 52px 52px 0 0; pointer-events: none;
  background: linear-gradient(180deg, #b98544, #7c5122);
  z-index: -1;
}

/* 顶栏 */
.topbar {
  position: absolute; top: 10px; left: 14px; right: 14px;
  display: flex; align-items: center; justify-content: space-between; z-index: 30;
  font-size: 13px; color: #cfe6d4;
}
.brand {
  padding: 5px 12px; border-radius: 8px; background: rgba(10, 26, 18, .55);
  border: 1px solid rgba(214, 178, 94, .4); color: #f0d28a; font-weight: 800; letter-spacing: 3px;
}
.room-info { background: rgba(10, 26, 18, .45); padding: 5px 12px; border-radius: 8px; }
.room-info b { color: #f0d28a; }
.wall-count { background: rgba(10, 26, 18, .45); padding: 5px 12px; border-radius: 8px; }
.wall-count b { color: #f0d28a; font-size: 15px; }

/* 玩家名牌 */
.opp-plate, .my-plate {
  position: absolute; display: flex; align-items: center; gap: 9px; z-index: 25;
  padding: 7px 12px 7px 8px; border-radius: 30px;
  background: linear-gradient(180deg, rgba(14, 36, 24, .92), rgba(8, 22, 14, .92));
  border: 1px solid rgba(214, 178, 94, .35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}
.opp-plate { top: 52px; right: 14px; }
.my-plate { bottom: 12px; left: 14px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: linear-gradient(160deg, #35795a, #1d4a33);
  display: flex; align-items: center; justify-content: center;
  color: #f0d28a; font-weight: 800; font-size: 15px; border: 2px solid rgba(214, 178, 94, .45);
}
.avatar.me { background: linear-gradient(160deg, #3a6fa5, #1e3f61); }
.plate-name { font-size: 13px; color: #f3ecd8; font-weight: 700; line-height: 1.2; }
.plate-score { font-size: 11px; color: #9db8a5; }
.plate-score b { color: #f0d28a; font-size: 13px; }
.ting-badge {
  padding: 2px 7px; border-radius: 8px; background: #b3271d; color: #fff; font-size: 12px; font-weight: 800;
  box-shadow: 0 0 10px rgba(179, 39, 29, .7);
}
.dc-badge { padding: 2px 7px; border-radius: 8px; background: #555; color: #ddd; font-size: 11px; }

/* 对手区 */
.opp-zone { position: absolute; top: 46px; left: 0; right: 0; display: flex; justify-content: center; z-index: 10; }
.opp-melds { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; justify-content: center; max-width: 70%; }

/* 牌河 */
.river {
  position: absolute; top: 118px; left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(9, auto); gap: 5px; z-index: 8;
}
.my-river {
  position: absolute; bottom: 148px; left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(9, auto); gap: 5px; z-index: 8;
}
/* 牌河：最新弃牌亮牌面高亮，旧牌背面化（防计牌），由 JS 控制类名 */
.river .tile, .my-river .tile { width: 34px; height: 44px; }
.river .tile .tile-face svg, .my-river .tile .tile-face svg { width: 100%; height: 100%; }
.river .tile.latest, .my-river .tile.latest {
  outline: 2px solid #ffd76a;
  box-shadow: 0 0 12px rgba(255, 215, 106, .85), 0 3px 6px rgba(0, 0, 0, .4);
  transform: scale(1.1);
  z-index: 3;
}
.river .tile.old, .my-river .tile.old { opacity: .8; }

/* 麻将牌 */
.tile {
  width: 46px; height: 60px; border-radius: 6px; position: relative; flex: none;
  background: linear-gradient(180deg, #e8dcb8 0%, #d9caa0 100%);
  border: 1px solid rgba(120, 90, 40, .35);
  box-shadow: 0 3px 5px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .8);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tile-face { position: absolute; inset: 3px; background: linear-gradient(175deg, #fdf8e8, #f2e9cd); border-radius: 4px; overflow: hidden; }
.tile-face svg { width: 100%; height: 100%; display: block; }
.tile-backface {
  position: absolute; inset: 3px; border-radius: 4px;
  background:
    repeating-linear-gradient(135deg, rgba(140, 90, 30, .25) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #c98d43, #9a6427);
  border: 1px solid rgba(90, 55, 15, .5);
}

/* 手牌：宽度自适应，任何张数（13/14+）都完整显示一行 */
.hand-zone {
  position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%);
  display: flex; gap: var(--hand-gap, 4px); z-index: 20; align-items: flex-end;
  max-width: calc(100vw - 16px);
}
.hand-zone .tile {
  width: var(--tile-w, 50px);
  height: calc(var(--tile-w, 50px) * 1.32);
  cursor: pointer;
  font-size: calc(var(--tile-w, 50px) * 0.5);
}
.hand-zone .tile.selected { transform: translateY(-14px); }
/* 刚摸的牌：金色光晕 + 呼吸动画，明显可见 */
.hand-zone .tile.drawn {
  outline: 2px solid #ffd76a;
  box-shadow: 0 0 12px rgba(255, 215, 106, .8), 0 3px 5px rgba(0, 0, 0, .35);
  animation: drawnPulse 1.6s ease-in-out infinite;
}
@keyframes drawnPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 106, .65), 0 3px 5px rgba(0, 0, 0, .35); }
  50% { box-shadow: 0 0 22px rgba(255, 215, 106, 1), 0 3px 5px rgba(0, 0, 0, .35); }
}
@media (prefers-reduced-motion: reduce) {
  .hand-zone .tile.drawn { animation: none; }
}
.hand-zone .tile.drawn.selected { transform: translateY(-14px); }
.hand-zone .tile.dimmed { filter: brightness(.55) saturate(.6); }
.hand-zone .tile:hover:not(.dimmed) { transform: translateY(-8px); }
.hand-zone .tile.drawn:hover { transform: translateY(-14px); }

/* 我的亮牌 */
.my-melds {
  position: absolute; bottom: 200px; left: 14px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 15; max-width: 40vw;
}
.my-melds .meld, .opp-melds .meld { display: flex; gap: 2px; padding: 3px; border-radius: 6px; background: rgba(0, 0, 0, .22); }
.my-melds .tile { width: 34px; height: 44px; }
.opp-melds .tile { width: 30px; height: 39px; }

/* 操作按钮 */
.action-bar {
  position: absolute; right: 12px; bottom: 210px; z-index: 40;
  display: flex; flex-direction: column; gap: 8px;
}
.act-btn {
  min-width: 74px; padding: 10px 16px; border: none; border-radius: 12px; cursor: pointer;
  font-size: 17px; font-weight: 800; letter-spacing: 2px; color: #fff;
  background: linear-gradient(180deg, #3f9d5f, #237243);
  box-shadow: 0 4px 12px rgba(20, 70, 40, .5), inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: transform .12s ease;
}
.act-btn:active { transform: scale(.94); }
.act-btn.hu { background: linear-gradient(180deg, #cf5a2e, #a63a17); font-size: 19px; }
.act-btn.gang { background: linear-gradient(180deg, #c99a3c, #9a7020); }
.act-btn.pass { background: linear-gradient(180deg, #5c6e62, #3d4a41); }
.act-btn.ting { background: linear-gradient(180deg, #3a6fa5, #24486d); }

/* 倒计时 */
.center-timer {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%); z-index: 15;
  width: 78px; height: 78px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #d84a35, #8f1d10);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(120, 20, 10, .55), inset 0 2px 6px rgba(255, 255, 255, .25);
}
.center-timer::after {
  content: ""; position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%);
  border: 9px solid transparent; border-top-color: #8f1d10;
}
.center-timer svg { position: absolute; inset: 4px; transform: rotate(-90deg); }
.timer-ring { fill: none; stroke: rgba(255, 220, 170, .85); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 213.6; transition: stroke-dashoffset .3s linear; }
#timerNum { font-size: 30px; font-weight: 800; color: #fff3d9; text-shadow: 0 2px 4px rgba(0,0,0,.4); }

/* 待响应提示 */
.pending-hint {
  position: absolute; top: 30%; left: 50%; transform: translateX(-50%); z-index: 18;
  background: rgba(10, 26, 18, .8); border: 1px solid rgba(214, 178, 94, .4);
  color: #f0d28a; padding: 7px 16px; border-radius: 20px; font-size: 13px;
}

/* 听牌面板 */
.ting-panel {
  position: absolute; bottom: 118px; left: 50%; transform: translateX(-50%); z-index: 18;
  display: flex; align-items: center; gap: 8px;
  background: rgba(10, 26, 18, .8); border: 1px solid rgba(214, 178, 94, .4);
  padding: 6px 14px; border-radius: 20px; font-size: 13px;
}
.ting-label { background: #b3271d; border-radius: 6px; padding: 1px 7px; font-weight: 800; color: #fff; }
.ting-face { display: inline-flex; margin: 0 1px; }
.ting-face .tile { width: 22px; height: 29px; border-radius: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.4); }

/* 托管/退出 */
.auto-btn, .leave-btn {
  position: absolute; z-index: 30; padding: 9px 16px; border-radius: 20px; cursor: pointer;
  border: 1px solid rgba(214, 178, 94, .45); background: rgba(10, 26, 18, .7);
  color: #e6d5a3; font-size: 13px; font-weight: 700; letter-spacing: 2px;
}
.auto-btn { right: 14px; bottom: 16px; }
.leave-btn { right: 84px; bottom: 16px; }
.auto-btn.on { background: linear-gradient(180deg, #d8a53c, #a8761f); color: #fff; }

/* 弹层 */
.modal {
  position: fixed; inset: 0; z-index: 90; background: rgba(4, 12, 8, .6);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px);
}
.modal-box {
  width: min(400px, 90vw); padding: 26px 24px; border-radius: 18px; text-align: center;
  background: linear-gradient(170deg, #1b3f2c, #10281b);
  border: 1px solid rgba(214, 178, 94, .4); box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.modal-box h3 { color: #f0d28a; font-size: 20px; margin-bottom: 12px; letter-spacing: 3px; }
.modal-sub { color: #9db8a5; font-size: 12px; margin-top: 10px; line-height: 1.6; }
.modal-btns { display: flex; gap: 10px; margin-top: 18px; }
.modal-btns .big-btn { flex: 1; padding: 11px 0; font-size: 15px; }
.settle-box h3.won { color: #ffd76a; }
.settle-box h3.lost { color: #9fb8a5; }
.settle-hands { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin: 12px 0; }
.settle-hands .tile { width: 32px; height: 42px; }
.fan-list { margin: 10px 0; font-size: 14px; color: #e6d5a3; line-height: 1.9; }
.fan-list b { color: #ffd76a; }
.settle-score { font-size: 26px; font-weight: 800; margin: 6px 0; }
.settle-score.plus { color: #7ee29a; }
.settle-score.minus { color: #e07b6a; }

/* toast */
.toast {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%); z-index: 99;
  background: rgba(10, 26, 18, .92); border: 1px solid rgba(214, 178, 94, .5);
  color: #f0d28a; padding: 10px 22px; border-radius: 24px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

/* 小屏适配 */
@media (max-width: 760px) {
  .river, .my-river { grid-template-columns: repeat(8, auto); }
  .river .tile, .my-river .tile { width: 28px; height: 37px; }
  .my-melds .tile, .opp-melds .tile { width: 26px; height: 34px; }
  .my-melds { bottom: 178px; }
  .opp-plate { top: 48px; }
  .act-btn { min-width: 62px; padding: 9px 12px; font-size: 15px; }
  .river { top: 108px; }
}
