/* ===== IF剧情模块 专属样式 ===== */

/* 页面基础布局 */
.if-page {
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--gradient);
  font-family: var(--font-sans);
  color: var(--text-primary);
}

.if-container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  padding-top: 80px;
}

/* ===== 导航栏 ===== */
.if-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(11, 15, 28, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-lg);
  z-index: 100;
  gap: var(--spacing-md);
}

.if-navbar-back {
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  transition: color var(--transition);
}

.if-navbar-back:hover {
  color: var(--text-primary);
}

.if-navbar-title {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  flex: 1;
  text-align: center;
}

/* ===== 解锁页（index.html）===== */
.if-unlock-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  text-align: center;
  box-shadow: var(--shadow);
}

.if-unlock-icon {
  font-size: 48px;
  margin-bottom: var(--spacing-md);
}

.if-unlock-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.if-unlock-desc {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--spacing-xl);
  line-height: 1.6;
}

.if-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: var(--spacing-md);
}

.if-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px var(--spacing-md);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition);
}

.if-input:focus {
  border-color: var(--brand);
}

.if-input::placeholder {
  color: var(--text-disabled);
}

.if-feedback {
  font-size: var(--font-size-sm);
  min-height: 20px;
  margin-top: 4px;
  text-align: left;
}

.if-feedback.is-error {
  color: #ff6b6b;
}

/* M2 OC 引子密度反馈（参考 OC40 风格但更紧）*/
.if-density-feedback[data-level="empty"] { color: var(--text-muted); }
.if-density-feedback[data-level="thin"]  { color: #d4a44a; }
.if-density-feedback[data-level="warm"]  { color: #e8a64a; }
.if-density-feedback[data-level="ok"]    { color: #4ade80; }
.if-density-feedback[data-level="long"]  { color: #d4a44a; }

.if-feedback.is-success {
  color: #52d68a;
}

/* ===== 世界观选择卡片（start.html）===== */
.if-page-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: var(--spacing-lg);
  color: var(--text-primary);
}

.if-page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--spacing-xl);
  line-height: 1.6;
}

.if-worlds-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: var(--spacing-xl);
  overflow-x: auto;
}

@media (max-width: 480px) {
  .if-worlds-grid {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
  }
}

.if-world-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--spacing-md);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  position: relative;
  user-select: none;
}

.if-world-card:hover {
  border-color: rgba(255, 92, 92, 0.4);
  background: rgba(255, 92, 92, 0.04);
}

.if-world-card.is-selected {
  border-color: var(--brand);
  background: rgba(255, 92, 92, 0.1);
  box-shadow: 0 0 0 1px var(--brand);
}

.if-world-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.if-world-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: block;
}

.if-world-tagline {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  display: block;
  margin-bottom: 10px;
}

.if-world-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
}

.if-world-status.is-unlocked {
  background: rgba(82, 214, 138, 0.15);
  color: #52d68a;
  border: 1px solid rgba(82, 214, 138, 0.3);
}

.if-world-status.is-locked {
  background: rgba(255, 92, 92, 0.12);
  color: var(--brand);
  border: 1px solid rgba(255, 92, 92, 0.25);
  cursor: pointer;
}

.if-world-status.is-locked:hover {
  background: rgba(255, 92, 92, 0.2);
}

/* 角色名输入区 */
.if-name-section {
  margin-bottom: var(--spacing-xl);
}

.if-name-section .if-input {
  width: 100%;
  box-sizing: border-box;
  font-size: var(--font-size-base);
  padding: 10px var(--spacing-md);
}

.if-name-label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.if-select-oc-btn {
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 8px var(--spacing-md);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  transition: all var(--transition);
}

.if-select-oc-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* 增购弹窗 */
.if-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
}

.if-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  width: 100%;
  max-width: 420px;
  animation: slideIn 0.25s ease-out;
}

.if-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-md);
}

.if-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.if-modal-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.if-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color var(--transition);
}

.if-modal-close:hover {
  color: var(--text-primary);
}

.if-modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--spacing-md) 0;
}

.if-modal-code-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

/* ===== 游戏页（play.html）===== */
.if-round-bar {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  background: rgba(11, 15, 28, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 10px var(--spacing-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 90;
}

.if-round-text {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.if-round-pack {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.if-round-dots {
  display: flex;
  gap: 5px;
}

.if-round-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background var(--transition);
}

.if-round-dot.done {
  background: var(--brand-weak);
}

.if-round-dot.current {
  background: var(--brand);
}

/* 游戏主体（增加顶部偏移）*/
.if-play-container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  padding-top: 116px;
  padding-bottom: 40px;
}

/* 场景区 */
.if-scene-area {
  position: relative;
  margin-bottom: var(--spacing-xl);
}

.if-scene-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--spacing-xl);
  line-height: 1.9;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  white-space: pre-wrap;
  min-height: 120px;
}

