/* 军棋 · 四国风云 样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1100px 520px at 18% -8%, rgba(120, 90, 40, .25), transparent 60%),
              radial-gradient(900px 500px at 88% 4%, rgba(60, 90, 160, .18), transparent 60%),
              #171512;
  color: #ece5d8;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 主菜单 ---------- */
#menu {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, #201b14 0%, #171512 55%, #12181d 100%);
}
#menu.show { display: flex; }
.menu-inner { text-align: center; max-width: 960px; padding: 24px; }
.menu-inner h1 { font-size: 44px; color: #ffd94f; letter-spacing: 6px; text-shadow: 0 4px 0 rgba(80, 50, 0, .6); }
.menu-inner .sub { margin: 12px 0 30px; color: #b9a988; font-size: 15px; letter-spacing: 2px; }
.mode-cards { display: flex; gap: 26px; justify-content: center; flex-wrap: wrap; }
.mode-card {
  width: 380px; max-width: 92vw; padding: 30px 26px 24px; border-radius: 20px;
  background: linear-gradient(180deg, #2a251c, #1d1a14);
  border: 1px solid rgba(255, 224, 102, .18); border-top: 3px solid var(--ac, #ffd94f);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  transition: transform .22s, box-shadow .22s, border-color .22s;
}
.mode-card:hover { transform: translateY(-6px); box-shadow: 0 26px 64px rgba(0, 0, 0, .6); border-color: var(--ac, #ffd94f); }
.mode-card .mc-icon { font-size: 46px; }
.mode-card h2 { font-size: 24px; margin: 10px 0 12px; color: #fff; letter-spacing: 3px; }
.mode-card p { font-size: 13.5px; line-height: 1.9; color: #c8bda6; min-height: 76px; }
.mode-card b { color: #ffd94f; }
.mc-go {
  display: inline-block; margin-top: 14px; padding: 9px 26px; border-radius: 999px;
  background: linear-gradient(180deg, #e8b93c, #c2902a); color: #3a2a05; font-weight: 800; font-size: 14.5px;
  box-shadow: 0 4px 0 #7a5a14;
}
.mode-card:hover .mc-go { filter: brightness(1.08); }
.menu-foot { margin-top: 26px; }
.ghost-btn {
  background: transparent; border: 1px solid #6b5f45; color: #c8bda6;
  padding: 9px 22px; border-radius: 999px; font-size: 14px;
}
.ghost-btn:hover { border-color: #ffd94f; color: #ffd94f; }

/* ---------- 顶部栏 ---------- */
#app { height: 100%; display: none; flex-direction: column; }
#app.show { display: flex; }
#topbar {
  height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: rgba(20, 17, 12, .9); border-bottom: 1px solid rgba(255, 217, 79, .15);
}
.tb-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
#tb-title { font-size: 18px; font-weight: 800; color: #ffd94f; letter-spacing: 2px; white-space: nowrap; }
.tb-badge { font-size: 12.5px; color: #d8c89f; background: rgba(255, 217, 79, .1); border: 1px solid rgba(255, 217, 79, .25); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.tb-score { font-size: 13.5px; color: #9fe08a; font-weight: 700; white-space: nowrap; }
.tb-right { display: flex; align-items: center; gap: 8px; }
#tb-tip { font-size: 12.5px; color: #a99c80; margin-right: 6px; white-space: nowrap; }
.mini-btn {
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .16); color: #d8cfbc;
  font-size: 12.5px; padding: 5px 12px; border-radius: 8px; white-space: nowrap;
}
.mini-btn:hover { border-color: #ffd94f; color: #ffd94f; }
.mini-btn.warn:hover { border-color: #ff7a5c; color: #ff7a5c; }

/* ---------- 主舞台 ---------- */
#stage { flex: 1; display: flex; min-height: 0; }
#board-wrap { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; padding: 10px; min-width: 0; }
#board { width: 100%; height: 100%; max-width: calc((100vh - 72px) * 1.0); max-height: 100%; user-select: none; }
#turn-banner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  font-size: 15px; font-weight: 800; letter-spacing: 2px; padding: 6px 22px; border-radius: 999px;
  background: rgba(15, 13, 10, .82); border: 1px solid rgba(255, 217, 79, .35); color: #ffd94f;
  pointer-events: none; opacity: 0; transition: opacity .25s;
}
#turn-banner.show { opacity: 1; }

/* ---------- 侧栏 ---------- */
#side-panel {
  width: 292px; flex: none; display: flex; flex-direction: column; gap: 10px;
  padding: 12px 12px 12px 0; min-height: 0;
}
#players { display: flex; flex-direction: column; gap: 8px; }
.pchip {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .09);
  font-size: 13.5px; transition: border-color .25s, background .25s;
}
.pchip.active { border-color: #ffd94f; background: rgba(255, 217, 79, .08); box-shadow: 0 0 0 1px rgba(255, 217, 79, .25); }
.pchip.dead { opacity: .42; filter: grayscale(.8); }
.pchip .dot { width: 13px; height: 13px; border-radius: 50%; flex: none; box-shadow: 0 0 5px currentColor; }
.pchip .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchip .ptag { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; opacity: .9; flex: none; }
.pchip .pside { font-size: 11.5px; color: #a99c80; flex: none; }

#action-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.action-btn {
  flex: 1; min-width: 100px; padding: 10px 8px; border-radius: 11px; font-size: 14px; font-weight: 700;
  background: linear-gradient(180deg, #e8b93c, #c2902a); color: #3a2a05; border: none; box-shadow: 0 3px 0 #7a5a14;
}
.action-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a5a14; }
.action-btn.primary { background: linear-gradient(180deg, #6fce55, #48a334); box-shadow: 0 3px 0 #2c7a24; color: #0c2b08; }
.action-btn:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }

#log-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 1px solid rgba(255, 255, 255, .09); border-radius: 12px; background: rgba(0, 0, 0, .22); }
#log-title { padding: 8px 12px; font-size: 12.5px; color: #a99c80; border-bottom: 1px solid rgba(255, 255, 255, .08); }
#log { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; }
#log::-webkit-scrollbar { width: 6px; }
#log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 3px; }
.log-line { font-size: 12.5px; line-height: 1.55; color: #cfc5ae; }
.log-line b { color: #ffd94f; }
.log-line.major { color: #ffb08c; }
.log-line.sys { color: #9fe08a; }
.log-line .ts { color: #7d745f; margin-right: 5px; font-size: 11px; }

/* ---------- SVG 棋盘 ---------- */
.rail-base { stroke: #3d3a34; stroke-width: 7.5; stroke-linecap: round; }
.rail-dash { stroke: #c9c2b2; stroke-width: 7.5; stroke-linecap: butt; stroke-dasharray: 7 7; }
.road-line { stroke: #8a7a58; stroke-width: 2.4; stroke-linecap: round; opacity: .85; }
.terr-fill { opacity: .1; }
.terr-front { fill: none; stroke-width: 1.6; opacity: .5; }
.node-station { fill: #d9cfb8; stroke: #6b6152; stroke-width: 1.4; }
.node-camp { fill: #2c2820; stroke: #d9cfb8; stroke-width: 2; }
.node-camp-inner { fill: none; stroke: #d9cfb8; stroke-width: 1; opacity: .6; }
.node-hq { fill: #4a4234; stroke: #d9cfb8; stroke-width: 1.6; }
.node-hq-star { fill: #d9cfb8; }
.hit-area { fill: transparent; cursor: pointer; }
.hit-area.sel-target { cursor: pointer; }

.target-dot { fill: #ffd94f; opacity: .95; pointer-events: none; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { r: 5.5; opacity: .95; } 50% { r: 7.5; opacity: .55; } }
.target-ring { fill: none; stroke: #ff6b4a; stroke-width: 3; pointer-events: none; animation: spinring 1.2s linear infinite; }
@keyframes spinring { from { stroke-dasharray: 6 5; } to { stroke-dasharray: 6 5; } }
.sel-ring { fill: none; stroke: #ffd94f; stroke-width: 2.6; pointer-events: none; }
.bomb-mark { font-size: 13px; pointer-events: none; }

.piece { transition: transform .38s cubic-bezier(.5, .1, .3, 1.2); cursor: default; }
.piece.mine-side { cursor: pointer; }
.piece .body { stroke: rgba(0, 0, 0, .5); stroke-width: 1.5; }
.piece .rank-text {
  font-size: 14.5px; font-weight: 800; fill: #fff; text-anchor: middle; dominant-baseline: central;
  paint-order: stroke; stroke: rgba(0, 0, 0, .35); stroke-width: 2.5; pointer-events: none;
}
.piece .back-star { fill: rgba(255, 255, 255, .5); pointer-events: none; }
.piece.back .body { fill: #56504a; }
.piece.selected .sel-ring { display: block; }
.piece.dead { opacity: 0; transition: opacity .45s; }
.piece.revealed-flag .body { stroke: #ffd94f; stroke-width: 2.5; }
.piece.just-fought .body { animation: fightflash .5s 2; }
@keyframes fightflash { 0%, 100% { fill-opacity: 1; } 50% { fill-opacity: .25; } }
.boom { font-size: 30px; pointer-events: none; animation: boompop .8s forwards; }
@keyframes boompop { 0% { transform: scale(.3); opacity: 0; } 30% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
.float-text { font-size: 14px; font-weight: 700; pointer-events: none; animation: floatup 1.4s forwards; }
@keyframes floatup { 0% { opacity: 0; transform: translateY(6px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }

.setup-slot-hint { fill: none; stroke: rgba(255, 217, 79, .35); stroke-width: 1.2; stroke-dasharray: 3 3; pointer-events: none; }
.setup-illegal { animation: shake .3s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- 弹层 ---------- */
#overlay { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; background: rgba(10, 8, 5, .78); backdrop-filter: blur(3px); }
#overlay.show { display: flex; }
.panel {
  width: min(620px, 94vw); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, #2a251c, #1c1913); border: 1px solid rgba(255, 217, 79, .25);
  border-radius: 20px; padding: 26px 30px; box-shadow: 0 26px 70px rgba(0, 0, 0, .65);
}
.panel h2 { color: #ffd94f; letter-spacing: 2px; font-size: 21px; margin-bottom: 14px; }
#bid-hand { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.hand-tile {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; height: 32px; padding: 0 8px; border-radius: 8px; font-size: 13.5px; font-weight: 700;
  background: linear-gradient(180deg, #5a4a30, #3d3220); color: #ffe9b0; border: 1px solid rgba(255, 217, 79, .3);
}
.hand-tile.special { background: linear-gradient(180deg, #6b3a2e, #47231a); color: #ffc9a8; }
#bid-strength { font-size: 15px; color: #9fe08a; font-weight: 700; margin-bottom: 12px; }
#bid-history { min-height: 84px; max-height: 150px; overflow-y: auto; margin-bottom: 14px; padding: 8px 12px; border-radius: 10px; background: rgba(0, 0, 0, .25); font-size: 13.5px; line-height: 2; }
#bid-history .cur { color: #ffd94f; font-weight: 800; }
#bid-buttons { display: flex; gap: 10px; }
.bid-btn {
  flex: 1; padding: 11px 0; border-radius: 12px; border: 1px solid rgba(255, 217, 79, .4);
  background: rgba(255, 217, 79, .08); color: #ffd94f; font-size: 15.5px; font-weight: 800;
}
.bid-btn:hover:not(:disabled) { background: rgba(255, 217, 79, .2); }
.bid-btn:disabled { opacity: .32; cursor: not-allowed; }
.bid-hint { margin-top: 12px; font-size: 12px; color: #a99c80; line-height: 1.7; }

#result-panel { text-align: center; }
#result-title { font-size: 42px; letter-spacing: 8px; margin-bottom: 12px; }
#result-title.win { color: #ffd94f; text-shadow: 0 4px 0 rgba(90, 60, 0, .6); }
#result-title.lose { color: #ff7a5c; text-shadow: 0 4px 0 rgba(70, 20, 10, .6); }
#result-detail { color: #cfc5ae; font-size: 15px; line-height: 1.9; margin-bottom: 14px; }
#result-score { font-size: 15px; color: #9fe08a; margin-bottom: 20px; line-height: 1.9; }
.result-btns { display: flex; gap: 12px; justify-content: center; }
.primary-btn {
  background: linear-gradient(180deg, #e8b93c, #c2902a); border: none; color: #3a2a05;
  font-size: 15.5px; font-weight: 800; padding: 11px 36px; border-radius: 999px; box-shadow: 0 4px 0 #7a5a14;
}
.primary-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #7a5a14; }

.rules-body p { font-size: 13.5px; line-height: 2; color: #cfc5ae; margin-bottom: 10px; }
.rules-body b { color: #ffd94f; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  #stage { flex-direction: column; }
  #side-panel { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 8px; max-height: 34vh; }
  #players { flex-direction: row; flex-wrap: wrap; }
  .pchip { flex: 1 1 40%; }
  #log-wrap { flex: 1 1 100%; min-height: 90px; }
  #board { max-width: 100%; }
}
