@charset "UTF-8";

:root {
  color-scheme: dark;
  --font-main: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  /* DESIGN.md: PlayStation Marketing System */
  --color-primary: #0070d1;
  --color-primary-pressed: #0064b7;
  --color-primary-active: #004d8d;
  --on-primary: #ffffff;

  --color-commerce: #d53b00;
  --color-commerce-pressed: #aa2f00;
  --on-commerce: #ffffff;

  /* Canvas & Surface */
  --canvas-dark: #000000;
  --canvas-light: #ffffff;
  --surface-dark-elevated: #121314;
  --surface-dark-card: #181818;
  --surface-soft: #f3f3f3;
  --surface-card: #f5f7fa;
  --surface-filter: rgba(245, 247, 250, 0.3);

  /* Ink */
  --ink: #000000;
  --ink-deep: #121314;
  --ink-elevated: #181818;
  --body-light: rgba(0, 0, 0, 0.6);
  --body-dark: rgba(255, 255, 255, 0.7);
  --mute-light: #6b6b6b;
  --mute-dark: rgba(229, 229, 229, 0.55);
  --ash-light: #cccccc;
  --ash-dark: rgba(229, 229, 229, 0.2);

  /* Hairlines */
  --hairline-light: #f3f3f3;
  --hairline-dark: rgba(229, 229, 229, 0.2);

  /* Links */
  --link-light: #0064b7;
  --link-dark: #53b1ff;

  /* Warning */
  --color-warning: #c81b3a;

  /* Semantic aliases (backward compat with existing CSS) */
  --bg-deep: var(--canvas-dark);
  --bg-surface: var(--surface-dark-elevated);
  --bg-panel: var(--surface-dark-elevated);
  --bg-panel-sub: var(--surface-dark-card);
  --bg-card: var(--surface-dark-card);
  --bg-card-hover: var(--surface-dark-elevated);
  --ink-primary: var(--on-dark, #ffffff);
  --ink-secondary: var(--body-dark);
  --ink-muted: var(--mute-dark);
  --ink-dim: var(--ash-dark);
  --on-dark: #ffffff;
  --color-blue: var(--color-primary);
  --color-blue-dark: var(--color-primary-pressed);
  --color-blue-glow: rgba(0, 112, 209, 0.35);
  --border-subtle: var(--hairline-dark);
  --border-strong: rgba(229, 229, 229, 0.35);
  --border-focus: var(--color-primary);
  /* Legacy aliases used by existing component styles. */
  --color-brand: var(--color-primary);
  --color-cyan: var(--color-primary);

  /* Rarity tiers — 统一色板（霓虹档，保证在 #121626 深底上醒目）：
     普通=米白 / 优秀=绿 / 稀有=天蓝 / 史诗=紫 / 传说=品红红。
     传说用 #ff2d6f 而非蓝：与 warrior 主题蓝、稀有档蓝撞色，
     也与既定红（rogue #ef4444 / 珊瑚 #ff756d）区分开。 */
  --rarity-1: #f4f1ea;
  --rarity-1-bg: rgba(244, 241, 234, 0.14);
  --rarity-2: #4ade80;
  --rarity-2-bg: rgba(74, 222, 128, 0.16);
  --rarity-3: #38bdf8;
  --rarity-3-bg: rgba(56, 189, 248, 0.16);
  --rarity-4: #c084fc;
  --rarity-4-bg: rgba(192, 132, 252, 0.18);
  --rarity-5: #ff2d6f;
  --rarity-5-bg: rgba(255, 45, 111, 0.18);

  /* P3 Shattered Ring Observatory tokens and compatibility aliases. */
  --obs-night: #091126;
  --obs-night-2: #0e1932;
  --obs-panel: #101d38e8;
  --obs-moon: #ecf5ff;
  --obs-muted: #8ca0be;
  --obs-ice: #79e2ef;
  --ember-coral: #ff766d;
  --ember-soft: #ff766d24;
  --ring-ghost: #b8d5e01f;
  --obs-line: #2a4669;
  --portrait-ink: #11131a;
  --portrait-ivory: #e9e1d2;
  --primary: var(--obs-ice);
  --action: var(--ember-coral);
  --color-primary: var(--obs-ice);
  --color-primary-pressed: #5ccfdb;
  --color-primary-active: #3aa8b4;
  --color-brand: var(--obs-ice);
  --color-cyan: var(--obs-ice);
  --color-blue: var(--obs-ice);
  --color-blue-dark: #3aa8b4;
  --color-blue-glow: var(--ember-soft);
  --color-commerce: var(--ember-coral);
  --color-commerce-pressed: #e65e59;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  font-family: var(--font-main);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--ink-primary);
}
/* Ambient Lighting — magenta/cyan duotone */
body::before {
  content: "";
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.07) 0%, rgba(37, 99, 235, 0.05) 45%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Main Container Shell */
#game-shell {
  position: relative;
  width: min(100vw, 450px);
  height: min(100vh, 880px);
  max-height: 920px;
  background: var(--bg-surface);
  overflow: hidden;
  box-shadow: 0 25px 70px -15px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(53, 224, 232, 0.12);
  display: flex;
  flex-direction: column;
}

/* Combat uses the complete viewport so the arena and dodge space are not letterboxed. */
#game-shell.battle-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
}

@media (min-width: 480px) {
  #game-shell {
    border-radius: 0;
  }

  #game-shell.battle-fullscreen {
    border-radius: 0;
  }
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  z-index: 1;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.scroll-container > * {
  animation: p3rCardIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.scroll-container > *:nth-child(1) { animation-delay: 0.08s; }
.scroll-container > *:nth-child(2) { animation-delay: 0.12s; }
.scroll-container > *:nth-child(3) { animation-delay: 0.16s; }
.scroll-container > *:nth-child(4) { animation-delay: 0.20s; }
.scroll-container > *:nth-child(5) { animation-delay: 0.24s; }
.scroll-container > *:nth-child(6) { animation-delay: 0.28s; }
.scroll-container > *:nth-child(n+7) { animation-delay: 0.32s; }

@keyframes p3rCardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* Scrollable Container */
.scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 2px 14px;
  display: grid;
  gap: 10px;
  scrollbar-width: none;
}

