/* ============================================================
   AI 灵感解码局 —— 全局样式
   深色宇宙 / 解码实验室主题
   ============================================================ */

:root {
  --bg-0: #070a18;
  --bg-1: #0d1226;
  --bg-2: #141a33;
  --panel: #1a2140;
  --panel-2: #212a4d;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef0ff;
  --text-dim: #a6adc8;
  --text-faint: #6f7696;

  --purple: #7c5cff;
  --purple-2: #9d7bff;
  --blue: #2f8cff;
  --teal: #19c2b5;
  --green: #34d399;
  --amber: #ffc53d;
  --orange: #ff7a45;
  --pink: #ff6b9d;
  --red: #ff5b5b;

  --success: #34d399;
  --success-dim: rgba(52, 211, 153, 0.16);
  --warn: #ff9d66;
  --warn-dim: rgba(255, 157, 102, 0.16);

  --radius: 18px;
  --radius-lg: 24px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --glow: 0 0 0 1px rgba(124, 92, 255, 0.35), 0 8px 40px rgba(124, 92, 255, 0.25);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 80% -10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(47, 140, 255, 0.18), transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 背景装饰星点 */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.7), transparent 40%),
    radial-gradient(1.5px 1.5px at 70% 15%, rgba(255, 255, 255, 0.5), transparent 40%),
    radial-gradient(2px 2px at 40% 70%, rgba(255, 255, 255, 0.5), transparent 40%),
    radial-gradient(1.5px 1.5px at 85% 60%, rgba(255, 255, 255, 0.6), transparent 40%),
    radial-gradient(2px 2px at 10% 85%, rgba(255, 255, 255, 0.4), transparent 40%);
}

.app {
  position: relative;
  z-index: 1;
}

a {
  color: var(--purple-2);
}

button {
  font-family: inherit;
  cursor: pointer;
}

h1, h2, h3, h4, p {
  margin: 0;
}

/* ---------- 布局 ---------- */
.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 14px 26px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s;
  box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35);
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn.secondary {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--line);
  border: 1.5px solid var(--line);
}
.btn.secondary:hover { background: rgba(255, 255, 255, 0.04); }

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
}

.btn.teal { background: linear-gradient(135deg, #12b39f, var(--green)); box-shadow: 0 6px 20px rgba(25, 194, 181, 0.35); }
.btn.amber { background: linear-gradient(135deg, var(--orange), var(--amber)); color: #2b1700; box-shadow: 0 6px 20px rgba(255, 197, 61, 0.3); }
.btn.danger { background: linear-gradient(135deg, #e5484d, var(--red)); box-shadow: 0 6px 20px rgba(255, 91, 91, 0.3); }
.btn.lg { padding: 18px 34px; font-size: 20px; border-radius: 16px; }
.btn.sm { padding: 9px 16px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; text-align: left; }
.field label {
  display: block;
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
}
.input {
  width: 100%;
  background: var(--bg-1);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 16px;
  font-size: 17px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25);
}
.input::placeholder { color: var(--text-faint); }

.error-text {
  color: #ff9d8f;
  font-size: 14px;
  margin-top: 6px;
  min-height: 1em;
}

/* 提示标签 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(124, 92, 255, 0.18);
  color: var(--purple-2);
}

/* ---------- 场景卡（题库插画） ---------- */
.scene-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(145deg, var(--panel-2), var(--bg-1));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 26px 20px;
  min-height: 160px;
  text-align: center;
}
.scene-card .scene-emoji {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.4));
}
.scene-card .scene-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.scene-card .scene-alt {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 440px;
}
.scene-card .scene-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(240px 160px at 50% 0%, var(--accent, rgba(124, 92, 255, 0.35)), transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}

.text-media {
  background: linear-gradient(145deg, var(--panel-2), var(--bg-1));
  border: 1px solid var(--line);
  border-left: 4px solid var(--purple);
  border-radius: var(--radius);
  padding: 20px 22px;
  text-align: left;
}
.text-media .text-media-title {
  font-size: 13px;
  color: var(--purple-2);
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}
.text-media .text-media-body {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* ---------- 选项按钮 A/B/C/D ---------- */
.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  min-height: 64px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.option:hover { border-color: var(--purple); background: var(--panel-2); }
.option:active { transform: scale(0.99); }
.option .opt-key {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}
.option.selected { border-color: var(--blue); background: rgba(47, 140, 255, 0.14); }
.option.selected .opt-key { background: var(--blue); color: #fff; }
.option.correct {
  border-color: var(--green);
  background: var(--success-dim);
}
.option.correct .opt-key { background: var(--green); color: #06281c; }
.option.wrong {
  border-color: var(--orange);
  background: var(--warn-dim);
}
.option.wrong .opt-key { background: var(--orange); color: #2b1700; }
.option.dim { opacity: 0.55; }
.option:disabled { cursor: default; }

/* ---------- 倒计时 ---------- */
.countdown {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.countdown .ring {
  --p: 1;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.12) 0);
  display: grid;
  place-items: center;
}
.countdown .ring .ring-inner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-1);
  display: grid;
  place-items: center;
  font-size: 18px;
}
.countdown.low .ring { background: conic-gradient(var(--orange) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.12) 0); }

/* ---------- 徽章 / 榜单 ---------- */
.badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 22px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(124, 92, 255, 0.22), rgba(47, 140, 255, 0.14));
  border: 1px solid rgba(124, 92, 255, 0.4);
}
.badge .badge-emoji { font-size: 44px; }
.badge .badge-title { font-size: 20px; font-weight: 800; }

