/* ==========================================================================
   Le 记分 —— 全局样式
   1. 变量与基础重置      5. 记分桌面
   2. 首页                6. 记录 / 设置
   3. 通用组件            7. 弹层与提示
   4. 新建牌局            8. 响应式
   ========================================================================== */

/* 1. 变量与基础重置 -------------------------------------------------------- */

:root {
  /* 品牌绿：深浅两套主题下都当底色 / 主色用，不跟着主题变 */
  --green-950: #064c3d;
  --green-900: #0a6e59;
  --green-800: #0f866b;
  --green-700: #159b7d;

  /* 界面色：深色主题在文件末尾整块重定义，所以这里都按"用途"起名，
     不写"颜色"的名字。字色用 --text-*，不要直接写 --green-*，
     否则深色底上会变成深绿压深绿。 */
  --page-bg: #d7efe7;
  --app-bg: linear-gradient(180deg, #f8fffc 0%, #eef9f4 100%);
  --hero-bg:
    radial-gradient(circle at 100% 0%, rgba(152, 202, 166, .36), transparent 35%),
    linear-gradient(160deg, #fbfff9, #e2f3eb 65%, #d6ece3);
  --surface: #fff;
  --surface-2: #fcfffe;
  --surface-3: #fbfefd;
  --surface-glass: rgba(255, 255, 255, .9);
  --nav-bg: rgba(255, 255, 255, .95);
  --sheet-bg: #f8fffc;
  --soft: #edf7f4;
  --soft-2: #e9f6f1;
  --soft-accent: #eafff6;
  --accent-line: #6dc9ad;
  --line-strong: #bfd6cd;
  --line-accent: #bfe3d4;
  --handle: #c4d7d2;
  --switch-off: #cbdad6;
  --backdrop: rgba(9, 44, 35, .38);
  --toast-bg: #173f36;
  --warn-bg: #fff4e5;
  --warn-text: #8a5a00;
  --danger-grad: linear-gradient(135deg, #e05c50, #b8453c);

  --text-1: #064c3d;
  --text-2: #0f866b;
  --text-3: #0a6e59;
  --label: #607781;
  --idle: #8da0a4;
  --quiet: #4e6e72;

  --mint: #eaf7f2;
  --paper: #fbfaf5;
  --ink: #1d3440;
  --muted: #77909a;
  --line: #dfece8;
  --gold: #d7a63a;
  --red: #df5f56;
  --shadow: 0 12px 32px rgba(15, 94, 76, .11);
  --radius: 22px;
}

/* 深色模式。只由设置里的开关控制（<html data-theme="dark">），不跟随系统：
   白天在户外跟着系统变暗反而看不清。 */
[data-theme="dark"] {
  color-scheme: dark;

  --page-bg: #040a09;
  --app-bg: linear-gradient(180deg, #0b1513 0%, #0f1d19 100%);
  --hero-bg:
    radial-gradient(circle at 100% 0%, rgba(46, 118, 96, .32), transparent 38%),
    linear-gradient(160deg, #0e1a17, #0b1513 65%, #091211);
  --surface: #16221f;
  --surface-2: #182724;
  --surface-3: #141f1d;
  --surface-glass: rgba(22, 34, 31, .92);
  --nav-bg: rgba(13, 22, 20, .95);
  --sheet-bg: #16221f;
  --soft: #1d2d29;
  --soft-2: #1d2d29;
  --soft-accent: #15332b;
  --accent-line: #34695b;
  --line-strong: #2f4742;
  --line-accent: #2b4d44;
  --handle: #354a44;
  --switch-off: #35473f;
  --backdrop: rgba(0, 0, 0, .62);
  --toast-bg: #2a5f52;
  --warn-bg: #3a2c12;
  --warn-text: #ffcf7a;
  --danger-grad: linear-gradient(135deg, #d4574b, #a83b33);

  --text-1: #cfeee4;
  --text-2: #5fd3b1;
  --text-3: #74dcbb;
  --label: #9db6b1;
  --idle: #7d968f;
  --quiet: #a7c0bb;

  --ink: #e7f3ef;
  --muted: #8da5a0;
  --line: #263a36;
  --red: #ff8d82;
  --gold: #e8bd5c;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page-bg);
  -webkit-tap-highlight-color: transparent;
  /* 只放行单指拖动，双指缩放和双击放大都在这里挡掉。
     touch-action 会沿祖先链取交集，写在 html 上就等于覆盖整个页面。 */
  touch-action: pan-x pan-y;
  /* 横屏时 iOS 会自行给文字"补"个字号，看起来就像整页被放大了 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

/* 提交中禁用，防止连点造成重复记分 */
button:disabled {
  opacity: .55;
  cursor: default;
}

/* 鼠标点击 / 触摸不显示系统蓝色焦点框，键盘 Tab 仍保留可见轮廓 */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--green-700);
  outline-offset: 2px;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 0;
}

.app {
  width: min(100%, 520px);
  min-height: 100vh;
  background: var(--app-bg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(7, 63, 51, .18);
}

.screen {
  min-height: 100vh;
  padding-bottom: 92px;
  position: relative;
}

/* 2. 首页 ------------------------------------------------------------------ */

.hero {
  min-height: 100vh;
  padding: 24px 20px 90px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--hero-bg);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-1);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .12em;
}

.brand-seal {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: contain;
  display: block;
  flex: none;
}

/* 首页字标：思源宋体 CN SemiBold，仅保留 Le记分 四个字符（3.1 KB）。
   许可：SIL Open Font License，完整许可见 fonts/source-han-serif-OFL.txt。 */
@font-face {
  font-family: "HeroTitle";
  src: url("fonts/hero-title.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+004C, U+0065, U+5206, U+8BB0;
}

/* 首页主视觉：中 / 白板 / 發 三张牌。
   半透明的象牙白牌面浮在暗绿底上，靠缓慢升降和透明度呼吸做"若隐若现"。
   站位一律用百分比，从手机到平板都不会跑偏。 */
.hero-art {
  margin: 30px 0 6px;
  position: relative;
  height: 290px;
  border-radius: 28px;
  background: radial-gradient(circle at 50% 50%, #208764 0%, #0c4a35 100%);
  box-shadow: 0 22px 30px rgba(7, 83, 63, .25);
  overflow: hidden;
  border: 6px solid rgba(255, 255, 255, .8);
}

/* 暗金内框：压住四角，让中间的牌显得更深 */
.hero-art::before {
  content: "";
  position: absolute;
  inset: 20px;
  border: 2px solid rgba(246, 226, 171, .25);
  border-radius: 20px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .4);
  pointer-events: none;
}

/* 环境呼吸光晕 */
.ambient-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150px;
  height: 150px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 255, 255, .15) 0%, transparent 70%);
  animation: pulse-glow 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse-glow {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .5; }
  50% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
}

/* 三张牌各自的站位。发财是主视觉，按中心点摆，负边距是牌体尺寸的一半。 */
.wrap-zhong { position: absolute; left: 15%; top: 25%; transform: scale(.65) rotate(-18deg); z-index: 1; }
.wrap-bai   { position: absolute; right: 15%; top: 30%; transform: scale(.7) rotate(16deg); z-index: 2; }
.wrap-fa    { position: absolute; left: 50%; top: 50%; margin: -45px 0 0 -37px; transform: scale(1.15) rotate(2deg); z-index: 3; }

/* 叫 .mj-tile 而不是 .tile —— 牌桌上那圈小牌已经占了 .tile */
.mj-tile {
  position: relative;
  width: 74px;
  height: 104px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 半透明象牙白，能透出后面的底色 */
  background: linear-gradient(135deg, rgba(255, 255, 255, .95), rgba(244, 241, 232, .7));
  border: 1px solid rgba(255, 255, 255, .6);
  /* 一层层错位的深翡翠绿堆出牌体厚度 */
  box-shadow:
    1px 1px 0 rgba(253, 252, 249, .9), 2px 2px 0 rgba(249, 247, 242, .9),
    3px 3px 0 rgba(27, 161, 113, .8), 4px 4px 0 rgba(23, 142, 99, .8),
    5px 5px 0 rgba(20, 124, 86, .8), 6px 6px 0 rgba(16, 103, 72, .8),
    7px 7px 0 rgba(13, 84, 58, .8), 8px 8px 0 rgba(10, 64, 44, .8),
    9px 9px 0 rgba(7, 49, 33, .8), 10px 10px 0 rgba(5, 36, 24, .8);
}

/* 牌面顶部的玻璃反光 */
.mj-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .8) 0%, rgba(255, 255, 255, 0) 40%);
  pointer-events: none;
}