.scroll-container::-webkit-scrollbar {
  display: none;
}

/* ========================================================
   SCREEN: ROLE SELECTION (角色选择 - 战术英雄卡)
   ======================================================== */

.hero-puppet-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}

/* The radar is drawn inside the combat canvas. Reserve the lower-right corner so
   the touch joystick and its gesture area keep a clear, predictable lane. */
#game-shell.battle-fullscreen #game-canvas {
  touch-action: none;
}

/* ========================================================
   SCREEN: UPGRADE (属性强化 / 等级提升)
   ======================================================== */

.upgrade-card {
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  padding: 14px 16px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

.upgrade-card:hover {
  border-color: var(--color-brand);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--color-magenta-glow);
}

.upgrade-card:active {
  transform: translateY(1px);
}

.rpg-icon {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 0 2px rgba(255, 42, 68, 0.6)) drop-shadow(0 0 6px rgba(255, 42, 68, 0.25));
  transition: filter 0.2s ease;
}

/* 位图图集 sprite（assets/icons-atlas/atlas_0.webp，96px 格）：背景图放大到整张,
   按格换算百分比定位, 随容器缩放, 与 .rpg-icon 同构可直接互换 */
.rpg-icon-atlas {
  width: 100%;
  height: 100%;
  display: block;
  background-image: url("assets/icons-atlas/atlas_0.webp");
  background-size: 2133.3333% 2133.3333%;
  background-repeat: no-repeat;
  border-radius: 10%;
}

.upgrade-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  background: radial-gradient(circle at center, #161a24 0%, #0a0c12 100%);
  border: 1.5px solid rgba(255, 42, 68, 0.45);
  color: #ff2a44;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 6px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(255, 42, 68, 0.25), inset 0 0 8px rgba(0, 0, 0, 0.7);
  transition: all 0.2s ease;
}

.upgrade-icon-wrap:hover {
  border-color: #ff2a44;
  box-shadow: 0 0 16px rgba(255, 42, 68, 0.5), inset 0 0 10px rgba(255, 42, 68, 0.2);
  transform: scale(1.04);
}

.upgrade-icon-wrap svg,
.upgrade-icon-wrap .rpg-icon {
  width: 28px;
  height: 28px;
  display: block;
}

.upgrade-content {
  flex: 1;
}

.upgrade-name {
  font-size: 16px;
  font-weight: 900;
  color: var(--ink-primary);
  display: block;
}

.upgrade-desc {
  font-size: 13px;
  font-weight: 700;
  color: #4ade80;
  margin-top: 3px;
  display: block;
}

.upgrade-btn-tag {
  padding: 6px 12px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.upgrade-card:hover .upgrade-btn-tag {
  background: var(--color-brand);
  color: #ffffff;
  border-color: var(--color-brand);
}

/* ========================================================
   TOAST & NOTIFICATIONS
   ======================================================== */
#toast {
  position: absolute;
  top: auto;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  padding: 10px 18px;
  border-radius: 2px;
  color: #ffffff;
  background: rgba(9, 15, 28, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 13.5px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  display: none;
}

#toast.show {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastDrop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastDrop {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ========================================================
   MODALS: GALLERY & SETTINGS (图鉴与设置模态框)
   CRITICAL: pointer-events: auto on overlay and sheet to guarantee close button works!
   ======================================================== */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 11, 17, 0.85);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: auto !important;
  animation: fadeIn 0.18s ease;
}

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

.modal-sheet {
  background: rgba(9, 15, 28, 0.98);
  border: 1px solid var(--border-strong);
  border-top: 2px solid var(--color-cyan);
  border-radius: 0;
  border-radius: 8px;
  padding: 16px 18px 24px;
  height: 86%;
  max-height: 88%;
  min-height: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto !important;
  box-shadow: 0 -12px 44px rgba(0, 0, 0, 0.65), 0 0 24px rgba(53, 224, 232, 0.1);
  animation: sheetUp 0.26s cubic-bezier(0.34, 1.36, 0.54, 1);
  overflow: hidden;
  position: relative;
}

.modal-sheet-handle {
  width: 40px;
  height: 4.5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  align-self: center;
  margin-bottom: 4px;
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
}

@keyframes sheetUp {
  from { transform: translateY(100%) skewY(1.5deg); opacity: 0.6; }
  to { transform: translateY(0) skewY(0); opacity: 1; }
}

.modal-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border-subtle);
  flex-shrink: 0;
  touch-action: pan-y;
}

.modal-sheet-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  color: var(--ink-primary);
}

.modal-sheet .scroll-container,
.scroll-container {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  height: 100% !important;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  overscroll-behavior-y: contain !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  padding-bottom: 32px !important;
  padding-right: 2px !important;
}

.btn-close-modal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: #1a293b;
  color: var(--ink-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto !important;
  transition: all 0.15s ease;
}

.btn-close-modal:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  transform: scale(1.08);
}

.btn-close-modal:active {
  transform: scale(0.94);
}

/* ====================================================
   SETTINGS MODAL REDESIGN (机能星痕战术系统设置面板)
   ==================================================== */
#modal-settings-sheet {
  background: radial-gradient(circle at 50% 0%, rgba(26, 18, 48, 0.96) 0%, rgba(10, 7, 18, 0.98) 70%, #05040a 100%);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-top: 2px solid #38bdf8;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.85), 0 0 28px rgba(56, 189, 248, 0.12);
  padding: 16px 18px 24px;
}

