/* SPDX-License-Identifier: GPL-3.0-or-later */
/* =========================================================================
   掼蛋 · 前端样式
   只写掼蛋特有的部分：色板、卡牌、按钮、对话框、侧栏抽屉全部继承 style.css。
   布局用纯 CSS 自适应，不靠 JS 量尺寸；手机竖屏是第一优先级。
   ========================================================================= */

.gd-body {
  background:
    radial-gradient(1100px 660px at 50% -12%, #1b2320 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 110%, #191d1a 0%, transparent 55%),
    var(--bg-0);
}

#gdCol {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  min-width: 0;
}

/* =========================== 比分条 =========================== */

.score-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 27, 24, .8), rgba(10, 16, 14, .5));
}

.score-team {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.score-team[data-team="1"] { justify-content: flex-end; }

.st-name { font-size: 12px; font-weight: 700; white-space: nowrap; }
.score-team[data-team="0"] .st-name { color: #f0a0a6; }
.score-team[data-team="1"] .st-name { color: #9cc3ee; }

.st-lv {
  font-family: var(--font-num);
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 8px;
  color: #2a1c05;
  background: linear-gradient(180deg, #f2d68f, #cda447);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.st-seats {
  font-size: 11px;
  color: var(--txt-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.st-deal {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 5px;
  color: var(--gold);
  border: 1px solid rgba(233, 196, 106, .45);
  background: rgba(233, 196, 106, .1);
}
/* 打 A 的队伍闪一下，提醒大家这局是关键局 */
.score-team.at-a .st-lv { animation: aPulse 1.5s ease-in-out infinite; }
@keyframes aPulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
  50% { box-shadow: 0 0 16px var(--gold-glow), 0 2px 6px rgba(0, 0, 0, .4); }
}

.score-mid { text-align: center; }
.sm-wild {
  font-size: 12px;
  color: var(--gold);
  white-space: nowrap;
}
.sm-hint {
  font-size: 11px;
  color: var(--txt-faint);
  white-space: nowrap;
}

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

#gdTable {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.gd-felt {
  position: absolute;
  inset: 10px clamp(56px, 8%, 116px);
  border-radius: 999px / 22%;
  background:
    radial-gradient(120% 90% at 50% 18%, #1a6b4c 0%, #0e4733 62%, #0a3527 100%);
  box-shadow:
    inset 0 0 0 6px var(--wood-2),
    inset 0 0 0 9px rgba(233, 196, 106, .18),
    inset 0 20px 60px rgba(0, 0, 0, .38),
    0 18px 44px rgba(0, 0, 0, .5);
}

/* ---- 座位 ---- */

.gd-seat {
  position: absolute;
  display: flex;
  z-index: 3;
}
#seatTop   { top: 4px;  left: 50%; transform: translateX(-50%); }
#seatLeft  { left: 6px; top: 46%;  transform: translateY(-50%); }
#seatRight { right: 6px; top: 46%; transform: translateY(-50%); }
#seatSelf  { bottom: 2px; left: 50%; transform: translateX(-50%); }

.pod {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px 5px 5px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(14, 22, 19, .92), rgba(8, 14, 12, .92));
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-1);
  max-width: min(42vw, 190px);
  position: relative;
}
/* 左右两家竖着排。徽章行必须能换行——"23 + 不要 + 人机"三个挤一行会顶出圆角框 */
#seatLeft .pod, #seatRight .pod {
  flex-direction: column;
  padding: 7px 8px;
  gap: 4px;
  width: 96px;
  max-width: 96px;
}
#seatLeft .pod-sub, #seatRight .pod-sub {
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 3px;
}
#seatLeft .pod-main, #seatRight .pod-main { width: 100%; align-items: center; }
.pod[data-team="0"] { border-color: rgba(240, 160, 166, .3); }
.pod[data-team="1"] { border-color: rgba(156, 195, 238, .3); }
.pod.is-mate { box-shadow: var(--shadow-1), 0 0 0 1px rgba(233, 196, 106, .35); }
.pod.acting {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-glow), 0 0 18px var(--gold-glow);
}
.pod.gone { opacity: .5; }
.pod.off { filter: grayscale(.7); }

