/* ============================================================
   apps/huarong.html 样式 · 纸白暖色系（品牌色令牌：墨 / 陶土橙 / 雾蓝 / 橄榄绿）
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* body 用 min-height（而非 height:100%）：让 body 高度随内容增长，保证 sticky 顶栏全程有效 */
html { height: 100%; }
body { min-height: 100%; }
body {
  background:
    radial-gradient(ellipse 60% 45% at 12% -5%,  rgba(217,119,87,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 92% 105%, rgba(106,155,204,0.07) 0%, transparent 60%),
    linear-gradient(180deg, #faf9f5 0%, #f3f1e9 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
a { color: inherit; text-decoration: none; }

:root {
  --bg-page:    #faf9f5;
  --bg-card:    rgba(255,255,255,0.72);
  --bg-card-strong: rgba(255,255,255,0.88);
  --bg-soft:    rgba(255,255,255,0.55);
  --bg-header:  rgba(250, 249, 245, 0.72);
  --text-primary:   #141413;
  --text-secondary: #4f4c44;
  --text-muted:     #7a766c;
  --text-hint:      #b0aea5;
  --text-on-accent: #faf9f5;
  --border:      rgba(20,20,19,0.10);
  --border-soft: rgba(20,20,19,0.06);
  --accent:        #d97757;
  --accent-hover:  #c0663f;
  --accent-soft:   #e0a878;
  --accent-fade:   rgba(217,119,87,0.12);
  --blue:        #6a9bcc;
  --success:     #788c5d;
  --warning:     #b07c3a;
  --danger:      #bb4a36;
  --shadow-sm: 0 1px 2px rgba(20,20,19,0.04), 0 1px 3px rgba(20,20,19,0.06);
  --shadow-md: 0 4px 12px rgba(20,20,19,0.06), 0 8px 24px rgba(20,20,19,0.07);
  --shadow-lg: 0 12px 40px rgba(20,20,19,0.09), 0 24px 60px rgba(20,20,19,0.10);
  --font-display: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-num: "Poppins", "SF Mono", "Consolas", "Liberation Mono", monospace;
}

/* ---------- 顶栏 ---------- */
.back-link-wrapper {
  padding: 0 40px 12px;
  background: var(--bg-header);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  z-index: 5;
}
.back-link { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted); transition: color 0.18s ease; }
.back-link:hover { color: var(--accent); }

/* ---------- 主体 ---------- */
main { flex: 1; padding: 48px 40px 60px; max-width: 1200px; width: 100%; margin: 0 auto; position: relative; z-index: 1; }
.head { text-align: center; margin-bottom: 36px; opacity: 0; animation: fadeUp 0.7s 0.05s ease forwards; }
.head .eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10px; letter-spacing: 0.4em;
  color: var(--accent-hover);
  text-transform: uppercase;
  margin-bottom: 14px;
  padding: 6px 14px;
  background: var(--accent-fade);
  border-radius: 999px;
  font-weight: 600;
}
.head h1 {
  font-family: var(--font-display);
  font-size: 44px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text-primary); line-height: 1.1;
}
.head .h1-en { display: block; margin-top: 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.3em; color: var(--text-muted); text-transform: uppercase; }
.head .sub { margin-top: 14px; font-size: 14px; color: var(--text-muted); line-height: 1.7; max-width: 520px; margin-left: auto; margin-right: auto; }

/* ---------- 难度切换 ---------- */
.diff-row {
  display: flex; justify-content: center; gap: 8px; margin-bottom: 28px;
  opacity: 0; animation: fadeUp 0.7s 0.18s ease forwards;
}
.diff-btn {
  padding: 10px 24px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(.4,0,.2,1);
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}
.diff-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.diff-btn.active {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(217,119,87,0.32);
  transform: translateY(-1px);
}