#modal-settings-sheet .modal-sheet-handle {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.2), rgba(251, 191, 36, 0.5), rgba(56, 189, 248, 0.2));
  width: 48px;
  height: 4px;
}

.settings-sheet-header {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.settings-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fbbf24;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
  width: fit-content;
}

.settings-badge .badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 6px #fbbf24;
}

.settings-main-title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.settings-subtitle {
  font-size: 11px;
  color: #94a3b8;
  letter-spacing: 0.2px;
}

.settings-close-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  background: rgba(19, 14, 36, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.settings-close-btn:hover {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
  transform: scale(1.05);
}

.settings-section-heading {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #38bdf8;
  text-transform: uppercase;
  margin: 14px 0 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.3), transparent);
}

.settings-section-heading.is-danger {
  color: #f87171;
}

.settings-section-heading.is-danger::after {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.3), transparent);
}

.setting-tactical-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(20, 16, 38, 0.75) 0%, rgba(12, 9, 21, 0.9) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 60px;
  box-sizing: border-box;
}

.setting-tactical-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.25), transparent);
  opacity: 0.5;
}

.setting-tactical-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(135deg, rgba(28, 22, 54, 0.85) 0%, rgba(16, 12, 30, 0.95) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 12px rgba(56, 189, 248, 0.1);
}

.setting-tactical-card.is-danger-card {
  border-color: rgba(239, 68, 68, 0.25);
  background: linear-gradient(135deg, rgba(38, 14, 20, 0.7) 0%, rgba(18, 8, 12, 0.88) 100%);
}

.setting-tactical-card.is-danger-card:hover {
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 14px rgba(239, 68, 68, 0.2);
}

.setting-icon-box {
  width: 48px;
  height: 48px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #1b1532 0%, #0c0915 100%);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 10px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.6), 0 0 10px rgba(56, 189, 248, 0.1);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.setting-tactical-card:hover .setting-icon-box {
  border-color: #38bdf8;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6), 0 0 14px rgba(56, 189, 248, 0.35);
  transform: scale(1.05);
}

.setting-icon-box.is-danger-icon {
  background: radial-gradient(circle at center, #2e1117 0%, #0e0507 100%);
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.6), 0 0 10px rgba(239, 68, 68, 0.15);
}

.setting-tactical-card:hover .setting-icon-box.is-danger-icon {
  border-color: #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.4);
}

.setting-icon-box svg {
  width: 28px !important;
  height: 28px !important;
  display: block;
}

.setting-content-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.setting-title {
  font-size: 14px;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.3;
}

.setting-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.setting-status-active {
  color: #38bdf8;
  font-weight: 700;
}

.setting-status-muted {
  color: #64748b;
}

.setting-toggle-switch {
  width: 48px;
  height: 26px;
  min-width: 48px;
  background: rgba(15, 23, 42, 0.9);
  border: 1.5px solid rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  padding: 2px;
  box-sizing: border-box;
}

.setting-toggle-switch .switch-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  transform: translateX(2px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.setting-toggle-switch.is-active {
  background: rgba(6, 182, 212, 0.25);
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.setting-toggle-switch.is-active .switch-thumb {
  transform: translateX(22px);
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8, 0 2px 4px rgba(0, 0, 0, 0.6);
}

.setting-action-btn {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.setting-action-btn:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
  transform: translateY(-1px);
}

.setting-action-btn.is-overclock {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.12);
}

.setting-danger-btn {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.setting-danger-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}

/* ========================================================
   MODAL: BACKGROUND CUSTOMIZER (关卡背景定制)
   ======================================================== */
.modal-sheet .scroll-container {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 24px;
  user-select: none;
  -webkit-user-select: none;
}

.modal-section-title {
  font-size: 13px;
  font-weight: 800;
  color: #35e0e8;
  margin: 6px 0 8px;
  user-select: none;
  -webkit-user-select: none;
}

.bg-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
  touch-action: pan-y;
}

.bg-preset-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  min-height: 120px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

.bg-preset-card:hover {
  border-color: #35e0e8;
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.bg-preset-card:active {
  transform: scale(0.97);
}

.bg-preset-card.active {
  border-color: #fbbf24;
  background: radial-gradient(circle at center, rgba(251, 191, 36, 0.15) 0%, rgba(15, 26, 39, 0.95) 100%);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.35);
}

.bg-preset-thumb {
  width: 100%;
  height: 52px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #091019;
}

.bg-preset-thumb svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bg-url-input-box {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.bg-url-input-field {
  flex: 1;
  background: rgba(9, 15, 28, 0.8);
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  padding: 8px 12px;
  color: var(--ink-primary);
  font-size: 12px;
  outline: none;
  transition: all 0.15s ease;
}

.bg-url-input-field:focus {
  border-color: #35e0e8;
  box-shadow: 0 0 8px rgba(53, 224, 232, 0.3);
}

.btn-apply-url {
  background: linear-gradient(135deg, #0e7490, #0369a1);
  color: #ffffff;
  border: 1px solid #35e0e8;
  border-radius: 3px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-apply-url:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  transform: translateY(-1px);
}

.bg-preset-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bg-preset-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-primary);
}

.bg-preset-desc {
  font-size: 10.5px;
  color: var(--ink-secondary);
  line-height: 1.3;
}

.bg-preset-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(53, 224, 232, 0.15);
  color: #35e0e8;
  align-self: flex-start;
  margin-top: 2px;
}

.bg-preset-card.active .bg-preset-badge {
  background: #fbbf24;
  color: #0c0c16;
}

.bg-upload-zone {
  border: 2px dashed rgba(53, 224, 232, 0.4);
  background: rgba(9, 15, 28, 0.6);
  border-radius: 5px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 10px;
}