/* 事件卡层（覆盖场景区）*/
/* 用 absolute 时，长事件卡（>200 字）的「继续」按钮会被推出场景区视口外 ——
   末班车 EC_cat 280 字 / EC_call 450 字踩到这条。改成 relative 让 overlay 自然撑高，
   并在 JS showEventOverlay 时把 sceneText 隐藏，避免 overlay 与场景文叠加。 */
.if-event-overlay {
  position: relative;
  background: var(--bg-card, #1a1a22);
  border: 1px solid rgba(91, 200, 255, 0.45);
  border-radius: var(--radius);
  padding: var(--spacing-xl);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.if-event-badge {
  font-size: 11px;
  color: rgba(91, 200, 255, 0.9);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.if-event-text {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: 1.8;
  /* 注：原来是 flex:1 配合 absolute overlay 撑满剩余空间。
     overlay 改 position:relative 后 flex-basis:0 + 无父高度参考 → 塌缩为 0 高。
     改成内容自然撑高，min-height 兜底防空状态视觉过窄。 */
  min-height: 80px;
  white-space: pre-wrap;
}

.if-event-continue {
  align-self: flex-end;
}

/* 选项区 */
.if-options-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.if-option-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--spacing-md) var(--spacing-lg);
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  line-height: 1.6;
}

.if-option-btn:hover:not(:disabled) {
  border-color: rgba(255, 92, 92, 0.5);
  background: rgba(255, 92, 92, 0.06);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.if-option-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.if-option-btn.is-chosen {
  border-color: var(--brand);
  background: rgba(255, 92, 92, 0.12);
  color: var(--text-primary);
}

.if-option-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-right: 8px;
}

/* ===== 结局卡（result.html）===== */
.if-result-container {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  padding-top: 80px;
  padding-bottom: 60px;
}

.if-story-card {
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  position: relative;
  overflow: hidden;
}

/* 普通结局 */
.if-card-normal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* 银色结局（触发过事件卡）*/
.if-card-silver {
  background: linear-gradient(160deg, rgba(180, 195, 220, 0.08), rgba(140, 160, 199, 0.04));
  border: 1px solid rgba(180, 195, 220, 0.35);
  box-shadow: 0 0 40px rgba(180, 195, 220, 0.08), var(--shadow);
}

.if-card-silver::before {
  content: '★';
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  color: rgba(180, 195, 220, 0.6);
  font-size: 14px;
}

/* 金色结局（反转路径）*/
.if-card-gold {
  background: linear-gradient(160deg, rgba(255, 210, 80, 0.1), rgba(255, 164, 40, 0.05));
  border: 1px solid rgba(255, 200, 60, 0.45);
  box-shadow: 0 0 60px rgba(255, 200, 60, 0.12), var(--shadow);
}

.if-card-gold::before {
  content: '✦';
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  color: rgba(255, 200, 60, 0.7);
  font-size: 16px;
}

.if-card-gold::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 200, 60, 0.02) 0px,
    rgba(255, 200, 60, 0.02) 1px,
    transparent 1px,
    transparent 12px
  );
  pointer-events: none;
}

.if-card-pack {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: var(--spacing-md);
  display: block;
}

.if-card-base-text {
  font-size: 18px;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: var(--spacing-md);
  font-weight: 500;
  white-space: pre-wrap;
}

.if-card-variant {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: var(--spacing-md);
  white-space: pre-wrap;
}

.if-card-echo {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: var(--spacing-lg);
  white-space: pre-wrap;
  font-style: italic;
}

.if-card-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--spacing-md) 0;
}

.if-card-meta {
  font-size: 12px;
  color: var(--text-disabled);
  line-height: 1.7;
}

.if-card-meta-label {
  color: var(--text-muted);
  font-weight: 500;
}

.if-card-title {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: var(--spacing-md);
  font-weight: 500;
}

.if-share-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-align: center;
  margin-bottom: var(--spacing-xl);
  line-height: 1.6;
}

.if-result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== 图鉴页（gallery.html）===== */
.if-gallery-container {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  padding-top: 80px;
  padding-bottom: 60px;
}

.if-gallery-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: var(--spacing-lg);
  color: var(--text-primary);
}

