/* ========== 基础样式 ========== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&family=Noto+Sans+SC:wght@300;400;500&display=swap');

:root {
  --bg-primary: #f5f0e8;
  --bg-secondary: #ebe5d9;
  --bg-card: #faf7f0;
  --text-primary: #2c2c2c;
  --text-secondary: #5a5a5a;
  --text-muted: #8a8a8a;
  --accent: #b8860b;
  --accent-light: #d4a843;
  --accent-dark: #8b6508;
  --border: #d4c9b8;
  --border-light: #e8e0d0;
  --shadow: rgba(0, 0, 0, 0.08);
  --danger: #c0392b;
  --success: #27ae60;
  --info: #2980b9;

  --font-serif: 'Noto Serif SC', 'Songti SC', serif;
  --font-sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --transition-fast: 0.2s ease;
  --transition-normal: 0.4s ease;
  --transition-slow: 0.8s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

/* ========== 页面切换 ========== */
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ========== 开始页面 ========== */
.start-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.game-title {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
}

.game-subtitle {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 3rem;
  letter-spacing: 0.05em;
}

.start-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 280px;
}

.version-info {
  margin-top: 3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== 按钮样式 ========== */
.btn {
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.05em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  background: rgba(184, 134, 11, 0.05);
}

.btn-large {
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  margin-top: 2rem;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.4rem;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}
.icon-btn:hover {
  opacity: 1;
}

/* ========== 角色创建 ========== */
.create-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
  padding-bottom: 4rem;
}

.create-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 2.5rem;
  color: var(--text-primary);
}

.create-section {
  margin-bottom: 2rem;
}

.create-label {
  display: block;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.create-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 1rem;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}
.create-input:focus {
  outline: none;
  border-color: var(--accent);
}
.create-input::placeholder {
  color: var(--text-muted);
}

.create-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.create-options.column {
  flex-direction: column;
}

.option-btn {
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  text-align: left;
}
.option-btn:hover {
  border-color: var(--accent-light);
  background: rgba(184, 134, 11, 0.03);
}
.option-btn.selected {
  border-color: var(--accent);
  background: rgba(184, 134, 11, 0.08);
  color: var(--accent-dark);
}

.opt-title {
  display: block;
  font-weight: 500;
}
.opt-desc {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.option-btn.selected .opt-desc {
  color: var(--accent);
}

/* ========== 游戏主界面 ========== */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.time-display {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 600;
}

.stage-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 500;
}

.header-right {
  display: flex;
  gap: 0.5rem;
}

/* 游戏主体 */
.game-body {
  flex: 1;
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* 叙事区域 */
.narrative-area {
  margin-bottom: 2rem;
}

.scene-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.narrative-text {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 2;
  color: var(--text-primary);
}

.narrative-text .narrative-paragraph {
  margin-bottom: 0.8rem;
  text-indent: 2em;
}

/* 选择区域 */
.choices-area {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.choice-btn {
  display: block;
  width: 100%;
  padding: 1rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-primary);
  text-align: left;
  line-height: 1.6;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.choice-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.choice-btn:hover {
  border-color: var(--accent-light);
  background: rgba(184, 134, 11, 0.04);
  transform: translateX(4px);
}
.choice-btn:hover::before {
  opacity: 1;
}
.choice-btn:active {
  transform: translateX(2px);
}
.choice-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.choice-label {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--accent);
  margin-right: 0.5rem;
  font-weight: 600;
}

/* 结果区域 */
.result-area {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
}

.result-text {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 2;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.effect-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.effect-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-size: 0.82rem;
  font-weight: 500;
}
.effect-tag.positive {
  background: rgba(39, 174, 96, 0.1);
  color: var(--success);
}
.effect-tag.negative {
  background: rgba(192, 57, 43, 0.1);
  color: var(--danger);
}
.effect-tag.neutral {
  background: rgba(41, 128, 185, 0.1);
  color: var(--info);
}

/* ========== 状态面板 ========== */
.status-panel,
.save-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px var(--shadow);
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition-normal);
}
.status-panel.hidden,
.save-panel.hidden {
  transform: translateX(100%);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}
.panel-header h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
}

.panel-body {
  padding: 1.5rem;
}

/* 玩家信息 */
.player-info {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* 属性条 */
.attributes-display {
  margin-bottom: 1.5rem;
}

.attr-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.8rem;
}
.attr-name {
  width: 50px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.attr-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  margin: 0 0.75rem;
  overflow: hidden;
}
.attr-bar {
  height: 100%;
  border-radius: 4px;
  transition: width var(--transition-normal);
}
.attr-bar.学识 { background: #3498db; }
.attr-bar.社交 { background: #e67e22; }
.attr-bar.健康 { background: #27ae60; }
.attr-bar.财富 { background: #f1c40f; }
.attr-bar.心态 { background: #9b59b6; }
.attr-value {
  width: 30px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* 标签展示 */
.tags-display {
  margin-bottom: 1.5rem;
}
.tags-display h4,
.relationships-display h4 {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag-item {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* 关系展示 */
.rel-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-light);
}
.rel-name {
  color: var(--text-primary);
}
.rel-value {
  color: var(--accent);
  font-weight: 500;
}

/* ========== 存档面板 ========== */
.save-slots {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.save-slot {
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.save-slot:hover {
  border-color: var(--accent-light);
}
.save-slot.empty {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}
.save-slot-title {
  font-weight: 500;
  margin-bottom: 0.3rem;
}
.save-slot-info {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.save-slot-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.save-actions {
  display: flex;
  gap: 0.75rem;
}

/* ========== 结局页面 ========== */
.ending-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 3rem 2rem;
  text-align: center;
}

.ending-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.ending-quote {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 3rem;
  line-height: 1.8;
}

.ending-stats {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

.stat-section {
  text-align: center;
}
.stat-section h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.stat-section canvas {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
}

/* 时间线 */
.timeline-display {
  text-align: left;
  margin-bottom: 3rem;
}
.timeline-display h3 {
  font-family: var(--font-serif);
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.timeline-list {
  position: relative;
  padding-left: 2rem;
}
.timeline-list::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1rem;
  padding-left: 1rem;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.65rem;
  top: 0.6rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-age {
  font-weight: 600;
  color: var(--accent);
  margin-right: 0.5rem;
}
.timeline-event {
  color: var(--text-primary);
}

/* 最终标签 */
.tags-final {
  margin-bottom: 3rem;
}
.tags-final h3 {
  font-family: var(--font-serif);
  margin-bottom: 1rem;
  color: var(--text-secondary);
}
.final-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.ending-summary {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 2;
  color: var(--text-primary);
  text-align: left;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  margin-bottom: 2rem;
}

.ending-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ========== 遮罩 ========== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 50;
  transition: opacity var(--transition-normal);
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ========== AI 模式 ========== */
#btn-ai-toggle {
  position: relative;
  transition: all var(--transition-fast);
}
#btn-ai-toggle.ai-on {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-color: #667eea;
  box-shadow: 0 0 12px rgba(102, 126, 234, 0.4);
}

#ai-indicator {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  padding: 0.4rem 1.2rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
#ai-indicator.visible {
  opacity: 1;
}
.ai-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: ai-pulse 1s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ========== 工具类 ========== */
.hidden {
  display: none !important;
}

/* 点击跳过提示 */
.skip-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