.bg-upload-zone:hover, .bg-upload-zone.dragover {
  border-color: #35e0e8;
  background: rgba(53, 224, 232, 0.1);
}

.bg-upload-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.bg-upload-text {
  font-size: 12.5px;
  color: var(--ink-primary);
}

.btn-subtle-pill {
  padding: 8px 14px;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--ink-primary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-subtle-pill:hover {
  background: var(--bg-card-hover);
  border-color: #35e0e8;
}

.btn-subtle-pill.danger {
  color: #ef4444;
  border-color: #991b1b;
  width: 100%;
}

/* ====================================================
   MOBILE TOUCH & SCROLLABLE INTERFACE OPTIMIZATIONS
   ==================================================== */
.scroll-container{
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
}

/* Touch friendly custom scrollbars */
.scroll-container::-webkit-scrollbar{
  width: 4px;
  height: 4px;
}

.scroll-container::-webkit-scrollbar-thumb{
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

/* ====================================================
   MOBILE VIEWPORT BASELINE
   Keep each screen scrollable on short devices while preserving
   dedicated horizontal carousels and the battle canvas gesture layer.
   ==================================================== */
@media (max-width: 640px) {
  html,
  body {
    min-height: 100%;
    height: 100%;
  }

  body {
    min-height: 100dvh;
    align-items: stretch;
  }

  #game-shell {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    min-height: 100svh;
    max-height: none;
    border-radius: 0;
  }

  .scroll-container{
    min-height: 0;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .modal-overlay {
    padding-top: env(safe-area-inset-top);
  }

  .modal-sheet {
    width: 100%;
    max-width: 100%;
    max-height: calc(92dvh - env(safe-area-inset-top));
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  #toast {
    top: auto;
    bottom: calc(78px + env(safe-area-inset-bottom));
    max-width: min(280px, calc(100vw - 32px));
    padding: 7px 12px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.25;
  }

}

/* 效果数值着色：正面绿色 / 负面红色 */
.fx-pos {
  color: #4ade80;
  font-weight: 600;
}

.fx-neg {
  color: #f87171;
  font-weight: 600;
}

/* ========================================================
   P3R BASELINE V2: ASH ARCHIVE / SHATTERED RING
   This is the real skin pass. It intentionally changes the
   component grammar instead of only swapping accent colors.
   ======================================================== */
:root {
  --canvas-dark: #0d0a0d;
  --surface-dark-elevated: #171116;
  --surface-dark-card: #21171c;
  --obs-night: #0d0a0d;
  --obs-night-2: #1a1117;
  --obs-panel: rgba(28, 18, 23, 0.94);
  --obs-moon: #f6e9e3;
  --obs-muted: #b29e9a;
  --obs-ice: #b8d8ce;
  --ember-coral: #ef6f61;
  --ember-soft: rgba(239, 111, 97, 0.16);
  --ring-ghost: rgba(235, 202, 192, 0.16);
  --obs-line: #60494a;
  --portrait-ink: #251318;
  --portrait-ivory: #f3dfd5;
  --color-primary: var(--ember-coral);
  --color-primary-pressed: #d95d54;
  --color-primary-active: #b94b45;
  --color-brand: var(--ember-coral);
  --color-cyan: var(--obs-ice);
  --color-blue: var(--obs-ice);
  --color-blue-dark: #87aea3;
  --color-blue-glow: var(--ember-soft);
  --color-commerce: var(--ember-coral);
  --color-commerce-pressed: #d95d54;
  --bg-deep: var(--canvas-dark);
  --bg-surface: var(--surface-dark-elevated);
  --bg-panel: var(--obs-panel);
  --bg-panel-sub: #21171c;
  --bg-card: #21171c;
  --bg-card-hover: #2b1c22;
  --ink-primary: var(--obs-moon);
  --ink-secondary: #d6c2bc;
  --ink-muted: var(--obs-muted);
  --border-subtle: rgba(235, 202, 192, 0.16);
  --border-strong: var(--obs-line);
}

html, body {
  background:
    radial-gradient(circle at 50% -10%, rgba(239, 111, 97, 0.12), transparent 38%),
    #0d0a0d;
}

body::before {
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  transform: none;
  opacity: 0.62;
  background:
    linear-gradient(90deg, transparent 0 7%, rgba(235, 202, 192, 0.035) 7.1%, transparent 7.3% 92.7%, rgba(235, 202, 192, 0.035) 92.8%, transparent 93%),
    repeating-linear-gradient(0deg, rgba(235, 202, 192, 0.025) 0 1px, transparent 1px 9px);
  filter: none;
}

#game-shell {
  background: var(--obs-night);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.78), inset 0 1px 0 rgba(239, 111, 97, 0.22);
}

/* All modal/card families inherit the archive grammar. */
.modal-sheet{
  border-radius: 3px !important;
  box-shadow: none !important;
  background:
    linear-gradient(135deg, rgba(239, 111, 97, 0.055), transparent 34%),
    rgba(33, 23, 28, 0.92);
}

.modal-sheet{
  border-color: var(--obs-line) !important;
  border-top: 3px solid var(--ember-coral) !important;
}

/* ========================================================================== */
/* TDXD UI 3.0: TACTICAL TERMINAL & REVOLUTIONARY LAYOUT REDESIGN             */
/* ========================================================================== */

:root {
  --tdxd-glow-coral: rgba(255, 85, 51, 0.45);
  --tdxd-glow-cyan: rgba(0, 229, 255, 0.35);
  --tdxd-glow-purple: rgba(168, 85, 247, 0.4);
  --tdxd-border-tactical: rgba(56, 189, 248, 0.28);
  --tdxd-bg-tactical: rgba(14, 22, 38, 0.92);
}