.if-gallery-pack {
  margin-bottom: var(--spacing-xl);
}

.if-gallery-pack-name {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.if-gallery-pack-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.if-gallery-slots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.if-gallery-slot {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: default;
  transition: all var(--transition);
  position: relative;
}

.if-gallery-slot.is-unlocked {
  cursor: pointer;
}

.if-gallery-slot.is-unlocked:hover {
  transform: translateY(-2px);
}

/* 图鉴格子稀有度色调 */
.if-gallery-slot.is-unlocked.rarity-normal {
  background: rgba(199, 208, 233, 0.08);
  border-color: rgba(199, 208, 233, 0.25);
}

.if-gallery-slot.is-unlocked.rarity-silver {
  background: rgba(180, 195, 220, 0.12);
  border-color: rgba(180, 195, 220, 0.4);
}

.if-gallery-slot.is-unlocked.rarity-gold {
  background: rgba(255, 200, 60, 0.1);
  border-color: rgba(255, 200, 60, 0.4);
}

.if-gallery-slot.is-locked {
  color: var(--text-disabled);
  font-size: 14px;
}

/* 图鉴称号 tooltip */
.if-gallery-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
  box-shadow: var(--shadow);
  animation: fadeIn 0.15s ease-out;
}

.if-gallery-total {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--spacing-lg);
}

/* ===== 通用加载状态 ===== */
.if-loading {
  text-align: center;
  color: var(--text-muted);
  padding: var(--spacing-xl);
  font-size: var(--font-size-sm);
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== IF UI 优化：新增变量、keyframes 和组件样式 ===== */

/* 新增 CSS 变量 */
:root {
  --if-gold: #ffd250;
  --if-gold-dim: rgba(255, 210, 80, 0.15);
  --if-silver: #b4c3dc;
  --if-silver-dim: rgba(180, 195, 220, 0.15);
  --if-glow-gold: 0 0 18px rgba(255, 210, 80, 0.45), 0 0 6px rgba(255, 164, 40, 0.3);
  --if-glow-silver: 0 0 14px rgba(180, 195, 220, 0.4);
}

@keyframes if-typewriter {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes if-breathe-gold {
  0%, 100% { box-shadow: var(--if-glow-gold); }
  50%       { box-shadow: 0 0 28px rgba(255, 210, 80, 0.6), 0 0 10px rgba(255, 164, 40, 0.4); }
}

@keyframes if-breathe-silver {
  0%, 100% { box-shadow: var(--if-glow-silver); }
  50%       { box-shadow: 0 0 22px rgba(180, 195, 220, 0.55); }
}

@keyframes if-ripple {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}

@keyframes if-event-glitch {
  0%   { clip-path: inset(0 0 100% 0); opacity: 0; }
  30%  { clip-path: inset(0 0 60% 0);  opacity: 1; }
  60%  { clip-path: inset(0 0 20% 0);  opacity: 1; }
  100% { clip-path: inset(0 0 0% 0);   opacity: 1; }
}

@keyframes if-pulse-border {
  0%, 100% { outline-color: rgba(255, 80, 80, 0.3); }
  50%       { outline-color: rgba(255, 80, 80, 0.9); }
}

@keyframes if-crack-glow {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 0.7; }
}

/* ===== start.html：世界观情境化 ===== */
.if-container {
  transition: background-color 400ms ease;
  background-color: var(--world-bg, transparent);
}

.if-world-card {
  position: relative;
  overflow: hidden;
  transition: transform 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.if-world-card::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to top, var(--world-accent, transparent), transparent);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
  border-radius: inherit;
}

.if-world-card.is-selected::before {
  opacity: 0.18;
}

/* ===== play.html：选项涟漪 ===== */
.if-option-btn {
  position: relative;
  overflow: hidden;
}

.if-ripple {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 92, 92, 0.35);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: if-ripple 500ms ease-out forwards;
  pointer-events: none;
}

/* ===== play.html：事件卡突袭 ===== */
.if-event-overlay.is-active {
  animation: if-event-glitch 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.if-container.event-incoming {
  outline: 1px solid rgba(255, 80, 80, 0.6);
  border-radius: var(--radius);
  animation: if-pulse-border 200ms ease 2;
}

/* ===== result.html：三级卡片质感 ===== */
.if-story-card {
  position: relative;
  overflow: hidden;
}

.if-card-glow-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  z-index: 0;
}

.if-story-card > *:not(.if-card-glow-layer) {
  position: relative;
  z-index: 1;
}

