:root {
  --bg-0: #07040d;
  --bg-1: #140b22;
  --bg-2: #1d1132;
  --gold: #d8b45a;
  --gold-2: #f4e0a3;
  --gold-dim: #8d6f33;
  --ink: #ece5d4;
  --muted: #a296b8;
  --red: #c4443a;
  --blue: #4a86c8;
  --panel: rgba(24, 14, 40, 0.82);
  --line: rgba(216, 180, 90, 0.38);
  --card-w: 96px; /* 实际尺寸由文末响应式段按视口重算 */
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 50% -10%, #2a1a4a 0%, transparent 60%),
    radial-gradient(900px 600px at 10% 100%, #231135 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 55%, #0a0612 100%);
  min-height: 100%;
  overflow-x: hidden;
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(2px 2px at 15% 22%, rgba(244, 224, 163, .55), transparent 60%),
    radial-gradient(2px 2px at 78% 18%, rgba(244, 224, 163, .4), transparent 60%),
    radial-gradient(1.5px 1.5px at 44% 68%, rgba(160, 200, 255, .35), transparent 60%),
    radial-gradient(2px 2px at 88% 72%, rgba(244, 224, 163, .3), transparent 60%);
}
h1, h2, h3, b { letter-spacing: .02em; }
.kicker { display: block; font-size: 11px; letter-spacing: .28em; color: var(--gold); text-transform: uppercase; opacity: .9; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.7; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; cursor: pointer; border-radius: 6px; padding: 11px 20px;
  font-size: 14px; font-weight: 600; letter-spacing: .08em; color: var(--ink);
  background: linear-gradient(180deg, #2a1a40, #1a0f2a);
  border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 4px 14px rgba(0,0,0,.45);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  color: #2a1c06; border-color: #f0d795;
  background: linear-gradient(180deg, #fbe7a8, #d7b158 55%, #b58a2f);
  box-shadow: 0 0 0 1px rgba(255, 230, 150, .35), 0 6px 22px rgba(200, 160, 60, .35);
}
.btn.ghost { background: transparent; border-color: rgba(216,180,90,.28); color: var(--muted); }
.btn.small { padding: 7px 12px; font-size: 12px; }
.btn.danger { color: #ffd9d3; border-color: rgba(196,68,58,.55); background: linear-gradient(180deg,#3a1414,#240b0b); }
.icon-btn {
  cursor: pointer; width: 40px; height: 32px; font-size: 13px; letter-spacing: .1em; color: var(--gold-2);
  background: rgba(30, 18, 48, .9); border: 1px solid var(--line); border-radius: 5px;
}
.icon-btn.danger { color: #ffb9ae; border-color: rgba(196,68,58,.5); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 大厅 ---------- */
.lobby { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 26px 22px 40px; }
.logo-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 26px; }
.logo { display: flex; gap: 12px; align-items: center; }
.logo-mark {
  width: 44px; height: 44px; display: grid; place-items: center; font-size: 22px; font-family: serif;
  color: #2b1c05; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, #c9a344 60%, #7a5c1c);
  box-shadow: 0 0 0 2px rgba(255, 235, 170, .35), 0 0 26px rgba(216,180,90,.35);
}
.logo b { display: block; font-size: 15px; letter-spacing: .3em; color: var(--gold-2); }
.logo small { font-size: 12px; color: var(--muted); letter-spacing: .12em; }
.account-box { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }

.lobby-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; }
.lobby-grid > * { min-width: 0; }
.panel-hero {
  position: relative; padding: 34px 32px; border-radius: 14px;
  background:
    radial-gradient(600px 300px at 20% 0%, rgba(120, 80, 200, .28), transparent 60%),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 18px 50px rgba(0,0,0,.5);
}
.panel-hero::after {
  content: ""; position: absolute; inset: 8px; border-radius: 10px;
  border: 1px solid rgba(216,180,90,.16); pointer-events: none;
}
.panel-hero h1 { font-size: 38px; margin: 10px 0 10px; font-weight: 700; letter-spacing: .06em;
  background: linear-gradient(180deg, #fff6d8, #e2c367 60%, #a9822c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 2px 18px rgba(216,180,90,.18);
}
.panel-hero .sub { color: var(--muted); font-size: 13.5px; line-height: 1.85; max-width: 560px; }
.hero-actions { display: flex; gap: 12px; margin: 24px 0 16px; flex-wrap: wrap; }
.hero-note { font-size: 12px; color: var(--gold-dim); letter-spacing: .06em; }
.join-row { display: flex; gap: 8px; margin-top: 14px; }
.join-row input {
  width: 160px; padding: 8px 12px; letter-spacing: .22em; text-transform: uppercase;
  border-radius: 6px; font-size: 13px; color: var(--gold-2);
  background: rgba(10, 6, 18, .85); border: 1px solid rgba(216,180,90,.3);
}

.panel-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.panel {
  min-width: 0; padding: 20px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.panel h3 { margin: 0 0 12px; font-size: 14px; color: var(--gold-2); letter-spacing: .18em; }
.deck-list {
  display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; overflow-y: hidden;
  padding-bottom: 6px; scroll-snap-type: x proximity; scrollbar-gutter: stable;
  min-width: 0; max-width: 100%;
}
.deck-item { flex: 0 0 208px; scroll-snap-align: start; }
.deck-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; min-width: 0;
  border: 1px solid rgba(216,180,90,.18); background: rgba(40, 24, 62, .5);
}
.deck-item > b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-tip { font-size: 10.5px; color: var(--muted); }
.deck-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.deck-more { grid-column: 1 / -1; width: 100%; }
@media (max-width: 680px) { .deck-item { flex-basis: 176px; } }
.deck-item.active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(216,180,90,.35) inset; }
.deck-item b { font-size: 13px; }
.deck-item small { color: var(--muted); font-size: 11px; }
.record-list {
  display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto;
  padding-right: 6px; scrollbar-gutter: stable;
}
.record-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px dashed rgba(216,180,90,.15); }
.record-row b.win { color: #7fe0a4; }
.record-row b.lose { color: #ff8d7e; }
.foot { margin-top: 26px; text-align: center; font-size: 11.5px; color: rgba(162,150,184,.7); letter-spacing: .05em; }

/* ---------- 对战 ---------- */
.duel { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; padding: 10px 14px 0; }
.duel-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 4px 10px; }
.room-chip { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); }
.room-chip span { font-size: 15px; letter-spacing: .22em; color: var(--gold-2); }
.duel-status { text-align: center; }
.duel-status b { display: block; font-size: 14px; letter-spacing: .16em; color: var(--gold-2); }
.duel-status span { font-size: 11px; color: var(--muted); }
.duel-tools { display: flex; gap: 6px; }

.board {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
  padding: 12px; border-radius: 14px;
  background:
    radial-gradient(700px 320px at 50% 12%, rgba(90, 60, 160, .22), transparent 65%),
    linear-gradient(180deg, rgba(20, 12, 34, .92), rgba(12, 7, 20, .96));
  border: 1px solid var(--line);
  box-shadow: inset 0 0 60px rgba(0,0,0,.7), 0 12px 40px rgba(0,0,0,.5);
  position: relative;
}
.board::before {
  content: ""; position: absolute; inset: 0; border-radius: 14px; pointer-events: none;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,.014) 0 2px, transparent 2px 6px);
}
.side { display: flex; flex-direction: column; gap: 8px; }
.lpbar {
  display: flex; align-items: center; gap: 14px; padding: 4px 8px;
  border-bottom: 1px solid rgba(216,180,90,.14);
}
.lp { display: flex; align-items: baseline; gap: 6px; }
.lp i { font-style: normal; font-size: 10px; letter-spacing: .2em; color: var(--gold-dim); }
.lp b {
  font-size: 26px; letter-spacing: .05em; font-variant-numeric: tabular-nums;
  color: var(--gold-2); text-shadow: 0 0 18px rgba(240, 210, 120, .45);
}
.who { display: flex; flex-direction: column; line-height: 1.35; }
.who span { font-size: 13px; color: var(--ink); }
.who small { font-size: 11px; color: var(--muted); }
.normal-flag {
  margin-left: auto; font-size: 11px; letter-spacing: .1em; padding: 4px 10px; border-radius: 999px;
  color: #bff3d0; border: 1px solid rgba(120, 220, 160, .4); background: rgba(30, 90, 60, .35);
}
.normal-flag.used { color: #ffc9b8; border-color: rgba(220, 120, 90, .4); background: rgba(90, 40, 30, .35); }

.zone-row { display: grid; grid-template-columns: repeat(5, var(--card-w)); gap: 10px; justify-content: center; }
.spt-row .slot { height: calc(var(--card-w) * .92); }

.divider { display: flex; align-items: center; gap: 12px; padding: 2px 10px; }
.divider-line { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(216,180,90,.45), transparent); }
.divider-center { font-size: 11.5px; color: var(--muted); letter-spacing: .08em; text-align: center; min-width: 200px; }

