/* ==========================================================================
   站内解谜寻宝游戏 treasure-hunt.css
   主题：藏宝图探险 · 金色点缀 · 支持主题暗色模式与移动端响应式
   ========================================================================== */

:root {
  --th-gold: #d4a017;
  --th-gold-deep: #b8860b;
  --th-gold-light: #f5c542;
  --th-ok: #4caf50;
  --th-error: #e53935;
  --th-panel-bg: #faf6ef;
  --th-panel-bg-2: #f5eddd;
  --th-card-bg: #fffdf7;
  --th-text: #3b2f2f;
  --th-text-soft: #8a7968;
  --th-border: rgba(212, 160, 23, 0.35);
  --th-shadow: 0 10px 30px rgba(59, 47, 47, 0.12);
  --th-radius: 14px;
}

[data-theme=dark] {
  --th-panel-bg: #2c3e50;
  --th-panel-bg-2: #1e2a38;
  --th-card-bg: #263445;
  --th-text: #f5e6c8;
  --th-text-soft: #a99c8a;
  --th-border: rgba(212, 160, 23, 0.28);
  --th-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ---------- 全屏粒子背景层 ---------- */

#th-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#treasure-hunt-app {
  position: relative;
  z-index: 1;
  margin: 16px 0 10px;
}

/* ---------- 游戏主面板（羊皮纸质感） ---------- */

.th-panel {
  position: relative;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(245, 197, 66, 0.08), transparent 55%),
    linear-gradient(160deg, var(--th-panel-bg), var(--th-panel-bg-2));
  border: 1.5px solid var(--th-border);
  border-radius: var(--th-radius);
  box-shadow: var(--th-shadow);
  padding: 20px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.th-panel.th-panel-in {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- 进度总览 ---------- */

.th-overview {
  margin-bottom: 18px;
}

.th-overview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 12px;
}

.th-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--th-text);
}

.th-stat .th-icon svg {
  width: 17px;
  height: 17px;
  fill: var(--th-gold);
}

.th-stat-best {
  color: var(--th-gold-deep);
}

.th-progress {
  height: 10px;
  background: rgba(212, 160, 23, 0.16);
  border-radius: 999px;
  overflow: hidden;
}

.th-progress-inner {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--th-gold-deep), var(--th-gold), var(--th-gold-light));
  box-shadow: 0 0 8px rgba(245, 197, 66, 0.6);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- 关卡卡片 ---------- */

.th-stage-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.th-stage-card {
  position: relative;
  display: flex;
  gap: 14px;
  background: var(--th-card-bg);
  border: 1.5px solid var(--th-border);
  border-radius: 12px;
  padding: 16px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
}

.th-stage-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(212, 160, 23, 0.18);
}

.th-stage-card.done {
  border-color: rgba(76, 175, 80, 0.4);
  opacity: 0.85;
}

.th-stage-card.active {
  border-color: var(--th-gold);
  animation: th-pulse 2.4s ease-in-out infinite;
}

.th-stage-card.locked {
  opacity: 0.55;
  filter: grayscale(0.4);
}

@keyframes th-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 197, 66, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(245, 197, 66, 0.08); }
}

/* 序号徽章 */
.th-badge {
  flex: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--th-gold), var(--th-gold-deep));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 3px 8px rgba(184, 134, 11, 0.35);
}

.th-stage-card.done .th-badge {
  background: linear-gradient(145deg, #66bb6a, var(--th-ok));
}

.th-stage-card.locked .th-badge {
  background: linear-gradient(145deg, #b0a89a, #8a7968);
}

.th-badge .th-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.th-stage-body {
  flex: 1;
  min-width: 0;
}

.th-stage-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--th-text);
}

.th-riddle {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--th-text);
}

/* 打字机光标 */
.th-caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--th-gold);
  animation: th-caret-blink 0.8s step-end infinite;
}

@keyframes th-caret-blink {
  50% { opacity: 0; }
}

