/* ---------- 顶部：标题 + 操作提示 ---------- */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 8px;
}
.brand { display: flex; align-items: baseline; gap: 7px; }

.ver { font-size: 11.5px; color: var(--dim); letter-spacing: 0; }

header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 3px;
  color: var(--text);
  flex: none;
}

/* 十三水 · 网页版样式 */
:root {
  --felt: #124a32;
  --panel: rgba(0, 0, 0, .18);
  --panel-border: rgba(212, 175, 96, .35);
  --gold: #d4af60;
  --text: #f0f4f0;
  --dim: #a8baae;
  --win: #eb5a50;
  --lose: #5acd82;

  /* 我摆好的牌：按屏宽自动放大，(屏宽-134px)/5，最宽 64px */
  --cw: min(64px, calc((100vw - 134px) / 5));
  --ch: calc(var(--cw) * 1.38);
  /* 三家的小牌：随屏幕缩放，5 张不溢出 */
  --sw: clamp(14px, 4.9vw, 28px);
  --sh: calc(var(--sw) * 1.38);
  --gap: 5px;
  --typew: 46px;   /* 牌型文字列宽（三道对齐用） */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--felt);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 26px 10px 16px;   /* 网页版顶部多留 20px；App 内由 html.in-app 覆盖 */
}

html.in-app #app { padding-top: 6px; }   /* APK 里不要那 20px */

/* ---------- 三家（一行） ---------- */
.opponents {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 8px;
}

.opp {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px 7px;
  min-width: 0;
}