.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.leaderboard .lb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
}
.leaderboard .lb-rank {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
}
.leaderboard .lb-rank.r1 { background: var(--amber); color: #2b1700; }
.leaderboard .lb-rank.r2 { background: #c7d0e6; color: #1a2140; }
.leaderboard .lb-rank.r3 { background: #d98b5f; color: #2b1700; }
.leaderboard .lb-name { flex: 1; font-weight: 700; }
.leaderboard .lb-score { font-variant-numeric: tabular-nums; color: var(--amber); font-weight: 800; }

/* ---------- 能力条 ---------- */
.ability-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ability-row .ability-name { width: 64px; color: var(--text-dim); font-size: 14px; }
.ability-row .ability-bar {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.ability-row .ability-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--blue));
  transition: width 0.6s ease;
}
.ability-row .ability-count { width: 44px; text-align: right; font-weight: 700; }

/* ---------- 首页 ---------- */
.hero { padding: 60px 0 40px; }
.hero .logo-mark {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 48px;
  margin-bottom: 24px;
  background: linear-gradient(145deg, var(--purple), var(--blue));
  box-shadow: var(--glow);
}
.hero h1 {
  font-size: clamp(34px, 6vw, 60px);
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #c9b8ff, #8fb7ff, #8ff0e4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .subtitle {
  font-size: clamp(17px, 2.5vw, 22px);
  color: var(--text-dim);
  margin: 16px auto 8px;
  max-width: 620px;
}
.hero .actions { display: flex; gap: 14px; margin-top: 30px; flex-wrap: wrap; justify-content: center; }
.how-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; }
.how-card { text-align: left; }
.how-card .how-emoji { font-size: 34px; }
.how-card h3 { margin: 12px 0 6px; font-size: 18px; }
.how-card p { color: var(--text-dim); font-size: 15px; }

/* ---------- 房间码展示 ---------- */
.room-code-display {
  font-size: clamp(40px, 9vw, 84px);
  font-weight: 900;
  letter-spacing: 8px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 30px rgba(124, 92, 255, 0.7);
}
.qr-card {
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  display: inline-block;
  box-shadow: var(--shadow);
}
.qr-card img, .qr-card svg { display: block; width: 100%; height: auto; }

/* ---------- 昵称气泡 ---------- */
.bubble-wall { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.bubble {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 600;
  animation: bubble-in 0.4s ease both;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 分布柱状图 ---------- */
.dist-list { display: flex; flex-direction: column; gap: 12px; }
.dist-row { display: flex; align-items: center; gap: 12px; }
.dist-row .dist-key {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
}
.dist-row .dist-track {
  flex: 1;
  height: 22px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  position: relative;
}
.dist-row .dist-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--purple), var(--blue));
  transition: width 0.6s ease;
  min-width: 0;
}
.dist-row .dist-fill.correct-bar { background: linear-gradient(90deg, var(--teal), var(--green)); }
.dist-row .dist-count { flex: 0 0 auto; width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- 状态徽标 ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 38, 0.6);
  backdrop-filter: blur(8px);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.topbar .brand .mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(145deg, var(--purple), var(--blue));
}

/* ---------- 隐藏 ---------- */
.hidden { display: none !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .container { padding: 16px 14px; }
  .option-grid { grid-template-columns: 1fr; }
  .how-cards { grid-template-columns: 1fr; }
  .hero { padding: 36px 0 24px; }
  .option { min-height: 56px; padding: 14px; }
  .btn.lg { padding: 16px 24px; font-size: 18px; }
}

/* ---------- 减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- 通用工具 ---------- */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; }
.gap-12 { display: flex; gap: 12px; }
.muted { color: var(--text-dim); }
.small { font-size: 14px; }
.center-text { text-align: center; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--purple-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