.slot {
  position: relative; width: var(--card-w); height: calc(var(--card-w) * 1.4);
  border-radius: 6px; border: 1px dashed rgba(216,180,90,.28);
  background: linear-gradient(180deg, rgba(56, 34, 86, .35), rgba(24, 14, 40, .5));
  box-shadow: inset 0 0 18px rgba(0,0,0,.55);
  display: grid; place-items: center;
}
.slot.filled { border-style: solid; border-color: rgba(216,180,90,.55); padding: 0; background: #120a1e; }
.slot .slot-hint { font-size: 10px; color: rgba(216,180,90,.3); letter-spacing: .2em; }
.slot.targetable { border-color: #ffd479; box-shadow: 0 0 0 2px rgba(255, 212, 121, .35), 0 0 24px rgba(255, 212, 121, .35); cursor: pointer; }
.slot.attacker { border-color: #ff9a6a; box-shadow: 0 0 0 2px rgba(255,154,106,.3); }
.slot.selectable { cursor: pointer; }
.slot.selectable:hover { border-color: var(--gold-2); }

.card {
  position: relative; width: 100%; height: 100%; border-radius: 5px; overflow: hidden;
  background: #0c0714; border: 1px solid rgba(216,180,90,.6);
  box-shadow: 0 6px 18px rgba(0,0,0,.55);
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.def { filter: saturate(.9); }
.card.def img { transform: rotate(90deg) scale(.86); }
.card.facedown img { display: none; }
.card.facedown::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 44%, rgba(240, 220, 160, .16), transparent 44%),
    repeating-linear-gradient(45deg, #241436 0 8px, #1b0f2b 8px 16px);
  box-shadow: inset 0 0 0 2px rgba(216, 180, 90, .45);
}
.card.facedown::before {
  content: "遊"; position: absolute; inset: 0; display: grid; place-items: center;
  font-family: serif; font-size: 26px; color: rgba(240, 220, 160, .5); z-index: 1;
}
.card-badge {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; justify-content: space-between; gap: 4px; padding: 3px 5px;
  font-size: 10px; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, rgba(6, 3, 12, .55), rgba(6, 3, 12, .97) 45%);
  color: #ffe9ad;
}
.card-badge .lv { color: #a8d8ff; }
.card.faceup-spell::after, .card.faceup-trap::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(120, 170, 255, .35);
}
.card.faceup-trap::after { box-shadow: inset 0 0 0 1px rgba(255, 130, 120, .4); }
.card .boost { color: #8ef0b0; }

.hand-dock {
  margin-top: 8px; padding: 8px 12px 14px; border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, rgba(22, 13, 38, .92), rgba(10, 6, 18, .96));
  border: 1px solid var(--line); border-bottom: 0;
}
.hand-head { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--gold-dim); letter-spacing: .2em; padding: 0 2px 6px; }
.hand-head > span { margin-right: auto; }
.hand-head small { color: var(--muted); letter-spacing: .1em; }
.hand { display: flex; gap: 10px; justify-content: safe center; min-height: calc(var(--card-w) * 1.4); padding-top: 14px; overflow-x: auto; }
.hand .card { width: var(--card-w); height: calc(var(--card-w) * 1.4); flex: 0 0 auto; cursor: pointer; transition: transform .14s, box-shadow .14s; }
.hand .card:hover { transform: translateY(-7px) scale(1.03); box-shadow: 0 14px 30px rgba(0,0,0,.6), 0 0 0 1px rgba(255, 220, 140, .5); }
.hand .card.selected { transform: translateY(-16px) scale(1.05); box-shadow: 0 0 0 2px rgba(255, 220, 140, .8), 0 18px 36px rgba(0,0,0,.65); }
.hand .card.dim { opacity: .55; }

.action-bar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 12;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; align-items: center;
  max-width: min(760px, calc(100% - 20px)); padding: 10px 14px; border-radius: 10px;
  background: rgba(16, 9, 26, .96); border: 1px solid var(--gold); box-shadow: 0 10px 34px rgba(0,0,0,.6);
}
.action-bar .tip { font-size: 12px; color: var(--muted); margin-right: 4px; }

.turn-clock { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 10px; letter-spacing: .04em; }
.turn-clock.urgent { color: #ff7676; font-weight: 700; }

.pending-banner {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 66;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  max-width: min(560px, calc(100% - 24px)); padding: 12px 18px; border-radius: 12px;
  background: rgba(26, 15, 44, .97); border: 1px solid var(--gold); box-shadow: 0 14px 44px rgba(0,0,0,.65);
}
.pending-banner b { font-size: 14px; color: var(--gold-2); }
.pending-banner p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; text-align: center; }
.pending-banner .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
@media (max-width: 640px) { .pending-banner { top: 8px; padding: 10px 12px; } .pending-banner b { font-size: 13px; } }