.opp .oname { display: flex; align-items: baseline; gap: 4px; font-size: 12.5px; margin-bottom: 5px; white-space: nowrap; overflow: hidden; min-height: 15px; }
.opp .oname .ospec { display: inline-flex; gap: 3px; flex: 1 1 auto; min-width: 0; justify-content: center; overflow: hidden; font-size: 12.5px; }
.opp .oname .badge { font-size: inherit; font-weight: 400; background: #000; padding: 0 4px; border-radius: 3px; }
.opp .oname .badge.gold { color: var(--gold); }
.opp .oname .badge.bad { color: var(--win); }

.opp .oline {
  min-height: calc(var(--sh) + 1px);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.opp .oline:last-child { margin-bottom: 0; }

.opp .ocards { display: flex; gap: 2px; flex: none; }
.opp .ocards .card {
  width: var(--sw);
  height: var(--sh);
  flex: none;
  cursor: default;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.opp .ocards .card .rank { font-size: calc(var(--sw) * .54); left: 6%; top: 2%; }
.opp .ocards .card .suit { font-size: calc(var(--sw) * .56); top: 64%; transform: translateY(-50%); }

/* 三家的分数：本局在上、累计在下 */
.opp .oscore {
  margin-left: 2px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-size: 8.5px;
  color: var(--dim);
  white-space: nowrap;
  flex: none;
  min-width: 0;
}
.opp .oscore .l { display: flex; align-items: baseline; justify-content: flex-start; gap: 3px; }
.opp .oscore i { font-style: normal; flex: none; }
.opp .oscore b { font-size: 11.5px; font-weight: 400; color: var(--text); min-width: 1.9em; text-align: left; }
.opp .oscore b.zero { text-align: center; }
.opp .oscore b.win { color: var(--win); }
.opp .oscore b.lose { color: var(--lose); }

/* ---------- 我的三道 ---------- */
.table {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 9px 11px;
  margin-bottom: 8px;
  touch-action: pan-y;
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  min-height: var(--ch);
}
.row:first-child { margin-top: 0; }
.row:last-child { margin-bottom: 0; }

.row .label { width: 32px; font-size: 13px; color: var(--gold); flex: none; }
.row .slots { display: flex; gap: var(--gap); flex: none; }

.row .rowscore {
  margin-right: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;                 /* 行距统一交给三行的 line-height: 18px */
  font-size: 10px;
  color: var(--dim);
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;      /* 徽标行要越过右侧牌型列，铺到面板右边框 */
  padding-left: 4px;
}
.row .rowscore .l { display: flex; align-items: baseline; justify-content: flex-start; gap: 4px; line-height: 18px; }
/* 我的名字：放在本局分数上方（字号与三家的名字一致，三行行距统一 18px） */
.row .rowscore .me {
  font-size: 12.5px;
  color: var(--gold);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 18px;
}

/* 名字 + 特殊牌型徽标同一行：徽标从名字右侧铺到面板右边框（宽度 + 牌型列 + 间距） */
.row .rowscore .meLine {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: calc(100% + var(--typew) + 6px);
  line-height: 18px;
}
.row .rowscore .meLine .me { flex: 0 1 auto; min-width: 0; }
.row .rowscore .meLine .spec {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-start;
  align-items: baseline;
  line-height: 18px;
}
.row .rowscore .spec { display: flex; flex-wrap: nowrap; gap: 4px; line-height: 1.2; font-size: 12.5px; justify-content: center; max-width: 100%; overflow: hidden; }
.badge { font-size: inherit; font-weight: 400; background: #000; padding: 0 4px; border-radius: 3px; }
.badge.gold { color: var(--gold); }
.badge.bad { color: var(--win); }
.row .rowscore .l i { font-style: normal; width: 1.9em; text-align: right; flex: none; }
.row .rowscore .l b { font-size: 13px; font-weight: 400; color: var(--text); min-width: 2.3em; text-align: left; }
.row .rowscore .l b.zero { text-align: center; }
.row .rowscore .l b.win { color: var(--win); }
.row .rowscore .l b.lose { color: var(--lose); }

.row .type {
  margin-left: auto;
  width: var(--typew);
  flex: none;
  font-size: 12px;
  color: var(--gold);
  text-align: right;
}

.slot {
  width: var(--cw);
  height: var(--ch);
  border: 1px dashed rgba(255, 255, 255, .14);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* ---------- 待选牌 ---------- */
.hand {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 10px;
  margin-bottom: 8px;
  touch-action: pan-y;
}
.handrow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 4px 0; }
.handrow .slot { width: 100%; height: auto; aspect-ratio: 5 / 7; }
.handrow .filler { visibility: hidden; }

/* ---------- 牌面 ---------- */
.card {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #fdfcf8, #f1ece0);
  border: 1px solid #cdc5b1;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  color: #1d1f23;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  transition: transform .06s ease;
}
.card .rank {
  position: absolute;
  left: 8%;
  top: 2%;
  font-size: calc(var(--cw) * .38);
  line-height: 1;
  font-weight: 700;
}
.card .suit {
  position: absolute;
  left: 0; right: 0;
  top: 60%;
  transform: translateY(-50%);
  text-align: center;
  font-size: calc(var(--cw) * .62);
  line-height: 1;
}
.card.red { color: #be282d; }

.card.sel { transform: translateY(-5px); box-shadow: 0 0 0 2px var(--gold), 0 6px 12px rgba(0,0,0,.45); }

/* 待选区的牌：更大 */
.handrow .card .rank { font-size: clamp(15px, 4.2vw, 24px); }
.handrow .card .suit { font-size: clamp(20px, 5.8vw, 33px); top: 62%; }

.card.back {
  /* 深蓝灰宽斜条：蓝:灰 = 2:1，用百分比让条纹随牌大小等比缩放 */
  background-color: #18202a;
  background-image: repeating-linear-gradient(
    45deg,
    #283545 0,
    #283545 13.33%,
    #18202a 13.33%,
    #18202a 20%
  );
  border: 1.5px solid #a88a54;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}

/* ---------- 按钮 ---------- */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
button {
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 96, .35);
  background: rgba(20, 62, 43, .95);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
button.primary {
  background: linear-gradient(180deg, #d8b366, #c19a45);
  color: #241a05;
  border-color: #e6c77c;
  font-weight: 700;
}
button:disabled { opacity: .4; cursor: not-allowed; }



/* ---------- 窄屏 ---------- */
@media (max-width: 420px) {
  :root {
    --gap: 4px;
    --typew: 40px;
  }
  #app { padding: 24px 8px 14px; }
  html.in-app #app { padding-top: 4px; }
  .opp { padding: 6px 6px; }
  .row .label { width: 28px; font-size: 12px; }
  .row .type { font-size: 11px; }
  button { padding: 11px 6px; font-size: 14px; }
}