.hero-standing-raster-img {
  width: 100%;
  height: 100%;
  max-width: 290px;
  max-height: 380px;
  object-fit: contain;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.85));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================================
   HERO-ADAPTIVE BATTLE UI THEMES (角色自适应战斗主色调)
   primary 色值对齐 src/portraits.js 各角色档案 themeColor，
   与选角/档案/立绘处的角色主色调保持一致。
   ======================================================== */
#game-shell[data-battle-hero="ranger"] {
  --battle-hero-primary: #06b6d4;
  --battle-hero-accent: #22d3ee;
  --battle-hero-light: #a5f3fc;
  --battle-hero-dark: #083344;
  --battle-hero-glow: rgba(6, 182, 212, 0.45);
  --battle-hero-glow-strong: rgba(34, 211, 238, 0.75);
  --battle-hero-surface: rgba(6, 182, 212, 0.14);
  --battle-hero-surface-hover: rgba(6, 182, 212, 0.25);
  --battle-hero-border: rgba(34, 211, 238, 0.6);
  --battle-hero-border-focus: rgba(34, 211, 238, 0.95);
  --ember-coral: #06b6d4;
}

#game-shell[data-battle-hero="warrior"] {
  --battle-hero-primary: #38bdf8;
  --battle-hero-accent: #7dd3fc;
  --battle-hero-light: #bae6fd;
  --battle-hero-dark: #0c4a6e;
  --battle-hero-glow: rgba(56, 189, 248, 0.45);
  --battle-hero-glow-strong: rgba(125, 211, 252, 0.75);
  --battle-hero-surface: rgba(56, 189, 248, 0.14);
  --battle-hero-surface-hover: rgba(56, 189, 248, 0.25);
  --battle-hero-border: rgba(125, 211, 252, 0.6);
  --battle-hero-border-focus: rgba(125, 211, 252, 0.95);
  --ember-coral: #38bdf8;
}

#game-shell[data-battle-hero="mage"] {
  --battle-hero-primary: #b780f0;
  --battle-hero-accent: #c084fc;
  --battle-hero-light: #f3e8ff;
  --battle-hero-dark: #3b0764;
  --battle-hero-glow: rgba(183, 128, 240, 0.45);
  --battle-hero-glow-strong: rgba(192, 132, 252, 0.75);
  --battle-hero-surface: rgba(183, 128, 240, 0.14);
  --battle-hero-surface-hover: rgba(183, 128, 240, 0.25);
  --battle-hero-border: rgba(192, 132, 252, 0.6);
  --battle-hero-border-focus: rgba(192, 132, 252, 0.95);
  --ember-coral: #b780f0;
}

#game-shell[data-battle-hero="engineer"] {
  --battle-hero-primary: #f59e0b;
  --battle-hero-accent: #fcd34d;
  --battle-hero-light: #fde68a;
  --battle-hero-dark: #78350f;
  --battle-hero-glow: rgba(245, 158, 11, 0.45);
  --battle-hero-glow-strong: rgba(252, 211, 77, 0.75);
  --battle-hero-surface: rgba(245, 158, 11, 0.14);
  --battle-hero-surface-hover: rgba(245, 158, 11, 0.25);
  --battle-hero-border: rgba(252, 211, 77, 0.6);
  --battle-hero-border-focus: rgba(252, 211, 77, 0.95);
  --ember-coral: #f59e0b;
}

#game-shell[data-battle-hero="gambler"] {
  --battle-hero-primary: #dfb447;
  --battle-hero-accent: #f0ce7e;
  --battle-hero-light: #f7e8c0;
  --battle-hero-dark: #71501a;
  --battle-hero-glow: rgba(223, 180, 71, 0.45);
  --battle-hero-glow-strong: rgba(240, 206, 126, 0.75);
  --battle-hero-surface: rgba(223, 180, 71, 0.14);
  --battle-hero-surface-hover: rgba(223, 180, 71, 0.25);
  --battle-hero-border: rgba(240, 206, 126, 0.6);
  --battle-hero-border-focus: rgba(240, 206, 126, 0.95);
  --ember-coral: #dfb447;
}

#game-shell[data-battle-hero="rogue"] {
  --battle-hero-primary: #ef4444;
  --battle-hero-accent: #f87171;
  --battle-hero-light: #fecdd3;
  --battle-hero-dark: #881337;
  --battle-hero-glow: rgba(239, 68, 68, 0.45);
  --battle-hero-glow-strong: rgba(248, 113, 113, 0.75);
  --battle-hero-surface: rgba(239, 68, 68, 0.14);
  --battle-hero-surface-hover: rgba(239, 68, 68, 0.25);
  --battle-hero-border: rgba(248, 113, 113, 0.6);
  --battle-hero-border-focus: rgba(248, 113, 113, 0.95);
  --ember-coral: #ef4444;
}

/* ========================================================
   TAROT LEVEL LOADING SCREEN (塔罗关卡加载界面)
   三档竖屏 clamp：360→16/30px，390→17/32px，430→18/36px；
   精英红 #ef4444 / Boss 粉 #f472b6 / 逆位为背景牌 180° 纯视觉变换。
   ======================================================== */
.tarot-load-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  background:
    radial-gradient(circle at 50% 48%, rgba(20, 16, 40, 0.96) 0%, rgba(11, 8, 22, 0.98) 60%, rgba(5, 3, 10, 0.995) 100%);
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.tarot-load-overlay.is-shown {
  opacity: 1;
}

/* 轮盘舞台容器 (严格对齐参考图：大曲率机械时钟罗盘，仅截取显露顶部弧面) */
.tarot-roulette-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden; /* 重点：水平裁切只显示罗盘顶部一小段圆弧！ */
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* 巨型金色占星时钟轮盘 (数字精准对齐当前关卡塔罗序号) */
.tarot-roulette-wheel {
  position: absolute;
  width: 1160px;
  height: 1160px;
  left: 50%;
  top: 78px;
  margin-left: -580px;
  transform-origin: 580px 580px;
  transform: rotate(0deg);
  pointer-events: none;
}

