:root {
  --bg-outer: #09080c;
  --velvet-top: #10241e;
  --velvet-mid: #0c1b18;
  --velvet-bot: #091213;
  --obsidian: #13111a;
  --panel: rgba(16, 15, 24, 0.88);
  --panel-solid: #171522;
  --gold-1: #fde68a;
  --gold-2: #d4a64a;
  --gold-3: #8c6422;
  --gold-border: rgba(212, 166, 74, 0.42);
  --gold-glow: rgba(245, 198, 92, 0.25);
  --crimson: #e11d48;
  --crimson-soft: rgba(225, 29, 72, 0.2);
  --emerald: #10b981;
  --cyan: #38bdf8;
  --violet: #a855f7;
  --amber: #f59e0b;
  --text-main: #f8f5ec;
  --text-muted: #a6a096;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(180, 130, 45, 0.14), transparent 45%),
    radial-gradient(circle at 80% 90%, rgba(16, 80, 62, 0.2), transparent 50%),
    linear-gradient(160deg, #0d0b12 0%, #07060a 100%);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* ==================== 9:16 WECHAT MINI GAME SHELL ==================== */
.wx-shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: min(100dvh, 860px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(30, 82, 66, 0.42) 0%, rgba(10, 25, 22, 0.94) 68%, #070d0e 100%),
    repeating-linear-gradient(
      45deg,
      rgba(255, 224, 150, 0.018) 0px,
      rgba(255, 224, 150, 0.018) 2px,
      transparent 2px,
      transparent 16px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(255, 224, 150, 0.018) 0px,
      rgba(255, 224, 150, 0.018) 2px,
      transparent 2px,
      transparent 16px
    ),
    var(--velvet-mid);
  border: 1px solid rgba(212, 166, 74, 0.28);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.78),
    inset 0 0 60px rgba(0, 0, 0, 0.55);
}

@media (min-width: 450px) {
  .wx-shell {
    border-radius: 26px;
  }
}

.wx-shell.boss-mode {
  background:
    radial-gradient(ellipse at 50% 25%, rgba(140, 22, 42, 0.45) 0%, rgba(28, 10, 18, 0.96) 68%, #0e0609 100%),
    repeating-linear-gradient(
      45deg,
      rgba(255, 110, 80, 0.025) 0px,
      rgba(255, 110, 80, 0.025) 2px,
      transparent 2px,
      transparent 16px
    ),
    #16080d;
  border-color: rgba(244, 63, 94, 0.48);
}

.wx-shell.shake {
  animation: shellShake 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shellShake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-5px, 2px, 0); }
  40% { transform: translate3d(5px, -2px, 0); }
  60% { transform: translate3d(-4px, -1px, 0); }
  80% { transform: translate3d(3px, 1px, 0); }
}

/* ==================== WECHAT TOP BAR ==================== */
.wx-topbar {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: linear-gradient(180deg, rgba(16, 13, 22, 0.96) 0%, rgba(16, 13, 22, 0.84) 100%);
  border-bottom: 1px solid rgba(212, 166, 74, 0.25);
  z-index: 20;
}

.wx-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(212, 166, 74, 0.12);
  border: 1px solid rgba(212, 166, 74, 0.32);
  color: var(--gold-1);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s, transform 0.12s;
}

.wx-back-btn:active {
  transform: scale(0.95);
  background: rgba(212, 166, 74, 0.24);
}

.wx-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  background: linear-gradient(180deg, #fff4cf 0%, #dfaf4c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
}

.wx-capsule {
  display: flex;
  align-items: center;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0 4px;
}

.wx-cap-btn {
  width: 28px;
  height: 24px;
  border: none;
  background: transparent;
  color: #f8f5ec;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.wx-cap-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

.wx-cap-divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.2);
}