.log-panel {
  position: fixed; top: 60px; right: 14px; width: 300px; max-height: 62vh; z-index: 12;
  display: flex; flex-direction: column; border-radius: 10px; overflow: hidden;
  background: rgba(12, 7, 20, .96); border: 1px solid var(--line);
}
.log-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid rgba(216,180,90,.2); font-size: 12px; color: var(--gold-2); }
.log-body { padding: 8px 10px; overflow: auto; font-size: 12px; line-height: 1.7; color: var(--muted); }
.log-body .lg { padding: 2px 0; border-bottom: 1px dashed rgba(216,180,90,.1); }
.log-body .lg b { color: var(--ink); }

.float-text {
  position: fixed; left: 50%; top: 38%; transform: translate(-50%, 0); z-index: 14; pointer-events: none;
  font-size: 34px; font-weight: 700; color: #ff9a6a; text-shadow: 0 0 26px rgba(255, 120, 70, .6);
  opacity: 0; transition: opacity .2s, transform .5s;
}
.float-text.show { opacity: 1; transform: translate(-50%, -26px); }

.result-overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(60, 30, 100, .35), rgba(4, 2, 8, .92));
  backdrop-filter: blur(3px);
}
.result-card {
  text-align: center; padding: 34px 40px; border-radius: 14px; max-width: 440px;
  background: var(--panel); border: 1px solid var(--gold);
  box-shadow: 0 0 0 1px rgba(255, 230, 160, .25), 0 24px 70px rgba(0,0,0,.7);
}
.result-card h2 {
  margin: 10px 0 8px; font-size: 40px; letter-spacing: .1em;
  background: linear-gradient(180deg, #fff7d8, #dfc06a 55%, #a4802c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result-card p { color: var(--muted); font-size: 13px; margin-bottom: 18px; }


/* ---------- 资产 / 商城 / 构筑 ---------- */
.wallet { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.wallet .coin { display: flex; align-items: baseline; gap: 8px; }
.wallet .coin i { font-style: normal; font-size: 10px; letter-spacing: .2em; color: var(--gold-dim); }
.wallet .coin b { font-size: 24px; color: var(--gold-2); font-variant-numeric: tabular-nums; text-shadow: 0 0 16px rgba(240, 210, 120, .35); }
.wallet-sub { font-size: 12px; color: var(--muted); }
.deck-item .deck-meta { display: flex; flex-direction: row; align-items: center; gap: 6px; margin-top: 4px; }
.deck-item .badge-out { font-size: 10px; color: #ffd479; border: 1px solid rgba(255,212,121,.45); border-radius: 999px; padding: 1px 6px; }
.deck-item .deck-tip { font-size: 11px; color: var(--muted); }

.shop-tabs { display: flex; gap: 6px; margin-left: auto; }
.tab { cursor: pointer; padding: 6px 14px; font-size: 12px; color: var(--muted); border-radius: 6px; background: rgba(40,24,62,.5); border: 1px solid rgba(216,180,90,.22); }
.tab.active { color: #2a1c06; background: linear-gradient(180deg, #fbe7a8, #d7b158); border-color: #f0d795; font-weight: 600; }
.shop-pane { margin: 12px 0 6px; }
.pack-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.pack-card {
  display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 10px;
  background: linear-gradient(160deg, rgba(58,36,92,.75), rgba(24,14,40,.85)); border: 1px solid rgba(216,180,90,.4);
}
.pack-art {
  width: 62px; height: 86px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 6px;
  font-family: serif; font-size: 26px; color: rgba(244,224,163,.85);
  background: radial-gradient(circle at 50% 40%, #3a2258, #1a0f2b 70%);
  box-shadow: inset 0 0 0 2px rgba(216,180,90,.55), 0 6px 18px rgba(0,0,0,.5);
}
.pack-art.gold { color: #2a1c06; background: radial-gradient(circle at 40% 30%, #ffe9a8, #c9a344 65%, #7a5c1c); }
.pack-info { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.pack-info b { font-size: 14px; white-space: nowrap; }
.pack-info small { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.price { color: var(--gold-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.pack-result { margin-top: 12px; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.result-head span { font-size: 12px; color: var(--muted); }
.result-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px;
  max-height: 40vh; overflow-y: auto; padding-right: 4px;
}
.result-item { position: relative; border-radius: 6px; overflow: hidden; border: 1px solid rgba(216,180,90,.5); }
.result-item img { width: 100%; display: block; }
.result-item .r { position: absolute; top: 3px; left: 3px; font-size: 9px; padding: 0 5px; border-radius: 999px; font-weight: 700; }
.r.N { background: #4b5563; color: #e5e7eb; }
.r.R { background: #2563eb; color: #eff6ff; }
.r.SR { background: #7c3aed; color: #f5f3ff; }
.r.UR { background: linear-gradient(90deg, #f59e0b, #fde68a); color: #422006; }

.shop-toolbar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.shop-toolbar input, .shop-toolbar select, #shop-search, #build-search, #build-name {
  padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--ink);
  background: rgba(10,6,18,.9); border: 1px solid rgba(216,180,90,.3);
}
.shop-toolbar input { flex: 1; min-width: 180px; }
.shop-grid-item { position: relative; }
.shop-grid-item .own-line {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between;
  padding: 3px 6px; font-size: 10.5px; background: linear-gradient(180deg, rgba(6,3,12,.2), rgba(6,3,12,.94));
}
.shop-grid-item .rar {
  position: absolute; top: 4px; left: 4px; font-size: 10px; padding: 1px 5px; border-radius: 999px; font-weight: 700;
}

.modal-box.wide.build-box { width: min(1000px, calc(100% - 24px)); }
.build-cols { align-content: start; display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; margin-top: 8px; }
.build-col { min-width: 0; }
.build-col-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.build-col-head b { font-size: 13px; color: var(--gold-2); letter-spacing: .1em; }
.build-col-head input { flex: 1; }
.build-grid { max-height: 54vh; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.build-grid .catalog-item { position: relative; }
.catalog-item .qty {
  position: absolute; right: 3px; bottom: 3px; z-index: 2; font-size: 10px; padding: 1px 5px; border-radius: 4px;
  background: rgba(6,3,12,.9); border: 1px solid rgba(216,180,90,.5); color: var(--gold-2);
}
.catalog-item .qty { position: absolute; right: 3px; bottom: 3px; z-index: 2; font-size: 10px; padding: 1px 5px; border-radius: 4px;
  background: rgba(6,3,12,.92); border: 1px solid rgba(216,180,90,.45); color: var(--gold-2); }
.build-grid .catalog-item.exhausted { opacity: .4; }

/* ---------- 弹窗 ---------- */
.card-modal, .auth-modal, .modal {
  position: fixed; inset: 0; z-index: 24; display: grid; place-items: center;
  background: rgba(4, 2, 8, .82); backdrop-filter: blur(2px);
}
.card-modal-inner {
  display: flex; gap: 20px; padding: 20px; border-radius: 12px; max-width: 720px; width: calc(100% - 40px);
  background: var(--panel); border: 1px solid var(--gold);
}
.card-modal-inner img { width: 300px; border-radius: 8px; border: 1px solid rgba(216,180,90,.6); }
.card-modal-side { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.card-modal-side h3 { margin: 0; font-size: 20px; color: var(--gold-2); }
.card-modal-side p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; white-space: pre-wrap; }
.card-stats { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.card-stats span { padding: 4px 9px; border-radius: 5px; border: 1px solid rgba(216,180,90,.3); color: var(--gold-2); }

.auth-box, .modal-box {
  display: flex; flex-direction: column; gap: 10px; padding: 26px 26px 20px; border-radius: 12px; width: min(420px, calc(100% - 32px));
  background: var(--panel); border: 1px solid var(--gold);
  box-shadow: 0 0 0 1px rgba(255,230,160,.2), 0 24px 60px rgba(0,0,0,.7);
}
.modal-box.wide { width: min(640px, calc(100% - 32px)); }
.auth-box h2, .modal-box h2 { margin: 2px 0 6px; font-size: 20px; color: var(--gold-2); }
.auth-box label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.auth-box input, .modal-box input {
  padding: 10px 12px; border-radius: 6px; font-size: 14px; color: var(--ink);
  background: rgba(10, 6, 18, .9); border: 1px solid rgba(216,180,90,.3);
}
.error { color: #ff9d8f; font-size: 12px; min-height: 16px; margin: 0; }
.diff-list { display: flex; flex-direction: column; gap: 8px; }
.diff-item {
  text-align: left; cursor: pointer; padding: 12px 14px; border-radius: 8px;
  background: rgba(40, 24, 62, .55); border: 1px solid rgba(216,180,90,.22); color: var(--ink);
}
.diff-item:hover { border-color: var(--gold); background: rgba(60, 36, 92, .7); }
.diff-item b { display: block; font-size: 14px; }
.diff-item small { color: var(--muted); font-size: 12px; }
.catalog-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.catalog-head h2 { margin: 0; }
.catalog-grid {
  align-content: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px;
  max-height: 62vh; overflow: auto; padding: 4px 4px 4px 0; margin: 6px 0 10px;
}
.catalog-grid::-webkit-scrollbar { width: 9px; }
.catalog-grid::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #6d5427, #3c2c14); border-radius: 5px; border: 1px solid rgba(216,180,90,.35); }
.catalog-grid::-webkit-scrollbar-track { background: rgba(255, 255, 255, .03); border-radius: 5px; }
.catalog-item {
  position: relative;
  width: 100%; border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 1px solid rgba(216,180,90,.45); background: #120a1e; transition: transform .14s, box-shadow .14s;
}
.catalog-item:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.55), 0 0 0 1px rgba(255,220,140,.5); }
.catalog-item img { width: 100%; height: auto; aspect-ratio: 5 / 7; object-fit: cover; display: block; }
.rules-list { margin: 4px 0 8px; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.rules-list li::marker { color: var(--gold); }

@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: 1fr; }
    .zone-row { gap: 6px; }
  .card-modal-inner { flex-direction: column; align-items: center; }
  .card-modal-inner img { width: 220px; }
  .log-panel { width: calc(100% - 28px); }
}

/* ============ 决斗演出：冲击 / 破坏 / 召唤 / 受伤 ============ */
#fx-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.fx-ring { position: fixed; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; border: 3px solid var(--fx, #ffc861); box-shadow: 0 0 22px var(--fx, #ffc861), inset 0 0 22px var(--fx, #ffc861); animation: fx-ring .58s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes fx-ring { 0% { transform: scale(.25); opacity: 1; } 100% { transform: scale(3.8); opacity: 0; } }
.fx-spark { position: fixed; width: 9px; height: 9px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--fx, #fff); box-shadow: 0 0 12px var(--fx, #fff); animation: fx-spark .66s cubic-bezier(.15,.7,.3,1) forwards; }
@keyframes fx-spark { 0% { transform: translate(0, 0) scale(.35); opacity: 1; } 100% { transform: translate(var(--dx, 0), var(--dy, 0)) scale(1.2); opacity: 0; } }
.fx-shake { animation: fx-shake .38s ease-in-out; }
@keyframes fx-shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-9px,4px); } 40% { transform: translate(8px,-5px); } 60% { transform: translate(-6px,-3px); } 80% { transform: translate(5px,4px); } }
.fx-flash { position: fixed; border-radius: 6px; background: radial-gradient(circle, #fff 0 22%, #ffd793 45%, transparent 70%); box-shadow: 0 0 40px #ffdf9c; animation: fx-flash .6s ease-out forwards; }
@keyframes fx-flash { 0% { opacity: 0; transform: scale(.7); } 18% { opacity: 1; } 100% { opacity: 0; transform: scale(1.35); } }
.fx-shard { position: fixed; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--fx, #ffc861); clip-path: polygon(50% 0, 100% 62%, 62% 100%, 0 58%); box-shadow: 0 0 12px var(--fx, #ffc861); animation: fx-shard 1s ease-out forwards; }
@keyframes fx-shard { 0% { transform: scale(.5) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx, 0), calc(var(--dy, 0) + 40px)) scale(.9) rotate(220deg); opacity: 0; } }
.fx-beam { position: fixed; border-radius: 6px; background: linear-gradient(0deg, #ffe7a8ee, #fff9dc99 45%, transparent 88%); box-shadow: 0 0 30px #ffe2a0, 0 0 60px #ffcf6b88; animation: fx-beam .9s cubic-bezier(.2,.8,.3,1) forwards; }
@keyframes fx-beam { 0% { opacity: 0; transform: scaleY(.2); transform-origin: bottom; } 25% { opacity: 1; transform: scaleY(1.25); } 100% { opacity: 0; transform: scaleY(1.6); transform-origin: bottom; } }
.fx-aura { position: fixed; border-radius: 10px; border: 2px solid var(--fx, #c48bff); box-shadow: 0 0 24px var(--fx, #c48bff), inset 0 0 24px #ffffff55; animation: fx-aura .9s ease-out forwards; }
@keyframes fx-aura { 0% { opacity: 0; transform: scale(.85); } 30% { opacity: 1; transform: scale(1.02); } 100% { opacity: 0; transform: scale(1.12); } }
.fx-shield { position: fixed; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%; border: 3px solid #9de0ff; background: radial-gradient(circle, #bfeaff44 0 40%, transparent 72%); box-shadow: 0 0 26px #7fd0ff, inset 0 0 22px #cdefff; animation: fx-shield .72s ease-out forwards; }
@keyframes fx-shield { 0% { opacity: 0; transform: scale(.5) rotate(-12deg); } 30% { opacity: 1; transform: scale(1.06); } 100% { opacity: 0; transform: scale(1.2) rotate(8deg); } }
.fx-text { position: fixed; transform: translate(-50%, -50%); padding: 4px 9px; border-radius: 8px; font-size: 22px; font-weight: 900; letter-spacing: .5px; color: #fff; text-shadow: 0 2px 0 #0009, 0 0 12px #0008; animation: fx-text 1s ease-out forwards; }
.fx-damage-text { background: #a8231ce8; border: 2px solid #ff9a7a; }
.fx-effect-text { background: #5d2a96e8; border: 2px solid #d8a6ff; color: #f0dcff; }
.fx-block-text { background: #145a6ee8; border: 2px solid #a9ecff; font-size: 18px; }
.fx-summon-text { background: #8a6a1ce8; border: 2px solid #ffe6a1; color: #fff6d8; font-size: 15px; }
@keyframes fx-text { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.12); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -155%) scale(.95); } }
.fx-lunge-up { animation: fx-lunge-up .7s ease-in-out; }
.fx-lunge-down { animation: fx-lunge-down .7s ease-in-out; }
@keyframes fx-lunge-up { 0%,100% { transform: translateY(0); } 28%,52% { transform: translateY(-20px) scale(1.05); filter: brightness(1.25); } }
@keyframes fx-lunge-down { 0%,100% { transform: translateY(0); } 28%,52% { transform: translateY(20px) scale(1.05); filter: brightness(1.25); } }
.fx-boom { animation: fx-boom .62s linear; }
@keyframes fx-boom { 0%,100% { filter: none; } 18%,44% { filter: brightness(4) saturate(0); transform: scale(1.06); } 30%,58% { filter: brightness(.5); transform: scale(.94); } }
.lp.fx-lp-hit { animation: fx-lp-hit .7s ease-out; }
@keyframes fx-lp-hit { 0%,100% { filter: none; transform: none; } 20% { filter: brightness(1.6) saturate(1.8); transform: translateX(-6px) scale(1.03); } 45% { filter: brightness(.8); transform: translateX(5px); } 70% { transform: translateX(-3px); } }
.lp.fx-lp-shock { animation: fx-lp-shock .7s ease-out; }
@keyframes fx-lp-shock { 0%,100% { filter: none; } 25% { filter: hue-rotate(-25deg) saturate(2.2) brightness(1.35); box-shadow: 0 0 26px #c07bff; } 60% { filter: none; box-shadow: 0 0 12px #c07bff88; } }
@media (prefers-reduced-motion: reduce) {
  .fx-ring,.fx-spark,.fx-shake,.fx-flash,.fx-shard,.fx-beam,.fx-aura,.fx-shield,.fx-text,.fx-lunge-up,.fx-lunge-down,.fx-boom,.lp.fx-lp-hit,.lp.fx-lp-shock { animation-duration: .02s !important; animation-iteration-count: 1 !important; }
}

/* 提示条：之前只在 JS 里建了节点，样式缺失导致服务端拒绝原因看不见 */
#toast, .toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 18px); z-index: 90; max-width: min(560px, 88vw); padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 700; letter-spacing: .4px; text-align: center; color: #ffe9a8; background: #2a1640f2; border: 1px solid #d8b45a88; box-shadow: 0 12px 30px #0009; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
#toast.show, .toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err, .toast.err { color: #ffdfd6; background: #4a1524f2; border-color: #ff8a6a; }
.fx-position-text { background: #6a5417e8; border: 2px solid #ffe9a8; color: #fff8dc; font-size: 15px; }

/* ---------- 商城：系列卡包 / 整套卡组 ---------- */
.pack-sets, .deck-sets { align-content: start; display: grid; gap: 10px; max-height: 60vh; overflow: auto; padding: 2px 2px 8px; }
.pack-set, .deck-set {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 10px;
  background: linear-gradient(160deg, rgba(58,36,92,.72), rgba(20,12,34,.88));
  border: 1px solid rgba(216,180,90,.35);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.pack-set:hover, .deck-set:hover { border-color: rgba(216,180,90,.75); transform: translateY(-1px); box-shadow: 0 8px 22px rgba(0,0,0,.45); }
.pack-set-art, .deck-set-art {
  position: relative; width: 62px; height: 86px; flex: 0 0 auto; border-radius: 6px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #3a2258, #1a0f2b 70%);
  box-shadow: inset 0 0 0 2px rgba(216,180,90,.5), 0 6px 18px rgba(0,0,0,.5);
}
.pack-set-art img, .deck-set-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pack-set-no {
  position: absolute; left: 4px; bottom: 4px; font-size: 10px; padding: 1px 5px; border-radius: 4px;
  background: rgba(10,6,18,.78); color: #f4e0a3; letter-spacing: .5px;
}
.pack-set-body, .deck-set-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pack-set-name, .deck-set-name { font-size: 14px; font-weight: 700; color: #f6ead0; }
.pack-set-tag, .deck-set-tag { display: inline-block; font-size: 11px; color: #ffd98a; opacity: .9; }
.pack-set-desc, .deck-set-desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.pack-set-body .muted, .deck-set-body .muted { font-size: 11px; color: #9c8fb8; font-variant-numeric: tabular-nums; }
.pack-set-actions, .deck-set-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.deck-set-actions .deck-owned {
  font-size: 11.5px; color: #8fe0a8; border: 1px solid rgba(143,224,168,.4); border-radius: 6px; padding: 4px 10px;
  background: rgba(20,60,36,.35);
}
@media (max-width: 640px) {
  .pack-set, .deck-set { flex-wrap: wrap; }
  .pack-set-actions, .deck-set-actions { flex-direction: row; width: 100%; }
  .pack-set-art, .deck-set-art { width: 50px; height: 70px; }
}

/* ---------- 判定/硬币提示横幅 ---------- */
#judge-banner{
  position:fixed; left:50%; top:86px; z-index:60; pointer-events:none;
  display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:10px 24px; border-radius:12px; min-width:200px; text-align:center;
  transform:translate(-50%,-16px) scale(.96); opacity:0;
  transition:opacity .22s ease, transform .22s ease;
  backdrop-filter:blur(6px);
}
#judge-banner.show{opacity:1; transform:translate(-50%,0) scale(1)}
#judge-banner.good{
  border:1px solid rgba(216,180,90,.9);
  background:linear-gradient(165deg,rgba(66,48,20,.95),rgba(26,18,10,.96));
  box-shadow:0 0 24px rgba(216,180,90,.35),0 10px 26px rgba(0,0,0,.5);
}
#judge-banner.bad{
  border:1px solid rgba(224,92,92,.9);
  background:linear-gradient(165deg,rgba(58,20,26,.95),rgba(26,10,14,.96));
  box-shadow:0 0 24px rgba(224,92,92,.32),0 10px 26px rgba(0,0,0,.5);
}
.judge-title{font-size:15px;font-weight:700;letter-spacing:.04em;color:#f6e3af}
#judge-banner.bad .judge-title{color:#ffc0c0}
.judge-text{font-size:12px;color:rgba(240,228,204,.85)}
#judge-banner.bad .judge-text{color:rgba(255,210,210,.85)}
.judge-line{display:inline-block;padding:1px 6px;border-radius:5px}
.judge-line.good{color:#f0d79a;background:rgba(120,88,30,.25)}
.judge-line.bad{color:#f2a8a8;background:rgba(120,40,40,.25)}

/* ---------- B 档：额外卡组与素材选择 ---------- */
.extra-dock{display:flex;align-items:center;gap:8px;margin-left:auto;margin-right:10px;padding:3px 10px;
  border:1px solid #4a3a72;border-radius:8px;background:#1a1230;max-width:46vw}
.extra-label{font-size:11px;color:#c9b6ff;letter-spacing:.5px}
.extra-list{display:flex;gap:4px;overflow-x:auto;padding-bottom:2px}
.extra-card img{width:30px;height:43px;object-fit:cover;border-radius:3px;cursor:pointer;
  border:1px solid #5b4588;transition:transform .15s ease}
.extra-card img:hover{transform:translateY(-2px);border-color:#ffd479}
#extra-count{font-size:11px;color:#8f7fb8}
.card.pickable{outline:2px dashed #8d7bff;outline-offset:-2px;cursor:pointer}
.card.pickable:hover{outline-color:#b8a9ff}
.card.matsel{outline:2px solid #ffd479;outline-offset:-2px;box-shadow:0 0 12px rgba(255,212,121,.55)}
.mon-slot.pickable{outline:2px dashed #8d7bff}
.mon-slot.matsel{outline:2px solid #ffd479}
#card-modal-desc{white-space:pre-line}

/* 卡牌详情浮层永远压在其他弹层之上（卡组/图鉴/编辑器里点卡都能看到） */
#card-modal { z-index: 70; }
.deck-set-actions .deck-locked { font-size: 12px; color: #a99bd0; padding: 5px 10px; border: 1px dashed #6a5a92; border-radius: 6px; }
.action-note { flex: 1 1 100%; order: -1; margin: 0 0 2px; font-size: 12px; line-height: 1.7; color: #c9b6ff; background: rgba(60, 40, 100, .55); border: 1px solid rgba(150, 120, 210, .5); border-radius: 8px; padding: 8px 12px; }

/* 手机上把操作条抬到手牌上方，避免被手牌/浏览器底栏压住 */
@media (max-width: 640px) {
  .action-bar { bottom: calc(118px + env(safe-area-inset-bottom)); z-index: 30; padding: 8px 10px; gap: 6px; }
  .action-bar button { min-height: 40px; }
}

/* ---------- 统一滚动条：暗底金边细条，去掉系统白条与箭头 ---------- */
/* 仅用 webkit 伪元素，避免 Chrome 回落到带箭头的原生滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.045); border-radius: 999px; margin: 3px; }
::-webkit-scrollbar-thumb {
  border-radius: 999px; border: 1px solid rgba(0,0,0,.35);
  background: linear-gradient(180deg, rgba(232,198,112,.85), rgba(148,110,44,.85));
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, rgba(250,224,152,.95), rgba(188,144,62,.9)); }
:-webkit-scrollbar-button,
::-webkit-scrollbar-button:single-button,
::-webkit-scrollbar-button:single-button:vertical:decrement,
::-webkit-scrollbar-button:single-button:vertical:increment,
::-webkit-scrollbar-button:single-button:horizontal:decrement,
::-webkit-scrollbar-button:single-button:horizontal:increment { display: none !important; width: 0 !important; height: 0 !important; background: transparent !important; }
::-webkit-scrollbar-corner { background: transparent; }

/* ============================================================
   响应式：手机 / 平板 / 桌面
   1) 场地 5 列按视口自动缩放，永不横向溢出
   2) 弹窗在小屏全屏、内部可滚动
   3) 触控目标 ≥ 40px
   ============================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:root {
  --card-w: clamp(46px, calc((100vw - 60px) / 5), 96px);
  --hand-w: max(var(--card-w), 66px);
  --page-pad: clamp(10px, 2.2vw, 22px);
}
.duel { min-height: 100dvh; }
body { min-height: 100dvh; }

/* ---- 平板 / 窄桌面 ---- */
@media (max-width: 900px) {
  .lobby { padding: 18px var(--page-pad) 30px; }
  .panel-hero { padding: 24px 20px; }
  .duel { padding: 8px 10px 0; }
  .board { padding: 10px; }
  .card-modal-inner { width: calc(100% - 24px); padding: 16px; gap: 14px; }
  .modal-box, .auth-box { width: calc(100% - 24px); }
  .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .log-panel { width: calc(100% - 20px); max-height: 56dvh; }
}

/* ---- 手机 ---- */
@media (max-width: 640px) {
  /* 大厅 */
  .lobby { padding: 12px 12px 26px; }
  .logo-row { flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
  .logo-mark { width: 38px; height: 38px; font-size: 19px; }
  .logo b { font-size: 13px; letter-spacing: .2em; }
  .logo small { font-size: 11px; }
  .account-box { font-size: 12px; flex-wrap: wrap; gap: 6px; }
  .panel-hero { padding: 20px 14px; border-radius: 12px; }
  .panel-hero::after { inset: 5px; }
  .panel-hero h1 { font-size: clamp(26px, 8vw, 38px); margin: 8px 0; }
  .panel-hero .sub { font-size: 12.5px; line-height: 1.8; }
  .hero-actions { gap: 8px; margin: 16px 0 12px; }
  .hero-actions .btn { flex: 1 1 100%; min-height: 44px; }
  .join-row { flex-wrap: wrap; }
  .join-row input { flex: 1 1 120px; width: auto; min-width: 0; min-height: 40px; }
  .join-row .btn { min-height: 40px; padding: 8px 16px; }
  .panel { padding: 14px; border-radius: 10px; }
  .panel h3 { font-size: 13px; margin-bottom: 10px; }
  .panel-side { gap: 12px; }
  .wallet .coin b { font-size: 21px; }
  .row-actions .btn { min-height: 40px; }
  .record-list { max-height: 40dvh; }
  .foot { font-size: 11px; margin-top: 18px; }

  /* 对局 */
  .duel { padding: 6px 6px 0; }
  .board { padding: 8px 6px; gap: 5px; border-radius: 10px; }
  .card-badge { font-size: 9px; padding: 2px 3px; gap: 2px; }
  .card-badge i { display: none; }
  .hand .card .card-badge { font-size: 8.5px; letter-spacing: -.2px; }
  .zone-row { gap: 4px; }
  .duel-top { flex-wrap: wrap; gap: 6px; padding: 2px 2px 6px; }
  .room-chip { font-size: 11px; gap: 6px; }
  .room-chip span { font-size: 13px; letter-spacing: .16em; }
  .duel-status { order: 3; width: 100%; text-align: left; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
  .duel-status b { font-size: 13px; letter-spacing: .1em; }
  .duel-status span { font-size: 11px; }
  .turn-clock { margin-left: 0; }
  .duel-tools { margin-left: auto; gap: 4px; }
  .icon-btn { width: 34px; height: 32px; font-size: 12px; }
  .lpbar { gap: 8px; padding: 2px 4px; }
  .lp b { font-size: 21px; }
  .who span { font-size: 12px; }
  .who small { font-size: 10px; }
  .normal-flag { font-size: 10px; padding: 3px 8px; }
  .divider { padding: 2px 4px; gap: 8px; }
  .divider-center { font-size: 11px; min-width: 0; }
  .hand-dock { padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); border-radius: 10px 10px 0 0; }
  .hand-head { font-size: 10px; letter-spacing: .12em; padding-bottom: 4px; gap: 8px; }
  .hand-head .btn.small { min-height: 34px; padding: 6px 10px; }
  .extra-dock { max-width: 52vw; }
  .hand { gap: 6px; padding-top: 8px; }
  .hand .card {
    width: var(--hand-w); height: calc(var(--hand-w) * 1.4);
  }
  .hand .card:hover { transform: translateY(-3px); }
  .action-bar { max-width: calc(100% - 12px); padding: 8px 10px; gap: 6px; border-radius: 12px; }
  .action-bar button { flex: 1 1 0; min-width: 0; min-height: 40px; }
  .action-bar { left: 6px; right: 6px; transform: none; max-width: none; width: auto; }
  .action-note { font-size: 11.5px; padding: 7px 10px; }
  .log-panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); max-height: 54dvh; }
  .float-text { font-size: 26px; }
  .result-card { padding: 24px 18px; width: calc(100% - 32px); max-width: none; }
  .result-card h2 { font-size: 30px; }
  .pending-banner { top: 6px; }
  #judge-banner { top: 64px; padding: 8px 16px; }
  #toast { bottom: calc(18px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); }

  /* 弹窗类：小屏全屏面板，内容在内部滚动 */
  .modal { place-items: stretch; padding: 0; }
  .card-modal { place-items: center; padding: 8px; }
  .auth-modal { place-items: center; padding: 8px; }
  .modal-box { width: 100%; max-height: none; height: 100dvh; border-radius: 0; padding: 14px 12px calc(12px + env(safe-area-inset-bottom)); gap: 8px; overflow-y: auto; }
  .modal-box.wide, .modal-box.wide.build-box { width: 100%; max-width: none; }
  .card-modal-inner { width: 100%; height: auto; max-height: calc(100dvh - 16px); border-radius: 12px; overflow-y: auto; }
  .auth-box { width: calc(100% - 24px); max-height: none; }
  .auth-box { padding: 18px 16px 16px; }
  .auth-box input, .modal-box input, .shop-toolbar input, .shop-toolbar select, #shop-search, #build-search, #build-name { min-height: 44px; font-size: 15px; }
  .catalog-head { gap: 8px; }
  .catalog-head h2 { font-size: 17px; }
  .shop-tabs { margin-left: 0; width: 100%; }
  .shop-tabs .tab { flex: 1; text-align: center; padding: 8px 6px; min-height: 38px; }
  .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 7px; max-height: 54dvh; }
  .pack-sets, .deck-sets { max-height: 52dvh; }
  .pack-set, .deck-set { gap: 10px; padding: 10px; flex-wrap: wrap; }
  .pack-set-art, .deck-set-art { width: 46px; height: 64px; }
  .pack-set-name, .deck-set-name { font-size: 13px; }
  .pack-set-actions, .deck-set-actions { flex-direction: row; width: 100%; gap: 8px; }
  .pack-set-actions .btn, .deck-set-actions .btn, .pack-set-actions .deck-owned, .deck-set-actions .deck-locked { flex: 1; justify-content: center; text-align: center; min-height: 40px; }
  .shop-toolbar input { flex: 1 1 100%; min-width: 0; }
  .shop-toolbar select { flex: 1 1 calc(50% - 3px); }
  .build-cols { grid-template-columns: 1fr; gap: 10px; }
  .build-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); max-height: 30dvh; }
  .build-col-head { flex-wrap: wrap; gap: 6px; }
  .build-col-head input { flex: 1 1 100%; }
  .card-modal-inner { flex-direction: column; align-items: center; padding: 14px; gap: 10px; }
  .card-modal-inner img { width: min(62vw, 260px); }
  .card-modal-side { width: 100%; }
  .card-modal-side h3 { font-size: 17px; }
  .card-modal-side p { font-size: 12.5px; }
  .result-grid { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); max-height: 44dvh; }
  .rules-list { font-size: 12.5px; line-height: 1.8; padding-left: 16px; }
  /* 商城 / 图鉴 / 卡组详情：列表撑满剩余高度，底部不留大片空白 */
  #shop-modal .modal-box, #cards-modal .modal-box, #deck-modal .modal-box { overflow: hidden; }
  #shop-modal .pack-sets, #shop-modal .deck-sets { max-height: calc(100dvh - 210px); }
  #shop-modal .shop-pane .catalog-grid { max-height: calc(100dvh - 330px); }
  #cards-modal .modal-box > .catalog-grid, #deck-modal .modal-box > .catalog-grid { max-height: calc(100dvh - 160px); }
  #shop-modal .pack-result { flex: 0 0 auto; }
  /* 构筑：整体滚动，单列堆叠 */
  #build-modal .modal-box { overflow-y: auto; }
  #build-modal .build-cols { overflow: visible; }
  #build-modal .build-grid { max-height: none; }

  .row-actions { gap: 6px; }
  .row-actions .btn { flex: 1 1 auto; min-height: 40px; }
}

/* ---- 超窄屏 / 小手机 ---- */
@media (max-width: 380px) {
  .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .icon-btn { width: 30px; height: 30px; font-size: 11px; }
  .hero-actions .btn { font-size: 13px; }
  .card-modal-inner img { width: min(70vw, 220px); }
}

/* ---- 手机横屏（低高度）缩短纵向占用 ---- */
@media (max-height: 520px) and (orientation: landscape) {
  .duel { padding-top: 2px; }
  .board { gap: 2px; padding: 4px 6px; }
  .lp b { font-size: 18px; }
  .hand-dock { padding-bottom: 4px; }
  .hand { padding-top: 4px; }
  .hand .card { width: 54px; height: 76px; }
  .log-panel { max-height: 76dvh; }
}

/* ---- 触控设备去掉 hover 位移，避免误触 ---- */
@media (hover: none) {
  .deck-item:hover, .pack-set:hover, .deck-set:hover, .catalog-item:hover, .hand .card:hover { transform: none; }
  .btn:hover { transform: none; }
}

/* ---- 手机：卡池网格改用 flex，避免固定高度下 grid 自动行被压扁 ---- */
@media (max-width: 640px) {
  .catalog-grid { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 7px; }
  .catalog-grid > * { width: calc((100% - 21px) / 4); }
  .catalog-grid.build-grid > * { width: calc((100% - 28px) / 5); }
}
@media (max-width: 380px) {
  .catalog-grid > * { width: calc((100% - 14px) / 3); }
  .catalog-grid.build-grid > * { width: calc((100% - 21px) / 4); }
}

@media (max-width: 640px) {
  .shop-grid-item .own-line { font-size: 9.5px; padding: 2px 4px; letter-spacing: 0; }
  #build-modal .build-grid { max-height: 32dvh; }
}

/* ================= 大厅：卡组滑动条 / 数据条 / 每日一卡 ================= */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; }
.slider-nav { display: flex; gap: 4px; }
.mini-arrow {
  width: 26px; height: 24px; cursor: pointer; font-size: 14px; line-height: 1;
  color: var(--gold-2); background: rgba(30, 18, 48, .9); border: 1px solid var(--line); border-radius: 5px;
}
.mini-arrow:active { transform: scale(.96); }

.hero-extra { margin-top: 20px; padding-top: 16px; border-top: 1px dashed rgba(216,180,90,.22); display: flex; flex-direction: column; gap: 12px; }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat-chip { min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(216,180,90,.22); background: rgba(40, 24, 62, .45); }
.stat-chip i { display: block; font-style: normal; font-size: 10px; letter-spacing: .16em; color: var(--gold-dim); }
.stat-chip b { display: block; margin-top: 2px; font-size: 20px; color: var(--gold-2); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.stat-chip small { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collect-top { display: flex; align-items: baseline; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.collect-top b { color: var(--gold-2); font-variant-numeric: tabular-nums; }
.collect-bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.collect-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #8d6f33, #f4e0a3); }
.daily-tasks { border: 1px solid rgba(216,180,90,.28); border-radius: 10px; background: rgba(255,255,255,.03); padding: 10px 12px; }
.daily-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.daily-head span { font-size: 12.5px; letter-spacing: .14em; color: #f4e0a3; }
.daily-head b { font-size: 11.5px; color: rgba(255,255,255,.55); font-weight: 500; }
.daily-list { display: flex; flex-direction: column; gap: 8px; }
.daily-row { display: grid; grid-template-columns: 1fr 92px auto; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 8px; background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.05); }
.daily-row.ready { border-color: rgba(244,224,163,.5); background: rgba(244,224,163,.07); }
.daily-row.done { opacity: .62; }
.daily-info { min-width: 0; }
.daily-info b { display: block; font-size: 12.5px; color: #fff; font-weight: 600; }
.daily-info small { display: block; font-size: 11px; color: rgba(255,255,255,.45); margin-top: 2px; }
.daily-prog { height: 5px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.daily-prog span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg,#8d6f33,#f4e0a3); transition: width .3s; }
.daily-btn { padding: 5px 10px; border-radius: 7px; font-size: 11.5px; border: 1px solid rgba(216,180,90,.45); background: transparent; color: #f4e0a3; cursor: pointer; white-space: nowrap; }
.daily-btn.primary { background: linear-gradient(180deg,#f7e9b6,#d8b45a); color: #2a1f06; border-color: rgba(244,224,163,.9); font-weight: 600; }
.daily-btn:disabled { cursor: default; opacity: .7; color: rgba(255,255,255,.45); border-color: rgba(255,255,255,.18); }

.daily-card {
  display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(216,180,90,.3); background: linear-gradient(160deg, rgba(58,36,92,.55), rgba(20,12,34,.8));
  transition: border-color .15s, transform .15s;
}
.daily-card:hover { border-color: rgba(244,224,163,.7); transform: translateY(-1px); }
.daily-card img { width: 54px; height: 76px; object-fit: cover; border-radius: 5px; border: 1px solid rgba(216,180,90,.5); flex: 0 0 auto; }
.dc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dc-tag { font-size: 10px; letter-spacing: .12em; color: #ffd98a; }
.dc-body b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-body small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-go { font-size: 11.5px; color: var(--gold-dim); flex: 0 0 auto; }

/* 开包结果弹窗 */
.pack-result-box { width: min(920px, calc(100% - 32px)) !important; }
.pack-result-box .result-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); max-height: 56vh; }
.pack-result-box .result-grid .result-item { cursor: pointer; }
.pack-result-box .result-head { display: none; }

@media (max-width: 640px) {
  .hero-extra { margin-top: 14px; padding-top: 12px; gap: 10px; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-chip { padding: 8px 10px; }
  .stat-chip b { font-size: 17px; }
  .daily-tasks { padding: 9px 10px; }
  .daily-row { grid-template-columns: 1fr auto; row-gap: 6px; }
  .daily-prog { grid-column: 1 / 2; }
  .daily-card { padding: 8px 10px; gap: 10px; }
  .daily-card img { width: 44px; height: 62px; }
  .dc-go { display: none; }
  .deck-item { flex-basis: 164px; }
  .pack-result-box { width: 100% !important; height: 100dvh; display: flex; flex-direction: column; }
  .pack-result-box .result-grid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); flex: 1 1 auto; min-height: 0; max-height: none; }
}

/* 在线随机匹配 */
.btn.accent { background: linear-gradient(180deg, rgba(95,209,196,.95), rgba(38,132,124,.95)); border-color: rgba(140,240,227,.6); color: #05201d; font-weight: 700; box-shadow: 0 6px 18px rgba(40,180,165,.25); }
.btn.accent:hover { filter: brightness(1.08); }
.match-box { width: min(420px, calc(100% - 32px)); text-align: center; }
.match-wheel { position: relative; width: 92px; height: 92px; margin: 14px auto 10px; display: grid; place-items: center; }
.match-wheel i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(244,224,163,.28); }
.match-wheel i::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid transparent; border-top-color: #f4e0a3; border-right-color: rgba(244,224,163,.5); animation: matchSpin 1.1s linear infinite; }
.match-wheel span { font-size: 13px; letter-spacing: .18em; color: #f4e0a3; }
@keyframes matchSpin { to { transform: rotate(360deg); } }
.match-meta { font-size: 12.5px; color: rgba(255,255,255,.6); }
.match-tip { margin-top: 8px; font-size: 11.5px; color: rgba(255,255,255,.38); line-height: 1.6; }
.match-box .row-actions { justify-content: center; margin-top: 14px; }
