@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(PressStart2P.ttf) format('truetype');
}

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

:root {
  --bg: #F5F1E7;
  --bg-card: #EBE4D3;
  --bg-panel: #DFD7C2;
  --accent: #8B2626;
  --gold: #B8860B;
  --green: #4F6F46;
  --text: #2C2925;
  --muted: #6B6254;
  --hp-player: #4F6F46;
  --hp-enemy: #8B2626;
  --radius: 0px;
}

html, body {
  height: 100%;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  image-rendering: pixelated;
  --pixel-font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.scene {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.scene.hidden { display: none; }
.hidden { display: none !important; }

#scene-map {
  padding-bottom: 0;
  justify-content: space-between;
}

/* ===== Buttons ===== */
.btn {
  border: 2px solid var(--accent);
  border-radius: 0;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--pixel-font);
  cursor: pointer;
  transition: none;
  background: var(--accent);
  color: #F5F1E7;
}
.btn:hover {
  background: var(--bg-panel);
  color: var(--accent);
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: #F5F1E7; border-color: var(--accent); }
.btn-primary:hover { background: var(--bg-panel); color: var(--accent); border-color: var(--accent); }
.btn-secondary { background: var(--bg-panel); color: var(--accent); border: 2px solid var(--accent); }
.btn-secondary:hover { background: var(--accent); color: #F5F1E7; }
.btn-small { padding: 8px 10px; font-size: 12px; border-radius: 0; }

/* ===== Map Scene ===== */
.map-header {
  width: 100%;
  max-width: 420px;
  text-align: center;
  margin-bottom: 12px;
}
.map-header h1 { font-size: 18px; color: var(--accent); margin-bottom: 6px; }
.player-status { display: flex; gap: 16px; justify-content: center; font-size: 13px; color: var(--muted); }

.map-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 420px;
}

.stage-title {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 6px;
  text-align: center;
}

.map-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  text-align: center;
  animation: hintPulse 2s step-end infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.map-nodes {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 420px;
}

.map-node {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 0;
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.1s step-end;
  width: 120px;
}
.map-node:hover { border-color: var(--gold); transform: none; }
.map-node .node-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.map-node .node-name { font-size: 13px; font-weight: 600; }
.map-node .node-hp { font-size: 12px; color: var(--muted); margin-top: 4px; }
.map-node.boss { border-color: var(--accent); border-width: 3px; }
.map-node.boss .node-name { color: var(--accent); }
.map-node.defeated {
  opacity: 0.35;
  pointer-events: none;
  border-color: var(--muted);
}

.deck-preview {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: 0;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  position: sticky;
  bottom: 0;
  border-top: 2px solid var(--accent);
}
.deck-hint {
  font-size: 12px;
  color: var(--accent);
  background: var(--bg-card);
  border: 2px dashed var(--muted);
  border-radius: 0;
  padding: 10px 10px;
  margin-top: 6px;
  text-align: center;
  cursor: pointer;
  animation: hintPulse 2s step-end infinite;
}

/* Bottom status bar */
.bottom-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bottom-bar-btn {
  flex-shrink: 0;
  background: var(--bg-panel);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.bottom-bar-btn:hover { background: var(--accent); color: var(--bg); }
.bottom-bar-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.bottom-hp-row, .bottom-qi-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bottom-hp-label, .bottom-qi-label {
  font-size: 12px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}
.bottom-hp-track, .bottom-qi-track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--muted);
  overflow: hidden;
}
.bottom-hp-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s linear;
}
.bottom-qi-fill {
  height: 100%;
  background: var(--gold);
  transition: width 0.3s linear;
}
.bottom-hp-text, .bottom-qi-text {
  font-size: 11px;
  font-family: var(--pixel-font);
  color: var(--muted);
  flex-shrink: 0;
  min-width: 50px;
  text-align: right;
}