/* ==================== TOP HUD ==================== */
.hud-bar {
  flex: 0 0 auto;
  padding: 7px 10px 6px;
  background: linear-gradient(180deg, rgba(14, 12, 20, 0.9) 0%, rgba(12, 14, 18, 0.72) 100%);
  border-bottom: 1px solid rgba(212, 166, 74, 0.2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 15;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hud-floor-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(212, 166, 74, 0.15);
  border: 1px solid rgba(212, 166, 74, 0.4);
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-1);
}

.hud-floor-badge.boss {
  background: rgba(225, 29, 72, 0.28);
  border-color: rgba(251, 113, 133, 0.7);
  color: #fecdd3;
  animation: pulseGlow 1.5s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.35); }
  50% { box-shadow: 0 0 12px 2px rgba(225, 29, 72, 0.65); }
}

.hud-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 2px 4px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.16);
  border: 1px solid rgba(192, 132, 252, 0.38);
  font-size: 12px;
  font-weight: 800;
}

.combo-pill {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 900;
}

.combo-pill.hot {
  background: linear-gradient(135deg, #ec4899, #ef4444);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.score-num {
  color: #f3e8ff;
  font-variant-numeric: tabular-nums;
}

.hud-timer-badge {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.hp-group {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.hp-heart {
  font-size: 14px;
  flex-shrink: 0;
}

.hp-track {
  position: relative;
  flex: 1;
  height: 22px;
  border-radius: 999px;
  background: rgba(20, 10, 14, 0.9);
  border: 1px solid rgba(244, 63, 94, 0.45);
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6);
}

.hp-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #be123c 0%, #f43f5e 60%, #fb7185 100%);
  transition: width 0.28s ease;
}

.hp-fill.low {
  background: linear-gradient(90deg, #991b1b 0%, #ef4444 100%);
  animation: lowHpBlink 0.9s infinite alternate;
}

@keyframes lowHpBlink {
  from { filter: brightness(0.9); }
  to { filter: brightness(1.3); }
}

.shield-overlay {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.35), rgba(125, 211, 252, 0.55));
  border-right: 2px solid rgba(186, 230, 253, 0.8);
  transition: width 0.28s ease;
  pointer-events: none;
}

.hp-text {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  text-align: center;
  line-height: 20px;
  font-size: 11.5px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  font-variant-numeric: tabular-nums;
}

.shield-pill,
.gold-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.shield-pill {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.42);
  color: #bae6fd;
}

.shield-pill.zero {
  opacity: 0.5;
}

.gold-pill {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.48);
  color: #fde68a;
}

/* ==================== RELIC BELT ==================== */
.relic-belt-wrap {
  position: relative;
  flex: 0 0 auto;
  padding: 5px 10px;
  background: rgba(9, 14, 16, 0.72);
  border-bottom: 1px solid rgba(212, 166, 74, 0.16);
  z-index: 16;
}

.relic-belt {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  overflow-x: auto;
  scrollbar-width: none;
}

.relic-belt::-webkit-scrollbar {
  display: none;
}

.relic-empty-hint {
  font-size: 11px;
  color: rgba(212, 198, 168, 0.65);
  white-space: nowrap;
}

.relic-chip {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 6px;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(46, 36, 20, 0.92), rgba(24, 19, 14, 0.95));
  border: 1px solid rgba(212, 166, 74, 0.55);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 236, 170, 0.2);
  color: var(--gold-1);
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s;
}

.relic-chip:hover,
.relic-chip.active {
  transform: translateY(-1px);
  border-color: #fde68a;
  box-shadow: 0 0 10px rgba(245, 198, 92, 0.45);
}

.relic-chip.pulse {
  animation: relicPulse 0.45s ease;
}

@keyframes relicPulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); box-shadow: 0 0 16px rgba(253, 230, 138, 0.85); }
  100% { transform: scale(1); }
}

.relic-chip-icon {
  font-size: 15px;
  line-height: 1;
}

.relic-chip-val {
  font-size: 10.5px;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.2);
  padding: 1px 4px;
  border-radius: 5px;
}

