.game-container,
.game-container * {
  box-sizing: border-box;
}

/* ========== 全局容器 & 深色适配 ========== */
.game-container {
  max-width: 1000px;
  margin: 20px auto;
  font-family: system-ui, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', Roboto, 'Helvetica Neue', sans-serif;
  background: linear-gradient(135deg, #6c5ce7 0%, #a363d9 100%);
  border-radius: 32px;
  padding: 25px;
  box-shadow: 0 25px 45px -12px rgba(0,0,0,0.4);
  transition: background 0.2s;
}

@media (prefers-color-scheme: dark) {
  .game-container {
    background: linear-gradient(135deg, #1e1a2f 0%, #2a1e3c 100%);
    box-shadow: 0 25px 45px -12px rgba(0,0,0,0.7);
  }
}

/* ========== 世界信息区 ========== */
.world-info {
  background: rgba(255,255,255,0.96);
  border-radius: 24px;
  padding: 18px 22px;
  margin-bottom: 24px;
  border-left: 6px solid #ffb347;
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
  transition: background 0.2s;
}
.world-info h3 {
  margin: 0 0 12px 0;
  color: #4b3b8c;
  font-size: 1.3rem;
}
.world-info-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  font-size: 0.9rem;
}
.info-item {
  background: #f9f5ff;
  padding: 8px 14px;
  border-radius: 40px;
  color: #2c2c54;
}
.info-label {
  font-weight: 700;
  color: #8855dd;
  margin-right: 6px;
}
.phase-badge {
  background: linear-gradient(120deg, #ff9a3c, #ff5e7c);
  padding: 4px 14px;
  border-radius: 40px;
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  display: inline-block;
}

@media (prefers-color-scheme: dark) {
  .world-info {
    background: rgba(20, 20, 35, 0.95);
    border-left-color: #f39c12;
  }
  .world-info h3 {
    color: #f5b042;
  }
  .info-item {
    background: #2c2c3a;
    color: #ddd;
  }
  .info-label {
    color: #c68eff;
  }
  .phase-badge {
    background: linear-gradient(120deg, #f39c12, #e67e22);
  }
}

/* ========== 故事正文 ========== */
.story-content {
  background: rgba(255,255,245,0.98);
  border-radius: 28px;
  padding: 26px 24px;
  margin-bottom: 28px;
  line-height: 1.7;
  font-size: 1rem;
  color: #1e2a3e;
  box-shadow: 0 12px 20px rgba(0,0,0,0.1);
  transition: all 0.2s;
}

@media (prefers-color-scheme: dark) {
  .story-content {
    background: rgba(30, 30, 45, 0.98);
    color: #ececec;
    box-shadow: 0 12px 20px rgba(0,0,0,0.3);
  }
}

/* ========== 可折叠面板 - 三色区分 ========== */
.fold-section {
  border-radius: 24px;
  margin-bottom: 20px;
  overflow: hidden;
}
.fold-section summary {
  padding: 18px 24px;
  font-weight: 800;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 24px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  transition: all 0.2s;
}
.fold-section summary::-webkit-details-marker {
  display: none;
}
.fold-section summary::before {
  font-size: 0.9rem;
  transition: transform 0.25s;
  display: inline-block;
  margin-right: 8px;
}
.fold-section[open] summary::before {
  transform: rotate(90deg);
}

/* 主角详情 — 蓝绿色系 */
.fold-section.player-section {
  background: rgba(255,255,255,0.95);
}
.fold-section.player-section summary {
  background: rgba(59, 130, 246, 0.1);
  border-left: 5px solid #3b82f6;
  color: #1e3a8a;
}
.fold-section.player-section summary::before {
  content: "▶";
  color: #3b82f6;
}
@media (prefers-color-scheme: dark) {
  .fold-section.player-section {
    background: rgba(30, 35, 55, 0.95);
  }
  .fold-section.player-section summary {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border-left-color: #3b82f6;
  }
}

/* 互动对象状态 — 粉紫色系 */
.fold-section.character-section {
  background: rgba(255,255,255,0.95);
}
.fold-section.character-section summary {
  background: rgba(236, 72, 153, 0.1);
  border-left: 5px solid #ec4899;
  color: #831843;
}
.fold-section.character-section summary::before {
  content: "▶";
  color: #ec4899;
}
@media (prefers-color-scheme: dark) {
  .fold-section.character-section {
    background: rgba(45, 30, 50, 0.95);
  }
  .fold-section.character-section summary {
    background: rgba(236, 72, 153, 0.2);
    color: #f9a8d4;
    border-left-color: #ec4899;
  }
}

/* 记忆区 — 琥珀色系 */
.fold-section.memory-section {
  background: rgba(255,255,255,0.95);
}
.fold-section.memory-section summary {
  background: rgba(245, 158, 11, 0.1);
  border-left: 5px solid #f59e0b;
  color: #78350f;
}
.fold-section.memory-section summary::before {
  content: "▶";
  color: #f59e0b;
}
@media (prefers-color-scheme: dark) {
  .fold-section.memory-section {
    background: rgba(40, 35, 25, 0.95);
  }
  .fold-section.memory-section summary {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border-left-color: #f59e0b;
  }
}

/* 折叠内容公共区域 */
.fold-content {
  padding: 20px 24px 24px 24px;
  border-top: 1px solid rgba(0,0,0,0.05);
  background: white;
}
@media (prefers-color-scheme: dark) {
  .fold-content {
    background: #1f1f2e;
    border-top-color: rgba(255,255,255,0.1);
  }
}

/* ========== 主角详情内部 ========== */
.player-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stat-line {
  background: #f5f0ff;
  padding: 12px 18px;
  border-radius: 60px;
  font-size: 0.92rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}
.status-label {
  font-weight: 700;
  color: #aa6fe5;
  margin-right: 10px;
}
@media (prefers-color-scheme: dark) {
  .stat-line {
    background: #2a2a3c;
    color: #ddd;
  }
  .status-label {
    color: #c084fc;
  }
}

/* ========== 互动对象内部：立绘 + 状态（图片完整显示） ========== */
.character-livestats {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.character-image-card {
  background: #faf5ff;
  border-radius: 28px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.character-image {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  border-radius: 24px;
  border: 3px solid #c084fc;
  background: #f0e6ff;
  box-shadow: 0 12px 18px -8px rgba(100,70,150,0.3);
}
.image-state-label {
  margin-top: 14px;
  font-weight: 700;
  background: #ffe6f0;
  display: inline-block;
  padding: 6px 20px;
  border-radius: 60px;
  font-size: 0.8rem;
  color: #bc6f9e;
}
.status-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.status-item {
  background: #fef9f0;
  padding: 12px 18px;
  border-radius: 24px;
  font-size: 0.92rem;
  border-left: 4px solid #ffb86b;
}
.inner-thought {
  background: linear-gradient(115deg, #fff2db, #ffe6c7);
  padding: 14px 20px;
  border-radius: 28px;
  font-style: italic;
  color: #5a3e2b;
  margin-top: 10px;
  border-left: 5px solid #f3a683;
}
.inner-thought::before {
  content: "「 ";
}
.inner-thought::after {
  content: " 」";
}

@media (prefers-color-scheme: dark) {
  .character-image-card {
    background: #2a2538;
  }
  .character-image {
    border-color: #a56cc2;
    background: #2e2a40;
  }
  .image-state-label {
    background: #3e2a3c;
    color: #f0c0d0;
  }
  .status-item {
    background: #2e2c3a;
    color: #e0e0e0;
    border-left-color: #f4a261;
  }
  .inner-thought {
    background: linear-gradient(115deg, #3a2e24, #2e261c);
    color: #f5deb3;
    border-left-color: #e6b17e;
  }
}

/* ========== 记忆区（修复溢出 - 无全局污染） ========== */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.memory-card {
  background: #fef5ea;
  border-radius: 20px;
  padding: 14px 16px;
  border-bottom: 3px solid #dec69a;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;       /* 允许收缩，防止撑开父容器 */
}
.memory-type {
  font-size: 1rem;
  font-weight: 800;
  color: #cb7b3c;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 3px solid #f4a261;
  padding-left: 10px;
}
.memory-desc {
  font-size: 0.85rem;
  color: #3d2a1a;
  line-height: 1.4;
  word-break: break-word;
}
.memory-time {
  color: #b86f2c;
  font-weight: bold;
  margin-right: 6px;
}

@media (prefers-color-scheme: dark) {
  .memory-card {
    background: #2e2a22;
    border-bottom-color: #b87c4a;
  }
  .memory-type {
    color: #f5a97f;
  }
  .memory-desc {
    color: #d4c5a8;
  }
  .memory-time {
    color: #f0b27a;
  }
}

/* ========== 行动选项 ========== */
.action-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.action-button {
  background: linear-gradient(115deg, #6c5ce7, #8d6be3);
  color: white;
  padding: 14px 12px;
  border-radius: 60px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 6px 12px rgba(108,92,231,0.3);
  border: none;
}
.action-button:hover {
  transform: translateY(-3px);
  background: linear-gradient(115deg, #7d6ef0, #9f7bea);
}

@media (prefers-color-scheme: dark) {
  .action-button {
    background: linear-gradient(115deg, #5b4bc4, #7a5bcb);
  }
}

/* ========== 响应式优化（修复手机记忆区溢出） ========== */
@media (max-width: 640px) {
  .game-container {
    padding: 14px;
  }
  .story-content {
    padding: 20px 18px;
    font-size: 0.93rem;
  }
  .fold-section summary {
    padding: 14px 18px;
    font-size: 1rem;
  }
  .fold-content {
    padding: 16px;
  }
  .world-info-content {
    grid-template-columns: 1fr;
  }
  .action-button {
    padding: 12px 8px;
    font-size: 0.85rem;
  }
  .character-image {
    max-height: 240px;
  }
  
  /* 记忆区移动端修复：强制单列、允许收缩、自动换行 */
  .memory-grid {
    grid-template-columns: 1fr;      /* 单列布局 */
    gap: 12px;
  }
  .memory-card {
    min-width: 0;                    /* 允许收缩到任意小宽度 */
    width: 100%;
    padding: 12px;
    word-break: break-word;
    overflow-wrap: break-word;
  }
  .memory-desc {
    word-break: break-word;
  }
  .memory-type {
    font-size: 0.95rem;
  }

  .stat-line, .status-item {
    font-size: 0.85rem;
    padding: 10px 14px;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .game-container {
    padding: 20px;
  }
  .character-image {
    max-height: 260px;
  }
}