.pod-av {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}
.pod-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pod-name {
  font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 108px;
}
#seatLeft .pod-name, #seatRight .pod-name { max-width: 76px; text-align: center; }
.pod-sub {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--txt-dim);
}
.pod-count {
  font-family: var(--font-num);
  font-weight: 700;
  color: var(--txt);
}
.pod-count::before {
  content: "";
  display: inline-block;
  width: 9px; height: 12px;
  margin-right: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: repeating-linear-gradient(45deg, #23477e 0 2px, #1b3663 2px 4px);
  box-shadow: 2px 0 0 -1px #101d33, 1px 0 0 0 rgba(255, 255, 255, .18);
}
/* 只剩 1~2 张的人很危险，标红 */
.pod-count.danger { color: #ffb3b8; }

.pod-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--line-soft);
  color: var(--txt-faint);
}
.pod-tag.pass { color: #9aa9a1; }
.pod-tag.place { color: #2a1c05; background: linear-gradient(180deg, #f2d68f, #cda447); border: none; font-weight: 700; }
.pod-tag.bot { color: #9cc3ee; border-color: rgba(156, 195, 238, .3); }
.pod-tag.host { color: var(--gold); border-color: rgba(233, 196, 106, .4); }

.pod-empty {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .22);
  font-size: 11px; color: var(--txt-faint);
}
.pod-empty .act { min-height: 30px; padding: 0 12px; font-size: 12px; }

/* ---- 中央：最后打出的一手 ---- */

.gd-center {
  position: absolute;
  left: 50%; top: 47%;
  transform: translate(-50%, -50%);
  width: min(90%, 460px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  z-index: 2;
  pointer-events: none;
}
.tc-name {
  font-size: 12px;
  color: var(--gold);
  letter-spacing: .04em;
  min-height: 14px;
}
.tc-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding-right: 18px;
  min-height: 10px;
}
.tc-cards .card {
  --cw: clamp(30px, 7.4vw, 44px);
  margin-right: -18px;
  animation: tcIn .22s cubic-bezier(.2, .9, .3, 1.2) both;
  animation-delay: calc(var(--i, 0) * .035s);
}
@keyframes tcIn {
  from { opacity: 0; transform: translateY(-14px) scale(.9); }
}
.tc-who {
  font-size: 11px;
  color: var(--txt-dim);
  min-height: 13px;
}
.tc-empty { font-size: 12px; color: var(--txt-faint); }

/* ---- 进贡横幅 ---- */

.tribute-bar {
  position: absolute;
  /* 让开对家的座位牌（#seatTop 在 top:4px，高约 44px），否则横幅会把队友整个盖住 */
  left: 50%; top: 56px;
  transform: translateX(-50%);
  z-index: 6;
  max-width: min(94%, 460px);
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: #f7e9c6;
  background: linear-gradient(180deg, rgba(80, 58, 14, .95), rgba(48, 34, 8, .95));
  border: 1px solid rgba(233, 196, 106, .4);
  box-shadow: var(--shadow-2);
}
.tribute-bar b { color: var(--gold); }

/* ---- 结算浮层 ---- */

.gd-result {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 60% at 50% 45%, rgba(0, 0, 0, .55), rgba(0, 0, 0, .82));
  animation: grFade .2s ease both;
}
@keyframes grFade { from { opacity: 0; } }

.gr-card {
  width: min(92%, 420px);
  max-height: 96%;
  overflow-y: auto;
  padding: 16px 18px;
  border-radius: 16px;
  text-align: center;
  background: linear-gradient(180deg, rgba(20, 30, 26, .98), rgba(10, 17, 14, .98));
  border: 1px solid rgba(233, 196, 106, .3);
  box-shadow: var(--shadow-2);
  animation: grPop .26s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes grPop { from { opacity: 0; transform: scale(.9) translateY(10px); } }

.gr-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .04em;
  background: linear-gradient(180deg, #f7e6b8, #cda447);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gr-sub { font-size: 13px; color: var(--txt-dim); margin-top: 3px; }
.gr-trophy { font-size: 44px; line-height: 1; }

.gr-places {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.gr-places li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 9px;
  font-size: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line-soft);
}
.gr-places li[data-team="0"] { border-left: 3px solid #d4646c; }
.gr-places li[data-team="1"] { border-left: 3px solid #5b8fc7; }
.gr-pl { font-weight: 700; color: var(--gold); flex: 0 0 auto; }
.gr-nm { flex: 1 1 auto; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-rest { color: var(--txt-faint); font-family: var(--font-num); flex: 0 0 auto; }

.gr-levels {
  margin-top: 12px;
  font-size: 13px;
  color: var(--txt);
}
.gr-levels b { color: var(--gold); font-family: var(--font-num); font-size: 16px; }
.gr-next { margin-top: 8px; font-size: 12px; color: var(--txt-faint); }
.gd-match .gr-card { border-color: var(--gold); }

/* =========================== 我的区域 =========================== */

#gdHero {
  flex: 0 0 auto;
  padding: 6px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(10, 16, 14, .3), rgba(9, 14, 12, .97) 36%);
  border-top: 1px solid var(--line);
}

.gd-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 20px;
  font-size: 12px;
  color: var(--txt-dim);
}
.gd-status .v-turn { color: var(--gold); font-weight: 600; }

/* ---- 手牌 ---- */

.gd-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  padding: 16px 24px 4px 0;
  min-height: 78px;
}
/* 手牌是叠着放的，只露出左边一条。点数字号要小到"10"能完整落在这条里，
   否则一手 27 张里所有的 10 都会被下一张盖掉半个字。 */
.gd-hand .card .c-rank { font-size: calc(var(--cw) * .40); }
.gd-hand .card {
  --cw: clamp(38px, 9.2vw, 54px);
  margin-right: -24px;
  margin-top: 6px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  box-shadow: 0 3px 9px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.gd-hand .card:hover { transform: translateY(-5px); }
.gd-hand .card.sel {
  transform: translateY(-15px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .6), 0 0 0 2px var(--gold), 0 0 16px var(--gold-glow);
}
.gd-hand .card.hint { box-shadow: 0 3px 9px rgba(0, 0, 0, .55), 0 0 0 2px rgba(120, 200, 255, .8); }
/* 逢人配：右上角一点金，方便一眼挑出来 */
.gd-hand .card.wild::after {
  content: "配";
  position: absolute;
  right: 2px; top: 2px;
  font-size: calc(var(--cw) * .26);
  font-weight: 800;
  line-height: 1;
  padding: 1px 2px;
  border-radius: 3px;
  color: #2a1c05;
  background: linear-gradient(180deg, #f2d68f, #cda447);
}
.gd-hand .ph {
  font-size: 12px;
  color: var(--txt-faint);
  padding: 22px 0;
}

/* 王牌：没有花色，用"大/小 + 王"排版 */
.card.joker .c-rank { left: 0; right: 0; text-align: center; font-size: calc(var(--cw) * .4); }
.card.joker .c-suit-sm { display: none; }
.card.joker .c-suit-big {
  left: 0; right: 0; bottom: 8%;
  text-align: center;
  font-size: calc(var(--cw) * .5);
  font-weight: 800;
}

/* ---- 操作条 ---- */

.gd-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 46px;
}
.pick-info {
  flex: 1 1 140px;
  min-width: 0;
  font-size: 12px;
  color: var(--txt-dim);
  line-height: 1.4;
}
.pick-info .ok { color: #7fe0ab; font-weight: 600; }
.pick-info .no { color: #f0a0a6; }
.pick-info .bomb { color: var(--gold); font-weight: 700; }

.gd-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.gd-actions .act { min-height: 42px; padding: 0 15px; }

/* =========================== 规则页 =========================== */

.rule-doc {
  padding: 12px 14px 24px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--txt-dim);
  overflow-y: auto;
}
.rule-doc h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--txt);
}
.rule-doc h5 {
  margin: 14px 0 4px;
  font-size: 12.5px;
  color: var(--gold);
  letter-spacing: .05em;
}
.rule-doc p { margin: 0 0 6px; }
.rule-doc ul { margin: 0; padding-left: 18px; }
.rule-doc li { margin: 2px 0; }
.rule-doc b { color: var(--txt); }
.rule-doc code {
  font-family: var(--font-num);
  font-size: 11.5px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .06);
}
.rule-order {
  font-family: var(--font-num);
  font-size: 12px;
  color: var(--txt);
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line-soft);
}