/* ===== Card (shared) ===== */
.card-unit {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 0;
  padding: 10px 8px;
  width: 100%;
  min-width: 0;
  text-align: center;
  position: relative;
  transition: border-color 0.1s step-end;
}
.card-unit .card-icon { font-size: 22px; display: block; margin-bottom: 2px; }
.card-unit .card-name { font-size: 11px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-cat {
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
  padding: 1px 5px;
  border-radius: 0;
  background: var(--bg);
  color: var(--muted);
  margin-top: 2px;
  border: 1px solid var(--muted);
}
.card-cat-体术 { background: var(--bg); color: var(--accent); border-color: var(--accent); }
.card-cat-法术 { background: var(--bg); color: var(--accent); border-color: var(--accent); }
.card-cat-阵法 { background: var(--bg); color: var(--muted); border-color: var(--muted); }
.card-cat-法宝 { background: var(--bg); color: var(--accent); border-color: var(--accent); }
.card-cat-灵兽 { background: var(--bg); color: var(--muted); border-color: var(--muted); }
.card-unit .card-skill { font-size: 11px; color: var(--muted); display: block; margin-top: 1px; }
.card-unit .card-value { font-size: 11px; color: var(--accent); display: block; margin-top: 1px; font-family: var(--pixel-font); }

/* Wide card (2 slots) */
.card-unit.card-wide { grid-column: span 2; border-color: var(--accent); border-width: 3px; }
/* Triple card (3 slots) */
.card-unit.card-triple { grid-column: span 3; border-color: var(--accent); border-width: 3px; }
/* Value badge (top-left corner) */
.card-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border-radius: 4px;
  z-index: 2;
  padding: 0 4px;
  font-family: var(--pixel-font);
}
.badge-dmg     { background: #c0392b; }
.badge-heal    { background: #27ae60; }
.badge-poison  { background: #8e44ad; }
.badge-shield  { background: #2980b9; }
.badge-silence { background: #6a5acd; }

/* Rarity border colors */
.card-unit.rarity-uncommon { border-color: #4a9e4a; }
.card-unit.rarity-rare     { border-color: #3a7bd5; }
.card-unit.rarity-epic     { border-color: #9b59b6; }
.card-unit.rarity-legendary { border-color: var(--gold); border-width: 3px; }

.card-size {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: #F5F1E7;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 0;
  font-family: var(--pixel-font);
}
.card-unit.card-triple .card-size { background: var(--gold); color: var(--bg); }

/* Silence card style */
.card-unit.silence-card { border-color: var(--gold); }
.card-unit.silence-card .cd-bar { background: var(--gold); }

/* Poison card style */
.card-unit.poison-card { border-color: var(--accent); }
.card-unit.poison-card .cd-bar { background: var(--accent); }

/* Shield card style */
.card-unit.shield-card { border-color: var(--muted); }
.card-unit.shield-card .cd-bar { background: var(--muted); }

/* Silence overlay on affected cards */
.silence-overlay {
  position: absolute;
  inset: 0;
  background: rgba(44, 41, 37, 0.25);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: none;
  font-family: var(--pixel-font);
}
.silence-overlay.hidden { display: none; }
.card-unit.silenced { opacity: 0.6; }
.card-unit.silenced .cd-bar { background: var(--accent) !important; }

/* Silence beam flash */
.card-unit.silence-fire {
  border-color: var(--accent);
  animation: cardPulse 0.3s ease-out;
}

/* Impact freeze flash */
.hp-bar-wrap.impact-freeze,
.card-unit.impact-freeze {
  animation: hpImpact 0.3s ease-out;
  border: 2px solid var(--accent);
}

/* ===== Config Scene ===== */
.config-panel {
  width: 100%;
  max-width: 420px;
}
.config-panel h2 { text-align: center; margin-bottom: 4px; font-size: 16px; }
.config-slots-text { text-align: center; color: var(--accent); font-size: 14px; margin-bottom: 4px; }
.config-hint { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.config-grid-section { margin-bottom: 12px; }
.config-grid-section h3, .config-section h3 {
  font-size: 13px; color: var(--muted); margin-bottom: 10px;
  border-bottom: 2px solid var(--muted); padding-bottom: 6px;
}
.config-section { margin-bottom: 20px; }

/* Grid: 4 slots in a row mimicking battle layout */
.config-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  min-height: 120px;
  background: var(--bg-card);
  border-radius: 0;
  padding: 14px 10px;
  border: 2px dashed var(--muted);
}

.config-slot {
  aspect-ratio: 3/4;
  border: 2px dashed var(--muted);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.1s step-end, background 0.1s step-end;
}
.config-slot.empty {
  color: var(--muted);
  font-size: 12px;
}
.config-slot.drag-over {
  border-color: var(--accent);
  background: var(--bg-panel);
}
.config-slot.wide-slot { grid-column: span 2; }
.config-slot.triple-slot { grid-column: span 3; }

/* Cards inside slots */
.config-slot .card-unit {
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: grab;
  border: none;
  background: var(--bg-card);
}
.config-slot .card-unit:active { cursor: grabbing; }
.config-slot .card-unit.card-wide { width: 100%; }
.config-slot .card-unit.card-triple { width: 100%; }

/* Bench */
.config-bench-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  min-height: 60px;
  background: var(--bg-card);
  border-radius: 0;
  padding: 14px 10px;
  border: 2px dashed var(--muted);
}
.config-bench-grid .card-unit {
  cursor: grab;
  opacity: 0.85;
  transition: opacity 0.1s step-end;
  width: 100%;
}
.config-bench-grid .card-unit.card-wide { grid-column: span 2; }
.config-bench-grid .card-unit.card-triple { grid-column: span 3; }
.config-bench-grid .card-unit:hover { opacity: 1; transform: none; }
.config-bench-grid .card-unit:active { cursor: grabbing; }
.config-bench-grid .card-unit.card-locked {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.card-lock-tag {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #F5F1E7;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 0;
  white-space: nowrap;
  font-family: var(--pixel-font);
}
.config-bench-grid.drag-over {
  border-color: var(--accent);
  background: var(--bg-panel);
}

/* Dragging ghost */
.card-dragging {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  opacity: 0.9;
  transform: scale(1.05);
  filter: none;
}

.config-empty-text { color: var(--muted); font-size: 12px; padding: 8px; }
.config-divider { height: 2px; background: var(--muted); margin: 8px 0 16px; }
.wide { width: 100%; }
.muted { color: var(--muted); font-size: 13px; }

@media (max-width: 440px) {
  .config-slot { width: 78px; height: 105px; }
  .config-slot.wide-slot { width: calc(78px * 2 + 8px); }
  .config-slot.triple-slot { width: calc(78px * 3 + 8px * 2); }
  .config-grid { gap: 8px; padding: 10px 8px; }
  .config-bench-grid { gap: 8px; padding: 10px 8px; }
}

/* Cooldown sweep line — scans bottom-to-top across card face */
.cd-sweep {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.cd-sweep-line {
  position: absolute;
  left: 2px; right: 2px;
  height: 2px;
  bottom: 0;
  background: var(--accent);
  box-shadow: 0 0 6px 2px var(--accent), 0 0 16px 4px rgba(139,38,38,0.35);
  transition: bottom 0.5s linear;
}
.cd-sweep-fill {
  position: absolute;
  left: 0; right: 0;
  bottom: 0; height: 0;
  background: linear-gradient(to top, rgba(139,38,38,0.12), transparent);
  transition: height 0.5s linear;
}
.card-unit.healing .cd-sweep-line {
  background: var(--green);
  box-shadow: 0 0 6px 2px var(--green), 0 0 16px 4px rgba(85,139,47,0.35);
}
.card-unit.healing .cd-sweep-fill { background: linear-gradient(to top, rgba(85,139,47,0.12), transparent); }
.card-unit.silence-card .cd-sweep-line {
  background: var(--gold);
  box-shadow: 0 0 6px 2px var(--gold), 0 0 16px 4px rgba(218,165,32,0.35);
}
.card-unit.silence-card .cd-sweep-fill { background: linear-gradient(to top, rgba(218,165,32,0.12), transparent); }
.card-unit.poison-card .cd-sweep-line {
  background: var(--accent);
  box-shadow: 0 0 6px 2px var(--accent), 0 0 16px 4px rgba(139,38,38,0.35);
}
.card-unit.shield-card .cd-sweep-line {
  background: var(--muted);
  box-shadow: 0 0 6px 2px var(--muted), 0 0 16px 4px rgba(136,136,136,0.35);
}
.card-unit.shield-card .cd-sweep-fill { background: linear-gradient(to top, rgba(136,136,136,0.1), transparent); }
.card-unit.silenced .cd-sweep-line {
  background: var(--muted) !important;
  box-shadow: none !important;
  opacity: 0.4;
}
.card-unit.silenced .cd-sweep-fill { background: rgba(0,0,0,0.05) !important; }

/* Hide old cd-bar (backward compat) */
.cd-bar-wrap { display: none; }
.cd-bar { display: none; }

/* Attack flash */
.card-unit.firing {
  border-color: var(--accent);
  animation: cardPulse 0.3s ease-out;
}
.card-unit.healing-fire {
  border-color: var(--green);
  animation: cardPulse 0.3s ease-out;
}

@keyframes cardPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ===== Beam Effect ===== */
.battle-field { position: relative; }
.beam-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  overflow: visible;
}

.beam {
  position: absolute;
  height: 2px;
  transform-origin: 0 50%;
  border-radius: 2px;
  animation: beamShoot 0.35s ease-out forwards;
  filter: blur(0.5px);
}
.beam::before {
  content: "";
  position: absolute;
  inset: -3px 0;
  height: 8px;
  border-radius: 4px;
  background: inherit;
  opacity: 0.2;
  filter: blur(4px);
}
/* head glow */
.beam::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(0, -50%);
  border-radius: 50%;
  background: inherit;
  opacity: 0.9;
  filter: blur(2px);
  animation: beamHead 0.35s ease-out forwards;
}

.beam.beam-dmg {
  background: var(--accent);
}
.beam.beam-heal {
  background: var(--green);
}
.beam.beam-freeze {
  background: var(--muted);
}
.beam.beam-fire {
  background: var(--accent);
}
.beam.beam-poison {
  background: var(--gold);
}
.beam.beam-shield {
  background: var(--muted);
}
.beam.beam-purify {
  background: var(--green);
}

@keyframes beamShoot {
  0%   { clip-path: inset(0 100% 0 0); opacity: 1; }
  50%  { clip-path: inset(0 0 0 0); opacity: 1; }
  100% { clip-path: inset(0 0 0 0); opacity: 0; }
}
@keyframes beamHead {
  0%   { opacity: 0; transform: translate(0, -50%) scale(0.5); }
  50%  { opacity: 1; transform: translate(0, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(0, -50%) scale(0.8); }
}

/* Beam impact flash on HP bar */
.hp-bar-wrap.impact-dmg {
  animation: hpImpact 0.3s ease-out;
  border: 2px solid var(--accent);
}
.hp-bar-wrap.impact-heal {
  animation: hpImpact 0.3s ease-out;
  border: 2px solid var(--green);
}
@keyframes hpImpact {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* Beam particles */
.beam-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  pointer-events: none;
  animation: particleFade 0.45s ease-out forwards;
}
@keyframes particleFade {
  0%   { opacity: 0.9; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}

/* ===== Preview Scene ===== */
.preview-panel {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 0;
  padding: 28px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.preview-panel h2 { font-size: 16px; margin-bottom: 8px; }
.preview-hp { font-size: 14px; color: var(--accent); margin-bottom: 16px; }
.preview-panel h3 { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.preview-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; justify-content: center; margin-bottom: 24px; max-width: 100%; }
.preview-cards .card-unit { width: auto; }
.preview-actions { display: flex; gap: 12px; justify-content: center; }

/* ===== Battle Scene ===== */
#scene-battle {
  padding: 0 16px;
  justify-content: center;
}
.battle-field {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 40px);
  min-height: calc(100dvh - 40px);
}

.side { text-align: center; position: relative; }
.enemy-side { padding-top: 12px; }
.player-side { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.side-label { font-size: 13px; color: var(--muted); margin: 6px 0; }

.hp-bar-wrap {
  position: relative;
  height: 22px;
  background: var(--bg-card);
  border-radius: 0;
  border: 2px solid var(--accent);
  overflow: hidden;
  margin: 6px 0;
}
.hp-bar {
  height: 100%;
  border-radius: 0;
  transition: width 0.35s ease-out;
  background: var(--hp-enemy);
}
.hp-bar-player { background: var(--hp-player); }
.hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #F5F1E7;
  text-shadow: 1px 1px 0 rgba(44, 41, 37, 0.5);
  font-family: var(--pixel-font);
}

.card-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 0;
}

.battle-line {
  text-align: center;
  padding: 10px 0;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
}
.battle-line span { font-family: var(--pixel-font); }
.battle-line .btn-small { background: var(--bg-panel); color: var(--text); border: 2px solid var(--accent); }

.battle-countdown { font-weight: bold; color: var(--gold); font-size: 15px; }

.battle-log {
  display: none;
}

/* Floating damage numbers */
.float-num {
  position: absolute;
  font-size: 15px;
  font-weight: 900;
  pointer-events: none;
  animation: floatUp 0.8s ease-out forwards;
  z-index: 10;
  text-shadow: 0 1px 3px rgba(44, 41, 37, 0.3);
  font-family: var(--pixel-font);
}
.float-num.dmg { color: var(--accent); }
.float-num.heal { color: var(--green); }
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-36px); }
}

/* ===== Result Scene ===== */
.result-panel {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 0;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.result-panel h2 { font-size: 18px; margin-bottom: 10px; }
.result-panel p { color: var(--muted); margin-bottom: 20px; font-size: 13px; }

.result-reward { margin-bottom: 20px; }
.result-reward h3 { font-size: 14px; color: var(--accent); margin-bottom: 12px; }
.reward-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; margin-bottom: 16px; max-width: 280px; margin-left: auto; margin-right: auto; }
.reward-list .card-unit { border-color: var(--accent); cursor: pointer; transition: none; width: 100%; grid-column: span 1 !important; }
.reward-list .card-unit:hover { transform: none; border-color: var(--gold); }
.reward-list .card-unit.claimed { opacity: 0.45; pointer-events: none; border-color: var(--muted); }
.reward-list .card-unit.claimed::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--green);
  background: rgba(44, 41, 37, 0.5);
  border-radius: 0;
  font-family: var(--pixel-font);
}
.reward-hint { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

.result-panel .btn { margin: 4px; }

/* ===== Card Detail Modal ===== */
.card-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(44, 41, 37, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s step-end;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card-detail-modal {
  background: var(--bg-card);
  border: 4px solid var(--muted);
  border-radius: 0;
  padding: 24px 20px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  position: relative;
  animation: modalSlideUp 0.25s step-end;
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-detail-header { margin-bottom: 12px; }
.cd-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: block;
  margin-bottom: 4px;
}
.cd-size-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 0;
  background: var(--accent);
  color: #F5F1E7;
  font-family: var(--pixel-font);
}
.cd-size-tag.size-1 { background: var(--gold); color: #F5F1E7; }
.cd-size-tag.size-3 { background: var(--accent); color: #F5F1E7; }

.cd-icon-wrap {
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cd-icon { font-size: 48px; }

.cd-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
}
.cd-divider::before, .cd-divider::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--muted);
}

.cd-skill-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border: 2px solid var(--muted);
  border-radius: 0;
  padding: 12px;
  margin-bottom: 14px;
  text-align: left;
}
.cd-cooldown {
  flex-shrink: 0;
  min-width: 48px;
  height: 48px;
  border: 2px solid var(--accent);
  border-radius: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  padding: 0 8px;
  color: var(--text);
}
.cd-interval-num {
  font-size: 18px;
  font-weight: 700;
  line-height: 48px;
}
.cd-interval-unit {
  font-size: 12px;
  color: var(--muted);
  line-height: 48px;
}
.cd-skill-desc {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
}
.cd-skill-desc .cd-val { color: var(--accent); font-weight: 700; }
.cd-skill-desc .cd-type-icon { margin-right: 4px; }

.cd-flavor {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 12px;
  line-height: 1.8;
}

.cd-effect-box {
  background: var(--bg);
  border: 2px solid var(--muted);
  border-radius: 0;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 2;
  text-align: left;
}
.cd-effect-box:empty { display: none; }
.cd-effect-item + .cd-effect-item {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px solid var(--muted);
}

.cd-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.cd-actions:empty { display: none; margin: 0; }
.cd-actions .btn { flex: 1; }

.cd-close-btn {
  background: none;
  border: 2px solid var(--accent);
  color: var(--muted);
  padding: 8px 24px;
  border-radius: 0;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--pixel-font);
  transition: border-color 0.1s step-end, color 0.1s step-end;
}
.cd-close-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Victory Scene ===== */
.victory-panel {
  text-align: center;
  padding-top: 60px;
}
.victory-panel h1 { font-size: 22px; color: var(--accent); margin-bottom: 12px; }
.victory-panel p { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.victory-panel .deck-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
}
.victory-panel .deck-cards .card-unit { width: 100%; grid-column: span 1 !important; }

/* ===== Story Scene ===== */
.story-panel {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 0;
  position: relative;
}
.story-skip-btn {
  position: absolute;
  top: 16px;
  right: 0;
  background: var(--bg-card);
  color: var(--muted);
  border: 2px solid var(--accent);
}
.story-speaker-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}
.story-icon {
  font-size: 56px;
  display: block;
  filter: none;
  animation: storyIconFloat 3s steps(4) infinite;
}
@keyframes storyIconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.story-speaker {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}
.story-text-area {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 0;
  padding: 20px 24px;
  width: 100%;
  min-height: 100px;
  margin-bottom: 16px;
}
.story-text {
  font-size: 14px;
  line-height: 2;
  color: var(--text);
}
.story-text .typewriter-cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.5s step-end infinite;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.story-continue {
  font-size: 13px;
  color: var(--muted);
  animation: hintPulse 2s step-end infinite;
  cursor: pointer;
}

