/* ============================================================================
 * 猜成语 · AI看图猜成语生成器 · 样式（暖色国风 / 自适应：桌面分栏，移动纵向）
 * ==========================================================================*/
:root {
  --bg:          #f5f0e1;   /* 暖米色页面背景 */
  --card:        #ffffff;   /* 卡片白 */
  --hint-bg:     #faf8f5;   /* 提示图暖白底 */
  --line:        #d4c5a9;   /* 浅木色描边 */
  --seal:        #c0392b;   /* 中国红印章 */
  --input-bd:    #8b7355;   /* 输入框深木色边框 */
  --focus:       #e6b422;   /* 聚焦金色光晕 */
  --btn:         #8b5e3c;   /* 棕木按钮 */
  --btn-dark:    #6f4a2e;
  --text:        #3e2723;   /* 文字深棕 */
  --text-2:      #8d6e63;   /* 辅助文字 */
  --green:       #27ae60;   /* 正确 */
  --red:         #e74c3c;   /* 错误 */
  --blue:        #2980b9;   /* 提示按钮 */
  --blue-dark:   #21618c;
  --shadow:      0 2px 8px rgba(0, 0, 0, 0.06);
  --topbar-h:    56px;
  --tabbar-h:    50px;
  --font-cn:     "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --font-serif:  "Kaiti SC", "KaiTi", "STKaiti", "Noto Serif SC", "Songti SC", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-cn);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul { list-style: none; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── 顶部导航（适配 safe-area-inset-top）──────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 20px;
  padding-right: 20px;
  background: var(--card);
  border-bottom: 1px solid #ece3d2;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 32px; height: 32px; object-fit: contain; }
.brand .name { font-size: 18px; font-weight: 600; color: var(--text); }
.nav-links { display: flex; gap: 18px; }
.nav-links a { color: var(--text-2); font-size: 16px; }
.nav-links a:hover { color: var(--btn); }

/* ── 游戏主区：桌面左右分栏 ──────────────────────────────────────────────── */
.game-screen {
  display: flex;
  gap: 24px;
  align-items: stretch;
  justify-content: center;
  min-height: calc(100dvh - var(--topbar-h));
  padding: 24px;
  max-width: 1180px;
  margin: 0 auto;
}

/* 左侧提示图区（55%） */
.hint-area {
  flex: 1 1 55%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 0;
}

.hint-frame {
  position: relative;
  width: min(480px, 100%);
  aspect-ratio: 1 / 1;
  background: var(--hint-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(62, 39, 35, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* 装裱画框的内衬细线 */
.hint-frame::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid #e8dec9;
  border-radius: 10px;
  pointer-events: none;
}

/* 加载骨架屏 */
.hint-skeleton {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--hint-bg);
  z-index: 3;
}
.hint-skeleton.show { display: flex; }
.sk-block {
  width: 56%;
  height: 26%;
  border-radius: 12px;
  background: linear-gradient(90deg, #efe8d8 25%, #f7f2e6 50%, #efe8d8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* 提示内容：Emoji 组合，淡入 */
.hint-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.hint-display.in { opacity: 1; }

.hint-emoji {
  font-size: clamp(48px, 11vw, 76px);
  letter-spacing: 8px;
  text-align: center;
  line-height: 1.3;
  word-break: break-all;
  user-select: none;
  -webkit-user-select: none;
}
.hint-read {
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--text-2);
  text-align: center;
}

/* 印章装饰 */
.seal {
  position: absolute;
  right: 20px;
  bottom: 44px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 20px;
  color: #fff;
  background: var(--seal);
  border-radius: 6px;
  transform: rotate(8deg);
  opacity: 0.88;
  pointer-events: none;
}

.ai-tag {
  position: absolute;
  left: 20px;
  bottom: 20px;
  font-size: 16px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #ece3d2;
  border-radius: 999px;
  padding: 2px 12px;
  pointer-events: none;
}

/* 答对/答错 盖章动画（默认隐藏，答对/答错后由 JS 去掉 hidden） */
.result-stamp {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}
.result-stamp:not([hidden]) {
  display: flex;
}
.stamp-text {
  font-family: var(--font-serif);
  font-size: 96px;
  font-weight: 700;
  color: var(--seal);
  border: 6px solid var(--seal);
  border-radius: 16px;
  padding: 6px 22px;
  background: rgba(255, 255, 255, 0.72);
  transform: rotate(-12deg) scale(1);
  animation: stamp-in 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.result-stamp.wrong .stamp-text { color: var(--text-2); border-color: var(--text-2); }
@keyframes stamp-in {
  from { transform: rotate(-12deg) scale(2.2); opacity: 0; }
  to   { transform: rotate(-12deg) scale(1); opacity: 1; }
}

/* 提示内容板 */
.hint-board {
  width: min(480px, 100%);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fdf9ee;
  border: 1px solid #ecd9a8;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 16px;
  color: #6d5a2e;
}
.hint-board-tag {
  flex: 0 0 auto;
  font-size: 16px;
  color: #fff;
  background: var(--blue);
  border-radius: 6px;
  padding: 0 8px;
  line-height: 26px;
}

/* ── 右侧答题区（45%）────────────────────────────────────────────────────── */
.answer-panel {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 24px;
  align-self: center;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.q-no {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.q-stats { display: flex; gap: 14px; font-size: 16px; color: var(--text-2); flex-wrap: wrap; }
.q-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.q-stats .combo b { color: var(--seal); }

.answer-input-wrap { position: relative; }
.answer-input {
  width: 100%;
  font-family: var(--font-serif);
  font-size: 30px;
  text-align: center;
  letter-spacing: 10px;
  color: var(--text);
  background: var(--hint-bg);
  border: 2px solid var(--input-bd);
  border-radius: 10px;
  padding: 12px 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.answer-input::placeholder { font-size: 18px; letter-spacing: 2px; color: #b5a58f; }
.answer-input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(230, 180, 34, 0.25);
}
.answer-input.ok    { border-color: var(--green); box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.18); }
.answer-input.bad   { border-color: var(--red); box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.18); animation: shake 0.3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.feedback {
  min-height: 72px;
  height: 72px;
  padding: 6px 4px;
  box-sizing: border-box;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
  color: var(--text-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  word-break: break-all;
}
.feedback.ok  { color: var(--green); }
.feedback.bad { color: var(--red); }

.btn-row { display: flex; gap: 10px; }
.btn {
  flex: 1 1 auto;
  min-width: 72px;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 17px;
  border-radius: 8px;
  background: var(--btn);
  color: #fff;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--btn-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { flex: 1.4 1 auto; font-weight: 600; }
.btn.hint-btn { background: var(--blue); }
.btn.hint-btn:hover { background: var(--blue-dark); }
.btn.ghost {
  background: var(--hint-bg);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: #f3ecdd; }
.btn.ghost.off { color: var(--text-2); }

.panel-options {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.field { flex: 1 1 auto; }
.field label { display: block; font-size: 16px; color: var(--text-2); margin-bottom: 6px; }
.field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--hint-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.sound-btn { flex: 0 0 auto; }

.best-line {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  color: var(--text-2);
  border-top: 1px dashed #e8dec9;
  padding-top: 12px;
}
.best-line b { color: var(--text); }

/* ── 广告位（CSS :not(:empty) 控制，JS 不操作）────────────────────────────── */
.ad-slot {
  display: none;
  min-height: 60px;
  max-height: 60px;
  margin: 10px 16px;
  color: #999;
  font-size: 14px;
  border-radius: 8px;
  border: 1px dashed #ccc;
  background: #fafafa;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-slot:not(:empty) { display: flex; flex: 0 0 60px; }

/* ── 内容区 ───────────────────────────────────────────────────────────────── */
.content {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}
.content-h2 { font-size: 26px; color: var(--text); margin-bottom: 8px; font-family: var(--font-serif); }
.content .lead {
  font-size: 17px;
  color: #5d5048;
  line-height: 1.8;
  margin-bottom: 24px;
  max-width: 760px;
}

.card-block[id], .game-screen, #panel { scroll-margin-top: calc(var(--topbar-h) + 16px); }

.card-block {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-block h2 { font-size: 20px; color: var(--text); margin-bottom: 12px; }
.card-block h3 { font-size: 17px; color: var(--text); margin: 16px 0 8px; }
.card-block p { color: #5d5048; margin-bottom: 12px; }
.card-block ol, .card-block ul.steps { padding-left: 22px; color: #5d5048; }
.card-block ol li, .card-block ul.steps li { margin-bottom: 10px; }
.card-block ul.steps { list-style: disc; }

.example-list { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 14px; }
.example-list li {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: var(--hint-bg);
  border: 1px solid #ece3d2;
  border-radius: 10px;
}
.example-list .ex-emoji {
  flex: 0 0 84px;
  font-size: 30px;
  text-align: center;
  letter-spacing: 2px;
}
.example-list .ex-ans { font-size: 16px; color: #5d5048; }
.example-list .ex-ans b {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text);
  margin-right: 6px;
}

.faq-item { border-bottom: 1px solid #f0ebe0; padding: 14px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-weight: 600; color: var(--text); margin-bottom: 6px; }
.faq-a { color: #5d5048; margin: 0; }

.records-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.records-table {
  width: 100%;
  min-width: 420px;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 16px;
}
.records-table .col-date { width: 24%; }
.records-table .col-diff { width: 14%; }
.records-table .col-score { width: 14%; }
.records-table .col-combo { width: 14%; }
.records-table .col-progress { width: 34%; }
.records-table th, .records-table td {
  padding: 12px 10px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid #f0ebe0;
  white-space: nowrap;
}
.records-table th { color: var(--text-2); font-weight: 600; font-size: 15px; }
.records-table td.empty { color: var(--text-2); padding: 24px; white-space: normal; }
.records-table tr.rec-row-live { background: #fdf9ee; }
.records-table .rec-progress { white-space: normal; }
.rec-frac {
  display: block;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}
.rec-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.4;
  padding: 1px 8px;
  border-radius: 999px;
}
.rec-badge.live { color: var(--blue); background: rgba(41, 128, 185, 0.12); }
.rec-badge.part { color: var(--text-2); background: #f0ebe0; }

@media (max-width: 560px) {
  .records-wrap { overflow-x: visible; }
  .records-table { min-width: 0; display: block; }
  .records-table thead { display: none; }
  .records-table tbody { display: block; }
  .records-table tr {
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid #f0ebe0;
  }
  .records-table tr.rec-row-live { border-radius: 10px; margin-bottom: 8px; }
  .records-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-bottom: none;
    text-align: right;
    white-space: nowrap;
  }
  .records-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--text-2);
    font-size: 15px;
    text-align: left;
  }
  .records-table td.rec-progress { align-items: flex-start; }
  .records-table td.rec-progress::before { padding-top: 2px; }
  .records-table .rec-progress .rec-frac { text-align: right; }
  .records-table td.empty {
    display: block;
    text-align: center;
    padding: 24px 12px;
  }
  .records-table td.empty::before { content: none; }
}

/* ── 页脚 ─────────────────────────────────────────────────────────────────── */
.footer {
  background: #3e2723;
  color: #e9ded2;
  text-align: center;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
  font-size: 14px;
  line-height: 1.8;
}
.footer a { color: inherit; text-decoration: none; }

/* ── 移动端 TabBar（适配 safe-area-inset-bottom）──────────────────────────── */
.tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 90;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid #ece3d2;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}
.tabbar-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 12px;
  color: var(--text-2);
}
.tabbar-btn .ico {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.2;
}
.tabbar-btn.active { color: var(--btn); }

/* ── 响应式：移动端（纵向布局，图上输入下）─────────────────────────────────── */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .topbar { justify-content: center; }

  .game-screen {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 12px;
    min-height: auto;
  }

  .hint-area { width: 100%; gap: 10px; }
  .hint-frame { width: min(86vw, 340px); margin: 0 auto; }
  .hint-emoji { font-size: clamp(44px, 13vw, 60px); letter-spacing: 6px; }
  .seal { width: 30px; height: 30px; font-size: 17px; right: 14px; bottom: 36px; }
  .ai-tag { left: 14px; bottom: 14px; }
  .stamp-text { font-size: 64px; border-width: 4px; }
  .hint-board { width: 100%; }

  .answer-panel {
    flex: 1 1 auto;
    width: 100%;
    align-self: stretch;
    padding: 18px 16px;
    gap: 13px;
  }
  .answer-input { font-size: 26px; letter-spacing: 8px; }
  .q-no { font-size: 19px; }
  .q-stats { gap: 10px; }

  /* 底部操作触控友好 */
  .btn { min-height: 48px; }

  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; }
}

@media (max-width: 480px) {
  .example-list li { gap: 12px; padding: 10px; }
  .example-list .ex-emoji { flex-basis: 64px; font-size: 26px; }
  .example-list .ex-ans { font-size: 15px; }
  .example-list .ex-ans b { display: block; margin-bottom: 2px; }
}

@media (max-width: 380px) {
  .brand .name { font-size: 16px; }
  .btn { min-width: 64px; font-size: 16px; padding: 10px 8px; }
  .btn-row { gap: 8px; }
  .hint-frame { width: 92vw; }
  .answer-input { font-size: 24px; letter-spacing: 6px; }
  .panel-options { flex-wrap: wrap; }
}