/* 提示区 */
.th-hint-row {
  margin-bottom: 8px;
}

.th-hint-btn {
  background: none;
  border: 1px dashed var(--th-border);
  border-radius: 8px;
  color: var(--th-text-soft);
  font-size: 13px;
  padding: 4px 12px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.th-hint-btn:hover {
  color: var(--th-gold-deep);
  border-color: var(--th-gold);
}

.th-hint-box {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.35s ease, margin 0.35s ease;
}

.th-hint-box.open {
  max-height: 220px;
  opacity: 1;
  margin-top: 10px;
}

.th-hint-box p {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--th-text-soft);
  line-height: 1.6;
}

.th-hint-link {
  font-size: 14px;
  color: var(--th-gold-deep);
  text-decoration: none;
}

.th-hint-link:hover {
  text-decoration: underline;
}

/* ---------- 钥匙孔输入区 ---------- */

.th-keyhole {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.th-input-wrap {
  flex: 1 1 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--th-panel-bg);
  border: 1.5px solid var(--th-border);
  border-radius: 10px;
  padding: 0 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.th-input-wrap:focus-within {
  border-color: var(--th-gold);
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.18);
}

.th-input-wrap .th-icon svg {
  width: 18px;
  height: 18px;
  fill: var(--th-gold);
  flex: none;
}

.th-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  padding: 11px 0;
  font-size: 15px;
  color: var(--th-text);
}

.th-input:disabled {
  opacity: 0.5;
}

.th-input::placeholder {
  color: var(--th-text-soft);
}

.th-submit-btn {
  flex: none;
  border: none;
  border-radius: 10px;
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--th-gold-deep), var(--th-gold) 60%, var(--th-gold-light));
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
}

.th-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(245, 197, 66, 0.45);
}

.th-submit-btn:disabled {
  cursor: not-allowed;
  filter: saturate(0.35) brightness(0.9);
}

.th-keyhole.cooling .th-input-wrap {
  border-color: var(--th-error);
}

.th-msg {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 13px;
  min-height: 1.2em;
}

.th-msg.warn { color: var(--th-gold-deep); }
.th-msg.error { color: var(--th-error); }
.th-msg.ok { color: var(--th-ok); }

/* 答错抖动 */
.th-stage-card.shake {
  animation: th-shake 0.45s ease;
}

@keyframes th-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* 解锁金光扫过 */
.th-stage-card.unlocked-flash::after {
  content: '';
  position: absolute;
  top: 0;
  left: -80%;
  width: 60%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 223, 120, 0.55), transparent);
  animation: th-shine 0.65s ease forwards;
  pointer-events: none;
}

@keyframes th-shine {
  to { left: 120%; }
}

.th-done-note {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--th-ok);
}

.th-locked-note {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--th-text-soft);
}

/* ---------- 终局宝箱 ---------- */

.th-chest-section {
  margin-top: 22px;
  text-align: center;
}

.th-chest {
  display: inline-block;
  cursor: pointer;
  transition: transform 0.25s ease;
  filter: drop-shadow(0 6px 14px rgba(184, 134, 11, 0.35));
  animation: th-chest-float 3s ease-in-out infinite;
}

.th-chest:hover {
  transform: scale(1.06);
}

@keyframes th-chest-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.th-chest-svg {
  width: 130px;
  height: 110px;
}

.th-chest-lid {
  transform-origin: 60px 46px;
  transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.th-chest.open .th-chest-lid {
  transform: rotate(-38deg) translateY(-4px);
}

.th-chest.open {
  animation: none;
}

.th-chest-tip {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--th-text-soft);
}

.th-reward {
  max-width: 520px;
  margin: 16px auto 0;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(245, 197, 66, 0.14), rgba(212, 160, 23, 0.08));
  border: 1.5px solid var(--th-gold);
}

.th-reward.hidden { display: none; }

.th-reward.show {
  animation: th-reward-in 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes th-reward-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.th-reward-title {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--th-gold-deep);
}