/* ===== Main Game Scene ===== */
#scene-main {
  padding: 0 16px 20px;
}
.main-tabs {
  display: flex;
  width: 100%;
  max-width: 420px;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.main-tab {
  flex: 1;
  background: none;
  border: 2px solid transparent;
  border-bottom: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--pixel-font);
  padding: 12px 0;
  cursor: pointer;
  transition: none;
  position: relative;
}
.tab-dot {
  position: absolute;
  top: 6px;
  right: calc(50% - 24px);
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 4px var(--accent);
}
.main-tab:hover {
  color: var(--text);
  background: var(--bg-card);
}
.main-tab.active {
  color: var(--accent);
  background: var(--bg-card);
  border-color: var(--accent);
  border-bottom: 2px solid var(--bg-card);
  margin-bottom: -2px;
}
.main-tab-content {
  width: 100%;
  max-width: 420px;
}

/* Home tab — pixel card system */
.px-card {
  width: 100%;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.px-card-title {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 1px;
  font-family: var(--pixel-font);
}

/* 角色信息卡 */
.home-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--muted);
}
.home-info-row:last-child { border-bottom: none; }
.home-info-label {
  font-size: 12px;
  color: var(--muted);
}
.home-info-val {
  font-size: 12px;
  color: var(--text);
}
.home-info-val.val-gold { color: var(--accent); }
.home-info-val.val-muted { color: var(--muted); }

