/* ============ 基础:极简、安静(项目书 5 节) ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #16171b;
  --bg-soft: #1d1f24;
  --text: #d9d7d0;
  --text-dim: #8a897f;
  --text-faint: #5d5c55;
  --accent: #c8a06a;       /* 温暖的琥珀,克制使用 */
  --accent-soft: rgba(200, 160, 106, 0.14);
  --bubble-ai: #232529;
  --bubble-user: #1c2230;
  --danger: #b3554d;
  --radius: 18px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  position: absolute; inset: 0;
  display: none;
  opacity: 0;
  transition: opacity .6s ease;
}
.screen.active { display: flex; flex-direction: column; opacity: 1; }

/* 沉默拉长时的全局柔和变暗(氛围,不是 HUD) */
#dim-overlay {
  position: fixed; inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
  z-index: 50;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.primary-btn {
  padding: 13px 48px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1408;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .12em;
  transition: transform .15s ease, opacity .2s;
}
.primary-btn:active { transform: scale(.97); }
.primary-btn:disabled { opacity: .4; cursor: default; }

.ghost-btn {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(217, 215, 208, .18);
  color: var(--text-dim);
  font-size: 13px;
  transition: color .2s, border-color .2s;
}
.ghost-btn:hover { color: var(--text); border-color: rgba(217, 215, 208, .4); }

/* ============ 开局页 ============ */
#screen-start { align-items: center; justify-content: center; }
.start-inner {
  width: min(440px, 92vw);
  display: flex; flex-direction: column; align-items: center;
  gap: 26px;
  padding: 32px 0;
}
.title { font-size: 30px; font-weight: 600; letter-spacing: .3em; text-indent: .3em; }
.subtitle { text-align: center; color: var(--text-dim); font-size: 14.5px; }

.difficulty-group { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.diff-card {
  text-align: left;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid transparent;
  display: flex; flex-direction: column; gap: 3px;
  transition: border-color .2s, background .2s;
}
.diff-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.diff-name { font-size: 16px; color: var(--text); }
.diff-desc { font-size: 13px; color: var(--text-dim); }

.attraction-row {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 18px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  cursor: pointer;
}
.attraction-text { display: flex; flex-direction: column; gap: 3px; }
.attraction-name { font-size: 15px; }
.attraction-desc { font-size: 12.5px; color: var(--text-dim); }

.switch { position: relative; flex: 0 0 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: #33353b;
  transition: background .25s;
}
.slider::before {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .25s, background .25s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: #1a1408; }

.start-hint { font-size: 12px; color: var(--text-faint); letter-spacing: .08em; }

.id-row {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: -6px;
}
.ghost-btn.tiny { padding: 5px 12px; font-size: 12px; }

/* ============ 身份页(无密码侧写) ============ */
#screen-profile { align-items: center; justify-content: center; }
.profile-inner {
  width: min(400px, 90vw);
  display: flex; flex-direction: column; align-items: center;
  gap: 24px;
  padding: 32px 0;
}
.profile-list {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 10px;
  width: 100%;
}
.profile-chip {
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid rgba(217, 215, 208, .14);
  font-size: 16px;
  display: flex; align-items: baseline; gap: 8px;
  transition: border-color .2s, background .2s;
}
.profile-chip:hover { border-color: var(--accent); }
.profile-chip .games { font-size: 12px; color: var(--text-faint); }
.profile-new { display: flex; gap: 10px; width: 100%; justify-content: center; }
.profile-new input {
  flex: 1; max-width: 200px;
  background: var(--bg-soft);
  border: 1px solid rgba(217, 215, 208, .15);
  border-radius: 999px;
  color: var(--text);
  padding: 10px 18px;
  font-size: 15px;
  text-align: center;
}
.profile-new .primary-btn { padding: 10px 26px; font-size: 15px; }
.profile-error { min-height: 20px; color: var(--danger); font-size: 13px; }

/* ============ 训练历史页 ============ */
#screen-history { overflow-y: auto; display: none; }
#screen-history.active { display: block; }
.history-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}
.history-top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.history-title { font-size: 19px; font-weight: 600; letter-spacing: .18em; flex: 1; text-align: center; }
.history-count { font-size: 12.5px; color: var(--text-faint); min-width: 52px; text-align: right; }
.history-pattern {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: #d8c39d;
  font-size: 13.5px;
  line-height: 1.8;
}
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  width: 100%;
  text-align: left;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; gap: 14px; align-items: flex-start;
  transition: border-color .2s;
}
.history-item:hover { border-color: rgba(200, 160, 106, .45); }
.hist-verdict {
  flex: 0 0 44px;
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}
.hist-verdict.win { color: var(--accent); }
.hist-verdict.loss { color: var(--danger); opacity: .85; }
.hist-verdict.open { color: var(--text-dim); font-size: 17px; padding-top: 5px; }
.hist-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.hist-meta { font-size: 12px; color: var(--text-faint); letter-spacing: .06em; }
.hist-scene {
  font-size: 13.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}