.tarot-roulette-wheel.has-spun {
  transform: rotate(0deg);
}

.tarot-roulette-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 16px 36px rgba(0, 0, 0, 0.9));
}

/* 塔罗牌贴在罗盘底座上 (严格1:1无重叠几何尺寸：96x162，正面朝外，双层金边与四角蔓草) */
.tarot-load-card {
  position: absolute;
  left: 50%;
  top: 52px;
  width: 96px;
  height: 154px;
  margin-left: -48px;
  z-index: 6;
  transform-origin: 48px 528px;
  pointer-events: auto;
  opacity: 1;
}

/* 侧翼轮盘槽位卡牌：保持实体不透明与大气透视微暗调 */
.tarot-load-card.is-slot {
  z-index: 6;
  opacity: 0.95;
  filter: brightness(0.82) contrast(0.96);
}

/* 上一关卡牌：切入前处于指针正中 */
.tarot-load-card.is-prev {
  z-index: 8;
  opacity: 1;
  filter: brightness(0.95);
}

/* 本关目标卡牌：指针正中焦点，旋转停稳后 3D 翻转并放大至顶层 */
.tarot-load-card.is-cur {
  z-index: 10;
  opacity: 1;
  filter: brightness(1);
}

.tarot-roulette-wheel.has-spun .tarot-load-card.is-cur {
  z-index: 50;
  filter: brightness(1);
}

.tarot-roulette-wheel.has-spun .tarot-load-card.is-prev,
.tarot-roulette-wheel.has-spun .tarot-load-card.is-slot,
.tarot-roulette-wheel.has-spun .tarot-roulette-svg {
  opacity: 0.32;
  filter: brightness(0.65) blur(1.2px);
  transition: opacity 1.2s ease, filter 1.2s ease;
}

/* 3D 卡牌容器与 Y 轴翻转器 (停稳后飞移至屏幕正中央并放大 2.3x) */
.tarot-card-3d {
  width: 100%;
  height: 100%;
  position: relative;
  perspective: 900px;
}

.tarot-card-flipper {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform-origin: center center;
  transition: transform 1.36s cubic-bezier(0.18, 0.95, 0.25, 1), filter 1.0s ease;
  transform: translateY(0) rotateY(0deg) rotateZ(0deg) scale(1);
}

/* 进场/转动未揭开状态：卡背朝外，处于轮盘槽位 (rotateY 180deg) */
.tarot-card-flipper.is-unrevealed {
  transform: translateY(0) rotateY(180deg) rotateZ(0deg) scale(1);
}

/* 轮盘普通槽位与前序卡牌揭面状态 (保持在轮盘上，1.0x 贴附) */
.tarot-card-flipper.is-revealed {
  transform: translateY(0) rotateY(0deg) rotateZ(0deg) scale(1);
}

/* 轮盘历史已揭开槽位卡牌逆位形态：在轮盘槽位上就地 180° 倒悬，微弱朱砂暗晕 */
.tarot-card-flipper.is-revealed.is-reversed {
  transform: translateY(0) rotateY(0deg) rotateZ(180deg) scale(1);
  filter: drop-shadow(0 4px 12px rgba(193, 58, 38, 0.55));
}

/* 本关当前目标卡牌 (只有目标卡牌转动停稳后飞移至屏幕正中央并放大 2.3x) */
.tarot-load-card.is-cur .tarot-card-flipper.is-revealed {
  transform: translateY(168px) rotateY(0deg) rotateZ(0deg) scale(2.3);
  filter: drop-shadow(0 20px 48px rgba(16, 11, 7, 0.98)) drop-shadow(0 0 32px rgba(223, 190, 121, 0.65)) drop-shadow(0 0 16px rgba(250, 241, 208, 0.45));
}

/* 逆位倒悬：前摇左右摆动蓄力 → 一瞬间翻到 180°。
   为什么不用 transition：这是一段**多相位**运动（摆动 3 次再急转），单条 transition 只能
   从 A 单调插到 B，表达不了前摇，所以走 @keyframes。
   为什么不能复用揭面那条缓动：它 y2>1 会过冲，用在原地旋转上就是冲过 180° 再弹回来
   （实测冲到 183.6°、回摆约 400ms，卡片角上十几像素的晃）。
   时序：挂载点、时长与 browser-main.js 的 INVERT_LEAD_MS / INVERT_MS 同源，别单独改。
   改这里要连同 tarot-preview.html 的内联镜像一起改。 */
/* 逆位倒悬：z 轴 5Hz 微幅摆动蓄力 → 一瞬间翻到 180°。
   为什么不用 transition：这是一段**多相位**运动（高频摆动再急转），单条 transition 只能
   从 A 单调插到 B，表达不了前摇，所以走 @keyframes。
   为什么不能复用揭面那条缓动：它 y2>1 会过冲，用在原地旋转上就是冲过 180° 再弹回来
   （实测冲到 183.6°、回摆约 400ms，卡片角上十几像素的晃）。
   摆动规格：z 轴（屏幕平面内）、**顺时针先摆**（CSS rotateZ 正角即顺时针）、±2°、5Hz。
   5Hz = 周期 200ms，所以键的间距是 **100ms 绝对时间**，不是固定百分比——
   整个动画时长一变（0.75s→0.6s），百分比就得跟着重算，否则频率会偷偷变掉。
   当前 0.6s：前 400ms 走 2 个周期（键在 50/100/…/400ms），后 200ms 一瞬翻完 180°。
   时序：挂载点、时长与 browser-main.js 的 INVERT_LEAD_MS / INVERT_MS 同源，别单独改。
   改这里要连同 tarot-preview.html 的内联镜像一起改。 */