/* 境界进度条 */
.realm-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.realm-bar-name {
  font-size: 14px;
  font-weight: 700;
}
.realm-bar-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--pixel-font);
}
.realm-bar-track {
  height: 10px;
  background: var(--bg-panel);
  border: 2px solid var(--accent);
  overflow: hidden;
}
.realm-bar-fill {
  height: 100%;
  background: var(--accent);
  background-image: repeating-linear-gradient(
    90deg,
    var(--accent) 0px,
    var(--accent) 6px,
    var(--bg-panel) 6px,
    var(--bg-panel) 8px
  );
}
.realm-bar-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.realm-info-row {
  display: flex;
  justify-content: space-between;
}

/* 功法卡片 */
.home-cult-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.home-cult-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cult-icon { font-size: 16px; }
.cult-name { font-size: 13px; font-weight: 700; }
.cult-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  animation: pxBlink 1s steps(1) infinite;
}
.cult-status-text {
  font-size: 12px;
  color: var(--accent);
}
.cult-desc-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
@keyframes pxBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 属性 */
.home-attrs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.home-attr {
  background: var(--bg);
  border: 2px solid var(--accent);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.attr-label {
  font-size: 12px;
  color: var(--muted);
}
.attr-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--pixel-font);
}

/* Quests tab */
.quests-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}
.quest-sub-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.quest-sub-tab {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-card);
  border: 1px solid var(--muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.quest-sub-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}