/* ---------- 游戏主区 ---------- */
.game-area {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  align-items: start;
  opacity: 0;
  animation: fadeUp 0.7s 0.30s ease forwards;
}
.board-wrap {
  background: var(--bg-card-strong);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.board-wrap::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.9) 50%, transparent);
}
.progress-row {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  font-size: 11px; letter-spacing: 0.18em; color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.progress-bar {
  flex: 1; height: 6px; background: rgba(20,20,19,0.08); border-radius: 999px; overflow: hidden; position: relative;
}
.progress-fill {
  height: 100%; width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 12px rgba(217,119,87,0.35);
}
.progress-text { font-family: var(--font-num); font-size: 12px; min-width: 56px; text-align: right; }

.board {
  position: relative;
  width: 480px;
  height: 480px;
  max-width: 100%;
  aspect-ratio: 1;
  background:
    radial-gradient(circle at 50% 40%, #ffffff 0%, #f2efe6 100%);
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 2px 12px rgba(20,20,19,0.05), inset 0 -1px 0 rgba(255,255,255,0.8);
  overflow: hidden;
}

/* 瓦片默认占位（凹槽） */
.tile-slot {
  position: absolute;
  width: calc(100% / var(--n) - 6px);
  height: calc(100% / var(--n) - 6px);
  margin: 3px;
  border-radius: 14px;
  background: rgba(20,20,19,0.045);
  box-shadow: inset 0 2px 6px rgba(20,20,19,0.05);
}

/* 数字瓦片：奶油白棋子 + 墨色数字 */
.tile {
  position: absolute;
  width: calc(100% / var(--n) - 6px);
  height: calc(100% / var(--n) - 6px);
  margin: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 600;
  color: var(--text-primary);
  background: linear-gradient(180deg, #ffffff 0%, #f4f1e8 100%);
  border: 1px solid rgba(20,20,19,0.08);
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), box-shadow 0.22s ease, border-color 0.22s ease, filter 0.22s ease;
  box-shadow:
    0 2px 6px rgba(20,20,19,0.05),
    0 6px 14px rgba(20,20,19,0.06),
    inset 0 1px 0 rgba(255,255,255,0.85),
    inset 0 -2px 4px rgba(20,20,19,0.04);
  will-change: transform;
  z-index: 2;
}
.tile::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.5) 0%, transparent 45%);
  pointer-events: none;
}
.tile:hover {
  box-shadow:
    0 4px 10px rgba(20,20,19,0.07),
    0 10px 24px rgba(20,20,19,0.09),
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -2px 4px rgba(20,20,19,0.04);
}
/* 可移动：陶土橙描边呼吸提示 */
.tile.movable {
  border-color: rgba(217,119,87,0.55);
  animation: pulseHint 2.2s ease-in-out infinite;
}
.tile.movable:hover {
  animation: none;
  border-color: var(--accent);
  filter: brightness(0.99);
  box-shadow:
    0 0 0 2px rgba(217,119,87,0.65),
    0 8px 22px rgba(217,119,87,0.25),
    inset 0 1px 0 rgba(255,255,255,0.9);
}
.tile.movable:hover::after { opacity: 0.7; }