/* 边缘内发光 */
.mj-tile::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .4);
  pointer-events: none;
}

/* 牌面字专用字体：只有「中 發」两个字的思源宋体子集，1.4 KB。
   楷体只有 Windows 和 iOS 带，安卓和国产 ROM 基本没有，
   系统字体挑不到就只能落到黑体上，牌面立刻不像麻将牌 —— 与其赌设备，不如自己带一份。
   许可：SIL Open Font License（思源宋体 / Source Han Serif），可自由内嵌分发。 */
@font-face {
  font-family: "TileChar";
  src: url("fonts/tile-char.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
  unicode-range: U+4E2D, U+767C;
}

/* 后面那串系统字体只在字体文件没加载出来时兜底 */
.mj-char {
  font-family:
    "TileChar",
    "KaiTi", "楷体", "STKaiti", "华文楷体", "Kaiti SC",
    "Songti SC", "STSong", "宋体", "SimSun",
    "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif CN",
    serif;
  font-weight: 700;
  font-size: 60px;
  line-height: 1;
  user-select: none;
}

/* 描边偏左上，做出油墨压印的凹陷 */
.mj-char.red { color: rgba(211, 21, 21, .9); text-shadow: -1px -1px 0 rgba(74, 0, 0, .6); }
.mj-char.green { color: rgba(15, 122, 84, .95); text-shadow: -1px -1px 0 rgba(4, 43, 26, .7); }

/* 白板：蓝框套蓝框 */
.bai-box {
  width: 36px;
  height: 52px;
  border: 5px solid rgba(29, 91, 196, .85);
  border-radius: 6px;
  position: relative;
  box-shadow: -1px -1px 0 rgba(0, 24, 74, .5);
}

.bai-box::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid rgba(29, 91, 196, .85);
  border-radius: 2px;
}