.quest-sub-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.quest-tab-content.hidden { display: none; }
.quest-section-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  padding-left: 2px;
}
.quest-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quest-empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
  opacity: 0.6;
}
.quest-card.quest-highlight {
  border-color: var(--accent);
  background: var(--bg-panel);
}
.quest-card.quest-done {
  opacity: 0.6;
  cursor: default;
  border-color: var(--muted);
}
.quest-card.quest-done:hover {
  border-color: var(--muted);
  background: var(--bg-card);
}
.quest-card.quest-expired {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
  border-color: var(--muted);
}
.quest-card.quest-expired:hover {
  border-color: var(--muted);
  background: var(--bg-card);
  transform: none;
}
.quest-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 0;
  padding: 14px;
  cursor: pointer;
  transition: none;
}
.quest-card:hover {
  border-color: var(--gold);
  transform: none;
  background: var(--bg-panel);
}
.quest-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.quest-info {
  flex: 1;
  min-width: 0;
}
.quest-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}
.quest-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.quest-difficulty {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.difficulty-困难 { background: #e67e22; color: #fff; }
.difficulty-噩梦 { background: #9b59b6; color: #fff; }
.difficulty-地狱 { background: #c0392b; color: #fff; }

/* Bounty (捉妖令) */
.bounty-tier { margin-bottom: 12px; }
.bounty-tier-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  padding: 6px 0 4px;
  border-bottom: 1px dashed var(--accent);
  margin-bottom: 6px;
}
.bounty-hp {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
}

.quest-arrow {
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Inventory tab */
.inventory-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 0;
}
.inventory-section-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  padding-left: 2px;
}
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 8px;
}
.inventory-grid .card-unit {
  cursor: pointer;
}
.inventory-grid .card-unit.card-empty {
  border: 2px dashed var(--muted);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  opacity: 0.5;
}
.card-empty-text {
  font-size: 11px;
  color: var(--muted);
}
.inventory-empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
  opacity: 0.6;
  grid-column: 1 / -1;
}

