:root {
  --felt-1: #0a2b21;
  --felt-2: #12543e;
  --felt-3: #0c3528;
  --gold: #ffd36e;
  --gold-deep: #e2a93b;
  --red: #ff6b6b;
  --blue: #7cc4ff;
  --ink: #1d2430;
  --paper: #fffdf5;
  --line: rgba(255, 255, 255, .14);
  --shadow: 0 10px 26px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  background: #071d17;
  color: #f2f7f3;
  overflow: hidden;
  user-select: none;
}
button { font-family: inherit; cursor: pointer; }

#app { height: 100%; padding: 10px; }
.felt {
  position: relative;
  height: 100%;
  border-radius: 20px;
  overflow: hidden;
  border: 7px solid #4a2c1b;
  box-shadow: inset 0 0 0 2px #7a4a29, inset 0 0 90px rgba(0, 0, 0, .55), 0 18px 50px rgba(0, 0, 0, .6);
  background:
    radial-gradient(ellipse 75% 62% at 50% 42%, rgba(255, 255, 255, .075), transparent 70%),
    radial-gradient(ellipse at 50% 40%, var(--felt-2), var(--felt-1) 74%, #061c15 100%);
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .34), rgba(0, 0, 0, .08));
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 6;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 186px; }
.logo { font-size: 30px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); }
.brand-txt b { display: block; font-size: 17px; letter-spacing: 2px; color: var(--gold); line-height: 1.15; }
.brand-txt small { font-size: 9px; letter-spacing: 1.4px; color: #a7c9b9; }
.chips { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, .28);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: #c7ded2;
  white-space: nowrap;
}
.chip b { color: #fff; font-size: 14px; font-variant-numeric: tabular-nums; }
.chip.mult b { color: var(--gold); }
.chip.coins b { color: #ffe08a; }
.chip.streak { background: rgba(255, 107, 107, .16); border-color: rgba(255, 107, 107, .4); }
.chip.streak b { color: #ffb3a7; }
.chip.bump { animation: bump .45s ease; }
@keyframes bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.22); } }
.tools { display: flex; gap: 6px; }
.tool {
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
  color: #e7f2ea;
  border-radius: 10px;
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  font-size: 14px;
  transition: .16s;
}
.tool span { font-size: 11px; }
.tool:hover { background: rgba(255, 255, 255, .2); transform: translateY(-1px); }
.tool.off { opacity: .42; }

/* ---------- 桌面 ---------- */
.arena { position: relative; height: calc(100% - 62px); }
.arena.shake { animation: shake .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-7px, 3px); }
  40%, 60% { transform: translate(7px, -3px); }
}

