/* =========================================================
 * 《玉之逆旅》 style.css —— 宣纸月白底 + 五朝主题色（借鉴《Gris》色彩叙事）
 * 配色：朱红 #C0392B 青 #2E8B83 明黄 #D4A017 墨 #1A1A1A 月白 #F5F0E6
 * ========================================================= */

:root {
  --paper: #F5F0E6;
  --paper-2: #EDE5D3;
  --ink: #1A1A1A;
  --ink-soft: #4A443A;
  --red: #C0392B;
  --cyan: #2E8B83;
  --gold: #D4A017;
  --accent: #8C6F4B;
  --accent-soft: #E9DFC8;
  --card: #FFFDF6;
  --shadow: rgba(26, 26, 26, .14);
}

body[data-theme="shang"]   { --accent: #6B5B3E; --accent-soft: #E6DCC2; }
body[data-theme="zhanguo"] { --accent: #A8323E; --accent-soft: #F2DAD2; }
body[data-theme="han"]     { --accent: #3A6B8C; --accent-soft: #D9E4EA; }
body[data-theme="tang"]    { --accent: #C08A00; --accent-soft: #F4E4C0; }
body[data-theme="ming"]    { --accent: #2E8B83; --accent-soft: #D8ECE7; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", "STSong", serif;
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, var(--accent-soft) 0%, transparent 55%),
    repeating-linear-gradient(0deg, var(--paper) 0px, var(--paper) 28px, var(--paper-2) 29px),
    var(--paper);
  color: var(--ink);
}

#app { max-width: 960px; min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; padding: 0 18px; }

/* ---------- 顶栏 ---------- */
#topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 6px; border-bottom: 1px solid rgba(26,26,26,.18); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 44px; width: auto; border-radius: 6px; }
#top-place { font-size: 15px; color: var(--ink-soft); letter-spacing: 2px; }
.top-right { display: flex; gap: 8px; }
.ghost-btn {
  font-family: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid rgba(26,26,26,.35); background: transparent; color: var(--ink); cursor: pointer; transition: all .15s;
}
.ghost-btn:hover { background: var(--ink); color: var(--paper); }

/* ---------- 五德 HUD ---------- */
#hud { padding: 10px 0 4px; }
.virtues { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.v-slot { text-align: center; width: 64px; }
.v-name { font-size: 14px; font-weight: bold; }
.v-num  { font-size: 12px; color: var(--ink-soft); margin-bottom: 3px; }
.v-bar { height: 7px; border-radius: 4px; background: rgba(26,26,26,.12); overflow: hidden; border: 1px solid rgba(26,26,26,.15); }
.v-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .5s ease; }
.v-slot.flash { animation: vflash .6s; }
@keyframes vflash { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* ---------- 舞台 ---------- */
#stage { flex: 1; padding: 16px 0 22px; }
.panel {
  background: var(--card); border: 1px solid rgba(26,26,26,.2); border-radius: 14px;
  box-shadow: 0 6px 24px var(--shadow); padding: 26px 30px;
  max-width: 720px; margin: 0 auto; animation: rise .35s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.dyn-tag {
  display: inline-block; font-size: 13px; letter-spacing: 4px;
  color: #FFFDF6; background: var(--accent); padding: 3px 14px; border-radius: 999px; margin-bottom: 12px;
}
h1.game-title { text-align: center; font-size: 44px; letter-spacing: 14px; margin: 8px 0 4px; font-weight: 900; }
h2.sec-title { font-size: 22px; letter-spacing: 4px; margin-bottom: 12px; color: var(--accent); }
h2.sec-title small { font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; margin-left: 10px; }

/* ---------- 场景横幅（程序化剪影） ---------- */
.scene-banner {
  position: relative; height: 170px; border-radius: 12px; overflow: hidden;
  margin-bottom: 6px; border: 1px solid rgba(26,26,26,.25);
  box-shadow: inset 0 -30px 40px rgba(0,0,0,.25);
}
.scene-banner svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-place {
  position: absolute; left: 14px; top: 12px; font-size: 15px; letter-spacing: 3px;
  color: #FFFDF6; text-shadow: 0 1px 6px rgba(0,0,0,.8); z-index: 2;
}
.scene-place b { font-size: 19px; letter-spacing: 5px; }

/* ---------- 视觉小说对话区 ---------- */
.vn-wrap { display: flex; gap: 14px; align-items: flex-end; margin-top: -34px; padding: 0 10px; position: relative; z-index: 3; }
.vn-char { width: 170px; flex-shrink: 0; text-align: center; }
.vn-char img {
  width: 100%; max-height: 260px; object-fit: contain; object-position: bottom;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.3));
  animation: charIn .5s ease;
}
@keyframes charIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.vn-char .char-name {
  display: inline-block; margin-top: 2px; padding: 2px 14px; border-radius: 999px;
  background: var(--accent); color: #FFFDF6; font-size: 13px; letter-spacing: 2px;
}
.vn-body { flex: 1; }
.vn-text {
  background: rgba(255,253,246,.94); border: 1px solid rgba(26,26,26,.25); border-radius: 12px;
  padding: 14px 18px; font-size: 15px; line-height: 1.95; min-height: 84px;
  box-shadow: 0 4px 16px var(--shadow); text-align: justify;
}
.vn-text.narr { color: var(--ink-soft); }
.vn-text .caret { display: inline-block; width: 8px; animation: blink 0.9s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 按钮 ---------- */
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.choice-btn {
  font-family: inherit; text-align: left; cursor: pointer; font-size: 15px; line-height: 1.6;
  background: var(--paper); color: var(--ink);
  border: 1.5px solid rgba(26,26,26,.3); border-radius: 10px; padding: 12px 16px; transition: all .15s;
}
.choice-btn:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateX(4px); }
.choice-btn .fx { float: right; font-size: 13px; color: var(--accent); font-weight: bold; margin-left: 10px; }
.choice-btn small { display: block; color: var(--ink-soft); font-size: 13px; }

.main-btn {
  font-family: inherit; cursor: pointer; font-size: 17px; letter-spacing: 6px; padding: 12px 20px;
  border-radius: 999px; border: none; background: var(--accent); color: #FFFDF6;
  box-shadow: 0 4px 14px var(--shadow); transition: all .15s;
}
.main-btn:hover { filter: brightness(1.12); transform: translateY(-2px); }
.main-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.sub-btn {
  font-family: inherit; cursor: pointer; font-size: 14px; letter-spacing: 3px; padding: 8px 18px;
  border-radius: 999px; border: 1.5px solid rgba(26,26,26,.35); background: transparent; color: var(--ink);
}
.sub-btn:hover { background: var(--ink); color: var(--paper); }
.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ---------- 标题页 ---------- */
.title-logo { display: block; margin: 6px auto 2px; max-width: 300px; width: 72%; filter: drop-shadow(0 6px 16px var(--shadow)); }
.title-fish { display: block; margin: 10px auto; width: 170px; animation: bob 3.2s ease-in-out infinite; filter: drop-shadow(0 8px 18px rgba(46,139,131,.4)); }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.title-sub { text-align: center; color: var(--ink-soft); letter-spacing: 3px; margin-bottom: 20px; font-size: 15px; }
.title-menu { display: flex; flex-direction: column; gap: 10px; max-width: 280px; margin: 0 auto; }

/* ---------- 谜题 ---------- */
.quiz-q {
  font-size: 17px; line-height: 1.9; margin-bottom: 18px; padding: 14px 18px;
  border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0;
}
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt-btn {
  font-family: inherit; font-size: 16px; cursor: pointer; padding: 12px; border-radius: 10px;
  border: 1.5px solid rgba(26,26,26,.3); background: var(--paper); color: var(--ink); transition: all .15s;
}
.opt-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.opt-btn.right { background: #DFF0E2; border-color: #2E7D46; animation: pulseR .5s; }
.opt-btn.wrong { background: #F6DEDA; border-color: var(--red); animation: shake .35s; }
@keyframes pulseR { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.explain { margin-top: 14px; font-size: 14px; line-height: 1.8; color: var(--ink-soft); }

/* ---------- 玉器收集卡 ---------- */
.relic-card { text-align: center; }
.relic-card img.pixel { width: 120px; height: 120px; image-rendering: pixelated; margin: 10px auto; display: block; filter: drop-shadow(0 0 16px rgba(212,160,23,.6)); animation: relicIn .8s ease; }
@keyframes relicIn { 0% { opacity: 0; transform: scale(.3) rotate(-20deg); } 70% { transform: scale(1.15) rotate(4deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.relic-form { color: var(--accent); letter-spacing: 2px; margin: 4px 0 8px; }
.relic-lore { font-size: 14px; color: var(--ink-soft); line-height: 1.9; max-width: 480px; margin: 0 auto 8px; }

/* ---------- 战斗（Q 版圆角卡片） ---------- */
.battle-wrap { max-width: 660px; margin: 0 auto; }
.battle-arena { display: flex; justify-content: space-between; align-items: stretch; gap: 16px; margin-bottom: 14px; position: relative; }
.fighter {
  flex: 1; text-align: center; background: var(--card);
  border: 2px solid rgba(26,26,26,.25); border-radius: 16px; padding: 14px 10px 12px; position: relative;
  transition: transform .2s; overflow: visible;
}
.fighter.hit { animation: shake .35s; }
.fighter .f-name { font-size: 15px; font-weight: bold; letter-spacing: 2px; margin-bottom: 6px; }
.fighter .f-img { height: 96px; display: flex; align-items: center; justify-content: center; }
.fighter .f-img img.pixel { width: 88px; height: 88px; image-rendering: pixelated; }
.fighter .f-img img.stand { max-height: 150px; object-fit: contain; object-position: bottom; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); }
.fighter.enemy .f-name { color: var(--red); }
.hp-bar { height: 12px; border-radius: 7px; background: rgba(26,26,26,.12); overflow: hidden; margin-top: 8px; border: 1px solid rgba(26,26,26,.2); }
.hp-fill { height: 100%; width: 100%; border-radius: 7px; transition: width .4s ease; }
.fighter.player .hp-fill { background: linear-gradient(90deg, #2E8B46, #5BB86E); }
.fighter.enemy .hp-fill { background: linear-gradient(90deg, #A8323E, #D05A50); }
.hp-num { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.vs-mark { align-self: center; font-size: 22px; font-weight: 900; color: var(--accent); letter-spacing: 0; text-shadow: 0 2px 6px var(--shadow); }

.buff-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; min-height: 24px; }
.buff-chip {
  font-size: 12px; padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); letter-spacing: 1px;
}
.action-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.act-btn {
  font-family: inherit; cursor: pointer; font-size: 20px; font-weight: bold; letter-spacing: 4px;
  padding: 14px 0 10px; border-radius: 14px; border: 2px solid rgba(26,26,26,.3);
  background: var(--card); color: var(--ink); transition: all .15s; position: relative;
}
.act-btn small { display: block; font-size: 11px; font-weight: normal; letter-spacing: 0; color: var(--ink-soft); margin-top: 4px; line-height: 1.5; }
.act-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-3px); }
.act-btn:disabled { opacity: .35; cursor: not-allowed; }
.battle-log {
  margin-top: 12px; background: rgba(26,26,26,.04); border-radius: 10px; padding: 10px 14px;
  font-size: 13.5px; line-height: 1.8; color: var(--ink-soft); min-height: 60px; max-height: 130px; overflow-y: auto;
}
.battle-log b { color: var(--accent); }

/* 伤害飘字 */
.float-dmg {
  position: absolute; font-size: 24px; font-weight: 900; pointer-events: none; z-index: 9;
  animation: floatUp 1s ease-out forwards; text-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.float-dmg.dmg { color: var(--red); }
.float-dmg.heal { color: #2E8B46; }
.float-dmg.miss { color: #888; font-size: 18px; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(6px) scale(.7); } 25% { opacity: 1; transform: translateY(-8px) scale(1.15); } 100% { opacity: 0; transform: translateY(-46px) scale(1); } }

/* ---------- 图鉴 ---------- */
.codex-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 14px 0; }
.codex-item {
  background: var(--paper); border: 1.5px solid rgba(26,26,26,.25); border-radius: 12px;
  padding: 12px 8px; text-align: center; transition: all .15s;
}
.codex-item:hover { transform: translateY(-3px); box-shadow: 0 6px 16px var(--shadow); }
.codex-item.locked { opacity: .35; filter: grayscale(1); }
.codex-item img { width: 72px; height: 72px; image-rendering: pixelated; }
.codex-item .cx-name { font-weight: bold; letter-spacing: 2px; margin-top: 4px; }
.codex-item .cx-virtue { font-size: 12px; color: var(--accent); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.badge-item {
  background: var(--paper); border: 1.5px solid rgba(26,26,26,.25); border-radius: 10px; padding: 10px; text-align: center;
}
.badge-item.locked { opacity: .35; filter: grayscale(1); }
.badge-item .bg-icon { font-size: 24px; }
.badge-item .bg-name { font-weight: bold; font-size: 14px; letter-spacing: 2px; margin-top: 2px; }
.badge-item .bg-desc { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; line-height: 1.5; }

/* ---------- 结算 / 结局 ---------- */
.center { text-align: center; }
.big-virtue { font-size: 40px; font-weight: 900; color: var(--accent); letter-spacing: 6px; margin: 10px 0; }
.ending-name { font-size: 34px; letter-spacing: 10px; font-weight: 900; color: var(--accent); margin: 14px 0 8px; }
.ending-text { font-size: 15px; line-height: 2.1; color: var(--ink-soft); text-align: justify; margin: 12px 0; }
.stat-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.stat-table td, .stat-table th { padding: 6px 10px; border-bottom: 1px dashed rgba(26,26,26,.2); font-size: 14px; }
.stat-table th { color: var(--accent); letter-spacing: 2px; }
.title-medal {
  display: inline-block; margin: 10px 0; padding: 8px 26px; font-size: 20px; letter-spacing: 5px;
  border: 2px solid var(--gold); border-radius: 999px; color: #7A5B00; background: #FBF3DC;
}
.end-fish { width: 190px; margin: 6px auto; display: block; animation: bob 3.4s ease-in-out infinite; }

/* ---------- toast ---------- */
#toast-box { position: fixed; right: 18px; top: 66px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: var(--paper); border-radius: 10px; padding: 10px 18px;
  font-size: 14px; letter-spacing: 1px; box-shadow: 0 6px 20px rgba(0,0,0,.3);
  animation: toastIn .3s ease, toastOut .4s ease 2.6s forwards;
  border-left: 4px solid var(--gold);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ---------- 底栏 ---------- */
#foot { text-align: center; font-size: 12px; color: var(--ink-soft); padding: 8px 0 14px; border-top: 1px solid rgba(26,26,26,.12); letter-spacing: 2px; }

/* ---------- 关卡过场 ---------- */
.interlude {
  min-height: 300px; display: flex; flex-direction: column; justify-content: center; align-items: center;
  animation: rise .5s ease; text-align: center;
}
.interlude .dyn-big { font-size: 88px; font-weight: 900; letter-spacing: 24px; color: var(--accent); text-shadow: 0 4px 0 rgba(26,26,26,.12); }
.interlude .place-big { font-size: 20px; letter-spacing: 8px; color: var(--ink-soft); margin: 8px 0 16px; }
.interlude .intro-text { max-width: 560px; font-size: 15px; line-height: 2.1; color: var(--ink-soft); }

@media (max-width: 640px) {
  .vn-char { width: 110px; }
  h1.game-title { font-size: 32px; letter-spacing: 8px; }
  .action-row { grid-template-columns: repeat(2, 1fr); }
  .opt-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px 16px; }
}

/* =========================================================
 * v2 增量样式：粒子层 / 探索热点 / 立绘呼吸 / 竞速倒计时 / 小游戏 / Wiki
 * ========================================================= */

/* ---- 场景粒子层（朝代差异化动态背景） ---- */
.particle-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.particle-layer::before, .particle-layer::after { content: ""; position: absolute; }
/* 商·墓道火星上飘 */
.particle-shang::before {
  width: 3px; height: 3px; background: #FFB84D; border-radius: 50%; box-shadow:
    40px 120px 0 #FFB84D, 90px 80px 0 #FF8C3A, 140px 140px 0 #FFD98A,
    200px 100px 0 #FFB84D, 260px 130px 0 #FF8C3A;
  animation: emberUp 3.5s linear infinite;
}
@keyframes emberUp { 0% { transform: translateY(20px); opacity: .8; } 100% { transform: translateY(-160px); opacity: 0; } }
/* 战国·灯笼摇曳红光 */
.particle-zhanguo::before {
  width: 60px; height: 60px; background: radial-gradient(circle, rgba(216,64,46,.5), transparent 70%);
  left: 360px; top: 30px; animation: lampSway 2.8s ease-in-out infinite;
}
@keyframes lampSway { 0%,100% { transform: translateX(-8px) rotate(-3deg); } 50% { transform: translateX(8px) rotate(3deg); } }
/* 汉·沙尘横移 */
.particle-han::before {
  width: 4px; height: 4px; background: #C89060; border-radius: 50%; box-shadow:
    20px 140px 0 #C89060, 80px 120px 0 #B08050, 160px 150px 0 #C89060,
    240px 130px 0 #B08050, 320px 145px 0 #C89060, 420px 125px 0 #B08050,
    520px 140px 0 #C89060, 620px 130px 0 #B08050;
  animation: sandDrift 4s linear infinite;
}
@keyframes sandDrift { 0% { transform: translateX(0); } 100% { transform: translateX(-40px); } }
/* 唐·金粉飘落 */
.particle-tang::before {
  width: 5px; height: 5px; background: #D4A017; border-radius: 50%; box-shadow:
    50px 0 0 #D4A017, 150px 30px 0 #E8B830, 280px 10px 0 #D4A017,
    400px 40px 0 #E8B830, 550px 20px 0 #D4A017, 660px 50px 0 #E8B830;
  animation: petalFall 5s ease-in infinite;
}
@keyframes petalFall { 0% { transform: translateY(-10px) rotate(0); opacity: .9; } 100% { transform: translateY(170px) rotate(180deg); opacity: 0; } }
/* 明·书页轻摆 */
.particle-ming::before {
  width: 8px; height: 10px; background: #E8DCC0; box-shadow:
    100px 20px 0 #D8C8A0, 300px 40px 0 #E8DCC0, 500px 15px 0 #D8C8A0;
  animation: pageFloat 6s ease-in-out infinite;
}
@keyframes pageFloat { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-12px) rotate(4deg); } }

/* ---- 场景探索热点 ---- */
.explore-dot {
  position: absolute; width: 18px; height: 18px; transform: translate(-50%, -50%);
  border-radius: 50%; background: rgba(212,160,23,.85); border: 2px solid #FFFDF6;
  box-shadow: 0 0 12px rgba(212,160,23,.9); cursor: pointer; z-index: 3;
  animation: dotPulse 1.6s ease-in-out infinite;
}
.explore-dot::after { content: "◈"; position: absolute; inset: 0; color: #FFFDF6; font-size: 11px; text-align: center; line-height: 16px; }
.explore-dot:hover { transform: translate(-50%, -50%) scale(1.3); }
.explore-dot.done { animation: none; opacity: .25; pointer-events: none; }
@keyframes dotPulse { 0%,100% { box-shadow: 0 0 8px rgba(212,160,23,.6); } 50% { box-shadow: 0 0 18px rgba(212,160,23,1); } }

/* ---- 立绘呼吸 ---- */
.char-breathe { animation: charBreathe 3.4s ease-in-out infinite; transform-origin: bottom center; }
@keyframes charBreathe { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-4px) scale(1.012); } }

/* ---- 竞速倒计时 ---- */
.battle-timer { position: relative; height: 16px; background: rgba(26,26,26,.1); border-radius: 8px; overflow: hidden; margin: 8px 0; border: 1px solid rgba(26,26,26,.2); }
.battle-timer-fill { position: absolute; left: 0; top: 0; height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.battle-timer-label { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; color: var(--ink); letter-spacing: 1px; }

/* ---- BOSS 技能 chip ---- */
.boss-chip { background: #F6DEDA; border-color: var(--red); color: var(--red); }

/* ---- 五德锁选项 ---- */
.choice-btn.locked { opacity: .5; cursor: not-allowed; filter: grayscale(.5); }
.choice-btn.locked:hover { border-color: rgba(26,26,26,.3); background: var(--paper); transform: none; }

/* ============ 小游戏 ============ */
.mg-stage { margin-top: 8px; }

/* 关1 拼接修复 */
.repair-grid { display: grid; grid-template-columns: repeat(2, 110px); gap: 4px; justify-content: center; margin: 14px auto; }
.repair-cell { width: 110px; height: 110px; border: 2px solid rgba(26,26,26,.3); border-radius: 6px; cursor: pointer; transition: all .15s; image-rendering: pixelated; }
.repair-cell:hover { border-color: var(--accent); transform: scale(1.03); }
.repair-cell.sel { border-color: var(--gold); box-shadow: 0 0 14px rgba(212,160,23,.7); }

/* 关2/4 诸子匹配 / 组佩搭配 */
.match-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.match-slot { min-height: 76px; border: 2px dashed rgba(26,26,26,.3); border-radius: 10px; padding: 8px; text-align: center; transition: all .15s; background: var(--paper); }
.match-slot.over { border-color: var(--accent); background: var(--accent-soft); }
.match-slot.done { border-style: solid; border-color: #2E7D46; background: #DFF0E2; }
.match-label { font-weight: bold; letter-spacing: 2px; margin-bottom: 4px; font-size: 14px; }
.match-drop { font-size: 12px; color: var(--ink-soft); }
.match-tray { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 10px; background: rgba(26,26,26,.04); border-radius: 10px; }
.match-card { display: flex; flex-direction: column; align-items: center; padding: 6px 10px; background: var(--card); border: 1.5px solid rgba(26,26,26,.25); border-radius: 10px; cursor: grab; transition: all .15s; }
.match-card:hover { transform: translateY(-3px); box-shadow: 0 4px 12px var(--shadow); }
.match-card img.pixel { width: 44px; height: 44px; image-rendering: pixelated; }
.match-card span { font-size: 12px; margin-top: 2px; }

/* 关4 组佩 */
.group-line { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }
.group-slot { width: 100px; min-height: 90px; border: 2px dashed rgba(26,26,26,.3); border-radius: 10px; padding: 6px; text-align: center; transition: all .15s; background: var(--paper); }
.group-slot.over { border-color: var(--accent); background: var(--accent-soft); }
.group-slot-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.group-drop { font-size: 11px; color: var(--ink-soft); }

/* 关3 打磨节奏 */
.polish-bar { height: 36px; background: rgba(26,26,26,.1); border-radius: 18px; border: 1px solid rgba(26,26,26,.25); margin: 18px 0; }
.polish-track { position: relative; height: 100%; border-radius: 18px; overflow: hidden; cursor: pointer; }
.polish-cursor { position: absolute; left: 0; top: 0; width: 4px; height: 100%; background: var(--ink); box-shadow: 0 0 8px var(--ink); }
.polish-green { position: absolute; top: 0; height: 100%; background: rgba(46,125,70,.35); border-left: 1px solid #2E7D46; border-right: 1px solid #2E7D46; }
.polish-charge { text-align: center; font-weight: bold; letter-spacing: 2px; padding: 6px; border-radius: 8px; background: rgba(26,26,26,.04); }

/* 关5 纹样记忆 */
.mem-grid { display: grid; grid-template-columns: repeat(3, 80px); gap: 8px; justify-content: center; margin: 14px auto; }
.mem-cell { width: 80px; height: 80px; border-radius: 10px; border: 2px solid rgba(26,26,26,.25); background: var(--paper); cursor: pointer; transition: all .15s; position: relative; }
.mem-cell::before { content: "♓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; color: rgba(26,26,26,.12); }
.mem-cell.lit, .mem-cell.hit { background: var(--accent); border-color: var(--gold); box-shadow: 0 0 16px rgba(212,160,23,.7); transform: scale(1.05); }
.mem-cell.lit::before, .mem-cell.hit::before { color: #FFFDF6; }

/* ============ Wiki 玉器百科 ============ */
.wiki-intro { background: var(--paper); border-radius: 12px; padding: 16px 20px; margin-bottom: 18px; border-left: 4px solid var(--accent); }
.wiki-h3 { font-size: 20px; letter-spacing: 4px; color: var(--accent); margin-bottom: 10px; }
.wiki-h4 { font-size: 15px; color: var(--ink); margin: 10px 0 4px; letter-spacing: 2px; }
.wiki-p { font-size: 14px; line-height: 1.95; color: var(--ink-soft); text-align: justify; }
.wiki-sec { margin: 8px 0; padding: 8px 0; border-bottom: 1px dashed rgba(26,26,26,.15); }
.wiki-relic { background: var(--card); border: 1px solid rgba(26,26,26,.2); border-radius: 12px; padding: 16px; margin: 12px 0; box-shadow: 0 4px 14px var(--shadow); }
.wiki-relic-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.wiki-relic-head img.pixel { width: 60px; height: 60px; image-rendering: pixelated; }
.wiki-dl { font-size: 14px; line-height: 1.85; }
.wiki-dl dt { font-weight: bold; color: var(--accent); letter-spacing: 2px; margin-top: 6px; }
.wiki-dl dd { color: var(--ink-soft); margin: 2px 0 6px; text-align: justify; }

/* =========================================================
 * v3 玉石之路地图彩蛋
 * ========================================================= */
.silk-map-box { margin: 12px 0 18px; }
.silk-map-wrap { text-align: center; }
.silk-svg {
  width: 100%; max-width: 640px; margin: 0 auto 12px;
  background: linear-gradient(180deg, #F5EFD6 0%, #E8DCC0 100%);
  border-radius: 12px; padding: 8px;
  box-shadow: inset 0 0 0 1px rgba(140,111,75,.35), 0 4px 16px var(--shadow);
}
.silk-map { width: 100%; height: auto; display: block; }
.silk-node circle { transition: all .4s; opacity: 0; }
.silk-node.lit circle { opacity: 1; animation: nodePulse 1.4s ease-out; }
.silk-node .halo { opacity: 0; transition: opacity .6s; }
.silk-node.lit .halo { opacity: .8; animation: haloExpand 2.4s ease-out; }
@keyframes nodePulse { 0% { r: 0; } 60% { r: 2.6; } 100% { r: 1.3; } }
@keyframes haloExpand { 0% { r: 1.3; opacity: .8; } 100% { r: 4.5; opacity: 0; } }
.silk-node text { font-family: "Noto Serif SC", "SimSun", serif; opacity: .8; }
.silk-narr {
  background: var(--paper); border-radius: 10px; padding: 14px 18px;
  margin: 8px auto 12px; max-width: 600px; min-height: 64px;
  border-left: 4px solid var(--accent); text-align: left;
}
.silk-narr-text { font-size: 14px; line-height: 1.95; color: var(--ink-soft); }
.silk-narr-text .cursor { color: var(--accent); animation: blink .7s steps(2) infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
.silk-narr-hint { font-size: 13px; color: var(--ink-soft); margin-top: 8px; min-height: 18px; }
.silk-start-btn { margin: 6px auto 4px; }

/* =========================================================
 * v3 移动端适配：触控 + 小屏呈现 + 横竖屏兼容
 * 三档断点：≤480px（手机竖屏）/ ≤720px（手机横屏/小平板）/ ≥721px（桌面）
 * 设计原则：① 44px 触达区 ② touch-action 防 300ms 延迟 ③ 信息密度收缩但可读性优先
 * ========================================================= */

/* 触控通用：消除移动端 click 300ms 延迟 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, .choice-btn, .opt-btn, .act-btn, .explore-dot, .match-card,
.mem-cell, .repair-cell, .main-btn, .sub-btn, .ghost-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* 手机端字号自适应：根字号随屏宽缩放 */
@media (max-width: 720px) {
  html { font-size: 15px; }
  #app { padding: 0 10px; }
  /* 顶栏 */
  .brand img { height: 36px; }
  #top-place { font-size: 13px; letter-spacing: 1px; }
  .ghost-btn { font-size: 12px; padding: 6px 10px; }
  /* HUD 紧凑 */
  .v-slot { width: 54px; }
  .v-name { font-size: 12px; }
  .v-num { font-size: 10px; }
  .v-bar { height: 6px; }
  /* 面板 */
  .panel { padding: 16px 14px; border-radius: 12px; }
  h1.game-title { font-size: 30px; letter-spacing: 6px; }
  h2.sec-title { font-size: 18px; letter-spacing: 2px; }
  h2.sec-title small { display: block; margin: 4px 0 0; font-size: 12px; }
  .dyn-tag { font-size: 11px; letter-spacing: 2px; padding: 2px 10px; }
  .narr { font-size: 14px; line-height: 1.85; }
  /* 立绘小屏贴底左/右 */
  .vn-wrap { flex-direction: row; align-items: flex-end; min-height: 180px; }
  .vn-char { width: 100px; flex-shrink: 0; }
  .vn-char img { max-height: 180px; width: auto; }
  .vn-char .char-name { font-size: 11px; padding: 1px 6px; }
  .vn-body { padding: 10px 12px; min-height: 110px; }
  .vn-text { font-size: 14px; line-height: 1.85; min-height: 70px; }
  /* 选项 */
  .choice-btn { font-size: 14px; padding: 11px 14px; min-height: 44px; }
  .choice-btn .fx { font-size: 12px; }
  .choice-btn small { font-size: 12px; }
  .main-btn { font-size: 15px; letter-spacing: 4px; padding: 11px 16px; min-height: 44px; }
  .sub-btn { font-size: 13px; padding: 9px 14px; min-height: 40px; }
  /* 谜题 */
  .quiz-q { font-size: 14px; padding: 12px 14px; }
  .opt-btn { font-size: 14px; padding: 12px; min-height: 44px; }
  /* 玉器收集 */
  .relic-card img.pixel { width: 96px; height: 96px; }
  .relic-lore { font-size: 13px; line-height: 1.85; }
  .big-virtue { font-size: 32px; letter-spacing: 4px; }
  /* 场景横幅与热点 */
  .scene-banner { height: 130px; }
  .scene-place { left: 10px; top: 8px; font-size: 13px; letter-spacing: 2px; }
  .scene-place b { font-size: 16px; letter-spacing: 3px; }
  .explore-dot { width: 28px; height: 28px; }
  .explore-dot::after { font-size: 16px; line-height: 26px; }
  /* 战斗 */
  .battle-arena { gap: 8px; }
  .fighter { padding: 10px 6px; border-radius: 12px; }
  .fighter img.enemy { width: 56px; height: 56px; }
  .fighter .f-name { font-size: 13px; }
  .hp-bar { height: 12px; }
  .hp-num { font-size: 11px; }
  .vs-mark { font-size: 18px; }
  .action-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .act-btn { font-size: 16px; padding: 10px 4px; min-height: 56px; letter-spacing: 2px; }
  .act-btn small { font-size: 10px; }
  .buff-chip { font-size: 11px; padding: 2px 8px; }
  .battle-log { font-size: 12.5px; line-height: 1.7; min-height: 50px; max-height: 110px; }
  /* 小游戏 */
  .repair-grid { grid-template-columns: repeat(2, 88px); }
  .repair-cell { width: 88px; height: 88px; }
  .match-grid { grid-template-columns: repeat(2, 1fr); }
  .match-card img.pixel { width: 38px; height: 38px; }
  .match-card span { font-size: 11px; }
  .mem-grid { grid-template-columns: repeat(3, 68px); }
  .mem-cell { width: 68px; height: 68px; }
  .mem-cell::before { font-size: 24px; }
  .group-slot { width: 80px; min-height: 76px; }
  .polish-bar { height: 30px; }
  /* 图鉴 */
  .codex-grid { grid-template-columns: repeat(2, 1fr); }
  .badge-grid { grid-template-columns: repeat(2, 1fr); }
  /* 结局 */
  .ending-name { font-size: 26px; letter-spacing: 6px; }
  .ending-text { font-size: 13px; line-height: 1.95; }
  .stat-table td, .stat-table th { padding: 5px 6px; font-size: 12px; }
  /* 过场 */
  .interlude .dyn-big { font-size: 56px; letter-spacing: 12px; }
  .interlude .place-big { font-size: 16px; letter-spacing: 4px; }
  .interlude .intro-text { font-size: 13px; line-height: 1.95; }
  /* 标题页 */
  .title-logo { max-width: 240px; }
  .title-sub { font-size: 13px; margin-bottom: 14px; }
  .title-fish { width: 110px; }
  /* Wiki */
  .wiki-h3 { font-size: 17px; letter-spacing: 2px; }
  .wiki-h4 { font-size: 14px; }
  .wiki-p { font-size: 13px; line-height: 1.85; }
  .wiki-dl { font-size: 13px; }
  .wiki-relic-head img.pixel { width: 48px; height: 48px; }
  .silk-svg { max-width: 100%; }
  .silk-narr-text { font-size: 13px; }
}

/* 超小屏（≤480px，主流手机竖屏） */
@media (max-width: 480px) {
  html { font-size: 14px; }
  #app { padding: 0 8px; }
  /* 顶栏 */
  .brand img { height: 30px; }
  #top-place { font-size: 11px; letter-spacing: 0.5px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ghost-btn { font-size: 11px; padding: 5px 8px; }
  /* HUD 五德极简：只显示字与短条 */
  .virtues { gap: 6px; }
  .v-slot { width: 44px; }
  .v-name { font-size: 11px; letter-spacing: 1px; }
  .v-num { font-size: 9px; }
  .v-bar { height: 5px; }
  /* 立绘进一步缩小、贴边 */
  .vn-wrap { min-height: 150px; }
  .vn-char { width: 78px; }
  .vn-char img { max-height: 140px; }
  .vn-body { padding: 8px 10px; min-height: 96px; }
  .vn-text { font-size: 13px; line-height: 1.8; min-height: 60px; }
  /* 立绘与文本堆叠改为：立绘半透明背景 + 文字浮于其上，节省纵向空间 */
  .vn-wrap { position: relative; }
  .vn-body { background: rgba(255,253,246,.94); border-radius: 10px; }
  /* 战斗按钮加大触达 */
  .act-btn { min-height: 60px; font-size: 15px; }
  /* 选项 */
  .choice-btn { font-size: 13px; padding: 10px 12px; min-height: 48px; line-height: 1.45; }
  .choice-btn .fx { font-size: 11px; }
  .choice-btn small { font-size: 11px; }
  /* 热点加大触达 */
  .explore-dot { width: 32px; height: 32px; }
  .explore-dot::after { font-size: 18px; line-height: 30px; }
  /* 小游戏：拼图列缩到 72px */
  .repair-grid { grid-template-columns: repeat(2, 72px); gap: 3px; }
  .repair-cell { width: 72px; height: 72px; }
  .match-grid { grid-template-columns: 1fr; }
  .mem-grid { grid-template-columns: repeat(3, 58px); gap: 6px; }
  .mem-cell { width: 58px; height: 58px; }
  .mem-cell::before { font-size: 20px; }
  /* 图鉴：单列 */
  .codex-grid { grid-template-columns: 1fr; }
  .badge-grid { grid-template-columns: repeat(2, 1fr); }
  /* 标题 */
  h1.game-title { font-size: 24px; letter-spacing: 4px; }
  .title-logo { max-width: 180px; }
  /* 结局 */
  .ending-name { font-size: 22px; letter-spacing: 4px; }
  .big-virtue { font-size: 28px; letter-spacing: 3px; }
  /* 过场 */
  .interlude .dyn-big { font-size: 42px; letter-spacing: 8px; }
  /* 战斗 arena 改纵向堆叠 */
  .battle-arena { flex-direction: column; align-items: stretch; gap: 10px; }
  .fighter { padding: 8px 6px; }
  .vs-mark { font-size: 14px; align-self: center; }
  /* footer */
  #foot { font-size: 10px; letter-spacing: 1px; }
}

/* 横屏（短边 ≥480px 且为横屏）：仍要紧凑 */
@media (orientation: landscape) and (max-height: 480px) {
  #topbar { padding: 4px 0 2px; }
  .brand img { height: 28px; }
  #hud { padding: 4px 0 2px; }
  #stage { padding: 6px 0 10px; }
  .panel { padding: 10px 14px; }
  .vn-wrap { min-height: 110px; align-items: center; }
  .vn-char img { max-height: 110px; }
  .vn-text { min-height: 50px; font-size: 13px; }
  .battle-arena { gap: 10px; }
  .fighter img.enemy { width: 48px; height: 48px; }
  .action-row { grid-template-columns: repeat(4, 1fr); }
  .act-btn { padding: 8px 4px; font-size: 14px; min-height: 44px; }
  .battle-log { max-height: 64px; font-size: 11px; }
  /* 横屏场景横幅更扁 */
  .scene-banner { height: 100px; }
  .interlude .dyn-big { font-size: 44px; letter-spacing: 10px; }
}

/* 大屏触屏设备（iPad/桌面触屏）：保留桌面密度但优化触控 */
@media (hover: none) and (min-width: 721px) {
  .choice-btn, .opt-btn, .act-btn { min-height: 44px; }
  .explore-dot { width: 26px; height: 26px; }
}

/* prefers-reduced-motion：尊重用户偏好关闭动画 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 拖拽小游戏的触屏兼容（关 2/4 拖拽，改 tap-to-place） */
@media (hover: none) {
  .match-card[draggable="true"] { cursor: pointer; }
  .match-card.dragging { opacity: 1; }
}

/* 焦点可见性（键盘导航可达） */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 安全区适配（iPhone 刘海/底部 Home Indicator） */
@supports (padding: env(safe-area-inset-top)) {
  #app { padding-top: env(safe-area-inset-top); }
  #foot { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  #topbar { padding-top: calc(6px + env(safe-area-inset-top)); }
}

/* 触屏 tap 选中态 */
.match-card.sel {
  border-color: var(--gold);
  background: var(--accent-soft);
  box-shadow: 0 0 14px rgba(212,160,23,.7);
  transform: translateY(-3px) scale(1.04);
}
.group-slot.done { border-style: solid; border-color: #2E7D46; background: #DFF0E2; }
