/* ============================================================
   钢铁前线 · 样式表
   视觉基调：深色军事指挥台 —— 让原版卡面成为画面的主角
   ============================================================ */

:root {
  --bg: #101318;
  --bg-2: #171b22;
  --panel: #1d222b;
  --panel-2: #242a35;
  --line: #333a47;
  --text: #e8e6e1;
  --text-dim: #9aa1ad;
  --text-dim2: #6c7480;
  --gold: #c9a227;
  --gold-soft: #e0bf5f;
  --red: #c04a3c;
  --green: #4e7c4a;
  --blue: #4a72a8;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .45);

  --card-w-hand: 112px;
  --card-w-board: 82px;
  --card-ratio: 1.404; /* 702 / 500 */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app { height: 100%; display: flex; flex-direction: column; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------- 启动遮罩 */

.boot {
  position: fixed; inset: 0; z-index: 999;
  background: radial-gradient(circle at 50% 40%, #1e242e, #0b0d11 70%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .5s;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; width: min(320px, 80vw); }
.boot-logo { font-size: 44px; color: var(--gold); margin-bottom: 8px; }
.boot-inner h1 { font-size: 24px; letter-spacing: .3em; margin: 0 0 6px; font-weight: 600; }
.boot-inner p { color: var(--text-dim); font-size: 13px; margin: 0 0 18px; }
.boot-bar { height: 3px; background: #2a3038; border-radius: 2px; overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); transition: width .3s; }
.boot-inner small { display: block; margin-top: 10px; color: var(--text-dim2); font-size: 11px; }

/* ---------------------------------------------------------- 顶部栏 */

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 16px; height: 52px; flex: 0 0 auto;
  background: linear-gradient(180deg, #1c212a, #161a21);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 20px; color: var(--gold); }
.brand-text strong { display: block; font-size: 15px; letter-spacing: .12em; }
.brand-text small { display: block; font-size: 9px; color: var(--text-dim2); letter-spacing: .16em; }

.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tab {
  padding: 7px 16px; font-size: 13.5px; color: var(--text-dim);
  border-radius: 6px; transition: .15s;
}
.tab:hover { background: #232935; color: var(--text); }
.tab.active { background: var(--gold); color: #17180f; font-weight: 600; }

.topbar-right { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 6px; font-size: 15px;
  background: #232935; color: var(--text-dim); transition: .15s;
}
.icon-btn:hover { background: #2d3542; color: var(--text); }

/* ---------------------------------------------------------- 视图 */

.view { flex: 1; overflow: hidden; display: none; }
.view.active { display: flex; flex-direction: column; }

/* ============================================================
   战 场
   ============================================================ */

.setup { flex: 1; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.setup-card {
  width: min(560px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 26px 28px;
  box-shadow: var(--shadow);
}
.setup-card h2 { margin: 0 0 20px; font-size: 19px; letter-spacing: .1em; font-weight: 600; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; letter-spacing: .06em; }
.field input[type=text] {
  width: 100%; padding: 10px 12px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-size: 14px;
}
.field input[type=text]:focus { outline: none; border-color: var(--gold); }
.field select {
  width: 100%; padding: 10px 12px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-size: 13.5px;
}

.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-btn {
  padding: 14px 8px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: .15s; color: var(--text-dim);
}
.mode-btn:hover:not(:disabled) { border-color: #4a5568; color: var(--text); }
.mode-btn.active { border-color: var(--gold); background: #262316; color: var(--text); }
.mode-btn:disabled { opacity: .4; cursor: not-allowed; }
.mode-icon { font-size: 20px; }
.mode-btn strong { font-size: 13px; font-weight: 600; }
.mode-btn small { font-size: 10.5px; color: var(--text-dim2); }

.hint { font-size: 11.5px; color: var(--text-dim2); margin: 8px 0 0; line-height: 1.6; }

.seg { display: flex; gap: 2px; background: var(--bg-2); padding: 3px; border-radius: 8px; }
.seg button {
  flex: 1; padding: 8px; border-radius: 6px; font-size: 13px; color: var(--text-dim); transition: .15s;
}
.seg button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }

.primary-btn {
  width: 100%; padding: 13px; background: linear-gradient(180deg, var(--gold), #a8871c);
  color: #16170e; font-size: 15px; font-weight: 700; letter-spacing: .24em;
  border-radius: 8px; transition: .15s;
}
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn.small { width: auto; padding: 8px 18px; font-size: 12.5px; letter-spacing: .1em; }

.stats-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line);
}
.stats-strip > div { text-align: center; }
.stats-strip b { display: block; font-size: 19px; color: var(--gold-soft); }
.stats-strip span { font-size: 11px; color: var(--text-dim2); }

/* ---------------------------------------------------------- 对局棋盘 */

.board-wrap {
  flex: 1; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
  justify-content: flex-start; gap: 2px;
  padding: 10px 12px 0;
  background:
    radial-gradient(ellipse at 50% 50%, #1a1f27 0%, #0d1015 75%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(255,255,255,.012) 38px 39px);
}

.side { flex: 0 0 auto; }
.side.foe { display: flex; align-items: center; gap: 14px; }
.side.me { display: flex; align-items: center; gap: 14px; }

.side-info { display: flex; align-items: center; gap: 14px; }
.side-meta { display: flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--text-dim); flex-wrap: wrap; }
.side-meta b { color: var(--text); font-size: 13px; }
.side-name { font-size: 13px; font-weight: 600; color: var(--text); }
.side-nation { font-size: 11px; padding: 1px 7px; border-radius: 3px; background: var(--panel-2); color: var(--text-dim); }

.hq-badge { display: flex; align-items: center; gap: 7px; }
.hq-icon { font-size: 15px; }
.hq-badge b { font-size: 20px; font-weight: 700; color: #e8d9a8; min-width: 26px; }
.hq-bar { width: 66px; height: 5px; background: #2a3038; border-radius: 3px; overflow: hidden; }
.hq-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #b8654a, #d98b6a); transition: width .35s; }

.foe-hand-mini { display: flex; gap: 2px; margin-left: auto; }
.foe-hand-mini i {
  display: block; width: 13px; height: 19px; border-radius: 2px;
  background: linear-gradient(150deg, #4a4030, #2a2620); border: 1px solid #5a4f3a;
}

/* 三线 */

.line-row { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.line-row .line-label {
  flex: 0 0 92px; font-size: 10.5px; color: var(--text-dim2);
  letter-spacing: .1em; text-align: center;
}
.front-row .line-label { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.front-owner { font-size: 10px; padding: 1px 6px; border-radius: 3px; background: #2a3038; color: var(--text-dim); }
.front-owner.me { background: #2c3a2a; color: #8fbf86; }
.front-owner.foe { background: #3a2a2a; color: #d19089; }

.line {
  flex: 1; min-width: 0;
  height: calc(var(--card-w-board) * var(--card-ratio) + 14px);
  display: flex; align-items: center; gap: 6px;
  padding: 6px; border-radius: 8px;
  overflow: hidden;
}
.line.support { background: rgba(255,255,255,.028); border: 1px solid rgba(255,255,255,.05); }
.line.front { background: rgba(201,162,39,.055); border: 1px dashed rgba(201,162,39,.22); }

/* 降级用：手机上高度不够时压缩 */
@media (max-height: 700px) {
  :root { --card-w-board: 68px; --card-w-hand: 96px; }
}

/* ---------------------------------------------------------- 卡牌 */

.card {
  position: relative; flex: 0 0 auto;
  width: var(--card-w-board);
  border-radius: 5px; overflow: hidden;
  background: #0e1116;
  border: 1.5px solid #3a4150;
  transition: transform .14s, box-shadow .14s, border-color .14s;
  cursor: pointer;
}
.card img { display: block; width: 100%; aspect-ratio: 500 / 702; object-fit: cover; }

.card.selectable { border-color: var(--green); box-shadow: 0 0 0 2px rgba(78,124,74,.4); }
.card.selectable:hover { transform: translateY(-4px) scale(1.04); z-index: 5; }
.card.attackable { border-color: var(--red); box-shadow: 0 0 0 2px rgba(192,74,60,.45); animation: pulse 1.4s infinite; }
.card.attackable:hover { transform: translateY(-4px) scale(1.05); z-index: 5; }
.card.selected { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.5); transform: translateY(-5px) scale(1.06); z-index: 6; }
.card.exhausted { filter: grayscale(.75) brightness(.62); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(192,74,60,.45); }
  50% { box-shadow: 0 0 0 4px rgba(192,74,60,.22); }
}

/* 场上的状态小标 */
.card .stat-chip {
  position: absolute; top: 3px; right: 3px;
  display: flex; gap: 2px;
}
.card .stat-chip i {
  width: 15px; height: 15px; border-radius: 3px;
  font-size: 9px; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.72); color: #ffd; font-style: normal; font-weight: 700;
}
.card .hp-delta {
  position: absolute; left: 3px; bottom: 3px;
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: rgba(0,0,0,.75); color: #9fdc92; font-weight: 700;
}
.card .hp-delta.hurt { color: #ff9d8f; }

/* 手牌 */

.hand-zone {
  flex: 0 0 auto; margin-top: auto; padding: 10px 0 12px;
  display: flex; justify-content: center; align-items: flex-end;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.28));
  min-height: calc(var(--card-w-hand) * var(--card-ratio) * 0.6 + 24px);
}
.hand { display: flex; gap: 6px; justify-content: safe center; align-items: flex-end; padding: 0 8px; max-width: 100%; overflow-x: auto; overflow-y: visible; }
.hand .card {
  width: var(--card-w-hand);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.hand .card:hover { transform: translateY(-16px) scale(1.28); z-index: 20; box-shadow: 0 14px 34px rgba(0,0,0,.7); }
.hand .card.playable { border-color: var(--green); }
.hand .card.unplayable { filter: grayscale(.55) brightness(.7); }
.hand .card.selected { transform: translateY(-18px) scale(1.3); border-color: var(--gold); z-index: 21; }

/* ---------------------------------------------------------- 中央状态条 */

.midbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 5px 14px; margin: 2px 0;
  background: rgba(0,0,0,.28); border-radius: 7px;
  border-top: 1px solid rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.turn-info { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--text-dim); }
.turn-info b { color: var(--text); }
.active-label { font-weight: 600; }
.active-label.mine { color: #9fd492; }
.active-label.foe { color: #e09a8d; }
.ap-display b { color: var(--gold-soft); font-size: 15px; }

.mid-actions { display: flex; gap: 8px; }
.end-btn {
  padding: 8px 22px; background: linear-gradient(180deg, #3f5a3a, #2f452c);
  color: #dcedd6; font-size: 13px; font-weight: 600; border-radius: 6px; transition: .15s;
  border: 1px solid #4a6b44;
}
.end-btn:hover { filter: brightness(1.15); }
.end-btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.ghost-btn {
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 12.5px; color: var(--text-dim); transition: .15s;
}
.ghost-btn:hover { border-color: #4a5568; color: var(--text); }
.ghost-btn.danger:hover { border-color: var(--red); color: #e58d80; }
.ghost-btn.small { padding: 7px 14px; font-size: 12px; }

/* ---------------------------------------------------------- 战报 */

.logbox {
  position: absolute; right: 12px; bottom: 12px; width: 240px;
  max-height: 200px; display: flex; flex-direction: column;
  background: rgba(14,17,22,.9); border: 1px solid var(--line);
  border-radius: 8px; backdrop-filter: blur(6px); z-index: 8;
  transition: .2s;
}
.logbox.collapsed { max-height: 32px; overflow: hidden; }
.log-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; font-size: 11.5px; color: var(--text-dim);
  border-bottom: 1px solid var(--line); letter-spacing: .08em;
}
.mini-x { font-size: 14px; color: var(--text-dim2); padding: 0 4px; }
.log-list { overflow-y: auto; padding: 6px 10px; font-size: 11.5px; line-height: 1.65; }
.log-list > div { color: var(--text-dim); padding: 2px 0; }
.log-list > div.turn { color: var(--gold-soft); font-weight: 600; margin-top: 4px; }
.log-list > div.attack { color: #e5a898; }
.log-list > div.death { color: #b98c8c; }
.log-list > div.effect { color: #9bb8dc; }
.log-list > div.play { color: #a9c99b; }

/* ---------------------------------------------------------- 弹窗 */

.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6,8,11,.82); display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-card {
  width: min(400px, 88vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; text-align: center; box-shadow: var(--shadow);
}
.result-badge {
  display: inline-block; padding: 4px 20px; border-radius: 4px; font-size: 13px;
  letter-spacing: .3em; font-weight: 700; margin-bottom: 14px;
  background: var(--gold); color: #17180f;
}
.result-badge.loss { background: var(--red); color: #fff; }
.result-badge.draw { background: var(--line); color: var(--text); }
.modal-card h3 { margin: 0 0 10px; font-size: 18px; }
.modal-card p { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .primary-btn { flex: 1; }
.modal-actions .ghost-btn { flex: 1; }

/* 热座遮挡 */
.curtain {
  position: fixed; inset: 0; z-index: 90;
  background: radial-gradient(circle at 50% 50%, #1c222b, #090b0e 70%);
  display: flex; align-items: center; justify-content: center;
}
.curtain-card { text-align: center; }
.curtain-card h3 { font-size: 20px; margin: 0 0 8px; letter-spacing: .1em; }
.curtain-card p { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }
.curtain-card .primary-btn { width: auto; padding: 12px 44px; }

/* ============================================================
   卡组编辑
   ============================================================ */

.deck-editor { flex: 1; display: flex; overflow: hidden; }

.deck-list-panel {
  flex: 0 0 234px; display: flex; flex-direction: column;
  background: var(--bg-2); border-right: 1px solid var(--line);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h3 { margin: 0; font-size: 14px; letter-spacing: .08em; }
.mini-btn {
  padding: 5px 12px; font-size: 12px; border: 1px solid var(--line);
  border-radius: 5px; color: var(--text-dim); transition: .15s;
}
.mini-btn:hover { border-color: #4a5568; color: var(--text); }
.mini-btn.wide { width: 100%; margin-top: 8px; }
.mini-btn.danger:hover { border-color: var(--red); color: #e58d80; }

.deck-list { flex: 1; overflow-y: auto; padding: 8px; }
.deck-item {
  padding: 10px 12px; border-radius: 6px; margin-bottom: 6px;
  background: var(--panel); border: 1px solid transparent; cursor: pointer; transition: .15s;
}
.deck-item:hover { border-color: #3d4552; }
.deck-item.active { border-color: var(--gold); background: #262316; }
.deck-item .di-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.deck-item .di-meta { font-size: 11px; color: var(--text-dim2); }
.panel-foot { padding: 12px; border-top: 1px solid var(--line); }

.deck-builder { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.builder-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.deck-name-input {
  flex: 1; padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text); font-size: 14px;
}
.builder-actions { display: flex; gap: 8px; }

.nation-picker {
  display: flex; gap: 24px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.np-group label { display: block; font-size: 11px; color: var(--text-dim2); margin-bottom: 7px; }
.nation-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.nation-btns button {
  padding: 5px 11px; font-size: 12px; border-radius: 5px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text-dim); transition: .15s;
}
.nation-btns button:hover { color: var(--text); border-color: #4a5568; }
.nation-btns button.active { background: var(--gold); color: #17180f; border-color: var(--gold); font-weight: 600; }
.nation-btns button.active.ally { background: var(--blue); color: #eef4ff; border-color: var(--blue); }

.deck-status { padding: 9px 16px; font-size: 12px; border-bottom: 1px solid var(--line); }
.deck-status .ok { color: #8fbf86; }
.deck-status .err { color: #e58d80; }
.deck-status .warn { color: #d8bf72; }

.builder-tools { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.pool-search {
  flex: 1; padding: 8px 11px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text); font-size: 13px;
}
.builder-tools select {
  padding: 8px 10px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text-dim); font-size: 12.5px;
}

.builder-body { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.card-pool {
  flex: 1; overflow-y: auto; padding: 14px 16px;
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
}
.card-pool .pool-card { width: 88px; }
.current-deck {
  flex: 0 0 296px; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; background: var(--bg-2);
  min-height: 0;
}
.cd-head {
  display: flex; justify-content: space-between; padding: 11px 14px;
  font-size: 12.5px; border-bottom: 1px solid var(--line); color: var(--text-dim);
}
.cd-head b { color: var(--gold-soft); font-size: 14px; }
.cd-curve { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.curve-bar { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.curve-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; justify-content: flex-end; }
.curve-col i { width: 100%; background: linear-gradient(180deg, var(--gold-soft), #8a6f1c); border-radius: 2px 2px 0 0; min-height: 2px; }
.curve-col span { font-size: 9px; color: var(--text-dim2); }
.cd-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.cd-list .deck-card { width: 82px; }

/* 卡池中的小卡 */

.pool-card, .deck-card {
  position: relative; border-radius: 5px; overflow: hidden;
  border: 1.5px solid #3a4150; background: #0e1116; cursor: pointer;
  transition: .15s;
}
.pool-card img, .deck-card img { display: block; width: 100%; aspect-ratio: 500/702; object-fit: cover; }
.pool-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.pool-card.disabled { filter: grayscale(.7) brightness(.55); cursor: not-allowed; }
.pool-card .count-badge, .deck-card .count-badge {
  position: absolute; right: 3px; top: 3px;
  background: rgba(0,0,0,.82); color: var(--gold-soft);
  font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
}
.pool-card .cost-badge, .deck-card .cost-badge {
  position: absolute; left: 3px; top: 3px;
  background: rgba(0,0,0,.82); color: #ffe9a8;
  font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
}

/* ============================================================
   图鉴
   ============================================================ */

.gallery { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 14px 16px; }
.gallery-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.gallery-count { font-size: 12px; color: var(--text-dim2); white-space: nowrap; }
.gallery-filter { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 5px; flex-wrap: wrap; }
.filter-row button {
  padding: 5px 11px; font-size: 12px; border-radius: 5px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text-dim); transition: .15s;
}
.filter-row button:hover { color: var(--text); }
.filter-row button.active { background: var(--gold); color: #17180f; border-color: var(--gold); font-weight: 600; }
.gallery-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px; align-content: start; padding-bottom: 20px;
}
.gallery-more { text-align: center; padding: 16px; }

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

.rules-page { flex: 1; overflow-y: auto; padding: 28px 32px; max-width: 900px; }
.rules-page h2 { font-size: 20px; margin: 0 0 8px; letter-spacing: .08em; }
.rules-page h3 { font-size: 15px; margin: 26px 0 10px; color: var(--gold-soft); letter-spacing: .06em; }
.rules-page p, .rules-page li { font-size: 13.5px; line-height: 1.85; color: var(--text-dim); }
.rules-page ul { padding-left: 20px; margin: 8px 0; }
.rules-page code {
  background: var(--panel-2); padding: 1px 6px; border-radius: 3px;
  font-size: 12.5px; color: var(--gold-soft);
}
.rules-page .kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 13px; margin: 10px 0; }
.rules-page .kv dt { color: var(--text); font-weight: 600; }
.rules-page .kv dd { margin: 0; color: var(--text-dim); }

/* ============================================================
   卡牌详情浮层
   ============================================================ */

.card-detail { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; }
.cd-backdrop { position: absolute; inset: 0; background: rgba(5,7,10,.86); backdrop-filter: blur(4px); }
.cd-panel {
  position: relative; display: flex; gap: 26px;
  width: min(760px, 92vw); max-height: 88vh;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 26px; box-shadow: var(--shadow);
  overflow: hidden;
}
.cd-panel .cd-img { flex: 0 0 auto; width: min(300px, 40vw); }
.cd-panel .cd-img img { width: 100%; border-radius: 8px; display: block; }
.cd-panel .cd-body { flex: 1; overflow-y: auto; }
.cd-panel .cd-title { font-size: 21px; font-weight: 700; margin: 0 0 4px; }
.cd-panel .cd-sub { font-size: 12px; color: var(--text-dim2); letter-spacing: .1em; margin-bottom: 16px; }
.cd-panel .cd-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.cd-panel .cd-tag {
  font-size: 11.5px; padding: 3px 10px; border-radius: 4px;
  background: var(--panel-2); color: var(--text-dim);
}
.cd-panel .cd-tag.rarity-gold { background: #3d3316; color: #e8ce74; }
.cd-panel .cd-tag.rarity-silver { background: #2f353d; color: #cfd8e2; }
.cd-panel .cd-tag.rarity-bronze { background: #382a1e; color: #d9a877; }
.cd-panel .cd-stats { display: flex; gap: 22px; margin-bottom: 18px; }
.cd-panel .cd-stat { text-align: center; }
.cd-panel .cd-stat b { display: block; font-size: 26px; color: var(--gold-soft); }
.cd-panel .cd-stat span { font-size: 11px; color: var(--text-dim2); }
.cd-panel .cd-text {
  font-size: 13.5px; line-height: 1.85; color: var(--text);
  background: var(--bg-2); border-left: 3px solid var(--gold);
  padding: 12px 14px; border-radius: 0 6px 6px 0; margin-bottom: 14px;
}
.cd-panel .cd-note { font-size: 11.5px; color: var(--text-dim2); line-height: 1.7; }
.cd-panel .cd-note.unsupported { color: #d8bf72; }
.cd-close {
  position: absolute; right: 14px; top: 12px; font-size: 20px;
  color: var(--text-dim2); padding: 4px 10px; border-radius: 5px;
}
.cd-close:hover { background: var(--panel-2); color: var(--text); }
.cd-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ---------------------------------------------------------- Toast */

.toast {
  position: fixed; left: 50%; bottom: 42px; transform: translateX(-50%);
  background: rgba(20,24,30,.96); border: 1px solid var(--line);
  color: var(--text); padding: 11px 22px; border-radius: 8px;
  font-size: 13px; z-index: 200; box-shadow: var(--shadow);
  animation: toastIn .2s;
}
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ============================================================
   响应式（手机）
   ============================================================ */

@media (max-width: 820px) {
  :root { --card-w-hand: 84px; --card-w-board: 62px; }
  .topbar { height: 46px; padding: 0 8px; gap: 6px; }
  .brand { gap: 6px; }
  .brand-mark { font-size: 16px; }
  .brand-text small { display: none; }
  .brand-text strong { font-size: 12px; letter-spacing: .06em; }
  .tabs { margin-left: 0; gap: 0; }
  .tab { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
  .icon-btn { width: 30px; height: 30px; font-size: 13px; }
  .line-row { gap: 6px; }
  .line-row .line-label { flex: 0 0 46px; font-size: 9px; line-height: 1.3; }
  .line { padding: 4px; gap: 4px; }
  .side { gap: 8px; }
  .side-info { gap: 8px; }
  .side-meta { font-size: 10px; gap: 6px; }
  .side-name { font-size: 11.5px; }
  .hq-icon { display: none; }
  .hq-badge b { font-size: 15px; min-width: 20px; }
  .hq-bar { width: 38px; }
  .foe-hand-mini { display: none; }
  .midbar { padding: 4px 8px; }
  .turn-info { gap: 7px; font-size: 11px; }
  .end-btn { padding: 7px 14px; font-size: 12px; }
  .ghost-btn { padding: 7px 10px; font-size: 11.5px; }

  /* 战报：手机上默认折叠，挪到手牌上方，不挡操作 */
  .logbox { right: 8px; bottom: 150px; width: 150px; max-height: 116px; }
  .logbox.collapsed { max-height: 30px; }
  .log-head { padding: 5px 8px; font-size: 10.5px; }
  .log-list { font-size: 10.5px; padding: 4px 8px; }

  .deck-editor { flex-direction: column; }
  .deck-list-panel { flex: 0 0 auto; max-height: 132px; border-right: none; border-bottom: 1px solid var(--line); }
  .deck-list { padding: 6px; }
  .deck-item { padding: 7px 10px; margin-bottom: 4px; }
  .panel-foot { padding: 8px; }
  .nation-picker { gap: 12px; padding: 9px 12px; }
  .builder-tools { padding: 8px 12px; flex-wrap: wrap; }
  .builder-tools select { flex: 1; min-width: 0; }
  .builder-body { flex-direction: column; }
  .card-pool { padding: 10px 12px; gap: 6px; }
  .card-pool .pool-card { width: 68px; }
  .current-deck { flex: 0 0 168px; border-left: none; border-top: 1px solid var(--line); }
  .cd-list .deck-card { width: 62px; }

  .cd-panel { flex-direction: column; padding: 16px; gap: 12px; max-height: 92vh; }
  .cd-panel .cd-img { width: min(210px, 56vw); align-self: center; }
  .cd-panel .cd-title { font-size: 18px; }

  .gallery { padding: 10px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
  .rules-page { padding: 18px 16px; }
  .rules-page .kv { grid-template-columns: 84px 1fr; }
}

/* ============================================================
   联机对战
   ============================================================ */

.header-right, .topbar-right { display: flex; align-items: center; gap: 8px; }

.net-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; letter-spacing: .04em;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text-dim); white-space: nowrap;
}
.net-badge i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim2); flex: 0 0 auto;
}
.net-badge.live { border-color: #3d5a37; color: #a9c8a3; }
.net-badge.live i { background: #6fae63; box-shadow: 0 0 6px rgba(111, 174, 99, .8); }
.net-badge.wait { border-color: #6b5a2a; color: var(--gold-soft); }
.net-badge.wait i { background: var(--gold); animation: pulse 1.4s infinite; }
.net-badge.dead { border-color: #5a3730; color: #d79a90; }
.net-badge.dead i { background: var(--red); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.online-box {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 14px;
}

.online-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px;
}
.online-status .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim2); flex: 0 0 auto;
}
.online-status.ok { color: #a9c8a3; }
.online-status.ok .dot { background: #6fae63; box-shadow: 0 0 6px rgba(111, 174, 99, .8); }
.online-status.err { color: #d79a90; }
.online-status.err .dot { background: var(--red); }
.online-status.busy .dot { background: var(--gold); animation: pulse 1.2s infinite; }

.online-join {
  display: flex; gap: 8px; margin-top: 10px; align-items: stretch;
}
.online-join input {
  flex: 1; min-width: 0;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 12px; font-size: 16px; letter-spacing: .28em;
  text-transform: uppercase; font-family: ui-monospace, "Consolas", monospace;
  text-align: center;
}
.online-join input:focus { outline: none; border-color: var(--gold); }
.online-join input::placeholder { letter-spacing: .04em; text-transform: none; font-family: inherit; font-size: 12.5px; }

.primary-btn.wide { width: 100%; }

.room-info {
  border-top: 1px dashed var(--line); padding-top: 12px;
}
.room-code-line {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.room-code-line > span { font-size: 12px; color: var(--text-dim); }
.room-code-line b {
  font-family: ui-monospace, "Consolas", monospace;
  font-size: 22px; letter-spacing: .18em; color: var(--gold-soft);
}
.room-code-line .mini-btn { margin-left: auto; }

.room-players { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.room-player {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg-2);
}
.room-player .seat {
  flex: 0 0 auto; font-size: 10.5px; color: var(--text-dim2);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
}
.room-player .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-player .pstate { font-size: 11px; color: var(--text-dim2); }
.room-player.filled .pstate { color: #a9c8a3; }
.room-player.empty { opacity: .6; }

@media (max-width: 820px) {
  .net-badge { font-size: 10.5px; padding: 3px 8px; }
  .net-badge span { display: none; }        /* 手机上只留一个状态点，不挤顶栏 */
  .net-badge { padding: 6px 8px; }
  .online-box { padding: 12px; }
  .room-code-line b { font-size: 19px; }
}