@keyframes tarot-invert {
  0%      { transform: translateY(168px) rotateY(0deg) rotateZ(0deg)    scale(2.3); }
  8.333%  { transform: translateY(168px) rotateY(0deg) rotateZ(2deg)    scale(2.3); }
  16.667% { transform: translateY(168px) rotateY(0deg) rotateZ(0deg)    scale(2.3); }
  25%     { transform: translateY(168px) rotateY(0deg) rotateZ(-2deg)   scale(2.3); }
  33.333% { transform: translateY(168px) rotateY(0deg) rotateZ(0deg)    scale(2.3); }
  41.667% { transform: translateY(168px) rotateY(0deg) rotateZ(2deg)    scale(2.3); }
  50%     { transform: translateY(168px) rotateY(0deg) rotateZ(0deg)    scale(2.3); }
  58.333% { transform: translateY(168px) rotateY(0deg) rotateZ(-2deg)   scale(2.3); }
  66.667% { transform: translateY(168px) rotateY(0deg) rotateZ(0deg)    scale(2.3);
            animation-timing-function: cubic-bezier(0.22, 0.9, 0.28, 1); }
  100%    { transform: translateY(168px) rotateY(0deg) rotateZ(180deg)  scale(2.3); }
}

.tarot-load-card.is-cur .tarot-card-flipper.is-revealed.is-reversed {
  /* transform 交给上面的动画（两者同时挂会互相打架）。
     filter 只留 0.1s 过渡，而且**刻意不在这里写 filter**：蓄力摆动期间沿用揭面那条金光，
     真正的转红由 .is-reddened 在落定前 0.1s 触发（见下面的红色滤镜块）。 */
  transition: filter 0.1s linear;
  animation: tarot-invert 0.6s cubic-bezier(0.45, 0, 0.55, 1) both;
  transform: translateY(168px) rotateY(0deg) rotateZ(180deg) scale(2.3);
}

/* 倒悬落定的红色滤镜：以**状态**压上来，不是闪一下就退。
   落定前 0.1s 开始压（browser-main.js 的 INVERT_MS - 100），0.1s 内到满，
   正好在卡牌落定那一刻全红，之后一直保持到冻结期结束切场。
   颜色随通道走——精英用冻结的 #ef4444，Boss 用冻结的粉 #f472b6，
   绝不把精英红漏进 Boss 通道（spec §5.5.2）。 */
/* 全屏均匀平铺，不用径向渐变（渐变会在中心留个亮斑，就不是"均匀"了）。 */
.tarot-load-red-filter {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s linear;
  /* 刻意**不写 z-index**，而且必须排在加载层 DOM 的第一个子节点，两个条件缺一不可：
     .tarot-roulette-wheel 带 transform、自成层叠上下文，卡牌在它内部（哪怕 z-index 50）
     也跳不出来。滤镜只要带正 z-index 就会盖住整张牌；不带 z-index 且排在轮盘之前，
     才会落在「背景之上、轮盘(含卡牌)与顶部表头之下」那一层。
     挪 DOM 位置或加 z-index 都会把牌糊住。 */
}

.tarot-load-overlay.is-elite .tarot-load-red-filter {
  background: rgba(150, 8, 8, 0.62);
}

.tarot-load-overlay.is-boss .tarot-load-red-filter {
  background: rgba(165, 22, 78, 0.58);
}

.tarot-load-overlay.is-reddened .tarot-load-red-filter {
  opacity: 1;
}

/* 卡牌的朱砂光也跟着同一拍转深红。蓄力摆动那 650ms 里它保持揭面的金光——
   红色提前冒出来就是这里漏的。 */
.tarot-load-overlay.is-reddened .tarot-load-card.is-cur .tarot-card-flipper.is-reversed {
  filter: drop-shadow(0 24px 54px rgba(16, 11, 7, 0.98)) drop-shadow(0 0 36px rgba(170, 18, 18, 0.95)) drop-shadow(0 0 18px rgba(254, 202, 202, 0.5));
}

/* 正面与背面 */
.tarot-card-front,
.tarot-card-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 12px 28px rgba(16, 11, 7, 0.92), 0 0 18px rgba(193, 58, 38, 0.25), 0 0 8px rgba(223, 190, 121, 0.2);
  border: 1.2px solid #16100B;
  background: #16100B;
}

.tarot-card-front {
  transform: rotateY(0deg);
  z-index: 2;
}

.tarot-card-back {
  transform: rotateY(180deg);
  background: #16100B url('assets/tarot/cards/card_back.webp') center/cover no-repeat;
  border-color: #8B5B1E;
  z-index: 1;
}

.tarot-svg-face,
.tarot-svg-back {
  width: 100%;
  height: 100%;
  display: block;
}

/* 精英挑战与逆位视效。
   精英红 #ef4444 是冻结值（docs/superpowers/specs/2026-09-11-tarot-level-skeleton-spec.md
   §5.5.2 / §5.6：与地图精英节点同值，不得再引入第三种红色）。此处原先用的是紫色
   #c084fc / #a855f7，属实现偏离规格；地图侧（.node-elite / .spire-type-badge.elite /
   .spire-legend-item.node-elite / .stage-modal-badge.elite）本来就是 #ef4444，
   现按规格对齐回红。底层背景也一并染红，否则只有字是红的、"界面"没红。 */
.tarot-load-overlay.is-elite {
  background: radial-gradient(circle at 50% 48%, rgba(78, 6, 6, 0.96) 0%, rgba(44, 4, 4, 0.98) 60%, rgba(16, 2, 2, 0.995) 100%);
}

/* ========================================================================= */
/* 方案 D 与 方案 A 游戏 UI 移植体系 (默认方案 D · 潮酷漫画机能风)            */
/* ========================================================================= */