.hist-takeaway {
  font-size: 14px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hist-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.hist-tag {
  font-size: 11.5px;
  color: var(--text-dim);
  border: 1px solid rgba(217, 215, 208, .16);
  border-radius: 999px;
  padding: 1px 9px;
}
.history-empty { text-align: center; color: var(--text-faint); padding: 60px 0; line-height: 2.2; }

/* 地点筛选条(场景多了按地点归类) */
.location-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.loc-filter {
  font-size: 12.5px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(217, 215, 208, .16);
  color: var(--text-dim);
  transition: border-color .2s, color .2s, background .2s;
}
.loc-filter.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* 一级:场景列表 */
.scene-list { display: flex; flex-direction: column; gap: 12px; }
.scene-card-row {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
}
.scene-card-row:hover { border-color: rgba(200, 160, 106, .35); }
.scene-open {
  flex: 1; min-width: 0;
  text-align: left;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.scene-row-top { display: flex; align-items: center; gap: 8px; }
.loc-chip {
  font-size: 11.5px;
  color: var(--accent);
  border: 1px solid rgba(200, 160, 106, .4);
  border-radius: 999px;
  padding: 1px 9px;
}
.scene-times { font-size: 12px; color: var(--text-faint); letter-spacing: .04em; }
.hist-verdict.mini { flex: 0; font-size: 15px; margin-left: auto; padding: 0; }
.scene-row-text {
  font-size: 14.5px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.scene-retry {
  flex: 0 0 auto;
  border: none;
  border-left: 1px solid rgba(217, 215, 208, .1);
  border-radius: 0;
  color: var(--accent);
  padding: 0 16px;
  font-size: 13px;
}
.scene-retry:hover { background: var(--accent-soft); }

/* 二级:某场景的全部训练 */
#history-attempts { display: flex; flex-direction: column; gap: 14px; }
.attempts-scene {
  padding: 16px 18px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px dashed rgba(200, 160, 106, .3);
}
.attempts-scene-text { font-size: 15px; line-height: 1.9; margin: 6px 0; }
#btn-retry-from-history { align-self: center; }
.attempts-list { display: flex; flex-direction: column; gap: 12px; }

/* 麦克风测试 */
.mic-test {
  position: absolute; inset: 0;
  background: rgba(22, 23, 27, .96);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.mic-test-card {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  width: min(360px, 90vw);
  text-align: center;
}
.mic-test-card h2 { font-size: 20px; font-weight: 500; }
#mic-test-hint { color: var(--text-dim); font-size: 14px; }
.mic-test-result { min-height: 48px; color: var(--accent); font-size: 14.5px; padding: 0 10px; }
.mic-test-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ============ 开局准备 & 场景介绍 ============ */
.prep-overlay {
  position: fixed; inset: 0;
  background: rgba(22, 23, 27, .97);
  display: flex;
  /* 居中靠子元素 margin:auto:内容超高时可滚动到顶部,按钮永远够得着
     (align-items:center 会把超出部分裁到视口外,小屏长场景直接卡死) */
  overflow-y: auto;
  z-index: 60;
}
.prep-card {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  width: min(340px, 86vw);
  margin: auto;
  text-align: center;
}
.prep-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 26px rgba(200, 160, 106, .55);
  animation: breathe 2.4s ease-in-out infinite;
}
#prep-stage { color: var(--text-dim); font-size: 14.5px; letter-spacing: .08em; }
.prep-bar {
  width: 100%; height: 3px;
  border-radius: 2px;
  background: rgba(217, 215, 208, .12);
  overflow: hidden;
}
.prep-bar i {
  display: block; height: 100%; width: 4%;
  border-radius: 2px;
  background: var(--accent);
  transition: width .24s ease;
}
.prep-error-msg { color: var(--danger); font-size: 14.5px; }

.scene-card {
  display: flex; flex-direction: column; align-items: center; gap: 28px;
  width: min(430px, 88vw);
  margin: auto;
  padding: 28px 6px;
  animation: sceneIn .8s ease;
}
@keyframes sceneIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.scene-kicker {
  color: var(--text-faint);
  font-size: 12.5px;
  letter-spacing: .5em; text-indent: .5em;
}
#scene-text {
  color: var(--text);
  font-size: 16.5px;
  line-height: 2.15;
  text-align: left;
}

/* 场景钉在对话顶部:轻、居中,只是背景信息 */
.bubble.scene-line {
  align-self: center;
  max-width: 92%;
  background: none;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 2px 8px 8px;
}

/* "对方正在输入"指示点:纯等待反馈,无任何成绩含义 */
.bubble.thinking { display: flex; gap: 5px; align-items: center; padding: 15px 18px; }
.bubble.thinking i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: think-pulse 1.2s ease-in-out infinite;
}
.bubble.thinking i:nth-child(2) { animation-delay: .18s; }
.bubble.thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes think-pulse {
  0%, 100% { opacity: .25; transform: translateY(0); }
  50% { opacity: .9; transform: translateY(-2.5px); }
}

/* ============ 对话页 ============ */
#screen-game { background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  z-index: 5;
}
.diff-chip { font-size: 12.5px; color: var(--text-faint); letter-spacing: .15em; }

