/* 祈灵连连乐 · 首页（英文 / 和中文 /zh/ 共用）。颜色跟游戏默认主题「夜色果园」一致（game/themes.js） */
:root {
  --bg1: #16323a;
  --bg2: #0e2228;
  --text: #f4efe6;
  --muted: #9fb7b9;
  --accent: #ffd166;
  --accent-ink: #3a2a00;
  --red: #ff5d73;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-line: rgba(255, 255, 255, 0.1);
  --line-glow: rgba(255, 209, 102, 0.8);
  --tile-top: 97%;
  --tile-bottom: 89%;
  --tile-edge: 62%;
  --radius: 18px;
  --wrap: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: radial-gradient(120% 60% at 50% 0%, var(--bg1), var(--bg2) 70%) no-repeat, var(--bg2);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, calc((100% - var(--wrap)) / 2)) 10px;
  background: rgba(14, 34, 40, 0.82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; text-decoration: none; white-space: nowrap; }
.brand img { border-radius: 8px; }
.top-nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.top-nav a { text-decoration: none; color: var(--muted); white-space: nowrap; }
.top-nav a:hover { color: var(--text); }
.top-nav .lang { padding: 4px 10px; border: 1px solid var(--panel-line); border-radius: 999px; }

.btn {
  display: inline-block; text-decoration: none; font-weight: 800; white-space: nowrap;
  background: var(--accent); color: var(--accent-ink) !important; border-radius: 999px;
  box-shadow: 0 4px 0 #c99a2e, 0 8px 18px rgba(0, 0, 0, 0.3);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 #c99a2e, 0 10px 22px rgba(0, 0, 0, 0.35); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c99a2e, 0 4px 10px rgba(0, 0, 0, 0.3); }
.btn.small { padding: 6px 16px; font-size: 14px; box-shadow: 0 3px 0 #c99a2e; }
.btn.big { padding: 14px 34px; font-size: 18px; }

/* ---------- 区块通用 ---------- */
main > section { max-width: var(--wrap); margin: 0 auto; padding: 72px 16px 0; }
.kicker { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 8px; }
h2 { font-size: clamp(26px, 4vw, 36px); font-weight: 800; letter-spacing: -.3px; }
.sub { color: var(--muted); max-width: 680px; margin-top: 12px; }
h3 { font-size: 17px; font-weight: 800; }

/* ---------- 首屏 ---------- */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; padding-top: 56px !important; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 2px; }
.hero h1 { font-size: clamp(40px, 6.4vw, 68px); font-weight: 900; letter-spacing: -1px; margin: 14px 0 18px; }
.hero h1 em { font-style: normal; color: var(--accent); text-shadow: 0 0 28px rgba(255, 209, 102, 0.45); display: inline-block; animation: pop-word 2.6s ease-in-out infinite; }
@keyframes pop-word { 0%, 70%, 100% { transform: scale(1); } 78% { transform: scale(1.14) rotate(-4deg); } 86% { transform: scale(.96); } }
.lead { color: var(--muted); font-size: 18px; max-width: 30em; }
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; margin-top: 30px; }
.note { color: var(--muted); font-size: 13px; }

