:root {
  --bg: #0b0e16;
  --panel: #131826;
  --panel-2: #192136;
  --panel-3: #222c46;
  --border: rgba(212, 175, 98, 0.25);
  --border-strong: rgba(228, 193, 122, 0.62);
  --gold: #e4c17a;
  --gold-dim: #9e834d;
  --text: #efe9dc;
  --muted: #a6a095;
  --chips: #38bdf8;
  --mult: #fb7185;
  --xmult: #f59e0b;
  --lu: #34d399;
  --quan: #f59e0b;
  --ke: #60a5fa;
  --ji: #f43f5e;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 18% 0%, #1d2542 0%, var(--bg) 56%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.48;
  overflow-x: clip;
  min-height: 100vh;
}

.app-shell {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 10px 14px 80px;
}
.main-stage { width: 100%; min-width: 0; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(19, 24, 38, 0.94);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-glyph {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(228, 193, 122, 0.16);
  border: 1px solid var(--border-strong);
  color: var(--gold); font-size: 18px; flex-shrink: 0;
}
.brand-title { font-size: 17px; font-weight: 800; color: #fff6e0; letter-spacing: 0.04em; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.topbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Buttons */
.btn {
  background: #1d253a;
  color: #eee6d5;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.14s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--gold); color: #fff; background: #26314c; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-gold {
  background: linear-gradient(135deg, #d8b162, #af8330);
  color: #141008;
  border-color: #f6dc9c;
  font-weight: 800;
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.08); color: #0e0a04; }
.btn-danger { background: rgba(244, 63, 94, 0.18); border-color: var(--ji); color: #ffc2cc; }
.btn-safe { background: rgba(56, 189, 248, 0.18); border-color: var(--chips); color: #bae6fd; }
.btn-ghost { background: rgba(255, 255, 255, 0.04); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-xs { padding: 2px 6px; font-size: 10.5px; border-radius: 6px; }
.btn-lg { padding: 11px 22px; font-size: 15px; border-radius: 11px; }
.btn.active {
  background: rgba(228, 193, 122, 0.24);
  border-color: var(--gold);
  color: #fff6de;
}

/* 30s Cheat Drawer */
.cheat-drawer {
  display: none;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 16px;
}
.cheat-drawer.open { display: block; }
.cheat-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; color: var(--gold); font-size: 14px;
}
.cheat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.cheat-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
}
.cheat-card p { margin: 4px 0 0; color: #d6cfc2; }
.cheat-title { font-weight: 700; color: var(--gold); }

/* Lobby */
.lobby-card {
  width: 100%;
  max-width: 980px;
  margin: 12px auto;
  background: linear-gradient(155deg, rgba(25, 32, 51, 0.96), rgba(13, 17, 28, 0.98));
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 22px;
}
.lobby-hero-banner {
  border: 1px solid rgba(228, 193, 122, 0.4);
  border-radius: 14px;
  padding: 18px 20px;
  background: radial-gradient(circle at 85% 20%, rgba(228, 193, 122, 0.16), rgba(12, 15, 23, 0.78));
  background-size: cover;
  background-position: center;
  margin-bottom: 16px;
}
.lobby-hero-banner h1 { margin: 0 0 6px; font-size: clamp(22px, 4vw, 32px); color: #fff6df; }
.lobby-hero-banner p { margin: 0; font-size: 13.5px; color: #dcd4c5; max-width: 760px; }
.lobby-section { margin-bottom: 16px; }
.lobby-label { font-size: 13px; color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.option-row { display: flex; flex-wrap: wrap; gap: 8px; }

.origins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 10px;
}
.origin-card {
  background: var(--panel-2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: 0.15s;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.origin-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.origin-card.active {
  border: 2px solid var(--gold);
  background: linear-gradient(155deg, rgba(228, 193, 122, 0.16), rgba(25, 33, 54, 0.96));
  box-shadow: 0 0 18px rgba(228, 193, 122, 0.22);
}
.oc-title { font-size: 15px; font-weight: 800; color: #fff6de; }
.oc-arch { font-size: 11.5px; color: var(--gold); font-weight: 700; }
.oc-stars { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.oc-desc { font-size: 12px; color: #d6cfc2; line-height: 1.45; }
.oc-stats { font-size: 11px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; }

/* Balatro Top HUD */
.hud-bar {
  background: linear-gradient(135deg, rgba(22, 29, 48, 0.96), rgba(14, 18, 30, 0.98));
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(260px, 1.3fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: center;
}
.hud-stage-tag {
  display: inline-block; font-size: 11px; font-weight: 800;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(228, 193, 122, 0.16); color: var(--gold); border: 1px solid var(--border);
}
.hud-stage-tag.is-boss {
  background: rgba(244, 63, 94, 0.2); color: #fda4af; border-color: var(--ji);
}
.hud-stage-title { font-size: 16px; font-weight: 800; color: #fff6de; margin: 4px 0; }
.boss-rule-box {
  font-size: 11.5px; color: #fecdd3;
  background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: 8px; padding: 5px 8px; margin-top: 4px;
}
.boss-rule-box strong { color: #fff; }

.hud-score-center { text-align: center; }
.score-progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: #ded6c6; margin-bottom: 4px;
}
.score-progress-head strong { font-size: 17px; color: var(--gold); }
.progress-track {
  height: 10px; border-radius: 999px; background: #0c101c;
  border: 1px solid var(--border); overflow: hidden; margin-bottom: 8px;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #e4c17a, #f59e0b);
  transition: width 0.35s ease;
}
.formula-bar {
  display: flex; align-items: center; justify-content: center; gap: 7px; flex-wrap: wrap;
}
.f-pill {
  padding: 4px 11px; border-radius: 9px; font-weight: 900; font-size: 18px;
  min-width: 72px; text-align: center; transition: transform 0.16s ease;
}
.f-pill.pop { transform: scale(1.12); }
.f-chips { background: rgba(56, 189, 248, 0.16); border: 1.5px solid var(--chips); color: #bae6fd; }
.f-mult { background: rgba(251, 113, 133, 0.18); border: 1.5px solid var(--mult); color: #fecdd3; }
.f-total {
  background: linear-gradient(135deg, rgba(228,193,122,0.28), rgba(245,158,11,0.22));
  border: 1.5px solid var(--gold); color: #fff7dd; min-width: 102px;
}
.f-op { font-weight: 900; color: var(--gold); font-size: 16px; }
.f-label { font-size: 10px; color: var(--muted); display: block; line-height: 1.1; }

.hud-resources {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
}
.res-pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.res-pill {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--border); color: #f1eadc;
}
.res-pill.hp { border-color: rgba(244, 63, 94, 0.45); color: #fecdd3; }
.res-pill.coin { border-color: rgba(228, 193, 122, 0.5); color: #fde68a; }
.res-pill.trig { border-color: rgba(56, 189, 248, 0.45); color: #bae6fd; }
.stem-strip { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; align-items: center; font-size: 11px; }

/* Main Game Layout */
.game-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1.32fr) minmax(320px, 1fr);
  gap: 12px;
  align-items: start;
}

/* 4x4 Board */
.board-wrap {
  position: relative;
  background: #0d121f;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 10px;
  min-width: 0;
}
.board-banner {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
  font-size: 12px; color: #dfd7c7;
}
.board-area { position: relative; }
.board-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(104px, auto));
  gap: 6px;
  position: relative;
  z-index: 2;
}
svg.board-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.palace {
  background: rgba(22, 29, 46, 0.94);
  border: 1px solid rgba(212, 175, 98, 0.22);
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: 0.14s;
  min-width: 0;
  position: relative;
}
.palace:hover { border-color: var(--gold); }
.palace.is-selected {
  border: 2px solid var(--gold);
  background: rgba(228, 193, 122, 0.16);
  box-shadow: 0 0 14px rgba(228, 193, 122, 0.28);
}
.palace.is-trine {
  border: 1.5px solid rgba(228, 193, 122, 0.72);
  background: rgba(228, 193, 122, 0.08);
}
.palace.is-opposite {
  border: 1.5px dashed #fb7185;
  background: rgba(244, 63, 94, 0.08);
}
.palace.is-flashed {
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.72);
  border-color: var(--chips);
}
.palace.is-blocked {
  opacity: 0.62;
  background: rgba(45, 16, 24, 0.65);
  border-color: rgba(244, 63, 94, 0.55);
}
.palace.hint-miao {
  box-shadow: inset 0 0 0 2px rgba(52, 211, 153, 0.9);
  background: rgba(52, 211, 153, 0.1);
}
.palace.hint-xian {
  box-shadow: inset 0 0 0 2px rgba(244, 63, 94, 0.75);
}
.p-head { display: flex; justify-content: space-between; align-items: center; gap: 2px; }
.p-name { font-size: 12px; font-weight: 800; color: #fff4d6; white-space: nowrap; }
.p-badges { display: flex; gap: 2px; align-items: center; font-size: 9.5px; flex-wrap: wrap; justify-content: flex-end; }
.p-stars { display: flex; flex-direction: column; gap: 3px; margin: 3px 0; min-height: 22px; }
.star-pill {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 11px; font-weight: 700; color: #fff;
  min-width: 0;
}
.star-pill.is-gold {
  border-color: var(--gold);
  background: rgba(228, 193, 122, 0.16);
}
.star-pill.is-pickable:hover {
  border-color: var(--chips);
  background: rgba(56, 189, 248, 0.16);
}
.star-pill-main { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; min-width: 0; flex: 1; }
.star-pill-main > span:first-child { white-space: nowrap; flex-shrink: 0; }

.aux-row { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.aux-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 4px; border-radius: 5px;
  font-size: 10px; font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.aux-pill.ji { background: rgba(52, 211, 153, 0.14); border-color: rgba(52, 211, 153, 0.45); color: #a7f3d0; }
.aux-pill.sha { background: rgba(244, 63, 94, 0.16); border-color: rgba(244, 63, 94, 0.5); color: #fecdd3; }

.star-art-slot, .aux-art-slot { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.star-art-slot.is-gold-star .star-art-img { border: 2px solid #fde047; box-shadow: 0 0 8px rgba(253, 224, 71, 0.55); }
.star-art-img { width: 100%; height: 100%; object-fit: cover; object-position: center 14%; border-radius: 50%; border: 1.5px solid var(--gold); }
.aux-art-img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid var(--gold); }

.empty-hint { font-size: 9.5px; color: #7e879b; border: 1px dashed rgba(126, 135, 155, 0.35); border-radius: 6px; padding: 2px 4px; text-align: center; }
.empty-hint.can-borrow { color: #bae6fd; border-color: rgba(56, 189, 248, 0.45); background: rgba(56, 189, 248, 0.08); }
.p-foot { font-size: 9.5px; color: var(--gold-dim); display: flex; justify-content: space-between; align-items: center; gap: 3px; }

/* Tags */
.sihua-tag {
  display: inline-block; font-size: 9px; font-weight: 800; padding: 0 4px; border-radius: 4px; line-height: 1.45;
}
.sh-lu { background: rgba(52, 211, 153, 0.22); color: var(--lu); border: 1px solid var(--lu); }
.sh-quan { background: rgba(245, 158, 11, 0.22); color: var(--quan); border: 1px solid var(--quan); }
.sh-ke { background: rgba(96, 165, 250, 0.22); color: var(--ke); border: 1px solid var(--ke); }
.sh-ji { background: rgba(244, 63, 94, 0.26); color: #ff8ca0; border: 1px solid var(--ji); }
.tag-miao { font-size: 9px; color: var(--lu); font-weight: 700; }
.tag-xian { font-size: 9px; color: var(--ji); font-weight: 700; }
.mini-badge {
  font-size: 9px; padding: 0 4px; border-radius: 4px; font-weight: 700;
  background: rgba(228, 193, 122, 0.2); color: var(--gold); border: 1px solid var(--border);
}
.mini-badge.danger { background: rgba(244, 63, 94, 0.22); color: #fda4af; border-color: var(--ji); }

/* Center Court */
.center-court {
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  background: radial-gradient(circle at center, rgba(33, 42, 68, 0.92), rgba(12, 16, 28, 0.96));
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 6px;
  min-width: 0;
}
.cc-palace { font-size: 13px; font-weight: 800; color: var(--gold); }
.cc-pattern {
  font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px;
  background: rgba(228, 193, 122, 0.18); border: 1px solid var(--gold); color: #fff6dc;
}
.cc-preview { font-size: 13px; font-weight: 800; color: #e2e8f0; }
.cc-preview .c { color: var(--chips); }
.cc-preview .m { color: var(--mult); }
.cc-preview .t { color: var(--gold); font-size: 15px; }
.cc-block { font-size: 11px; color: #fda4af; line-height: 1.35; }

/* Right Side Console */
.side-stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.panel-box h3 {
  margin: 0 0 8px; font-size: 14.5px; color: var(--gold);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
}

.chain-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 290px; overflow-y: auto;
}
.chain-step {
  background: rgba(25, 33, 54, 0.9); border: 1px solid rgba(228, 193, 122, 0.18);
  border-radius: 8px; padding: 6px 10px; font-size: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  animation: popIn 0.18s ease-out;
}
.chain-step.is-xmult { border-color: rgba(245, 158, 11, 0.55); background: rgba(245, 158, 11, 0.08); }
.chain-step.is-retrigger { border-color: rgba(56, 189, 248, 0.55); background: rgba(56, 189, 248, 0.08); }
.chain-step.is-penalty { border-color: rgba(244, 63, 94, 0.5); background: rgba(244, 63, 94, 0.08); }
.chain-delta { font-weight: 800; white-space: nowrap; font-size: 12px; }
.chain-step.is-xmult .chain-delta { color: var(--xmult); }
.chain-step.is-retrigger .chain-delta { color: var(--chips); }
.chain-step.is-penalty .chain-delta { color: var(--ji); }
.chain-step.is-gold .chain-delta { color: var(--gold); }
.chain-step.is-chips .chain-delta { color: #bae6fd; }
.chain-step.is-mult .chain-delta { color: #fecdd3; }
@keyframes popIn { from { opacity: 0; transform: translateY(4px) scale(0.98); } to { opacity: 1; transform: none; } }

.bag-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.bag-chip {
  flex: 1 1 160px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px;
}
.bag-chip-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: #fff6de; }
.sub-action-box {
  margin-top: 8px; padding: 9px 11px;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 10px; font-size: 12px;
}

.log-list {
  max-height: 150px; overflow-y: auto; font-size: 11.5px; color: #cfc8b8;
  display: flex; flex-direction: column; gap: 4px;
}
.log-item { padding: 4px 7px; background: rgba(255, 255, 255, 0.03); border-radius: 6px; }

/* Shop (天机星坊) */
.shop-banner {
  background: linear-gradient(135deg, rgba(28, 36, 58, 0.96), rgba(14, 18, 30, 0.98));
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.shop-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.12fr) minmax(340px, 1.25fr);
  gap: 12px;
  align-items: start;
}
.shelf-block {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 10px;
}
.shelf-head {
  font-size: 13.5px; font-weight: 800; color: var(--gold);
  margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
}
.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
  gap: 8px;
}
.shop-card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; display: flex; flex-direction: column;
}
.shop-card.is-picked { border: 2px solid var(--gold); box-shadow: 0 0 14px rgba(228, 193, 122, 0.25); }
.shop-card.is-sold { opacity: 0.48; }
.sc-art-banner { position: relative; width: 100%; aspect-ratio: 3 / 4; overflow: hidden; background: #0b0e18; }
.sc-art-banner img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.sc-art-fade {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(12, 15, 23, 0) 68%, rgba(25, 33, 54, 0.98) 100%);
}
.sc-body { padding: 8px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.sc-head { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: #fff6e0; }
.sc-cost { margin-left: auto; color: var(--gold); font-size: 12px; }
.sc-desc { font-size: 11px; color: #d6cfc2; line-height: 1.4; flex: 1; }

/* Sticky Mobile Action Bar */
.sticky-pick-bar {
  position: fixed;
  left: 10px; right: 10px; bottom: 10px;
  max-width: 720px; margin: 0 auto; z-index: 95;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; border-radius: 12px;
  background: rgba(14, 19, 34, 0.96); border: 1.5px solid var(--gold);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
}
.spb-text { font-size: 12px; color: #fff6e0; }
.spb-actions { display: flex; gap: 6px; margin-left: auto; }

/* End Screen */
.end-card {
  max-width: 820px; margin: 14px auto;
  background: var(--panel); border: 1.5px solid var(--border-strong); border-radius: 16px; padding: 22px;
}
.end-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0;
}
.end-stat-box {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; text-align: center;
}
.end-stat-box .v { font-size: 20px; font-weight: 900; color: var(--gold); }
.end-stat-box .k { font-size: 11.5px; color: var(--muted); }

/* Mobile 390px Responsive */
@media (max-width: 960px) {
  .app-shell { padding: 8px 8px 88px; }
  .topbar { padding: 8px 10px; }
  .btn { white-space: normal; text-align: center; }
  .hud-bar { grid-template-columns: 1fr; gap: 8px; padding: 10px; }
  .hud-resources, .res-pills, .stem-strip { align-items: flex-start; justify-content: flex-start; }
  .app-shell { padding-bottom: 108px; }
  .game-layout, .shop-layout { grid-template-columns: minmax(0, 1fr); }
  .board-wrap { padding: 6px; }
  .board-grid { grid-template-rows: repeat(4, minmax(84px, auto)); gap: 4px; }
  .palace { padding: 4px; border-radius: 8px; }
  .p-name { font-size: 10.5px; }
  .star-pill { padding: 2px 3px; font-size: 10px; }
  .star-art-slot { width: 20px !important; height: 20px !important; }
  .aux-art-slot { width: 16px !important; height: 16px !important; }
  .center-court { padding: 6px 4px; gap: 4px; }
  .cc-palace { font-size: 11.5px; }
  .cc-preview { font-size: 11px; }
  .shelf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- v2.1 新手教学关样式 ---------- */
.lobby-cta-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.lobby-tut-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tut-rec-btn {
  animation: tutPulseGold 1.9s ease-in-out infinite;
}
.tut-rec-badge {
  position: absolute;
  top: -10px;
  right: 8px;
  font-size: 10px;
  font-weight: 900;
  padding: 1px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fb7185, #f59e0b);
  color: #fff;
  border: 1px solid #fff3c4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.tutorial-coachbar {
  position: sticky;
  top: 6px;
  z-index: 88;
  background: linear-gradient(135deg, rgba(24, 32, 54, 0.97), rgba(13, 18, 32, 0.98));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--gold);
  border-radius: 14px;
  padding: 9px 14px;
  margin-bottom: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.52);
}
.tut-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}
.tut-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tut-step-pill {
  font-size: 11px;
  font-weight: 900;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(228, 193, 122, 0.22);
  border: 1px solid var(--gold);
  color: #fff6dc;
}
.tut-step-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--gold);
}
.tut-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.tut-progress-track {
  width: 96px;
  height: 7px;
  border-radius: 999px;
  background: #0b101b;
  border: 1px solid var(--border);
  overflow: hidden;
}
.tut-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #e4c17a);
  transition: width 0.25s ease;
}
.tut-instruction {
  font-size: 14px;
  font-weight: 800;
  color: #fff8e6;
  line-height: 1.4;
}
.tut-recap {
  background: rgba(56, 189, 248, 0.1);
  border-left: 3px solid var(--chips);
  border-radius: 6px;
  padding: 4px 9px;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #d8f0fe;
  line-height: 1.38;
}
.tut-expand-btn {
  display: none;
}
.tut-compact-summary {
  display: none;
}
.tut-causal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.tut-causal-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 98, 0.24);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.42;
  color: #e6dfd0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.tut-causal-item.is-eff {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.06);
}
.tut-tag {
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 5px;
  white-space: nowrap;
}
.tut-tag-why {
  background: rgba(228, 193, 122, 0.2);
  color: #fde68a;
  border: 1px solid rgba(228, 193, 122, 0.45);
}
.tut-tag-eff {
  background: rgba(52, 211, 153, 0.2);
  color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.45);
}
.tut-causal-text {
  color: #eae3d5;
}
.tut-warn {
  display: none;
  margin-top: 6px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.65);
  color: #fde68a;
  font-size: 12px;
  font-weight: 700;
}
.tut-warn.show {
  display: block;
}

.is-tutorial .tut-dim {
  opacity: 0.4;
  transition: opacity 0.18s ease;
}
.is-tutorial .tut-target {
  position: relative;
  z-index: 8;
  opacity: 1 !important;
  outline: 2.5px solid #fde047;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(253, 224, 71, 0.22), 0 0 22px rgba(228, 193, 122, 0.65) !important;
  animation: tutPulseGold 1.45s ease-in-out infinite;
}
.is-tutorial .tut-target.tut-flash {
  animation: tutFlashRelocate 0.45s ease-out 2;
}
.tut-pointer {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #fde047, #f59e0b);
  color: #161005;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid #fff9d6;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  pointer-events: none;
  z-index: 12;
  animation: tutPointerBob 1.1s ease-in-out infinite;
}
.tut-pointer.edge-left {
  left: 4px;
  transform: none;
}
.tut-pointer.edge-right {
  left: auto;
  right: 4px;
  transform: none;
}
.tut-pointer.edge-bottom {
  top: auto;
  bottom: -11px;
}
.tut-inline-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fde047, #f59e0b);
  color: #161005;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.25;
  border: 1px solid #fff9d6;
  white-space: nowrap;
  max-width: 100%;
  vertical-align: middle;
  pointer-events: none;
}
button.tut-target {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px 5px;
  max-width: 100%;
}
.btn-gold .tut-inline-pill {
  background: #161108;
  color: #fde047;
  border-color: #fde047;
}
.star-pill.tut-target {
  flex-wrap: wrap;
}

@keyframes tutPulseGold {
  0%, 100% { box-shadow: 0 0 0 3px rgba(253, 224, 71, 0.2), 0 0 14px rgba(228, 193, 122, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(253, 224, 71, 0.36), 0 0 26px rgba(253, 224, 71, 0.85); }
}
@keyframes tutFlashRelocate {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 8px rgba(253, 224, 71, 0.5), 0 0 28px rgba(253, 224, 71, 0.95); }
}
@keyframes tutPointerBob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -3px); }
}
.tut-pointer.edge-left,
.tut-pointer.edge-right {
  animation-name: tutPointerBobEdge;
}
@keyframes tutPointerBobEdge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.tut-takeaway-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.tut-takeaway-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.tt-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 4px;
}
.tt-desc {
  font-size: 12px;
  color: #dcd4c5;
  line-height: 1.45;
}

@media (max-width: 960px) {
  .tutorial-coachbar {
    top: 4px;
    padding: 6px 9px;
    margin-bottom: 8px;
  }
  .tut-top {
    margin-bottom: 3px;
  }
  .tut-progress-track {
    width: 48px;
  }
  .tut-expand-btn {
    display: inline-flex;
    color: var(--gold);
    border-color: rgba(228, 193, 122, 0.45);
  }
  .tut-instruction {
    font-size: 12.5px;
  }
  .tut-recap {
    display: none;
  }
  .tut-causal-grid {
    display: none;
    grid-template-columns: 1fr;
    gap: 5px;
    margin-top: 5px;
  }
  .tut-compact-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 5px;
    font-size: 11px;
    color: #d6cfc2;
    margin-top: 3px;
    line-height: 1.35;
  }
  .tut-mini-k.why { color: #fde68a; }
  .tut-mini-k.eff { color: #a7f3d0; }
  .tut-mini-sep { color: var(--muted); }
  .tutorial-coachbar.is-expanded .tut-compact-summary {
    display: none;
  }
  .tutorial-coachbar.is-expanded .tut-recap {
    display: block;
    font-size: 11px;
    padding: 3px 7px;
    margin-bottom: 4px;
  }
  .tutorial-coachbar.is-expanded .tut-causal-grid {
    display: grid;
  }
  .tutorial-coachbar.is-expanded .tut-causal-item {
    font-size: 11px;
    padding: 4px 7px;
  }
  .tut-pointer {
    font-size: 9.5px;
    padding: 1px 6px;
    top: -10px;
    max-width: calc(100vw - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tut-pointer.edge-bottom {
    top: auto;
    bottom: -10px;
  }
  .tut-inline-pill {
    font-size: 9.5px;
    padding: 0 5px;
    margin-left: 2px;
  }
  .lobby-cta-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ---------- v2.3 格局图鉴弹层 ---------- */
.pattern-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(7, 10, 18, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.pattern-modal-backdrop.open {
  display: flex;
}
.pattern-modal {
  width: min(940px, 100%);
  max-height: min(86vh, 780px);
  background: linear-gradient(155deg, #161e33, #0e1320);
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.72);
}
.pm-head {
  flex-shrink: 0;
  padding: 12px 16px 10px;
  background: rgba(16, 22, 38, 0.98);
  border-bottom: 1px solid var(--border);
}
.pm-head-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.pm-title {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  color: #fff6df;
}
.pm-subtitle {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.pm-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pm-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pm-sec-head {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 8px;
}
.pm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr));
  gap: 8px;
}
.pm-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pm-card.is-synergy {
  border-color: rgba(192, 132, 252, 0.28);
}
.pm-card.is-live-hit {
  border: 2px solid #fde047;
  background: linear-gradient(135deg, rgba(228, 193, 122, 0.2), rgba(25, 33, 54, 0.96));
  box-shadow: 0 0 16px rgba(253, 224, 71, 0.24);
}
.pm-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pm-rank {
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(228, 193, 122, 0.16);
  color: var(--gold);
}
.pm-cat {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 5px;
}
.pm-cat.is-aux {
  background: rgba(244, 63, 94, 0.18);
  color: #fecdd3;
  border: 1px solid rgba(244, 63, 94, 0.45);
}
.pm-cat.is-sihua {
  background: rgba(56, 189, 248, 0.16);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.45);
}
.pm-name {
  font-size: 13.5px;
  color: #fff7e2;
}
.pm-lv {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  padding: 0 5px;
  border-radius: 4px;
}
.pm-hit-badge {
  font-size: 10px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fde047, #f59e0b);
  color: #161005;
}
.pm-score {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  color: #bae6fd;
}
.pm-power {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 800;
  color: #fde68a;
}
.pm-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pm-growth {
  font-size: 10.5px;
  color: var(--lu);
  font-weight: 700;
}
.pm-combo {
  font-size: 11px;
  color: #e9d5ff;
  font-weight: 700;
}
.pm-desc {
  font-size: 11.5px;
  color: #d6cfc2;
  line-height: 1.42;
}

@media (max-width: 960px) {
  .pattern-modal-backdrop {
    padding: 8px;
  }
  .pattern-modal {
    max-height: calc(100dvh - 16px);
    border-radius: 14px;
  }
  .pm-head {
    padding: 10px 12px 8px;
  }
  .pm-body {
    padding: 10px 12px 14px;
  }
  .pm-title {
    font-size: 15.5px;
  }
}