.if-card-normal {
  backdrop-filter: blur(12px);
  background: rgba(30, 30, 38, 0.75);
}

.if-card-silver {
  animation: if-breathe-silver 3s ease-in-out infinite;
  border-color: var(--if-silver) !important;
}

.if-card-silver .if-card-glow-layer {
  background: linear-gradient(
    125deg,
    transparent 30%,
    rgba(180, 195, 220, 0.12) 50%,
    transparent 70%
  );
  background-size: 200% 200%;
  background-position: var(--glint-x, 50%) var(--glint-y, 50%);
  transition: background-position 80ms linear;
}

.if-card-gold {
  animation: if-breathe-gold 2.5s ease-in-out infinite;
  border-color: var(--if-gold) !important;
}

.if-card-gold .if-card-glow-layer {
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 8px,
      rgba(255, 210, 80, 0.04) 8px,
      rgba(255, 210, 80, 0.04) 9px
    ),
    linear-gradient(
      125deg,
      transparent 25%,
      rgba(255, 210, 80, 0.18) 50%,
      transparent 75%
    );
  background-size: auto, 200% 200%;
  background-position: auto, var(--glint-x, 50%) var(--glint-y, 50%);
  transition: background-position 80ms linear;
}

/* echo_line 视觉区分 */
.if-card-echo {
  font-style: italic;
  letter-spacing: 0.06em;
  font-size: calc(var(--font-size-base) * 1.05);
  color: var(--brand);
  border-left: 2px solid var(--brand);
  padding-left: var(--spacing-sm);
  margin: var(--spacing-md) 0;
}

/* 路径时间线节点 */
.if-path-timeline {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.if-path-node {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.if-card-gold .if-path-node {
  border-color: var(--if-gold);
  color: var(--if-gold);
}

.if-card-silver .if-path-node {
  border-color: var(--if-silver);
  color: var(--if-silver);
}

.if-path-edge {
  width: 16px;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
  flex-shrink: 0;
}

/* ===== gallery.html：命运拼图感 ===== */
.if-gallery-slot.is-locked {
  background:
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 6px,
      rgba(255, 255, 255, 0.02) 6px,
      rgba(255, 255, 255, 0.02) 7px
    ) !important;
  border-style: dashed !important;
}

.if-gallery-slot.is-locked.rarity-gold {
  position: relative;
}

.if-gallery-slot.is-locked.rarity-gold::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 210, 80, 0.22), transparent 70%);
  animation: if-crack-glow 2s ease-in-out infinite;
  border-radius: inherit;
  pointer-events: none;
}

.if-gallery-slot.is-locked.rarity-silver {
  position: relative;
}

.if-gallery-slot.is-locked.rarity-silver::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(180, 195, 220, 0.18), transparent 70%);
  animation: if-crack-glow 2.5s ease-in-out infinite;
  border-radius: inherit;
  pointer-events: none;
}

/* ===== R6 回声轮 ===== */
.if-round-inner {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.if-gallery-pack-name {
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ============================================ */
/* 结果页反馈弹窗（if-fb-*）                      */
/* ============================================ */

.if-fb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  box-sizing: border-box;
  animation: ifFbFadeIn 0.2s ease-out;
}

.if-fb-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
  animation: ifFbSlideUp 0.25s ease-out;
}

@keyframes ifFbFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes ifFbSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.if-fb-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
  padding: 0;
}
.if-fb-close:hover { color: var(--text-primary); }

.if-fb-header { padding-right: 32px; margin-bottom: 16px; }
.if-fb-header h3 {
  margin: 0 0 6px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}
.if-fb-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.if-fb-reward {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, rgba(255, 92, 92, 0.14), rgba(255, 142, 92, 0.08));
  border: 1px solid rgba(255, 92, 92, 0.4);
  border-radius: 10px;
}
.if-fb-reward-icon { font-size: 24px; flex-shrink: 0; }
.if-fb-reward-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.4; }
.if-fb-reward-text strong {
  font-size: 14px;
  color: var(--brand);
  font-weight: 600;
}
.if-fb-reward-text span {
  font-size: 12px;
  color: var(--text-muted);
}

.if-fb-body { padding-top: 4px; }

.if-fb-rating-group { margin-bottom: 22px; }

.if-fb-rating-label {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-weight: 500;
}

.if-fb-required {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: normal;
}

.if-fb-slider-wrap {
  position: relative;
  padding: 14px 0 4px;
}