/* 三张牌各一套关键帧，节奏错开，主牌（发财）沉得浅些保持存在感。
   数字全部写死：部分内嵌浏览器（微信、安卓旧 WebView）不认 @keyframes 里的 var()，
   那种环境下 transform / opacity 会被当成无效声明整条丢掉，
   动画照跑但画面纹丝不动，看起来就是"动画没了"。 */
.wrap-zhong .mj-tile { animation: breathe-zhong 4s ease-in-out infinite; animation-delay: -2s; }
.wrap-bai   .mj-tile { animation: breathe-bai   4s ease-in-out infinite; animation-delay: -1s; }
.wrap-fa    .mj-tile { animation: breathe-fa    4s ease-in-out infinite; animation-delay: 0s; }

/* 升降 + 透明度 + 光晕一起变，才是"若隐若现"而不是单纯上下飘 */
@keyframes breathe-zhong {
  0%, 100% { transform: translateY(0); opacity: .3; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .2)); }
  50% { transform: translateY(-15px); opacity: .85; filter: drop-shadow(0 15px 20px rgba(0, 0, 0, .4)) drop-shadow(0 0 15px rgba(255, 255, 255, .3)); }
}

@keyframes breathe-bai {
  0%, 100% { transform: translateY(0); opacity: .35; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .2)); }
  50% { transform: translateY(-12px); opacity: .85; filter: drop-shadow(0 15px 20px rgba(0, 0, 0, .4)) drop-shadow(0 0 15px rgba(255, 255, 255, .3)); }
}

@keyframes breathe-fa {
  0%, 100% { transform: translateY(0); opacity: .75; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .2)); }
  50% { transform: translateY(-8px); opacity: 1; filter: drop-shadow(0 15px 20px rgba(0, 0, 0, .4)) drop-shadow(0 0 15px rgba(255, 255, 255, .3)); }
}

.hero-copy h2 {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 0;
  color: var(--text-1);
  font-family: "HeroTitle", "Songti SC", "STSong", "SimSun", serif;
  font-size: 0;
  font-weight: 600;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

.hero-title-latin {
  font-size: 56px;
  line-height: .9;
  letter-spacing: -.06em;
}

.hero-title-cn {
  font-size: 35px;
  line-height: 1;
  letter-spacing: .08em;
  transform: translateY(-2px);
}

.hero-copy p {
  text-align: center;
  color: var(--text-2);
  letter-spacing: .2em;
  margin: 13px 0 24px;
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 360px) {
  .hero-title-latin { font-size: 50px; }
  .hero-title-cn { font-size: 32px; }
}

.hero-actions {
  display: grid;
  gap: 12px;
}

/* 3. 通用组件 -------------------------------------------------------------- */

.topbar {
  height: 76px;
  background: linear-gradient(135deg, var(--green-950), var(--green-800));
  color: #fff;
  padding: 16px 18px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 8;
  box-shadow: 0 4px 14px rgba(4, 65, 51, .2);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: .08em;
  font-weight: 700;
}

.topbar .sub {
  font-size: 12px;
  color: #c9eee3;
  margin-top: 4px;
}

/* 记分页的房间号：只在需要时瞄一眼，做成一枚淡胶囊，不跟标题抢注意力 */
.topbar .room-chip {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .75);
  font-size: 12px;
  letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
}

.topbar .right {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 22px;
  display: grid;
  place-items: center;
  line-height: 1;
}

.content {
  padding: 18px 16px 20px;
}

.primary,
.secondary {
  height: 54px;
  border-radius: 28px;
  padding: 0 24px;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .2s transform, .2s box-shadow;
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--green-800), var(--green-700));
  box-shadow: 0 10px 20px rgba(9, 126, 96, .2);
}

.secondary {
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--accent-line);
}

.primary:active,
.secondary:active,
.quick-btn:active,
.nav-item:active {
  transform: scale(.98);
}

.section-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-1);
  margin: 22px 2px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card {
  background: var(--surface-glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #d8f5e5, #8bd3bc);
  font-size: 23px;
  flex: 0 0 auto;
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(3, 99, 76, .14);
}

.avatar.small {
  width: 34px;
  height: 34px;
  font-size: 19px;
}

/* 头像是微信给的一张图，撑满整个圆形框：方形原图居中裁切，不要拉变形。
   容器都是单格 grid，img 的 100% 指的就是去掉边框之后的内容区。 */
.avatar img,
.seat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.player-name {
  flex: 1;
  font-weight: 700;
}

.player-score {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

/* 底部导航 */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 520px);
  height: 76px;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  z-index: 9;
}

.nav-item {
  background: transparent;
  color: var(--idle);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  letter-spacing: .02em;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.nav-label {
  line-height: 1;
}

.nav-item.active {
  color: var(--text-2);
  font-weight: 800;
}

/* 4. 建房 / 加入 / 大厅 ---------------------------------------------------- */

.form-card {
  padding: 16px;
}

.field-label {
  font-size: 13px;
  color: var(--label);
  margin-bottom: 8px;
  font-weight: 700;
}

.text-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-3);
  padding: 13px 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  outline: 0;
}