.demo { margin: 0; }
.demo-board {
  position: relative; display: grid; grid-template-columns: repeat(var(--c), 1fr); gap: 6px;
  padding: calc(100% / (var(--c) + 2) * .62); border-radius: 22px;
  background: rgba(0, 0, 0, 0.18); border: 1px solid var(--panel-line);
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.02), 0 30px 60px rgba(0, 0, 0, 0.35);
}
.demo-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 5; }
.demo-lines polyline { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 6px var(--line-glow)); animation: linefade .5s ease-out forwards; }
@keyframes linefade { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }
.demo figcaption { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 14px; }
.rec { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* 图块（和游戏里一样的立体奶白块，底色色相按图案算） */
.tile { aspect-ratio: 1; position: relative; }
.tile .face {
  width: 100%; height: 100%; border-radius: 22%; display: grid; place-items: center;
  background: linear-gradient(180deg, hsl(var(--h) 80% var(--tile-top)), hsl(var(--h) 65% var(--tile-bottom)));
  box-shadow: 0 var(--depth, 4px) 0 hsl(var(--h) 35% var(--tile-edge)), 0 calc(var(--depth, 4px) + 2px) 6px rgba(0, 0, 0, 0.35);
  transition: transform .15s, box-shadow .15s;
}
.tile .face span { font-size: min(5.2vw, 30px); line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.tile.sel .face { transform: translateY(-3px); box-shadow: 0 0 0 3px var(--accent), 0 7px 0 hsl(var(--h) 35% var(--tile-edge)), 0 8px 14px rgba(0, 0, 0, 0.35); }
.tile.gone { visibility: hidden; }
.tile.popping .face { animation: pop .32s ease-in forwards; }
.tile.enter .face { animation: enter .4s cubic-bezier(.3, 1.4, .5, 1) backwards; animation-delay: var(--delay, 0s); }
@keyframes pop { 30% { transform: scale(1.18); } 100% { transform: scale(0); opacity: 0; } }
@keyframes enter { from { transform: scale(0); opacity: 0; } }

/* ---------- 规则示意图 ---------- */
.rules { list-style: none; padding: 0; margin: 32px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.rule { background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius); padding: 18px; }
.rule p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.diagram { display: block; width: 100%; height: auto; margin-bottom: 14px; }
.diagram .outside { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-dasharray: 3 4; }
.diagram .cell { fill: rgba(255, 255, 255, 0.04); }
.diagram .block { fill: rgba(159, 183, 185, 0.35); }
.diagram .pair { fill: #fff6ee; }
.diagram text { font-size: 13px; text-anchor: middle; }
.diagram polyline { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 3px var(--line-glow)); }
.diagram.bad polyline { stroke: var(--red); stroke-dasharray: 5 5; filter: none; }
.diagram .x circle { fill: var(--red); }
.diagram .x path { stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.rule.no h3 { color: var(--red); }

/* ---------- 关卡 ---------- */
.lv-list { list-style: none; padding: 0; margin: 32px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.lv { background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius); padding: 16px; }
.lv-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lv-head .g { font-size: 12px; color: var(--muted); white-space: nowrap; }
.lv.moving .lv-head .g { color: var(--accent); }
.lv-board { display: grid; grid-template-columns: repeat(var(--c), 1fr); gap: 2px; margin: 14px 0 12px; }
.lv-board i { aspect-ratio: 1; border-radius: 2px; background: hsl(var(--h) 70% 86%); opacity: .8; }
.nw { white-space: nowrap; }
.lv p { color: var(--muted); font-size: 13px; }

/* ---------- 细节 ---------- */
.feat-list { list-style: none; padding: 0; margin: 32px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feat-list li { padding: 20px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--panel-line); }
.feat-list h3::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); margin-right: 10px; vertical-align: 1px; }
.feat-list p { color: var(--muted); font-size: 14px; margin-top: 8px; }

/* ---------- 主题 ---------- */
.theme-list { list-style: none; padding: 0; margin: 32px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.theme { padding: 22px; border-radius: var(--radius); }
.theme.orchard { background: radial-gradient(120% 100% at 50% 0%, #1d4049, #0e2228); border: 1px solid var(--panel-line); }
.theme.sweets { background: linear-gradient(160deg, #fff6ef, #ffdfe2); color: #4a2c2a; --tile-top: 99%; --tile-bottom: 93%; --tile-edge: 78%; }
.theme.sweets .tile .face { border-radius: 32%; box-shadow: 0 4px 0 hsl(var(--h) 55% 78%), 0 6px 8px rgba(120, 60, 50, 0.18); }
.theme p { opacity: .78; font-size: 14px; margin-top: 6px; }
.minis { display: grid; grid-template-columns: repeat(3, 56px); gap: 10px; margin-bottom: 18px; }
.minis .tile .face span { font-size: 28px; }

/* ---------- 常见问题 ---------- */
.faq-list { margin-top: 28px; max-width: 820px; }
.faq details { border-bottom: 1px solid var(--panel-line); }
.faq summary { cursor: pointer; list-style: none; padding: 18px 36px 18px 0; font-weight: 700; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 6px; top: 14px; font-size: 22px; color: var(--accent); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--muted); padding: 0 0 18px; }

/* ---------- 更新 ---------- */
.log { list-style: none; padding: 0; margin: 28px 0 0; }
.log > li { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 18px 0; border-top: 1px solid var(--panel-line); }
.log time { color: var(--accent); font-weight: 700; font-size: 14px; }
.log ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }

/* ---------- 结尾 ---------- */
.final { text-align: center; padding-bottom: 24px !important; }
.final h2 { margin-bottom: 26px; }
footer { text-align: center; color: var(--muted); font-size: 13px; padding: 56px 16px max(32px, env(safe-area-inset-bottom)); }
footer a { color: var(--muted); }

/* ---------- 语言提示条（脚本判断后才出现，不在 HTML 里写文案） ---------- */
.lang-hint {
  position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px);
  padding: 10px 10px 10px 16px; border-radius: 14px; font-size: 14px;
  background: #1f3f48; border: 1px solid var(--panel-line); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.lang-hint a { color: var(--accent); font-weight: 700; white-space: nowrap; }
.lang-hint button { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 960px) {
  .rules, .lv-list { grid-template-columns: repeat(2, 1fr); }
  .feat-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 36px !important; }
  .hide-s { display: none; }
  main > section { padding-top: 56px; }
  .theme-list { grid-template-columns: 1fr; }
  .log > li { grid-template-columns: 1fr; gap: 4px; }
  .tile .face span { font-size: 7vw; }
}
@media (max-width: 520px) {
  .rules, .lv-list, .feat-list { grid-template-columns: 1fr; }
  .top-nav { gap: 10px; }
  .btn.big { width: 100%; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero h1 em, .rec { animation: none; }
}
