* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #1b5e3a;
  color: #fff;
  min-height: 100vh;
}

#app { max-width: 1280px; margin: 0 auto; padding: 10px 16px; }

header { text-align: center; padding: 6px 0 10px; }
header h1 { font-size: 22px; letter-spacing: 6px; color: #ffe28a; }
.header-info { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 6px 0; font-size: 14px; color: #cfe9d8; }
.rules-tip { font-size: 12px; color: #9fc7ab; }
.config-bar { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 8px 0; font-size: 12.5px; color: #cfe9d8; }
.config-bar label { display: inline-flex; align-items: center; gap: 4px; }
.config-bar select { background: #234d38; color: #eaf6ee; border: 1px solid #3d7a57; border-radius: 5px; padding: 2px 6px; font-size: 12.5px; }

#btn-start, .act {
  border: none; border-radius: 999px; padding: 7px 18px;
  font-size: 15px; cursor: pointer; font-weight: 600;
  transition: transform .08s, box-shadow .08s;
}
#btn-start { background: linear-gradient(#ffe9a8, #f4cf6a); color: #5a4310; }
.act.primary { background: linear-gradient(#e8564f, #c8362f); color: #fff; box-shadow: 0 3px 0 #8c2b28; }
.act.primary:hover { transform: translateY(-1px); }
.act.secondary { background: linear-gradient(#5a8f6d, #3f6d50); color: #eaf6ee; box-shadow: 0 3px 0 #294a34; }
.act.big { font-size: 18px; padding: 11px 32px; }

/* 牌桌布局 */
#table {
  position: relative;
  display: grid;
  grid-template-columns: 150px 1fr 150px;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    ".    top    ."
    "left center right"
    "me   me     me";
  gap: 6px;
  min-height: 430px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255,255,255,.10), rgba(0,0,0,0) 55%),
    radial-gradient(ellipse at center, #2f8153 0%, #1c6039 60%, #144527 100%);
  box-shadow: inset 0 0 60px rgba(0,0,0,.45);
  border-radius: 16px;
  padding: 12px;
}
#seat-top { grid-area: top; }
#seat-left { grid-area: left; }
#seat-right { grid-area: right; }
#center-info { grid-area: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#seat-me { grid-area: me; }

#msg { font-size: 16px; color: #ffe28a; min-height: 22px; }
#actions {
  grid-area: center;
  display: flex; gap: 10px; justify-content: center; align-items: flex-end;
  margin-top: 24px;
  pointer-events: none;
}
#actions button { pointer-events: auto; animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.7); } to { transform: scale(1); } }

.seat { padding: 4px; }
.seat-name { font-size: 13px; color: #d7ecdf; margin-bottom: 4px; }
.seat-name.active { color: #ffe28a; font-weight: bold; }

/* 麻将牌（图片牌面 + 文字回退） */
.tile {
  width: 34px; height: 46px;
  background: linear-gradient(#fffdf6, #e9e2cd);
  border-radius: 6px;
  border: 1px solid rgba(60,50,30,.35);
  box-shadow: 0 2px 3px rgba(0,0,0,.45);
  display: inline-flex; align-items: center; justify-content: center;
  margin: 1px; color: #333; user-select: none;
  overflow: hidden; position: relative;
}
.tile-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; pointer-events: none; }
.tile.small { width: 24px; height: 32px; border-radius: 4px; }
.tile .t-num { font-size: 15px; font-weight: 600; line-height: 1.15; text-align: center; }
.tile.small .t-num { font-size: 11px; }
.tile.back { background: linear-gradient(#3d8f5f, #2c6f49); border-color: #1e5236; }
.tile.back-fallback { background: repeating-linear-gradient(45deg, #3d8f5f, #3d8f5f 4px, #2c6f49 4px, #2c6f49 8px); }
.tile.wan .t-num { color: #b23b2e; }
.tile.tong .t-num { color: #1f6bb0; }
.tile.tiao .t-num { color: #177a43; }
.tile.zi .t-num { color: #4b3a86; }
.tile.zhong .t-num { color: #c0392b; }
.tile.fa .t-num { color: #1e8449; }
.tile.bai .t-num { color: #85929e; }
.tile.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.tile.clickable:hover { transform: translateY(-8px); box-shadow: 0 8px 12px rgba(0,0,0,.45); }
.tile.hl { outline: 3px solid #ffd966; margin-left: 10px; }
.tile.caishen { outline: 2px solid #ffcf4d; box-shadow: 0 0 8px #ffd966, 0 2px 3px rgba(0,0,0,.4); }
.tile .cs-tag { position: absolute; top: -5px; right: -3px; background: #ffcf4d; color: #5a4310; font-size: 9px; border-radius: 50%; width: 15px; height: 15px; line-height: 15px; text-align: center; font-weight: bold; z-index: 2; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.meld-kind { align-self: center; font-size: 10px; color: #ffe28a; padding: 0 3px; font-weight: bold; }

/* 字牌（CSS 文字/边框渲染，字号统一） */
.tile.honor { background: linear-gradient(#fffdf6, #efe6d0); }
.honor-char {
  font-weight: 800; line-height: 1;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "PingFang SC", "Microsoft YaHei", serif;
}
.honor-char.hb { color: #1f4f80; }
.honor-char.hr { color: #c0392b; }
.honor-char.hg { color: #1c6b39; }
.tile .honor-char { font-size: 22px; }
.hand .tile .honor-char { font-size: 40px; }
.tile.small .honor-char { font-size: 16px; }
.bai-frame { width: 54%; height: 66%; box-sizing: border-box; border: 2.5px solid #1f4f80; border-radius: 3px; }
.hand .tile .bai-frame { border-width: 3.5px; }
.tile.small .bai-frame { border-width: 1.6px; }

/* 万子（CSS 文字：上数字、下萬） */
.tile.man { flex-direction: column; background: linear-gradient(#fffdf6, #efe6d0); }
.man-num, .man-wan {
  font-weight: 800; line-height: 1.02;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "PingFang SC", "Microsoft YaHei", serif;
}
.man-num { color: #232323; }
.man-wan { color: #c0392b; }
.tile .man-num, .tile .man-wan { font-size: 15px; }
.hand .tile .man-num, .hand .tile .man-wan { font-size: 27px; }
.tile.small .man-num, .tile.small .man-wan { font-size: 11px; }

.hand { display: flex; flex-wrap: wrap; }
.hand .tile { width: 46px; height: 62px; }
.hand .tile .t-num { font-size: 19px; }

.meld-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.meld-row.vertical { flex-direction: column; }
.meld-row.backs { gap: 2px; margin: 3px 0; }
.meld-row.backs .tile.small { width: 18px; height: 24px; }
.meld-group { display: flex; align-items: center; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.12); border-radius: 6px; padding: 3px; }

.river { display: grid; grid-template-columns: repeat(6, 20px); gap: 2px; max-width: 132px; min-height: 30px; margin: 4px 0; background: rgba(0,0,0,.16); border-radius: 8px; padding: 4px; }
.river .tile.small { width: 20px; height: 28px; }
#seat-me .river { max-width: 100%; grid-template-columns: repeat(12, 20px); }

/* 日志 */
#log-panel {
  margin-top: 10px;
  background: rgba(0,0,0,.28);
  border-radius: 8px;
  padding: 8px 12px;
  height: 110px;
  overflow-y: auto;
  font-size: 12.5px;
  color: #cde7d6;
  line-height: 1.7;
}

/* toast */
#toast {
  position: fixed; left: 50%; top: 40%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.75);
  color: #ffe28a;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 50;
}
#toast.show { opacity: 1; }

/* 结算 */
#overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
#result-card {
  background: linear-gradient(#2b5a41, #1d4030);
  border: 2px solid #ffe28a;
  border-radius: 16px;
  padding: 24px 32px;
  min-width: 360px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
#result-body h2 { color: #ffe28a; margin-bottom: 14px; font-size: 21px; }
.fan-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.fan-item { background: rgba(255,226,138,.16); color: #ffe28a; padding: 4px 12px; border-radius: 12px; font-size: 13px; border: 1px solid rgba(255,226,138,.3); }
.result-hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; margin-bottom: 12px; }
.score-table { margin: 0 auto 14px; border-collapse: collapse; font-size: 14px; }
.score-table th, .score-table td { padding: 4px 14px; border-bottom: 1px solid rgba(255,255,255,.15); }
.score-table .up { color: #7fff9f; }
.score-table .down { color: #ff9a8b; }

@media (max-width: 900px) {
  .hand .tile { width: 30px; height: 42px; }
  .hand .tile .t-num { font-size: 13px; }
  #table { grid-template-columns: 120px 1fr 120px; }
  .river { max-width: 320px; }
}