.text-input:focus {
  border-color: var(--green-700);
}

.code-input {
  text-align: center;
  letter-spacing: .34em;
  font-size: 24px;
  font-weight: 800;
  text-indent: .34em;   /* 抵消末位字距，让六个字符视觉居中 */
}

/* 首次授权进来时的确认页 */

.onboard-card {
  text-align: center;
  padding-top: 12px;
}

.avatar.onboard-avatar {
  width: 96px;
  height: 96px;
  font-size: 44px;
  margin: 0 auto;
  border-width: 3px;
  box-shadow: 0 6px 18px rgba(3, 99, 76, .18);
}

.onboard-tip {
  margin: 16px 0 26px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.onboard-label {
  text-align: left;
}

/* 大厅 */

.lobby-qr {
  padding: 18px;
  text-align: center;
}

.lobby-qr-img {
  width: min(62vw, 220px);
  margin: 0 auto;
  aspect-ratio: 1;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 8px;
}

.lobby-qr p {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.lobby-code-card {
  margin-top: 12px;
  padding: 14px 16px;
  text-align: center;
}

.lobby-code small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.lobby-code strong {
  display: block;
  font-size: 26px;
  letter-spacing: .16em;
  text-indent: .16em;   /* 抵消末位字距，让六位数字视觉居中 */
  color: var(--text-1);
}

.section-label .count {
  float: right;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.seat-slots {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.seat-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.seat-slot.empty {
  border-style: dashed;
  background: transparent;
  color: var(--muted);
}

.seat-slot.joined {
  border-color: var(--line-accent);
  background: var(--soft-accent);
}

.seat-slot.offline .seat-avatar {
  filter: grayscale(1);
  opacity: .55;
}

.seat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--soft-2);
  flex: none;
}

.seat-slot.empty .seat-avatar {
  background: transparent;
  border: 1px dashed var(--line-strong);
  font-size: 18px;
}

.seat-text {
  flex: 1;
  min-width: 0;
}

.seat-text strong {
  display: block;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-text em {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  margin-left: 4px;
}

.seat-text span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.seat-tick {
  font-size: 17px;
  font-weight: 800;
  color: var(--green-700);
}

.seat-slot.offline .seat-tick {
  color: var(--muted);
}

.lobby-hint {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0 12px;
}

/* 顶部同步异常提示条 */

.sync-banner {
  margin: 0 16px 10px;
  padding: 9px 13px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 12.5px;
}

/* 5. 记分桌面 -------------------------------------------------------------- */

/* 顶部的座位条：还没落座 / 正在观战的人。只摆头像和昵称，
   「未落座」「观战」这类说明缩成右上角一行小字 —— 条子每高一截，
   桌子就得往下让一截，之前就是这么被顶到的。 */
.seat-strip {
  position: relative;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.seat-strip-label {
  position: absolute;
  top: 3px;
  right: 9px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  color: var(--text-3);
}

.seat-strip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* 头像和名字并排的胶囊，比原来竖排的三行矮一半 */
.mini-score {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 2px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.mini-score b {
  font-size: 12px;
}

.avatar.tiny {
  width: 24px;
  height: 24px;
  font-size: 13px;
  border-width: 1px;
}

.score-screen {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding-bottom: 76px;
  display: flex;
  flex-direction: column;
}

.score-screen .topbar {
  flex: 0 0 76px;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  padding: 12px;
  display: grid;
  /* 第一行按内容撑开，不写死比例：里面的提示条一高就被切成滚动区，
     看着像被桌子压住了。剩下两行还是 4:1，桌子照旧居中。 */
  grid-template-rows: auto minmax(0, 4fr) minmax(0, 1fr);
  align-items: center;
}

.table-info {
  grid-row: 1;
  align-self: stretch;
  min-height: 0;
  overflow: auto;
}

.table-info .table-hint {
  margin: 0 0 6px;
}

.table-info .seat-strip {
  margin: 0 0 6px;
}

.mahjong-table {
  grid-row: 2;
  width: 100%;
  height: 100%;
  max-height: 420px;
  position: relative;
  border-radius: 42px;
  /* 桌面图由 JS 贴上（见 app.js 的 applyTableArt，图先存本地缓存不重复下载）。
     这里只是一层绿绒打底，等图到位前不闪白。 */
  background: linear-gradient(145deg, #146f59, #075341) center / 100% 100% no-repeat;
  box-shadow: 0 17px 24px rgba(4, 63, 51, .2);
  overflow: hidden;
}

/* 浅色桌面（樱花粉）上，原来那套浅绿字糊在底色里看不清，换成深色 */
.mahjong-table.is-light .seat-name {
  color: #7d4655;
  text-shadow: 0 1px 2px rgba(255, 255, 255, .7);
}

.mahjong-table.is-light .seat.empty .avatar {
  background: rgba(255, 255, 255, .55);
  border-color: rgba(180, 118, 140, .75);
  color: #8a5566;
}

/* 浅色皮肤上的分数牌是白底，不加点阴影会跟粉桌子糊在一起 */
.mahjong-table.is-light .seat-score {
  box-shadow: 0 1px 4px rgba(150, 90, 110, .3);
}

.seat {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  padding: 0;
  color: inherit;
}

.seat .avatar {
  position: relative;
  width: 52px;
  height: 52px;
  font-size: 27px;
}

/* 空位：虚线圆圈里写着方位，一眼看出这里能点 */
.seat.empty .avatar {
  background: rgba(255, 255, 255, .16);
  border: 2px dashed rgba(234, 255, 246, .75);
  box-shadow: none;
  color: #eafff6;
  font-size: 22px;
  font-weight: 800;
}

/* 方位角标：东南西北跟着座位号走，挪到哪个屏幕位置都不变 */
.seat .seat-dir {
  position: absolute;
  top: -6px;
  left: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  background: #fdf1d2;
  color: #6d4a12;
  font-size: 11px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
}

/* 自己的座位点不了（分只能转给别人），给个「我」的角标说明原因，
   免得点了半天才发现点的是自己。 */
.seat.is-me .avatar {
  box-shadow: 0 0 0 3px rgba(246, 226, 171, .85), 0 4px 10px rgba(3, 99, 76, .14);
}

.seat .me-tag {
  position: absolute;
  top: -5px;
  right: -7px;
  padding: 0 6px;
  border-radius: 9px;
  border: 1.5px solid #fff;
  background: var(--chip-bg, var(--green-900));
  color: var(--chip-fg, #fff);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
}

/* 怒气环。用 conic-gradient 画一整圈，--rage 是进度；整圈压在头像下面
   （z-index: -1，.seat 有 z-index 所以逃不出去），露在外面的就是那 5px 的环。 */
.seat .avatar.rage-ring::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(from -90deg, #ff8a3d var(--rage, 0%), rgba(255, 255, 255, .22) 0);
  z-index: -1;
}

/* 赢家的皇冠扣在头顶正中，歪一点才像是随手戴上去的 */
.seat .crown {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%) rotate(-10deg);
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .5));
}

/* 安抚特效：头像回弹，双层光环扩散，彩色爱心沿不同轨迹散开。
   整组挂在 body 上，四个方向的座位都不会被桌面裁掉。 */
.comfort-effect {
  position: fixed;
  z-index: 45;
  width: 168px;
  height: 168px;
  transform: translate(-50%, -50%);
  line-height: 1;
  pointer-events: none;
  contain: layout style;
}

.comfort-halo,
.comfort-core,
.comfort-particle {
  position: absolute;
  left: 50%;
  top: 50%;
}

.comfort-halo {
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  border: 2px solid rgba(255, 245, 208, .95);
  box-shadow: 0 0 18px rgba(255, 209, 102, .42), inset 0 0 13px rgba(112, 225, 187, .3);
  animation: comfort-halo 1.45s cubic-bezier(.2, .75, .25, 1) forwards;
}

.comfort-halo-two {
  border-color: rgba(112, 225, 187, .78);
  animation-delay: 140ms;
}

.comfort-core {
  display: grid;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  color: #ed5e72;
  box-shadow: 0 7px 22px rgba(78, 26, 42, .24), 0 0 0 5px rgba(255, 255, 255, .18);
  font-size: 22px;
  animation: comfort-core 1.75s cubic-bezier(.2, .8, .25, 1) forwards;
}

.comfort-particle {
  font-size: 16px;
  text-shadow: 0 2px 5px rgba(55, 24, 32, .28);
  opacity: 0;
}

.comfort-particle-1 { color: #ff7b78; animation: comfort-particle-1 1.45s cubic-bezier(.18, .72, .25, 1) forwards; }
.comfort-particle-2 { color: #ffd166; animation: comfort-particle-2 1.45s cubic-bezier(.18, .72, .25, 1) 70ms forwards; }
.comfort-particle-3 { color: #fff4d6; animation: comfort-particle-3 1.45s cubic-bezier(.18, .72, .25, 1) 30ms forwards; }
.comfort-particle-4 { color: #70e1bb; animation: comfort-particle-4 1.45s cubic-bezier(.18, .72, .25, 1) 100ms forwards; }
.comfort-particle-5 { color: #ffb0bb; animation: comfort-particle-5 1.45s cubic-bezier(.18, .72, .25, 1) 120ms forwards; }
.comfort-particle-6 { color: #ffffff; animation: comfort-particle-6 1.45s cubic-bezier(.18, .72, .25, 1) 150ms forwards; }

.seat.comfort-target .avatar,
.seat.comfort-target .avatar.rage-max {
  animation: comfort-avatar 1.35s cubic-bezier(.2, .8, .25, 1);
}

@keyframes comfort-halo {
  0%   { opacity: 0; transform: scale(.42); }
  28%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.85); }
}

@keyframes comfort-core {
  0%   { opacity: 0; transform: scale(.35) rotate(-12deg); }
  20%  { opacity: 1; transform: scale(1.16) rotate(5deg); }
  48%  { opacity: 1; transform: scale(1) rotate(0); }
  78%  { opacity: 1; transform: translateY(-8px) scale(.94); }
  100% { opacity: 0; transform: translateY(-18px) scale(.78); }
}

@keyframes comfort-particle-1 {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.25); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(calc(-50% - 48px), calc(-50% - 54px)) scale(.72) rotate(-18deg); }
}

@keyframes comfort-particle-2 {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.25); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(calc(-50% - 22px), calc(-50% - 76px)) scale(.72) rotate(12deg); }
}

@keyframes comfort-particle-3 {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.25); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(calc(-50% + 18px), calc(-50% - 72px)) scale(.72) rotate(-8deg); }
}

@keyframes comfort-particle-4 {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.25); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(calc(-50% + 49px), calc(-50% - 48px)) scale(.72) rotate(18deg); }
}