/* 底牌 */
.bottom-cards {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  text-align: center; z-index: 3;
}
.bottom-label { font-size: 11px; letter-spacing: 3px; color: #a9cbb9; margin-bottom: 5px; }
.bottom-slots { display: flex; gap: 5px; justify-content: center; }
.bottom-slots .card { animation: flipIn .55s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes flipIn { from { transform: rotateY(90deg) scale(.8); opacity: 0; } to { transform: rotateY(0) scale(1); opacity: 1; } }

/* 座位 */
.seat { position: absolute; top: 21%; z-index: 4; width: 150px; text-align: center; }
.seat-left { left: 3.2%; }
.seat-right { right: 3.2%; }
.avatar-box { position: relative; display: inline-block; }
.avatar {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center; font-size: 34px;
  background: linear-gradient(145deg, #ffe6a8, #e2a94a);
  border: 3px solid rgba(255, 255, 255, .75);
  box-shadow: var(--shadow);
}
.seat-right .avatar { background: linear-gradient(145deg, #ffd0e0, #e887ae); }
.me-avatar { background: linear-gradient(145deg, #b9e8ff, #5aa9e6); }
.avatar-box .role {
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 10px;
  background: #b5322f; color: #fff; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.avatar-box .role.farmer { background: #2f7a53; }
.avatar-box .role:empty { display: none; }
.seat.turn .avatar, .seat-me.turn .avatar { box-shadow: 0 0 0 4px rgba(255, 211, 110, .55), 0 0 24px rgba(255, 211, 110, .75); }
.seat-name { margin-top: 12px; font-size: 13px; font-weight: 600; color: #f4fff8; }
.cards-left { display: inline-block; margin-left: 6px; font-size: 11px; color: #bdd7c9; font-weight: 400; }
.cards-left b { color: var(--gold); font-size: 14px; }
.cards-left.danger b { color: #ff9b8f; }
.back-stack { position: relative; height: 22px; margin-top: 5px; }
.back-stack i {
  position: absolute; left: 50%; top: 0; width: 20px; height: 28px;
  margin-left: -10px; border-radius: 3px;
  background: repeating-linear-gradient(45deg, #2b4d90 0 4px, #e8eefc 4px 8px);
  border: 1px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.bubble {
  position: absolute; top: -18px; left: 100%; margin-left: 6px;
  background: #fffdf5; color: #24322b; font-size: 12px; font-weight: 600;
  padding: 7px 11px; border-radius: 12px 12px 12px 2px; white-space: nowrap;
  box-shadow: var(--shadow); opacity: 0; transform: scale(.7) translateY(6px);
  transition: .22s; pointer-events: none; z-index: 8;
}
.seat-right .bubble { left: auto; right: 100%; margin: 0 6px 0 0; border-radius: 12px 12px 2px 12px; }
.bubble.show { opacity: 1; transform: scale(1) translateY(0); }
.seat-me { position: absolute; left: 3.2%; bottom: 218px; z-index: 4; width: 150px; text-align: center; }
.seat-me .bubble { top: -6px; }

/* 出牌区 */
.play-area { position: absolute; left: 17%; right: 17%; top: 17%; height: 44%; z-index: 2; }
.play-slot { position: absolute; display: flex; justify-content: center; align-items: center; min-height: 74px; }
.play-slot .card { margin-left: -20px; animation: playIn .26s ease both; }
.play-slot .card:first-child { margin-left: 0; }
.slot-left { left: 0; top: 22%; width: 46%; }
.slot-right { right: 0; top: 22%; width: 46%; }
.slot-me { left: 50%; transform: translateX(-50%); bottom: 0; width: 76%; }
@keyframes playIn { from { opacity: 0; transform: translateY(22px) scale(.75) rotate(-6deg); } to { opacity: 1; transform: none; } }
.play-slot .pass-tag {
  font-size: 22px; font-weight: 800; color: #d6e8dd; letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .7); animation: playIn .24s ease both;
}
.play-slot .type-tag {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: #0d3326; background: var(--gold);
  padding: 2px 10px; border-radius: 10px; font-weight: 700; white-space: nowrap;
}
.center-banner {
  position: absolute; top: 44%; left: 50%; transform: translate(-50%, -50%);
  font-size: 42px; font-weight: 900; letter-spacing: 5px;
  color: #fff; text-shadow: 0 0 24px rgba(255, 100, 60, .9), 0 6px 12px rgba(0, 0, 0, .6);
  opacity: 0; pointer-events: none; z-index: 9; white-space: nowrap;
}
.center-banner.show { animation: bannerPop 1.1s ease both; }
@keyframes bannerPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-12deg); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.18) rotate(3deg); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1.05); }
}

/* 手牌 */
.hand-wrap {
  position: absolute; left: 0; right: 0; bottom: 66px; height: 148px;
  display: flex; justify-content: center; align-items: flex-end; z-index: 5;
  padding: 0 26px;
}
.hand { display: flex; justify-content: center; align-items: flex-end; height: 100%; padding-top: 26px; }
.hand .card { cursor: pointer; transition: transform .14s ease, box-shadow .14s ease; }
.hand.dealing .card { animation: dealIn .34s cubic-bezier(.2, .8, .3, 1) both; }
.hand .card:hover { transform: translateY(-9px); }
.hand .card.selected { transform: translateY(-26px); box-shadow: 0 0 0 3px var(--gold), 0 14px 22px rgba(0, 0, 0, .5); z-index: 3; }
.hand .card.selected:hover { transform: translateY(-30px); }
.hand .card.hint { animation: hintPulse .7s ease infinite alternate; }
@keyframes hintPulse { from { box-shadow: 0 0 0 2px rgba(124, 196, 255, .5); } to { box-shadow: 0 0 0 4px rgba(124, 196, 255, 1); } }
@keyframes dealIn { from { opacity: 0; transform: translate(180px, -140px) rotate(24deg) scale(.6); } to { opacity: 1; transform: none; } }

/* 牌面 */
.card {
  position: relative; flex: 0 0 auto;
  width: 76px; height: 110px;
  background: linear-gradient(160deg, #fffef9, #f0ecdf);
  border: 1px solid #d8d2be; border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .35);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  overflow: hidden;
}
.card.red { color: #d3322f; }
.card .c-top { position: absolute; top: 5px; left: 7px; text-align: center; line-height: 1; }
.card .c-rank { display: block; font-size: 21px; font-weight: 700; letter-spacing: -1px; }
.card .c-suit { display: block; font-size: 16px; margin-top: 1px; }
.card .c-center { position: absolute; right: 7px; bottom: 8px; font-size: 40px; opacity: .92; line-height: 1; }
.card .c-bottom { display: none; }
.card .c-bottom .c-rank { font-size: 15px; }
.card .c-bottom .c-suit { font-size: 12px; }
.card.joker .c-rank { font-size: 17px; font-family: "PingFang SC", sans-serif; }
.card.joker .c-center { left: 7px; top: 36px; right: auto; bottom: auto; font-size: 28px; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 700; }
.card.back {
  background: repeating-linear-gradient(45deg, #2b4d90 0 6px, #dce6f8 6px 12px);
  border: 2px solid #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .4);
}
.card.back::after {
  content: ''; position: absolute; inset: 6px; border: 2px solid rgba(255, 255, 255, .85); border-radius: 4px;
}
.card.mini { width: 48px; height: 70px; border-radius: 6px; }
.card.mini .c-top { top: 3px; left: 4px; }
.card.mini .c-rank { font-size: 15px; }
.card.mini .c-suit { font-size: 11px; }
.card.mini .c-center { font-size: 25px; right: 4px; bottom: 5px; }
.card.mini .c-bottom { bottom: 2px; left: 4px; }
.card.mini .c-bottom .c-rank { font-size: 10px; }
.card.mini .c-bottom .c-suit { font-size: 8px; }
.card.mini.joker .c-rank { font-size: 12px; }
.card.mini.joker .c-center { left: 4px; top: 22px; font-size: 17px; }
.card.tiny.joker .c-center { left: 3px; top: 17px; font-size: 14px; }
.card.tiny { width: 40px; height: 58px; border-radius: 5px; }
.card.tiny .c-top { top: 2px; left: 3px; }
.card.tiny .c-rank { font-size: 13px; }
.card.tiny .c-suit { font-size: 9px; }
.card.tiny .c-center { font-size: 20px; right: 3px; bottom: 4px; }
.card.tiny .c-bottom { display: none; }

/* 状态 / 按钮 */
.status-line {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 224px;
  font-size: 12px; color: #a9c9b8; z-index: 5; white-space: nowrap;
}
.actionbar {
  position: absolute; left: 0; right: 0; bottom: 12px;
  display: flex; gap: 10px; align-items: center; z-index: 7; flex-wrap: wrap; justify-content: center;
  padding: 0 10px;
}
.btn {
  border: none; border-radius: 24px; padding: 10px 24px; font-size: 14px; font-weight: 700;
  color: #21332a; background: linear-gradient(180deg, #fffdf2, #e9e2c9);
  box-shadow: 0 4px 0 #b0a681, 0 8px 14px rgba(0, 0, 0, .3); transition: .12s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #b0a681, 0 10px 18px rgba(0, 0, 0, .35); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b0a681; }
.btn.primary { background: linear-gradient(180deg, #ffe08c, #f0ac35); color: #3b2607; box-shadow: 0 4px 0 #a9711c, 0 8px 16px rgba(0, 0, 0, .35); }
.btn.danger { background: linear-gradient(180deg, #ff9d8f, #e8564b); color: #fff; box-shadow: 0 4px 0 #9d322c, 0 8px 16px rgba(0, 0, 0, .35); }
.btn.ghost { background: rgba(255, 255, 255, .12); color: #e9f5ed; box-shadow: none; border: 1px solid var(--line); }
.btn.ghost:hover { background: rgba(255, 255, 255, .22); transform: none; box-shadow: none; }
.btn.small { padding: 7px 16px; font-size: 12px; }
.btn.on { outline: 2px solid var(--gold); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.timer {
  position: absolute; right: 22%; bottom: 232px; z-index: 6;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: var(--gold);
  border: 3px solid rgba(255, 211, 110, .55); background: rgba(0, 0, 0, .3);
}

/* 特效 */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
.blast {
  position: absolute; left: 50%; top: 44%; width: 10px; height: 10px;
  border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle, #fff6c9, #ffb02e 35%, rgba(255, 80, 20, .65) 60%, transparent 72%);
  animation: blast .7s ease-out both;
}
@keyframes blast { from { opacity: 1; width: 10px; height: 10px; } to { opacity: 0; width: 620px; height: 620px; } }
.spark { position: absolute; font-size: 26px; animation: spark 1s ease-out both; }
@keyframes spark { from { opacity: 1; transform: translate(0, 0) scale(.4) rotate(0); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.5) rotate(var(--rot)); } }
.confetti { position: absolute; width: 9px; height: 15px; top: -20px; animation: fall linear both; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .2; } }

/* 记牌器 */
.counter-panel {
  position: absolute; right: 0; top: 62px; bottom: 0; width: 290px; z-index: 20;
  background: rgba(7, 30, 22, .96); border-left: 1px solid var(--line);
  box-shadow: -14px 0 40px rgba(0, 0, 0, .5);
  transform: translateX(105%); transition: transform .28s ease;
  padding: 18px; overflow-y: auto;
}
.counter-panel.open { transform: none; }
.counter-head { display: flex; justify-content: space-between; align-items: center; color: var(--gold); font-size: 16px; }
.counter-head button { background: none; border: none; color: #cfe3d7; font-size: 18px; }
.counter-tip { font-size: 11px; color: #9dbbab; line-height: 1.6; margin: 10px 0 16px; }
.counter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.counter-cell { background: rgba(255, 255, 255, .07); border: 1px solid var(--line); border-radius: 9px; padding: 8px 4px; text-align: center; }
.counter-cell b { display: block; font-size: 17px; color: #fff; }
.counter-cell span { font-size: 10px; color: #9dbbab; }
.counter-cell.zero { opacity: .38; }
.counter-cell.zero b { color: #ff9c8f; }
.counter-cell.king b { color: var(--gold); }
.counter-foot { margin-top: 16px; font-size: 11px; color: #9dbbab; line-height: 1.8; border-top: 1px solid var(--line); padding-top: 12px; }

/* toast */
.toast {
  position: absolute; left: 50%; top: 76px; transform: translate(-50%, -14px);
  background: rgba(24, 20, 16, .92); color: #fff; border: 1px solid rgba(255, 211, 110, .5);
  padding: 9px 20px; border-radius: 20px; font-size: 13px; font-weight: 600;
  opacity: 0; transition: .22s; pointer-events: none; z-index: 30; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 弹窗 */
.modal {
  position: absolute; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgba(3, 16, 11, .74); backdrop-filter: blur(5px); padding: 18px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(520px, 94vw); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(165deg, #174c39, #0a2a20);
  border: 1px solid rgba(255, 211, 110, .35); border-radius: 20px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .65); padding: 26px 28px;
  animation: modalIn .3s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; transform: none; } }
.modal-card h2 { margin: 0 0 8px; color: var(--gold); font-size: 24px; letter-spacing: 2px; text-align: center; }
.modal-card .sub { text-align: center; color: #a8c9b8; font-size: 12px; margin-bottom: 20px; }
.modal-card p { font-size: 13px; line-height: 1.85; color: #dcece2; }
.modal-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.level-pick { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.level-pick button {
  flex: 1; max-width: 130px; padding: 12px 6px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: #e5f2ea; font-size: 13px;
}
.level-pick button b { display: block; font-size: 15px; margin-bottom: 3px; }
.level-pick button.active { background: rgba(255, 211, 110, .18); border-color: var(--gold); color: var(--gold); }
.rule-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.rule-table td { padding: 7px 8px; border-bottom: 1px solid rgba(255, 255, 255, .08); color: #dcece2; }
.rule-table td:first-child { color: var(--gold); width: 92px; white-space: nowrap; }
.result-score { text-align: center; margin: 6px 0 18px; }
.result-score .big { font-size: 46px; font-weight: 900; letter-spacing: 2px; }
.result-score .big.plus { color: #ffd36e; text-shadow: 0 0 26px rgba(255, 211, 110, .55); }
.result-score .big.minus { color: #ff9b8f; }
.result-rows { background: rgba(0, 0, 0, .24); border-radius: 12px; padding: 12px 16px; font-size: 13px; }
.result-row { display: flex; justify-content: space-between; padding: 5px 0; color: #cfe3d7; }
.result-row b { color: #fff; }
.result-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 15px; }
.result-row.total b { color: var(--gold); font-size: 19px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 14px 0 2px; }
.badge { font-size: 11px; padding: 5px 10px; border-radius: 14px; background: rgba(255, 211, 110, .16); border: 1px solid rgba(255, 211, 110, .45); color: var(--gold); }
.stat-line { text-align: center; font-size: 11px; color: #9dbbab; margin-top: 14px; }

@media (max-width: 900px) {
  #app { padding: 0; }
  .felt { border-radius: 0; border-width: 3px; }
  .topbar { height: 54px; padding: 0 8px; gap: 6px; }
  .brand { min-width: 0; }
  .brand-txt { display: none; }
  .chip { padding: 3px 8px; font-size: 10px; }
  .chip b { font-size: 12px; }
  .tools .tool span { display: none; }
  .tool { min-width: 30px; padding: 0 6px; height: 30px; font-size: 13px; }
  .arena { height: calc(100% - 54px); }
  .seat { top: 15%; width: 96px; }
  .seat-left { left: 1%; }
  .seat-right { right: 1%; }
  .avatar { width: 46px; height: 46px; font-size: 25px; }
  .seat-name { font-size: 11px; margin-top: 9px; }
  .cards-left { display: block; margin: 0; }
  .play-area { left: 8%; right: 8%; top: 15%; height: 45%; }
  .play-slot .card { margin-left: -26px; }
  .seat-me { bottom: 176px; left: 2%; width: 90px; }
  .seat-me .avatar { width: 42px; height: 42px; }
  .hand-wrap { bottom: 60px; height: 116px; padding: 0 6px; }
  .hand { padding-top: 22px; }
  .card { width: 56px; height: 82px; }
  .card .c-rank { font-size: 16px; }
  .card .c-suit { font-size: 12px; }
  .card .c-center { font-size: 28px; }
  .card .c-bottom .c-rank { font-size: 11px; }
  .card .c-bottom .c-suit { font-size: 9px; }
  .card.mini { width: 38px; height: 55px; }
  .card.mini .c-rank { font-size: 12px; }
  .card.mini .c-suit { font-size: 9px; }
  .card.mini .c-center { font-size: 18px; }
  .card.joker .c-center { left: 5px; top: 28px; font-size: 22px; }
  .card.mini .c-bottom { display: none; }
  .status-line { bottom: 184px; font-size: 11px; }
  .actionbar { gap: 6px; bottom: 8px; padding: 0 6px; }
  .btn { padding: 8px 12px; font-size: 12px; white-space: nowrap; }
  .btn.small { padding: 8px 10px; }
  .card.tiny { width: 30px; height: 44px; }
  .bottom-slots { gap: 3px; }
  .center-banner { font-size: 28px; }
  .bottom-cards { top: 6px; }
  .counter-panel { top: 54px; width: 240px; }
}