/* ===== Prologue Scroll Scene ===== */
.prologue-scroll {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 0 40px;
}
.prologue-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 28px;
  letter-spacing: 2px;
  font-family: var(--pixel-font);
}
.prologue-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.prologue-line {
  background: var(--bg-card);
  border-left: 4px solid var(--muted);
  padding: 14px 18px;
  line-height: 2;
  font-size: 14px;
  color: var(--text);
}
.prologue-line + .prologue-line {
  margin-top: 6px;
}
.prologue-line .pl-icon {
  margin-right: 6px;
}
.prologue-line .pl-speaker {
  color: var(--accent);
  font-weight: 600;
  margin-right: 8px;
}
.prologue-line.narrator {
  border-left-color: var(--muted);
  color: var(--muted);
}
.prologue-line.dialogue {
  border-left-color: var(--accent);
}
@keyframes prologueFadeIn {
  to { opacity: 1; transform: translateY(0); }
}
.prologue-fight-btn {
  margin-top: 32px;
  font-size: 15px;
  padding: 14px 48px;
}

/* ===== Root Selection Scene ===== */
.root-select-panel {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding-top: 60px;
}
.root-select-panel h2 {
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 12px;
}
.root-select-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 2;
}
.root-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.root-option {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 0;
  padding: 16px 20px;
  text-align: left;
  cursor: pointer;
  transition: none;
}
.root-option:hover {
  border-color: var(--gold);
  transform: none;
  background: var(--bg-panel);
}
.root-option .root-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}
.root-option .root-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