@keyframes comfort-particle-5 {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.25); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(calc(-50% - 57px), calc(-50% - 20px)) scale(.72) rotate(-25deg); }
}

@keyframes comfort-particle-6 {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.25); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(calc(-50% + 56px), calc(-50% - 16px)) scale(.72) rotate(24deg); }
}

@keyframes comfort-avatar {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  28% { transform: translateY(-3px) scale(1.12); filter: brightness(1.12); }
  52% { transform: translateY(1px) scale(.98); filter: brightness(1.06); }
  72% { transform: scale(1.04); filter: brightness(1.03); }
}

@media (prefers-reduced-motion: reduce) {
  .comfort-halo,
  .comfort-particle {
    display: none;
  }

  .comfort-core {
    opacity: 1;
    animation: comfort-reduced 1.1s ease-out forwards;
  }

  .seat.comfort-target .avatar,
  .seat.comfort-target .avatar.rage-max {
    animation: none;
    box-shadow: 0 0 0 4px rgba(255, 209, 102, .82), 0 0 20px rgba(112, 225, 187, .48);
  }
}

@keyframes comfort-reduced {
  0%, 100% { opacity: 0; transform: scale(.9); }
  18%, 72% { opacity: 1; transform: scale(1); }
}

/* 怒气脸压在左下角，跟左上的方位、右上的「我」错开 */
.seat .rage-face {
  position: absolute;
  bottom: -6px;
  left: -8px;
  font-size: 15px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
}