.if-fb-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: transparent;
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.if-fb-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: linear-gradient(to right,
    var(--brand) 0%,
    var(--brand) var(--fill-percent, 44%),
    rgba(255, 255, 255, 0.12) var(--fill-percent, 44%),
    rgba(255, 255, 255, 0.12) 100%);
  border-radius: 3px;
}
.if-fb-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.if-fb-slider::-moz-range-progress {
  height: 6px;
  background: var(--brand);
  border-radius: 3px;
}
.if-fb-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  background: var(--brand);
  border: 3px solid #fff;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
  margin-top: -9px;
}
.if-fb-slider::-moz-range-thumb {
  width: 24px; height: 24px;
  background: var(--brand);
  border: 3px solid #fff;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.if-fb-slider:hover::-webkit-slider-thumb { transform: scale(1.15); }
.if-fb-slider:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.25);
  box-shadow: 0 0 0 6px rgba(255, 92, 92, 0.2);
}

.if-fb-ticks {
  display: flex;
  justify-content: space-between;
  padding: 6px 2px 0;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}
.if-fb-ticks span { flex: 1; text-align: center; }

.if-fb-rating-axis {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.if-fb-rating-value {
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.if-fb-rating-value strong {
  color: var(--brand);
  font-weight: 600;
  font-size: 14px;
}

.if-fb-comment-group { margin-bottom: 18px; }

.if-fb-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color var(--transition);
}
.if-fb-textarea:focus {
  outline: none;
  border-color: var(--brand);
}
.if-fb-textarea:disabled { opacity: 0.5; cursor: not-allowed; }

.if-fb-char-count {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.if-fb-error {
  margin: 0 0 12px 0;
  padding: 8px 12px;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.4);
  border-radius: 6px;
  color: #f87171;
  font-size: 13px;
}

.if-fb-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
}

.if-fb-dismiss {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition);
}
.if-fb-dismiss:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

.if-fb-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: rgba(20, 28, 50, 0.95);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  z-index: 10000;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: ifFbToastSlideUp 0.32s ease-out;
}

.if-fb-toast--reward {
  padding: 14px 22px;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(255, 92, 92, 0.95), rgba(255, 142, 92, 0.95));
  border: 1px solid rgba(255, 200, 120, 0.6);
  color: #fff;
  box-shadow: 0 12px 36px rgba(255, 92, 92, 0.45);
}

.if-fb-toast-icon {
  font-size: 20px;
  line-height: 1;
}

@keyframes ifFbToastSlideUp {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 768px) {
  .if-fb-modal { padding: 22px 18px; max-height: 92vh; }
  .if-fb-header h3 { font-size: 18px; }
  .if-fb-slider::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -11px; }
  .if-fb-slider::-moz-range-thumb { width: 28px; height: 28px; }
}

/* ============================================================
   跨产品引流 sticky bar (IF 剧情 → OC40 小剧场)
   仅 result.html 加载本组件；永久 fixed 在视口底部
   z-index 50 低于 if-fb-overlay 9999 自动让位反馈弹窗
   ============================================================ */

/* 仅 result.html body 留 padding（其他 if-story 页不挂 .if-page-with-promo 不受影响）*/
body.if-page-with-promo {
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
}

.if-cross-promo-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* iOS home indicator safe-area 处理：
     - 老写法 height:52px + padding-bottom 含 safe-area → border-box 内 safe-area 挤压可见内容到 ~16px（用户报告"只露一点"根因）
     - 新写法用 min-height 让 bar 自然撑高 = 52px 内容区 + safe-area 余量
     - viewport-fit=cover 配合 env(safe-area-inset-bottom) 才生效（已加 meta） */
  min-height: 52px;
  padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: content-box;
  /* OC40 橙色渐变（与 IF 紫蓝形成"换个工具"的视觉区分）*/
  background: linear-gradient(135deg, rgba(230, 126, 34, 0.92), rgba(231, 76, 60, 0.92));
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: 0.3px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease;
  cursor: pointer;
}
.if-cross-promo-bar:hover,
.if-cross-promo-bar:active {
  background: linear-gradient(135deg, rgba(230, 126, 34, 1), rgba(231, 76, 60, 1));
  text-decoration: none;
  color: #fff;
}
.if-cross-promo-icon { font-size: 18px; line-height: 1; }
.if-cross-promo-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100vw - 96px);
}
.if-cross-promo-arrow { font-size: 16px; opacity: 0.85; }

@media (max-width: 480px) {
  .if-cross-promo-bar { font-size: 13px; min-height: 50px; }
  .if-cross-promo-text { letter-spacing: 0; }
}