/* ===== Status Bar ===== */
.status-bar {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 8px;
  min-height: 24px;
  pointer-events: auto;
}
.status-bar:empty { min-height: 24px; }

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 2px solid var(--muted);
  border-radius: 0;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: none;
  white-space: nowrap;
}
.status-tag:hover {
  background: var(--bg-panel);
  border-color: var(--accent);
}
.status-tag .status-icon { font-size: 14px; }
.status-tag .status-value { color: var(--accent); }

.status-tag.status-poison { border-color: var(--accent); color: var(--accent); }
.status-tag.status-shield { border-color: var(--muted); color: var(--muted); }
.status-tag.status-silence { border-color: var(--gold); color: var(--gold); }

/* Status detail modal */
.status-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(44, 41, 37, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s step-end;
}
.status-detail-modal {
  background: var(--bg-card);
  border: 4px solid var(--muted);
  border-radius: 0;
  padding: 24px 20px;
  max-width: 280px;
  width: 100%;
  text-align: center;
  animation: modalSlideUp 0.25s step-end;
}
.sd-icon { font-size: 36px; display: block; margin-bottom: 8px; }
.status-detail-modal h3 { font-size: 15px; margin-bottom: 10px; color: var(--text); }
.status-detail-modal p { font-size: 13px; color: var(--muted); line-height: 2; margin-bottom: 16px; }

/* ===== Explore Scene ===== */
#scene-explore { padding-bottom: 0; }
.explore-header {
  width: 100%; max-width: 420px; text-align: center; margin-bottom: 16px;
}
.explore-header h2 { font-size: 18px; color: var(--accent); margin-bottom: 4px; }
.explore-progress { font-size: 12px; color: var(--muted); }

.explore-slots {
  width: 100%; max-width: 420px;
  display: flex; gap: 12px; justify-content: center;
  align-items: flex-start; padding-top: 8vh;
}
.explore-slot-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 8px;
}
.explore-card {
  position: relative;
  background: var(--bg-card); border: 2px solid var(--muted);
  border-radius: 0; padding: 20px 10px; text-align: center;
  cursor: pointer; transition: border-color 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 160px; justify-content: center;
}
.explore-card:hover { border-color: var(--accent); }
.explore-card .ec-icon { font-size: 32px; }
.explore-card .ec-type { font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.explore-card .ec-name { font-size: 13px; font-weight: 700; }
.explore-card .ec-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }
.explore-card.selected { border-color: var(--accent) !important; box-shadow: 0 0 12px rgba(139,38,38,0.3); }


.explore-card.type-battle { border-color: rgba(139,38,38,0.3); }
.explore-card.type-elite { border-color: rgba(168,85,247,0.3); }
.explore-card.type-boss { border-color: var(--accent); background: linear-gradient(180deg, rgba(139,38,38,0.08), var(--bg-card)); }
.explore-card.type-finale { border-color: var(--gold); background: linear-gradient(180deg, rgba(184,134,11,0.1), var(--bg-card)); }
.explore-card.type-shop { border-color: rgba(184,134,11,0.3); }
.explore-card.type-treasure { border-color: rgba(184,134,11,0.3); }
.explore-card.type-rest { border-color: rgba(79,111,70,0.3); }
.explore-card.type-event { border-color: rgba(107,98,84,0.3); }