.relic-tooltip {
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(100% + 4px);
  padding: 8px 11px;
  border-radius: 11px;
  background: rgba(18, 15, 26, 0.97);
  border: 1px solid rgba(212, 166, 74, 0.65);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.75);
  font-size: 12px;
  line-height: 1.45;
  color: #f8f5ec;
  z-index: 30;
}

.relic-tooltip strong {
  color: var(--gold-1);
  margin-right: 6px;
}

/* ==================== TABLETOP & 2x2 CARD GRID ==================== */
.tabletop-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 8px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: hidden;
}

.room-status-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(212, 166, 74, 0.16);
  align-self: center;
}

.room-dots {
  display: inline-flex;
  gap: 5px;
}

.room-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(212, 166, 74, 0.45);
  transition: all 0.2s ease;
}

.room-dot.done {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  border-color: #fff3c4;
  box-shadow: 0 0 7px rgba(245, 198, 92, 0.75);
  transform: scale(1.1);
}

.room-status-text {
  font-size: 11px;
  color: #e6dcc8;
  font-weight: 600;
}

/* Boss Header */
.boss-header {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.55), rgba(45, 10, 20, 0.85));
  border: 1px solid rgba(251, 113, 133, 0.55);
  box-shadow: 0 4px 14px rgba(190, 18, 60, 0.3);
}

.boss-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.boss-tag {
  font-size: 9.5px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 5px;
  background: #e11d48;
  color: #fff;
  letter-spacing: 0.6px;
}

.boss-title {
  flex: 1;
  font-size: 12.5px;
  font-weight: 900;
  color: #ffe4e6;
}

.boss-hp-label {
  font-size: 11.5px;
  font-weight: 900;
  color: #fda4af;
  font-variant-numeric: tabular-nums;
}

.boss-hp-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  border: 1px solid rgba(251, 113, 133, 0.35);
}

.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #9f1239 0%, #f43f5e 55%, #fb923c 100%);
  transition: width 0.3s ease;
}

/* 2x2 Card Grid */
.card-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
  perspective: 900px;
}

/* ==================== GOTHIC CARD STYLING ==================== */
.dungeon-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 9px 9px 8px;
  border-radius: 15px;
  border: 1.5px solid var(--gold-border);
  background: linear-gradient(165deg, #211d2e 0%, #15121f 55%, #0f0d17 100%);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 236, 179, 0.16),
    inset 0 0 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  color: var(--text-main);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.16s ease, border-color 0.16s ease;
  animation: cardDealIn 0.34s cubic-bezier(0.2, 0.85, 0.3, 1) backwards;
}

.dungeon-card::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 11px;
  border: 1px solid rgba(212, 166, 74, 0.14);
  pointer-events: none;
}

.dungeon-card:hover:not(.resolved):not(.empty-slot) {
  transform: translateY(-3px) scale(1.015);
  border-color: rgba(253, 230, 138, 0.78);
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.65),
    0 0 16px rgba(212, 166, 74, 0.22);
}

.dungeon-card:active:not(.resolved):not(.empty-slot) {
  transform: scale(0.96);
}

@keyframes cardDealIn {
  0% {
    opacity: 0;
    transform: translateY(-18px) rotateY(-58deg) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotateY(0deg) scale(1);
  }
}

.dungeon-card.carry-over {
  animation: none;
}

.dungeon-card.resolving {
  pointer-events: none;
  animation: cardResolveOut 0.24s ease forwards;
}

@keyframes cardResolveOut {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.06); }
  100% { opacity: 0; transform: scale(0.84) translateY(-10px); }
}

.dungeon-card.boss-hit {
  animation: bossHitAnim 0.28s ease;
}

@keyframes bossHitAnim {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(0.93) translateX(-4px); filter: brightness(1.5); }
  65% { transform: scale(1.03) translateX(4px); }
}