.th-reward-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--th-text);
}

.th-reward-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--th-gold-deep);
  font-weight: 600;
  text-decoration: none;
}

.th-reward-link:hover { text-decoration: underline; }

/* ---------- 页面顶部渐变横幅（无封面图时兜底） ---------- */

.th-header {
  position: relative;
  margin: 0 0 18px;
  padding: 46px 24px 40px;
  border-radius: 0 0 18px 18px;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(135deg, #2b1d0e 0%, #5d3a18 45%, #b8860b 100%);
  box-shadow: 0 8px 24px rgba(93, 58, 24, 0.25);
}

.th-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 30%, rgba(255, 223, 120, 0.22), transparent 45%),
    radial-gradient(circle at 82% 70%, rgba(255, 223, 120, 0.16), transparent 45%);
  pointer-events: none;
}

.th-header-badge {
  position: relative;
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 223, 120, 0.65);
  background: rgba(255, 223, 120, 0.12);
  color: #ffe08a;
  font-size: 13px;
  letter-spacing: 2px;
}

.th-header-title {
  position: relative;
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 800;
  color: #fff7e0;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.th-header-sub {
  position: relative;
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(255, 240, 205, 0.85);
}

@media screen and (max-width: 768px) {
  .th-header { padding: 34px 16px 30px; border-radius: 0 0 14px 14px; }
  .th-header-title { font-size: 22px; }
}

/* ---------- 通关留名 ---------- */

.th-cert {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.th-cert-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--th-border);
}

[data-theme=dark] .th-cert-item {
  background: rgba(255, 255, 255, 0.06);
}

.th-cert-label {
  font-size: 12px;
  color: var(--th-text-soft);
}

.th-cert-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--th-gold-deep);
  font-variant-numeric: tabular-nums;
}

.th-report {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--th-border);
  text-align: left;
}

.th-report-title {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--th-gold-deep);
}

.th-report-desc {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--th-text-soft);
}

.th-report-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--th-border);
  background: var(--th-panel-bg);
  color: var(--th-text);
  font-size: 14px;
}

.th-report-input:focus {
  outline: none;
  border-color: var(--th-gold);
}

.th-report-btn {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--th-gold-light), var(--th-gold-deep));
  color: #3a2800;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.th-report-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(184, 134, 11, 0.35);
}

.th-report-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.th-report-done {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--th-ok);
}

/* ---------- 金币雨 ---------- */

.th-coin {
  position: fixed;
  top: -30px;
  z-index: 9999;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, var(--th-gold-light) 45%, var(--th-gold-deep));
  box-shadow: 0 0 6px rgba(245, 197, 66, 0.8), inset -2px -3px 4px rgba(184, 134, 11, 0.55);
  animation-name: th-coin-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes th-coin-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0.2; }
}

/* ---------- 图标通用 ---------- */

.th-icon {
  display: inline-flex;
  line-height: 0;
}

/* ---------- 重置入口 ---------- */

#th-reset-area {
  text-align: right;
  margin: 6px 0 16px;
}

#th-reset-btn {
  background: none;
  border: 1px dashed var(--th-border);
  border-radius: 8px;
  color: var(--th-text-soft);
  font-size: 13px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

#th-reset-btn:hover {
  color: var(--th-error);
  border-color: var(--th-error);
}

/* ---------- 响应式 ---------- */

@media screen and (max-width: 768px) {
  .th-panel { padding: 14px; }
  .th-stage-card { flex-direction: column; gap: 10px; padding: 13px; }
  .th-badge { width: 38px; height: 38px; font-size: 13px; }
  .th-stage-title { font-size: 16px; }
  .th-submit-btn { flex: 1 1 100%; }
}

/* 尊重系统减弱动效设置 */
@media (prefers-reduced-motion: reduce) {
  .th-stage-card.active { animation: none; }
  .th-chest { animation: none; }
  .th-caret { animation: none; }
  .th-coin { animation-duration: 1.6s !important; }
}