.card-close-btn {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border: 1px solid var(--muted);
  border-radius: 50%; background: var(--bg); color: var(--muted);
  font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.card-close-btn:hover { color: var(--text); border-color: var(--text); }

.btn-confirm-enter {
  width: 100%; padding: 10px 0; font-size: 13px; border-radius: 0;
  animation: fadeSlideUp 0.2s ease-out;
}
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cardSlideIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.explore-card.entering { animation: cardSlideIn 0.3s ease-out; }

/* Explore bottom bar */
.explore-bottom-bar {
  width: 100%; max-width: 420px;
  background: var(--bg-card); border-top: 2px solid var(--muted);
  padding: 10px 16px; margin-top: auto;
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 12px;
}
.explore-hp { position: relative; width: 100px; height: 18px; flex-shrink: 0; }
.explore-hp-bg { width: 100%; height: 100%; background: rgba(0,0,0,0.3); overflow: hidden; }
.explore-hp-fill { height: 100%; background: var(--accent); transition: width 0.4s; }
.explore-hp-text {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; text-shadow: 1px 1px 1px rgba(0,0,0,0.6);
  pointer-events: none;
}
.explore-gold { font-size: 13px; color: var(--gold); font-weight: 600; }
.btn-explore-equip { margin-left: auto; background: var(--bg-panel); color: var(--text); border: 2px solid var(--muted); border-radius: 0; }

/* Explore modal overlay */
.explore-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(44,41,37,0.8); z-index: 150;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s;
}
.explore-modal {
  background: var(--bg); border: 2px solid var(--muted);
  border-radius: 0; padding: 28px 24px;
  width: 90%; max-width: 380px; max-height: 80vh; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
}
.explore-modal h2 { color: var(--accent); font-size: 16px; }
.explore-panel-desc { color: var(--muted); font-size: 13px; line-height: 1.8; }
.explore-panel-icon { font-size: 40px; display: block; }
.explore-reward-list { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* Explore equip modal */
.explore-equip-cards { display: flex; gap: 8px; flex-wrap: wrap; min-height: 40px; }
.equip-card {
  background: var(--bg-card); border: 2px solid var(--muted);
  border-radius: 0; padding: 8px 10px; text-align: center;
  width: 70px; font-size: 11px; cursor: pointer;
}
.equip-card:hover { border-color: var(--accent); }
.equip-card .eq-icon { font-size: 20px; display: block; }
.equip-card .eq-name { font-weight: 600; }
.equip-empty { font-size: 12px; color: var(--muted); }

/* ===== Explore Event Choices ===== */
.event-choices {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.event-choice {
  background: var(--bg-card);
  border: 2px solid var(--muted);
  border-radius: 0;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}
.event-choice:hover {
  border-color: var(--accent);
  background: var(--bg-panel);
}
.event-choice-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
.event-choice-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* Event story (linear narrative) */
.event-story {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.event-story-line {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  padding: 10px 14px;
  background: var(--bg-card);
  border-left: 3px solid var(--muted);
  text-align: left;
}
.event-story-line + .event-story-line {
  margin-top: 4px;
}
.event-outcome-text {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  margin-top: 4px;
}
.explore-modal .explore-reward-list { margin-bottom: 4px; }
.explore-modal .btn { margin-top: 8px; }

/* ===== Explore Shop ===== */
.shop-gold {
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
  text-align: center;
  margin-bottom: 4px;
}
/* Shop overlay — full screen with gold cutout */
.shop-overlay {
  position: fixed; inset: 0; z-index: 150;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s;
}
.shop-overlay-bg {
  position: absolute; inset: 0;
  background: rgba(44,41,37,0.8);
  pointer-events: none;
}
.shop-gold-highlight {
  position: fixed;
  z-index: 151;
  pointer-events: none;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 9999px rgba(44,41,37,0.8);
  animation: fadeIn 0.3s;
}
.shop-panel {
  position: relative; z-index: 152;
  background: var(--bg); border: 2px solid var(--muted);
  border-radius: 0; padding: 28px 20px 20px;
  width: 90%; max-width: 380px; max-height: 75vh; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
}
.shop-close-btn {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  background: none; border: 2px solid var(--muted);
  color: var(--muted); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.shop-close-btn:hover { border-color: var(--accent); color: var(--accent); }

.shop-items {
  width: 100%;
  display: flex;
  gap: 10px;
  justify-content: center;
}
.shop-item {
  flex: 1;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg-card);
  border: 2px solid var(--muted);
  border-radius: 0;
  padding: 12px 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  text-align: center;
}
.shop-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.shop-item:active { transform: scale(0.97); }
.shop-item.sold {
  opacity: 0.35;
  pointer-events: none;
  border-color: var(--muted);
}
.shop-item.sold .shop-item-icon { filter: grayscale(1); }
.shop-item-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}
.shop-item-icon {
  font-size: 32px;
  display: block;
  padding: 8px 0;
}
.shop-item-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  min-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.shop-item-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed var(--muted);
  width: 100%;
}
.shop-item.sold .shop-item-price { color: var(--muted); }
.shop-item-info { display: contents; }

/* ===== Explore Reward Items ===== */
.reward-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 2px solid var(--muted);
  border-radius: 0;
  padding: 8px 12px;
  font-size: 13px;
}
.reward-icon { font-size: 18px; }

/* ===== Responsive ===== */
@media (max-width: 440px) {
  .scene { padding: 16px 12px; }
  #scene-map { padding-bottom: 0; }
  .map-header { margin-bottom: 8px; }
  .map-header h1 { font-size: 16px; }
  .card-unit { width: 100%; padding: 8px 6px; }
  .card-unit.card-wide { width: 100%; grid-column: span 2; }
  .card-unit.card-triple { width: 100%; grid-column: span 3; }
  .card-unit .card-icon { font-size: 22px; }
  .map-node { width: 100px; padding: 14px 10px; }
  .deck-preview { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .deck-cards { gap: 8px; }
  .battle-field { gap: 4px; }
}

/* 宗门Tab + 藏功阁 */
.sect-card { margin-bottom: 8px; }
.library-item {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: default;
}
.library-item:not(.owned):not(.disabled) { cursor: pointer; }
.library-item:not(.owned):not(.disabled):hover { border-color: var(--gold); }
.library-item.owned { border-color: var(--green); background: rgba(78,204,163,0.05); }
.library-item.disabled { opacity: 0.5; }