/* Card Type Palettes */
.dungeon-card.type-monster {
  background: linear-gradient(165deg, #2d1421 0%, #1c0f18 58%, #120910 100%);
  border-color: rgba(244, 63, 94, 0.5);
}

.dungeon-card.type-boss {
  background: linear-gradient(165deg, #4c1120 0%, #2a0a14 55%, #16050b 100%);
  border-color: rgba(251, 113, 133, 0.85);
  box-shadow:
    0 0 22px rgba(225, 29, 72, 0.38),
    inset 0 0 24px rgba(251, 113, 133, 0.16);
}

.dungeon-card.type-weapon {
  background: linear-gradient(165deg, #162538 0%, #101927 58%, #0b111b 100%);
  border-color: rgba(96, 165, 250, 0.52);
}

.dungeon-card.type-potion {
  background: linear-gradient(165deg, #112d25 0%, #0d1f1b 58%, #081412 100%);
  border-color: rgba(52, 211, 153, 0.52);
}

.dungeon-card.type-event {
  background: linear-gradient(165deg, #332512 0%, #1f170e 58%, #130e09 100%);
  border-color: rgba(251, 191, 36, 0.65);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 14px rgba(245, 158, 11, 0.18);
}

.dungeon-card.type-bomb {
  background: linear-gradient(165deg, #361d12 0%, #22120c 58%, #140b08 100%);
  border-color: rgba(251, 146, 60, 0.65);
}

.dungeon-card.type-shield {
  background: linear-gradient(165deg, #122836 0%, #0d1c27 58%, #09131b 100%);
  border-color: rgba(56, 189, 248, 0.58);
}

.dungeon-card.wasted-potion {
  opacity: 0.76;
  filter: saturate(0.65);
}

.dungeon-card.empty-slot {
  background: rgba(8, 16, 15, 0.42);
  border: 1.5px dashed rgba(212, 166, 74, 0.22);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.35);
  cursor: default;
  align-items: center;
  justify-content: center;
  gap: 4px;
  animation: none;
}

.dungeon-card.empty-slot::before {
  display: none;
}

.empty-slot-icon {
  font-size: 20px;
  opacity: 0.35;
}

.empty-slot-label {
  font-size: 11px;
  color: rgba(212, 198, 168, 0.4);
  font-weight: 700;
}

/* Card Internal Parts */
.card-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  position: relative;
  z-index: 2;
}

.card-val-badge {
  min-width: 34px;
  height: 28px;
  padding: 0 7px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.type-monster .card-val-badge,
.type-boss .card-val-badge {
  background: linear-gradient(135deg, #be123c, #e11d48);
  color: #fff;
}

.type-weapon .card-val-badge {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
}

.type-potion .card-val-badge {
  background: linear-gradient(135deg, #047857, #10b981);
  color: #fff;
}

.type-event .card-val-badge {
  background: linear-gradient(135deg, #b45309, #f59e0b);
  color: #fff;
}

.type-bomb .card-val-badge {
  background: linear-gradient(135deg, #c2410c, #f97316);
  color: #fff;
}

.type-shield .card-val-badge {
  background: linear-gradient(135deg, #0369a1, #38bdf8);
  color: #fff;
}

.card-type-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e7e1d5;
  white-space: nowrap;
}

.card-carry-tag {
  position: absolute;
  top: 28px;
  right: 0;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(212, 166, 74, 0.22);
  color: var(--gold-1);
}

.card-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  z-index: 2;
  padding: 2px 0;
}

.card-art {
  font-size: clamp(32px, 8.5vw, 44px);
  line-height: 1.05;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.55));
}

.card-name {
  font-size: 13px;
  font-weight: 900;
  color: #fff9eb;
  text-align: center;
  line-height: 1.15;
}

.card-sub {
  font-size: 10.5px;
  color: rgba(232, 224, 210, 0.72);
  text-align: center;
  line-height: 1.2;
}

/* Boss Mini HP bar inside Boss card */
.boss-card-hp {
  width: 92%;
  height: 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(251, 113, 133, 0.45);
  overflow: hidden;
  margin-top: 3px;
}

.boss-card-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #e11d48, #fb923c);
  transition: width 0.25s ease;
}

/* Bottom Outcome Preview Pill on Every Card */
.card-preview {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 5px 6px;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  background: rgba(0, 0, 0, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.card-preview.safe {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(52, 211, 153, 0.55);
  color: #6ee7b7;
}

.card-preview.shielded {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(125, 211, 252, 0.55);
  color: #bae6fd;
}

.card-preview.warn {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(251, 191, 36, 0.55);
  color: #fde68a;
}

.card-preview.danger {
  background: rgba(225, 29, 72, 0.26);
  border-color: rgba(251, 113, 133, 0.65);
  color: #fecdd3;
}

.card-preview.lethal {
  background: rgba(190, 18, 60, 0.5);
  border-color: #fda4af;
  color: #fff;
  animation: lethalPulse 0.9s infinite alternate;
}

@keyframes lethalPulse {
  from { box-shadow: 0 0 0 rgba(244, 63, 94, 0); }
  to { box-shadow: 0 0 12px rgba(244, 63, 94, 0.8); }
}

.card-preview.gold {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(253, 224, 71, 0.55);
  color: #fef08a;
}

.card-preview.violet {
  background: rgba(168, 85, 247, 0.24);
  border-color: rgba(192, 132, 252, 0.6);
  color: #e9d5ff;
}

.card-preview.info {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(147, 197, 253, 0.52);
  color: #dbeafe;
}

/* ==================== VFX & FLOATING POPUPS ==================== */
.vfx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 25;
}

.float-pop {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
  animation: floatUpPop 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: none;
}

.float-pop.dmg { color: #fb7185; }
.float-pop.heal { color: #34d399; }
.float-pop.gold { color: #fde047; }
.float-pop.shield { color: #7dd3fc; }
.float-pop.crit { color: #fbbf24; font-size: 18px; }
.float-pop.zap { color: #d8b4fe; font-size: 16px; }

@keyframes floatUpPop {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -12px) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -54px) scale(0.95); }
}

.banner-toast {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 13, 24, 0.94);
  border: 1.5px solid var(--gold-2);
  color: var(--gold-1);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.72), 0 0 18px rgba(212, 166, 74, 0.35);
  z-index: 28;
  pointer-events: none;
  animation: toastPop 0.25s ease;
}

@keyframes toastPop {
  from { opacity: 0; transform: translate(-50%, -40%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ==================== BOTTOM LOADOUT DOCK ==================== */
.loadout-dock {
  flex: 0 0 auto;
  padding: 8px 10px calc(9px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(16, 14, 24, 0.92) 0%, rgba(10, 9, 15, 0.98) 100%);
  border-top: 1px solid rgba(212, 166, 74, 0.32);
  display: flex;
  gap: 8px;
  align-items: stretch;
  z-index: 15;
}

.weapon-panel {
  flex: 1.48;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(212, 166, 74, 0.28);
}

.weapon-panel.barehand-mode {
  border-color: rgba(168, 85, 247, 0.55);
  background: rgba(168, 85, 247, 0.09);
}

.weapon-main {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.weapon-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.25), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(147, 197, 253, 0.4);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.weapon-info {
  flex: 1;
  min-width: 0;
}

.weapon-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.weapon-name {
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weapon-atk-badge {
  font-size: 11px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.28);
  border: 1px solid rgba(147, 197, 253, 0.45);
  color: #bfdbfe;
  flex-shrink: 0;
}

.weapon-cap-row {
  margin-top: 2px;
}

.weapon-cap-text {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weapon-cap-text.limited {
  color: #fbbf24;
  font-weight: 700;
}

.stance-toggle-btn {
  width: 100%;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  background: rgba(30, 58, 138, 0.38);
  color: #dbeafe;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.stance-toggle-btn.barehand {
  border-color: rgba(192, 132, 252, 0.65);
  background: rgba(126, 34, 206, 0.42);
  color: #f3e8ff;
}

.stance-toggle-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.action-panel {
  flex: 0.96;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.flee-btn {
  flex: 1;
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.5);
  background: linear-gradient(160deg, rgba(180, 110, 25, 0.35), rgba(85, 45, 14, 0.58));
  color: #fef3c7;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.12s, filter 0.15s;
}

.flee-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.flee-btn:disabled {
  opacity: 0.42;
  filter: grayscale(0.75);
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.flee-main {
  font-size: 12.5px;
  font-weight: 900;
}

.flee-sub {
  font-size: 10px;
  color: rgba(254, 243, 199, 0.78);
}

.deck-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 10.5px;
  font-weight: 700;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

/* ==================== START & END OVERLAYS ==================== */
.overlay-screen {
  position: absolute;
  inset: 44px 0 0 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: radial-gradient(circle at 50% 25%, rgba(28, 56, 46, 0.94), rgba(9, 10, 16, 0.98));
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

.start-card,
.end-card {
  width: 100%;
  border-radius: 20px;
  padding: 18px 16px 16px;
  background: linear-gradient(170deg, rgba(28, 24, 38, 0.96) 0%, rgba(14, 13, 22, 0.98) 100%);
  border: 1.5px solid rgba(212, 166, 74, 0.5);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(253, 230, 138, 0.22);
  text-align: center;
  position: relative;
}

.start-emblem {
  position: relative;
  width: 68px;
  height: 68px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
}

.emblem-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 198, 92, 0.34) 0%, transparent 70%);
}

.emblem-icon {
  font-size: 42px;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
}

.emblem-sub-icon {
  position: absolute;
  right: -2px;
  bottom: 0;
  font-size: 24px;
  z-index: 3;
}

.start-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(212, 166, 74, 0.16);
  border: 1px solid rgba(212, 166, 74, 0.45);
  color: var(--gold-1);
  margin-bottom: 6px;
}

.start-title {
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #fff8dc 0%, #eab64d 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.start-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 3px 0 12px;
}

.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.16s;
}

.mode-btn.active {
  border-color: var(--gold-2);
  background: linear-gradient(135deg, rgba(212, 166, 74, 0.2), rgba(212, 166, 74, 0.06));
  box-shadow: 0 0 16px rgba(212, 166, 74, 0.2);
}

.mode-btn-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.mode-name {
  font-size: 13.5px;
  font-weight: 900;
  color: #fff8e7;
}

.mode-tag {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.22);
  color: var(--gold-1);
}

.mode-desc {
  font-size: 11px;
  color: #bfb8ab;
}

.start-rules-box {
  text-align: left;
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(212, 166, 74, 0.18);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 11px;
}

.rule-line {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11.5px;
  line-height: 1.42;
  color: #dfd8cb;
}

.rule-line b {
  color: var(--gold-1);
}

.best-score-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(212, 166, 74, 0.1);
  border: 1px solid rgba(212, 166, 74, 0.28);
  font-size: 12px;
  color: #e6dcc8;
  margin-bottom: 12px;
}

.best-score-strip strong {
  font-size: 15px;
  color: var(--gold-1);
  font-variant-numeric: tabular-nums;
}

.primary-gold-btn {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 13px;
  background: linear-gradient(135deg, #f5c65c 0%, #d9942a 55%, #b46918 100%);
  color: #1c1205;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(217, 148, 42, 0.38), inset 0 1px 0 rgba(255, 250, 220, 0.65);
  transition: transform 0.12s, filter 0.15s;
}

.primary-gold-btn.compact {
  height: 40px;
  font-size: 13.5px;
}

.primary-gold-btn:active {
  transform: scale(0.97);
  filter: brightness(0.95);
}

/* ==================== MODALS (CHOICE & HELP) ==================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(5, 4, 10, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gothic-modal {
  width: 100%;
  max-height: 92%;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 15px;
  border-radius: 18px;
  background: linear-gradient(170deg, #211c2e 0%, #13111c 100%);
  border: 1.5px solid rgba(212, 166, 74, 0.62);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.8), 0 0 24px rgba(212, 166, 74, 0.16);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(212, 166, 74, 0.16);
  border: 1px solid rgba(212, 166, 74, 0.45);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--gold-1);
}

.modal-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-close-x {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.choice-item {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 13px;
  border: 1.5px solid rgba(212, 166, 74, 0.38);
  background: linear-gradient(135deg, rgba(45, 36, 22, 0.55), rgba(22, 19, 32, 0.85));
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
}

.choice-item:hover:not(:disabled) {
  border-color: var(--gold-1);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(212, 166, 74, 0.2);
}

.choice-item:active:not(:disabled) {
  transform: scale(0.98);
}

.choice-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.7);
}

.choice-item-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(253, 230, 138, 0.35);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}

.choice-item-body {
  flex: 1;
  min-width: 0;
}

.choice-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.choice-item-title {
  font-size: 13.5px;
  font-weight: 900;
  color: #fff6db;
}

.choice-item-tag {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.24);
  color: #fde68a;
  flex-shrink: 0;
}

.choice-item-tag.cost {
  background: rgba(234, 179, 8, 0.22);
  color: #fef08a;
}

.choice-item-tag.hp-cost {
  background: rgba(225, 29, 72, 0.25);
  color: #fda4af;
}

.choice-item-desc {
  font-size: 11.5px;
  line-height: 1.4;
  color: #cdc5b8;
  margin-top: 3px;
}

.modal-secondary-btn {
  width: 100%;
  height: 38px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* Help Modal Scroll */
.help-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  max-height: 55vh;
}

.help-section h4 {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-1);
  margin-bottom: 3px;
}

.help-section p,
.help-relic-list li {
  font-size: 12px;
  line-height: 1.48;
  color: #d8d1c4;
}

.help-section code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  color: #fde68a;
}

.help-relic-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==================== END SCREEN ==================== */
.end-rank-stamp {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid var(--gold-1);
  background: linear-gradient(135deg, rgba(245, 198, 92, 0.28), rgba(180, 105, 24, 0.45));
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 900;
  color: var(--gold-1);
  transform: rotate(10deg);
  box-shadow: 0 4px 14px rgba(245, 198, 92, 0.35);
}

.end-icon {
  font-size: 40px;
  margin-bottom: 4px;
}

.end-title {
  font-size: 23px;
  font-weight: 900;
  color: var(--gold-1);
}

.end-title.defeat {
  color: #fda4af;
}

.end-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 3px 0 12px;
}

.end-score-banner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 166, 74, 0.3);
  margin-bottom: 10px;
}

.end-score-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
}

.end-score-label {
  font-size: 11px;
  color: var(--text-muted);
}

.end-score-val {
  font-size: 24px;
  font-weight: 900;
  color: var(--gold-1);
  font-variant-numeric: tabular-nums;
}

.end-score-best {
  font-size: 20px;
  font-weight: 900;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.end-score-divider {
  width: 1px;
  height: 36px;
  background: rgba(212, 166, 74, 0.25);
}

.new-record-tag {
  font-size: 9.5px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  margin-top: 2px;
}

.end-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 11px;
}

.end-stat-box {
  padding: 8px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10.5px;
  color: var(--text-muted);
}

.stat-val {
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.end-relics-section {
  text-align: left;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 166, 74, 0.2);
  margin-bottom: 12px;
}

.end-relics-title {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--gold-1);
  margin-bottom: 6px;
}

.end-relics-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.end-relic-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(212, 166, 74, 0.14);
  border: 1px solid rgba(212, 166, 74, 0.38);
  font-size: 11px;
  font-weight: 700;
  color: #fef3c7;
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.secondary-hub-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  color: #f8f5ec;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 800;
}

/* Compact screen height adjustments */
@media (max-height: 700px) {
  .hud-bar { padding: 5px 10px; gap: 4px; }
  .relic-belt-wrap { padding: 4px 10px; }
  .tabletop-stage { padding: 6px 8px; gap: 5px; }
  .card-grid { gap: 7px; }
  .dungeon-card { padding: 7px; }
  .card-art { font-size: 30px; }
  .loadout-dock { padding: 6px 8px; }
}