/* =========================== 窄屏 =========================== */

@media (max-width: 620px) {
  .st-seats { display: none; }
  .pod { max-width: 38vw; padding: 4px 7px 4px 4px; }
  .pod-av { width: 26px; height: 26px; font-size: 13px; }
  #seatLeft .pod, #seatRight .pod { width: 84px; max-width: 84px; padding: 6px; }
  .gd-felt { inset: 10px clamp(46px, 12%, 90px); }
  /* 27 张牌横排在手机上会把每张压成一条缝，"10" 会被切掉半个字。
     宁可折成两行：每张露出半张宽，点数看得清才点得准。 */
  .gd-hand { padding-right: 26px; }
  .gd-hand .card {
    --cw: clamp(40px, 11.5vw, 52px);
    margin-right: calc(var(--cw) * -.5);
  }
  .pick-info { flex-basis: 100%; }
  .gd-actions { justify-content: stretch; width: 100%; }
  .gd-actions .act { flex: 1 1 auto; }
}

@media (max-width: 380px) {
  .sm-wild, .sm-hint { font-size: 10px; }
  .st-lv { font-size: 16px; padding: 2px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .tc-cards .card, .gr-card, .gd-result { animation: none; }
  .score-team.at-a .st-lv { animation: none; }
}

/* =========================== 语音连麦 =========================== */
/* 面板与按钮的样式在 style.css 里，两张桌子共用；这里只补掼蛋座位牌上的指示。 */

.pod { position: relative; }
.pod.speaking { border-color: rgba(47, 164, 106, .55); }
.pod.speaking .pod-av {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16),
              0 0 0 2px rgba(47, 164, 106, .9), 0 0 14px rgba(47, 164, 106, .55);
  animation: gdPodSpeak 1.1s ease-in-out infinite;
}
@keyframes gdPodSpeak {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16),
                         0 0 0 2px rgba(47, 164, 106, .9), 0 0 12px rgba(47, 164, 106, .45); }
  50%      { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16),
                         0 0 0 4px rgba(47, 164, 106, .5), 0 0 22px rgba(47, 164, 106, .75); }
}
.pod-tag.mic { color: #04120b; background: var(--green); border-color: transparent; }
.pod-tag.mic.muted { background: var(--txt-faint); color: #101613; }