/* 怒气到顶：环转起来变成火色，头像再往外冒一层脉动的光 */
.seat .avatar.rage-max::before {
  background: conic-gradient(from -90deg, #ffd166, #ff6b1a, #ff2d00, #ff8a3d, #ffd166);
  animation: rage-spin 2.6s linear infinite;
}

.seat .avatar.rage-max {
  animation: rage-burn 1.3s ease-in-out infinite;
}

@keyframes rage-spin {
  to { transform: rotate(360deg); }
}

@keyframes rage-burn {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 168, 72, .95), 0 0 12px 2px rgba(255, 96, 20, .55); }
  50%      { box-shadow: 0 0 0 2px rgba(255, 214, 128, 1), 0 0 24px 8px rgba(255, 56, 0, .8); }
}

/* 分数牌和「我」的角标都是压在桌面上的小色块，配色跟着皮肤走：
   具体颜色由 app.js 的 TABLE_SKINS 写在 --chip-bg / --chip-fg 上。
   变量没设上（图还没贴好）时用下面这套默认值。 */
.seat .seat-score {
  min-width: 96px;
  text-align: center;
  background: var(--chip-bg, rgba(0, 66, 52, .92));
  color: var(--chip-fg, #fff);
  padding: 5px 8px;
  border-radius: 13px;
  font-size: 13px;
}

.seat .seat-score strong {
  display: block;
  font-size: 16px;
}

.seat.top {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
}

.seat.bottom {
  bottom: 11px;
  left: 50%;
  transform: translateX(-50%);
}

.seat.left {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.seat.right {
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.seat-name {
  font-size: 12px;
  color: #e4fff1;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

/* 6. 记录 / 设置 ---------------------------------------------------------- */

/* 同 .setting-row：这也是 <button>，宽度和右侧箭头都不能靠 flex 自动撑 */
.history-card {
  width: 100%;
  padding: 15px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.history-card .history-main {
  flex: 1;
  min-width: 0;
}

.history-card h3 {
  font-size: 15px;
  margin: 0 0 6px;
}

.history-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.history-card .chev {
  font-size: 22px;
  color: var(--idle);
}

.rank-list {
  padding: 4px 14px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.rank-row:last-child {
  border-bottom: 0;
}

.rank-row .player-score {
  margin-left: auto;
}

.rank-no {
  font-weight: 800;
  width: 24px;
  color: var(--text-2);
}

/* 对局详情 / 总览：先看结果，再看排名和过程。避免每块都长得一样。 */
.overview-content {
  padding-bottom: 32px;
}

.overview-hero {
  padding: 18px;
  border-top: 3px solid var(--green-700);
  box-shadow: 0 10px 26px rgba(15, 94, 76, .08);
}

[data-theme="dark"] .overview-hero {
  box-shadow: 0 10px 26px rgba(0, 0, 0, .25);
}

.overview-hero-head,
.overview-leader,
.overview-section-head,
.overview-rank-row,
.overview-ledger-row {
  display: flex;
  align-items: center;
}

.overview-hero-head {
  justify-content: space-between;
  gap: 14px;
}

.overview-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.overview-hero-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.overview-status {
  flex: none;
  padding: 5px 9px;
  border: 1px solid var(--line-accent);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--soft-accent);
  font-size: 11px;
  font-weight: 700;
}

.overview-leader {
  gap: 12px;
  margin-top: 18px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.overview-avatar {
  width: 48px;
  height: 48px;
}

.overview-leader-copy {
  flex: 1;
  min-width: 0;
}

.overview-leader-copy small,
.overview-player small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.overview-leader-copy strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-leader-score {
  flex: none;
  color: var(--text-2);
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding-top: 15px;
}

.overview-metrics > div {
  min-width: 0;
  padding: 0 9px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.overview-metrics > div:first-child {
  padding-left: 0;
}

.overview-metrics > div:last-child {
  padding-right: 0;
  border-right: 0;
}

.overview-metrics strong,
.overview-metrics span {
  display: block;
}

.overview-metrics strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.overview-metrics span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.overview-section-head {
  justify-content: space-between;
  gap: 12px;
  margin: 24px 2px 10px;
}

.overview-section-head h3,
.overview-section-head p {
  margin: 0;
}

.overview-section-head h3 {
  color: var(--text-1);
  font-size: 15px;
}

.overview-section-head p,
.overview-section-head > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.overview-section-head > span {
  flex: none;
  margin-top: 0;
  font-variant-numeric: tabular-nums;
}

.overview-ranking,
.overview-ledger {
  overflow: hidden;
}

.overview-rank-row {
  gap: 11px;
  min-height: 66px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.overview-rank-row:last-child,
.overview-ledger-row:last-child {
  border-bottom: 0;
}

.overview-rank-row.is-leading {
  background: var(--soft-accent);
}

.overview-position {
  width: 23px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.overview-rank-row.is-leading .overview-position {
  color: var(--text-2);
}

.overview-player {
  flex: 1;
  min-width: 0;
}

.overview-player strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-player small {
  margin-top: 3px;
}

.overview-score {
  flex: none;
  min-width: 54px;
  color: var(--ink);
  font-size: 18px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.overview-ledger-row {
  gap: 12px;
  min-height: 61px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--line);
}

.overview-ledger-flow {
  flex: 1;
  min-width: 0;
}

.overview-ledger-flow > div {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

.overview-ledger-flow strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-ledger-flow span,
.overview-ledger-flow small {
  color: var(--muted);
  font-size: 11px;
}

.overview-ledger-flow small {
  display: block;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.overview-ledger-points {
  flex: none;
  min-width: 54px;
  color: var(--text-2);
  font-size: 17px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.overview-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.overview-actions button {
  width: 100%;
}

.setting-group {
  margin: 18px 0 0;
}

.setting-group h3 {
  font-size: 13px;
  color: var(--muted);
  margin: 0 4px 8px;
}

.setting-list {
  overflow: hidden;
}

/* 设置里的一行。这些行是 <button>，而部分移动端内核不认"按钮当 flex 容器"，
   会缩成内容宽、也不理 justify-content，开关和箭头就贴到文字后面去了。
   所以宽度写死 100%，右边的元素用 flex: none + margin-left: auto 顶到边上，
   不依赖 space-between。 */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  background: var(--surface);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row > span {
  flex: 1;
  min-width: 0;
  text-decoration: none;
}

.setting-row small,
.setting-row .toggle {
  flex: none;
  margin-left: auto;
  text-decoration: none;
}

.setting-row small {
  color: var(--muted);
}

.room-setting-row {
  padding: 0;
  gap: 0;
}

.room-resume,
.room-leave {
  min-height: 52px;
  border: 0;
  background: transparent;
  text-align: left;
}

.room-resume {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  color: var(--ink);
  font-size: 14px;
}

.room-resume span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-resume small {
  margin-left: auto;
}

.room-code-inline {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.room-host-lock {
  flex: none;
  padding: 0 14px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.room-leave {
  flex: none;
  padding: 0 14px;
  border-left: 1px solid var(--line);
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.toggle {
  width: 45px;
  height: 26px;
  border-radius: 15px;
  background: var(--switch-off);
  padding: 3px;
  transition: .2s;
}

.toggle::after {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
  transition: .2s;
}

.toggle.on {
  background: var(--green-700);
}

.toggle.on::after {
  transform: translateX(19px);
}

/* 7. 弹层与提示 ------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: min(100%, 520px);
  background: var(--sheet-bg);
  border-radius: 28px 28px 0 0;
  padding: 18px 16px 24px;
  box-shadow: 0 -18px 40px rgba(0, 0, 0, .2);
  max-height: 92vh;
  overflow: auto;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 9px;
  background: var(--handle);
  margin: 0 auto 16px;
}

.sheet-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sheet-title h2 {
  font-size: 20px;
  margin: 0;
}

.sheet-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.quick-btn {
  height: 52px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-3);
  font-size: 16px;
  font-weight: 800;
}

.quick-btn.active {
  background: var(--green-800);
  color: #fff;
  border-color: var(--green-800);
}

/* 加分 / 安抚操作 */
.sign-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 12px 0;
}

.sign-btn {
  height: 46px;
  border-radius: 13px;
  background: var(--soft);
  color: var(--quiet);
  border: 1.5px solid transparent;
  font-weight: 700;
  font-size: 15px;
}

.sign-btn.active {
  border-color: var(--green-700);
  background: var(--soft-accent);
  color: var(--text-3);
}

.custom-input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0 13px;
  background: var(--surface);
  outline: 0;
  font-size: 17px;
}

.sheet-actions {
  display: flex;
  gap: 9px;
  margin-top: 8px;
}

.sheet-actions button {
  flex: 1;
}

/* 皮肤选择：两列缩略图，选中的那个描一圈绿边 */
.skin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 6px;
}

.skin-pick {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 7px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: var(--soft);
  color: var(--ink);
}

.skin-pick.active {
  border-color: var(--green-700);
  background: var(--soft-accent);
}

.skin-preview {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 4;
  border-radius: 11px;
  background: linear-gradient(145deg, #146f59, #075341) center / 100% 100% no-repeat;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}

.skin-name {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

/* 确认框：标题下面直接排按钮，多留一点空隙 */
.confirm-sheet .sheet-actions {
  margin-top: 18px;
}

/* 退出 / 结束牌局这类收不回来的操作，确认键用红色，跟一路点下去的绿色分开 */
.primary.danger {
  background: var(--danger-grad);
  box-shadow: 0 10px 20px rgba(193, 74, 65, .22);
}

/* 记分面板底部那行：这笔分从谁那儿出、到谁那儿去 */
.transfer-preview {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--soft);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.transfer-preview b {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.transfer-preview .neg {
  color: var(--red);
}

.transfer-preview .pos {
  color: var(--text-2);
}

.result-hero {
  padding: 20px 0;
  text-align: center;
}

.result-hero h2 {
  margin: 5px 0;
  color: var(--text-1);
  font-size: 21px;
}

.result-hero strong {
  font-size: 31px;
  color: var(--text-2);
}

.trophy {
  font-size: 36px;
}

.result-list {
  padding: 3px 14px;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.result-row:last-child {
  border-bottom: 0;
}

.result-row .total {
  margin-left: auto;
  font-weight: 800;
}

/* 流水：一行一笔，「谁 · 几点 · 加减多少」 */
.log-list {
  padding: 4px 15px;
}

.log-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.log-row:last-child {
  border-bottom: 0;
}

.log-flow {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  color: var(--ink);
}

.log-flow b {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-flow i {
  flex: 0 0 auto;
  font-style: normal;
  color: var(--muted);
}

.log-kind {
  flex: none;
  padding: 3px 5px;
  border-radius: 5px;
  background: var(--soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.log-flow em {
  flex: none;
  font-size: 10px;
  font-style: normal;
  color: var(--muted);
}

.log-flow strong {
  min-width: 0;
  text-align: left;
  font-size: 13px;
}

.log-minus {
  color: var(--red);
}

.log-plus {
  color: var(--text-2);
}

.log-row small {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.log-row strong {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.trend-card {
  padding: 10px 12px 8px;
}

.overview-trend {
  padding: 12px 12px 10px;
}

.trend-chart svg {
  display: block;
  width: 100%;
  height: 142px;
  overflow: visible;
}

.trend-zero,
.trend-grid {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.trend-grid {
  stroke-dasharray: 3 4;
  opacity: .7;
}

.trend-axis-label {
  fill: var(--muted);
  font-size: 8px;
  text-anchor: end;
  font-variant-numeric: tabular-nums;
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  padding: 8px 3px 2px 31px;
  color: var(--muted);
  font-size: 11px;
}

.trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.trend-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 30;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transition: .25s;
}

.toast.show {
  opacity: 1;
}

.empty {
  padding: 30px 15px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.summary-link {
  color: var(--text-2);
  font-weight: 700;
  font-size: 13px;
  background: none;
}

@media (max-width: 360px) {
  .overview-hero {
    padding: 15px;
  }

  .overview-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 13px;
  }

  .overview-metrics > div:nth-child(2) {
    border-right: 0;
  }

  .overview-metrics > div:nth-child(3),
  .overview-metrics > div:nth-child(4) {
    padding-top: 13px;
    border-top: 1px solid var(--line);
  }

  .overview-metrics > div:nth-child(3) {
    padding-left: 0;
  }

  .overview-leader-score {
    font-size: 26px;
  }
}

/* 8. 响应式 ---------------------------------------------------------------- */

@media (min-width: 700px) {
  body {
    padding: 20px 0;
  }

  .app {
    border-radius: 28px;
    min-height: calc(100vh - 40px);
  }

  .score-screen {
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
  }

  .topbar {
    border-radius: 28px 28px 0 0;
  }

  .hero {
    min-height: calc(100vh - 40px);
    border-radius: 28px;
  }

  .bottom-nav {
    bottom: 20px;
  }

  .modal-backdrop {
    padding-bottom: 20px;
  }

  .sheet {
    border-radius: 28px;
  }
}