/* 在场感光环:呼吸式,随沉默温和淡去 */
.presence-wrap {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: center;
  pointer-events: none;
  z-index: 0;
}
#presence-halo {
  width: 340px; height: 340px;
  margin-top: -170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200,160,106,.20) 0%, rgba(200,160,106,.06) 45%, transparent 70%);
  animation: breathe 4.2s ease-in-out infinite;
  opacity: 1;
  transition: opacity 1s ease;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px max(18px, calc(50vw - 320px)) 30px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
  z-index: 1;
}
.chat::-webkit-scrollbar { width: 0; }

.bubble {
  max-width: 78%;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 15.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.ai {
  align-self: flex-start;
  background: var(--bubble-ai);
  border-bottom-left-radius: 6px;
}
.bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  border-bottom-right-radius: 6px;
  color: #c2c7d1;
}
.bubble.meta-bubble {
  align-self: center;
  background: none;
  color: var(--text-faint);
  font-size: 13px;
}
/* 角色神态/动作(括号内容)用更轻的颜色 */
.bubble .stage { color: var(--text-faint); }

.typing-cursor::after {
  content: "▍";
  color: var(--text-faint);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============ 输入区 ============ */
.inputbar {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px;
  padding: 6px 18px calc(22px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 45; /* 高于暂停幕布:暂停时说话按钮仍可用(说「继续」恢复) */
}
.status-line {
  min-height: 22px;
  font-size: 13.5px;
  color: var(--text-dim);
  letter-spacing: .06em;
  transition: opacity .3s;
}

.talk-btn {
  position: relative;
  width: 104px; height: 104px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1.5px solid rgba(200,160,106,.35);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: .1em;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  transition: transform .18s ease, border-color .25s, background .25s, opacity .25s;
  display: flex; align-items: center; justify-content: center;
}
.talk-btn.small { width: 88px; height: 88px; font-size: 14px; }
/* 禁用期放行指针:让按压冒泡到 .inputbar 给轻提示(部分引擎不给 disabled 控件派发指针事件) */
.talk-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }
.talk-btn.recording {
  transform: scale(1.12);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.talk-btn.recording span { display: none; }

.wave { display: flex; gap: 4px; align-items: center; height: 30px; }
.wave i {
  width: 4px; height: 8px;
  border-radius: 2px;
  background: var(--accent);
  transition: height .09s linear;
}

.dev-input-row { display: flex; gap: 8px; width: min(480px, 90vw); }
.dev-input-row input {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid rgba(217,215,208,.15);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
}

.pause-veil {
  position: absolute; inset: 0;
  background: rgba(22,23,27,.82);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  z-index: 40;
  font-size: 18px;
  letter-spacing: .2em;
  /* 幕布只是氛围:绝不拦截指针,否则暂停后按不到说话按钮说「继续」 */
  pointer-events: none;
}
.pause-veil .pause-sub { font-size: 13px; color: var(--text-dim); letter-spacing: .08em; }

/* ============ 报告页 ============ */
#screen-report { overflow-y: auto; display: none; }
#screen-report.active { display: block; }
.report-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 22px 80px;
}
.report-title {
  font-size: 24px; font-weight: 600;
  letter-spacing: .25em;
  margin-bottom: 34px;
  text-align: center;
}

/* 结果英雄区:结局是这局唯一的"成绩",放大、放显眼(评判延迟到此刻,但此刻不含糊) */
.report-hero {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  margin-bottom: 30px;
  padding: 30px 24px 26px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  text-align: center;
}
.hero-verdict { font-size: 64px; font-weight: 700; line-height: 1.15; letter-spacing: .1em; }
.hero-verdict.win { color: var(--accent); text-shadow: 0 0 34px rgba(200, 160, 106, .35); }
.hero-verdict.loss { color: var(--danger); }
.hero-verdict.open { font-size: 40px; color: var(--text-dim); }
.hero-sub { font-size: 12.5px; color: var(--text-faint); letter-spacing: .2em; }
.hero-takeaway {
  margin-top: 8px;
  font-size: 18.5px;
  line-height: 1.9;
  color: #e8e6de;
  border-left: none;
  padding: 0 8px;
  max-width: 560px;
}
.hero-takeaway::before { content: "「"; color: var(--accent); }
.hero-takeaway::after { content: "」"; color: var(--accent); }

/* 场景回放块:把人带回那个现场,报告读起来不悬空 */
.report-scene {
  margin-bottom: 30px;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px dashed rgba(200, 160, 106, .35);
  color: var(--text-dim);
  font-size: 14px;
  line-height: 2;
}
.report-scene::before {
  content: "场景";
  display: block;
  font-size: 11.5px;
  letter-spacing: .4em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.report-section {
  margin-bottom: 14px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
/* 可折叠:点标题展开/收起。summary 是点击热区,右侧雪佛龙随开合旋转 */
.report-section > summary {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 18px 24px;
  -webkit-user-select: none; user-select: none;
}
.report-section > summary::-webkit-details-marker { display: none; }
.report-section > summary h2 {
  flex: 1;
  font-size: 16.5px;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
  letter-spacing: .05em;
}
.report-section > summary::after {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(-45deg);  /* 收起:朝下 */
  transition: transform .2s ease;
  margin-top: -3px;
}
.report-section[open] > summary::after { transform: rotate(45deg); margin-top: 3px; } /* 展开:朝上 */
.report-section > summary:hover h2 { color: #d9b27c; }
.section-body { padding: 0 24px 20px; }
.report-section p { margin: 8px 0; font-size: 14.5px; }
.report-section blockquote {
  margin: 14px 0 6px;
  padding: 8px 14px;
  border-left: 2.5px solid var(--accent);
  background: rgba(200,160,106,.07);
  border-radius: 6px;
  color: #cfcdc4;
  font-size: 14.5px;
}
/* 第 1 区回放:区分说话人,读起来像对话记录 */
.report-section blockquote .who {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: .1em;
  margin-right: 8px;
  opacity: .8;
}
.report-section blockquote.quote-user {
  border-left-color: var(--accent);
}
.report-section blockquote.quote-user .who { color: var(--accent); }
.report-section blockquote.quote-actor {
  border-left-color: rgba(150,160,180,.55);
  background: rgba(150,160,180,.07);
  color: #c4c8d0;
}
.report-section blockquote.quote-actor .who { color: #9aa3b2; }
.report-section ul { margin: 6px 0 6px 2px; list-style: none; }
.report-section li {
  margin: 7px 0;
  padding-left: 16px;
  position: relative;
  font-size: 14.5px;
}
.report-section li::before {
  content: "·";
  position: absolute; left: 2px;
  color: var(--accent);
}

/* 第 5 部分:2~3 种接法并列对比(项目书 5 节) */
.answer-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 10px 0 18px;
}
.answer-card {
  background: var(--bg);
  border: 1px solid rgba(217,215,208,.1);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}
.answer-card .style-name {
  display: block;
  color: var(--accent);
  font-size: 12.5px;
  margin-bottom: 6px;
  letter-spacing: .05em;
}

/* 第 6 部分:一句话带走,放大 */
.report-section.takeaway p {
  font-size: 17.5px;
  line-height: 1.9;
  color: #e6e4dc;
}

.report-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; margin-top: 10px; }
/* 次要主按钮:重试用描边而非实心,让"换个场景"是主行动 */
.primary-btn.ghost-like {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.primary-btn.ghost-like:active { transform: scale(.97); }

@media (max-width: 520px) {
  .bubble { max-width: 86%; }
  .talk-btn { width: 96px; height: 96px; }
}
