/* ================================================================
   LUT 偏好排序测试 · 样式（自适应：手机不滚动，桌面大屏最大化）
   ================================================================ */

:root {
  --bg: #0f0f12;
  --surface: #1a1a20;
  --border: #2a2a32;
  --text: #e8e8ec;
  --text-dim: #9a9aa6;
  --accent: #5b8def;
  --accent-hover: #7aa3ff;
  --danger: #e85b5b;
  --radius: 12px;
  /* 顶部 header + 进度条 + 底部按钮的预留高度，由布局自动分配，这里只作安全间距参考 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 占满整屏，用 dvh 适配移动端地址栏伸缩；老浏览器回退 vh */
html, body { height: 100vh; height: 100dvh; }

body {
  overflow: hidden; /* 整页不滚动，全部内容适配一屏 */
}

/* 主容器：纵向 flex，占满视口，各区块按可用空间分配 */
.app {
  max-width: 1400px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(16px + var(--safe-top)) 20px calc(16px + var(--safe-bottom));
  gap: 16px;
}

/* ---------- 顶部 ---------- */
.header {
  text-align: center;
  flex: 0 0 auto;
}
.header h1 {
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 600;
  margin-bottom: 6px;
}
.header p {
  color: var(--text-dim);
  font-size: clamp(13px, 1.4vw, 15px);
}

/* ---------- 进度条 ---------- */
.progress {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  font-size: 14px;
  color: var(--text-dim);
}
.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ---------- 对比区（核心，撑满剩余高度） ---------- */
.compare {
  flex: 1 1 auto;
  min-height: 0;            /* 允许 flex 子项收缩，否则会撑破容器导致滚动 */
  display: grid;
  grid-template-rows: 1fr;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  touch-action: manipulation;   /* ④ 减少点击延迟，禁用双指缩放手势干扰 */
}
.compare-side {
  position: relative;
  min-height: 0;            /* 关键：让图片在限高容器内被 object-fit 裁切 */
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
  outline: none;
  padding: 0;
}
.compare-side:focus-visible,
.compare-side:hover {
  border-color: var(--accent);
}
.compare-side:active {
  transform: scale(0.98);
}
.compare-side img {
  width: 100%;
  height: 100%;
  object-fit: cover;        /* 限高容器内填满并裁切，避免溢出 */
  display: block;
  background: var(--surface);
  /* ① 微信 X5 内核：禁用图片拖拽/长按菜单，点击直接落到 button 上，避免"乱跳" */
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.compare-side .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}
.compare-side.loaded .placeholder { display: none; }

/* 底部操作：始终贴底可见，flex 0 0 auto 不参与拉伸 */
.compare-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--border); border-color: var(--accent); }
.btn-tie { color: var(--text-dim); }
.btn-skip { color: var(--text-dim); font-size: 13px; padding: 8px 14px; }

/* ---------- 致谢页 ---------- */
.done {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}
.done h2 {
  font-size: 24px;
  font-weight: 600;
}
.done p {
  color: var(--text-dim);
}
.done-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- 结果页（不受影响，保持原样） ---------- */
.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card .label { color: var(--text-dim); font-size: 12px; margin-bottom: 4px; }
.stat-card .value { font-size: 22px; font-weight: 600; }

.section-title {
  font-size: 18px;
  margin: 32px 0 16px;
  font-weight: 600;
}

.top10-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.top10-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.top10-cell .rank {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}
.top10-cell .name { font-size: 14px; font-weight: 500; }
.top10-cell .score { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.tiers {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tier {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.tier-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.tier-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tier-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
}

/* ---------- 移动端（竖屏窄屏）：两张图上下排，仍在一屏内 ---------- */
@media (max-width: 720px) {
  .app { padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bottom)); gap: 12px; }
  .header h1 { font-size: 18px; }
  .header p { font-size: 13px; }
  .compare {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;   /* 上下平分高度 */
    gap: 8px;
  }
}

/* ---------- 错误状态 ---------- */
.error-banner {
  background: rgba(232, 91, 91, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