/* 方案 D (默认): 【立绘同频·潮酷漫画机能风】 (Action Manga & Comic Ink) */
#game-shell:not([data-ui-scheme="obsidian"]) {
  background: #080a11 url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='3' cy='3' r='1.5' fill='%23192238' fill-opacity='0.65'/%3E%3Ccircle cx='19' cy='19' r='1.5' fill='%23192238' fill-opacity='0.65'/%3E%3C/svg%3E");
}

/* 方案 D 通用面板分镜与硬边立体投影 */
#game-shell:not([data-ui-scheme="obsidian"]) .modal-sheet {
  background: #111422;
  border: 3px solid #000000;
  border-radius: 0px;
  box-shadow: 5px 5px 0px #000000;
}

/* 方案 D 次级按键 */
#game-shell:not([data-ui-scheme="obsidian"]) .btn-subtle-pill {
  background: #171b2a;
  border: 2.5px solid #000000;
  box-shadow: 3.5px 3.5px 0px #000000;
  border-radius: 0px;
  color: #f8fafc;
  font-weight: 900;
  font-style: italic;
  transform: skewX(-4deg);
  clip-path: none;
}

#game-shell:not([data-ui-scheme="obsidian"]) .btn-subtle-pill:hover {
  background: #252c42;
  border-color: var(--run-accent);
  color: #ffffff;
  transform: skewX(-4deg) translate(2px, 2px);
  box-shadow: 1.5px 1.5px 0px #000000;
}

/* 3. 升级与命运抽卡 (Card Draw & Upgrades) */
#game-shell:not([data-ui-scheme="obsidian"]) .upgrade-card {
  background: #131726;
  border: 3px solid #000000;
  box-shadow: 5px 5px 0px #000000;
  border-radius: 0px;
  transform: skewX(-4deg);
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#game-shell:not([data-ui-scheme="obsidian"]) .upgrade-card > * {
  transform: skewX(4deg);
}

#game-shell:not([data-ui-scheme="obsidian"]) .upgrade-card:hover {
  background: #1c233c;
  transform: skewX(-4deg) translate(2px, 2px);
  box-shadow: 2px 2px 0px #000, 5px 5px 0px var(--run-accent);
}

/* ========================================================================= */
/* 局内卡片强调色：跟随所选角色主题色 (--battle-hero-primary)                 */
/* 单一定义点，卡片规则统一引用 var(--run-accent)，勿再写死青色。            */
/* ========================================================================= */
#game-shell {
  --run-accent: var(--battle-hero-primary, #00f0ff);
}

/* ========================================================================= */
/* 移动端适配：全站隐藏滚动条（保留滚动能力，仅去掉 PC 端滚条视觉）           */
/* ========================================================================= */
* {
  scrollbar-width: none;   /* Firefox */
  -ms-overflow-style: none; /* 旧版 Edge / IE */
}

*::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

/* ===== 结算页本局战果 ===== */
.result-meta-block {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-meta-block .rm-title {
  font-size: 12px;
  font-weight: 900;
  color: #fef08a;
}

.result-meta-block .rm-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.result-meta-block .rm-chip {
  font-size: 10.5px;
  font-weight: 700;
  color: #f8fafc;
  padding: 2px 7px;
  background: rgba(245, 158, 11, 0.16);
  border-radius: 4px;
}

.result-meta-block .rm-chip--repeat {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.16);
}

.result-meta-block .rm-note {
  font-size: 10px;
  color: #94a3b8;
}

/* 疾羽教学关：DOM 通讯小窗（墨线皮；由 browser-main.js 订阅 tutorialLine 挂到 #game-shell，只在抽卡 / 升级 / 补给终端三个 DOM 视图显示，
   战斗里由 Canvas 画在左列 HUD 之下）。贴顶部安全区下方，高 ≤ 64px、最多 3 行，不交互、不拦截触摸；每句 150ms 从左滑入，播完立即收起 */
#tutorial-comm {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 6px);
  left: 12px;
  right: 12px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  min-height: 52px;
  max-height: 64px;
  padding: 6px;
  overflow: hidden;
  color: #ffffff;
  background: rgba(17, 17, 17, 0.75);
  border: 1.5px solid rgba(243, 238, 227, 0.6);
  border-radius: 0;
  pointer-events: none;
  animation: tutorialCommIn 0.15s ease-out;
}

.tutorial-comm-avatar {
  position: relative;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  align-self: flex-start;
  overflow: hidden;
  background: #f3eee3;
  border: 2.5px solid #111111;
  border-radius: 0;
  outline: 1.5px solid #f3eee3;
  box-shadow: 2px 2px 0 #111111;
  transform: rotate(-4deg);
}

.tutorial-comm-avatar img {
  position: absolute;
  max-width: none;
  height: auto;
  display: block;
  -webkit-user-select: none;
  user-select: none;
}

.tutorial-comm-avatar img.is-full {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 黄胶带名牌：斜贴在头像下沿 */
.tutorial-comm-tape {
  position: absolute;
  left: 4px;
  top: 38px;
  width: 34px;
  height: 12px;
  box-sizing: border-box;
  background: #ffd400;
  border: 1.5px solid #111111;
  color: #111111;
  font-size: 10px;
  line-height: 9px;
  font-weight: 900;
  text-align: center;
  transform: rotate(-3deg);
}

.tutorial-comm-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 900;
  /* 半透明底下透出标题时靠硬描边保字：四向 1px 墨色，没有模糊 */
  text-shadow: 1px 0 #111111, -1px 0 #111111, 0 1px #111111, 0 -1px #111111;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

@keyframes tutorialCommIn {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  #tutorial-comm { animation: none; }
}

/* 新手序章：整屏由 Canvas 绘制，画布需要独占触摸与长按（禁止滚动、长按菜单与文字选中） */
#game-shell.prologue-active #game-canvas {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