/* 已归位：橙色棋子（与"新一局"主按钮 #d97757 同色族） */
.tile.correct {
  color: var(--text-on-accent);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--accent) 100%);
  border-color: rgba(20,20,19,0.12);
  box-shadow:
    0 2px 6px rgba(217,119,87,0.30),
    0 6px 16px rgba(217,119,87,0.22),
    inset 0 1px 0 rgba(255,255,255,0.25),
    inset 0 -2px 4px rgba(20,20,19,0.08);
}
.tile.correct::after {
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, transparent 45%);
}
.tile.correct.movable {
  box-shadow:
    0 0 0 2px rgba(217,119,87,0.6),
    0 6px 18px rgba(217,119,87,0.30),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

/* 难度调整字号 */
.board[data-diff="5"] .tile { font-size: 22px; border-radius: 12px; }
.board[data-diff="5"] .tile-slot { border-radius: 12px; }
.board[data-diff="3"] .tile { font-size: 40px; }
.board[data-diff="3"] .tile-slot { border-radius: 16px; }

@keyframes pulseHint {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(217,119,87,0.32),
      0 6px 16px rgba(217,119,87,0.12),
      inset 0 1px 0 rgba(255,255,255,0.9);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(217,119,87,0.65),
      0 8px 22px rgba(217,119,87,0.26),
      inset 0 1px 0 rgba(255,255,255,0.9);
  }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 右侧状态栏 ---------- */
.stats-panel {
  display: flex; flex-direction: column; gap: 14px;
  opacity: 0; animation: fadeUp 0.7s 0.42s ease forwards;
}
.stat-card {
  background: var(--bg-card-strong);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 3px; height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card .l { font-size: 10px; letter-spacing: 0.3em; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; font-weight: 600; }
.stat-card .v { font-family: var(--font-num); font-size: 30px; font-weight: 300; color: var(--text-primary); line-height: 1; letter-spacing: -0.02em; }

.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  flex: 1; padding: 13px 16px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  background: var(--bg-card-strong);
  backdrop-filter: blur(12px);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(.4,0,.2,1);
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(217,119,87,0.28);
}
.btn.primary:hover {
  background: var(--accent-hover);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: 0 10px 28px rgba(217,119,87,0.36);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.best-card {
  background: linear-gradient(135deg, rgba(217,119,87,0.08) 0%, rgba(106,155,204,0.06) 100%);
  border: 1px solid rgba(217,119,87,0.22);
}
.best-card::before { background: var(--success); }
.best-card .l { color: var(--accent-hover); }
.best-card .v { color: var(--accent-hover); font-size: 22px; font-weight: 400; }

.hint {
  font-size: 12px; color: var(--text-secondary); line-height: 1.8;
  padding: 14px 18px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px dashed rgba(20,20,19,0.14);
  border-radius: 12px;
}
.hint b { color: var(--text-primary); font-weight: 600; }
.hint code {
  background: var(--accent-fade);
  color: var(--accent-hover);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.status-info {
  padding: 14px 18px;
  font-size: 12px; line-height: 1.7;
  color: var(--text-secondary);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}
.status-info .guest { color: var(--warning); font-weight: 600; }

/* ---------- 通关弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(20,20,19,0.45);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.modal-mask.show { display: flex; opacity: 1; }
.modal {
  background: var(--bg-card-strong);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  max-width: 440px; width: calc(100% - 40px);
  padding: 44px 36px 32px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-lg);
  transform: scale(0.92) translateY(20px);
  transition: transform 0.4s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}
.modal-mask.show .modal { transform: scale(1) translateY(0); }
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, #d97757 0%, #6a9bcc 50%, #788c5d 100%);
}
.modal h2 {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.modal h2 .em { color: var(--accent); }
.modal .sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.modal .result { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.modal .result .r {
  padding: 16px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
}
.modal .result .r .l { font-size: 10px; letter-spacing: 0.3em; color: var(--text-muted); text-transform: uppercase; margin-bottom: 6px; font-weight: 600; }
.modal .result .r .v { font-family: var(--font-num); font-size: 24px; font-weight: 400; color: var(--text-primary); }
.modal .badge {
  display: inline-block;
  padding: 6px 16px;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  background: var(--accent);
  color: var(--text-on-accent);
  border-radius: 999px;
  margin-bottom: 20px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(217,119,87,0.28);
}
.modal .badge[hidden] { display: none; }
.modal .badge.guest { background: #f2ede0; color: #8a7450; box-shadow: none; }
.modal .actions { display: flex; gap: 10px; justify-content: center; margin-top: 4px; }
.modal .close {
  position: absolute; top: 14px; right: 18px;
  background: rgba(20,20,19,0.06);
  border: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
}
.modal .close:hover { background: rgba(187,74,54,0.12); color: var(--danger); transform: rotate(90deg); }

/* ---------- Confetti ---------- */
.confetti-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 99;
}
.confetti {
  position: absolute;
  width: 8px; height: 14px;
  top: -20px;
  opacity: 0.95;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.4; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #141413;
  color: var(--text-on-accent);
  padding: 12px 24px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(20,20,19,0.28);
  opacity: 0;
  transition: all 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 100;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ---------- 底栏 ---------- */
.footer {
  padding: 24px 40px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 5;
}
.footer .right { display: inline-flex; gap: 24px; }
.footer .live::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 8px rgba(120,140,93,0.6);
  animation: pulseDot 2s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 6px rgba(120,140,93,0.4); }
  50%      { box-shadow: 0 0 10px rgba(120,140,93,0.8); }
}

@media (max-width: 900px) {
  .game-area { grid-template-columns: 1fr; }
  .board { width: 360px; height: 360px; }
  main { padding: 32px 20px 40px; }
  .head h1 { font-size: 36px; }
}
@media (max-width: 480px) {
  .board { width: 300px; height: 300px; }
  .back-link-wrapper, .footer { padding: 16px 20px; }
  .head h1 { font-size: 28px; }
  .stat-card .v { font-size: 24px; }
}
