:root {
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --touch-min: 44px;
  --ink: #17110c;
  --ink-2: #221a12;
  --wood: #2a1c13;
  --wood-2: #3a2819;
  --parch: #e7d9ba;
  --parch-2: #d8c6a1;
  --parch-3: #f1e6ca;
  --ember: #e07b3c;
  --flame: #ffd27d;
  --blood: #9c3126;
  --copper: #6f8f7e;
  --gold: #c9a24a;
  --pale: #f3e9d3;
  --muted: #a9977c;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", "STSong", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #070504;
  color: var(--pale);
  font-family: var(--serif);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

#frame { position: fixed; inset: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 40%, #1c130d 0%, #0a0705 65%, #050303 100%); }
/* 画框按 16:9 缩放后两侧/上下会留黑边；把画框里的场景图铺到 #frame 上，
   黑边就变成同一张场景图的延续，视觉上是满屏而不是黑条。
   只在有 --scene-bg 时才画出内容（title / map 等设了 --scene-bg 的界面）。 */
#frame::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: var(--frame-scene, none);
  background-size: cover; background-position: center;
  filter: blur(18px) brightness(0.55) saturate(0.85);
  opacity: 0; transition: opacity .4s ease;
}
body.has-scene #frame::before { opacity: 1; }

#wrap {
  position: absolute; left: 50%; top: 50%;
  width: 1280px; height: 720px;
  transform-origin: center center;
  overflow: hidden;
  background: #150e09;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.92), 0 0 0 1px #2c2016;
}

#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; display: block; pointer-events: none; touch-action: none; }
body.screen-battle #stage { pointer-events: auto; }

#ui { position: absolute; inset: 0; pointer-events: none; }

.screen {
  position: absolute; inset: 0;
  pointer-events: auto;
  display: none;
  flex-direction: column;
  padding: 26px 40px;
}
.screen.active { display: flex; }
/* 非战斗界面复用当前章节场景图作背景，压暗保证文字可读 */
#scr-map.active, #scr-reward.active, #scr-camp.active, #scr-event.active,
#scr-end.active, #scr-codex.active {
  background-image: linear-gradient(rgba(9, 11, 9, 0.86), rgba(9, 11, 9, 0.93)), var(--scene-bg, none);
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

/* ------------------------------------------------------------ title */
#scr-title {
  padding: 0;
  background:
    radial-gradient(ellipse 620px 420px at 26% 46%, rgba(255, 190, 110, 0.13), transparent 70%),
    linear-gradient(90deg, rgba(8, 5, 3, 0.2) 0%, rgba(8, 5, 3, 0.35) 55%, rgba(8, 5, 3, 0.78) 100%);
}
.title-layout { display: flex; align-items: center; justify-content: space-between; height: 100%; padding: 0 96px 0 104px; }
.title-left { max-width: 620px; }
.logo-cn {
  font-size: 148px; line-height: 0.98; letter-spacing: 18px;
  color: var(--parch-3);
  text-shadow: 0 0 40px rgba(255, 190, 100, 0.26), 0 4px 0 #241810, 0 9px 26px rgba(0, 0, 0, 0.85);
  margin-left: 16px;
}
.logo-en { margin-top: 14px; font-size: 21px; letter-spacing: 17px; color: var(--copper); opacity: 0.9; text-indent: 17px; }
.logo-rule { width: 280px; height: 1px; margin: 28px 0 20px; background: linear-gradient(90deg, rgba(201, 162, 74, 0.7), transparent); }
.tagline { font-size: 22px; color: var(--parch-2); opacity: 0.86; letter-spacing: 3px; }
.title-foot { margin-top: 54px; font-size: 13px; color: #8d7c66; letter-spacing: 3px; }
.title-right { width: 320px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.mode-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); letter-spacing: 2px; padding: 4px 2px; }
.mode-label select { flex: 1; font-family: var(--serif); font-size: 14px; padding: 7px 8px; background: rgba(24, 17, 11, 0.9); color: var(--parch-2); border: 1px solid rgba(201, 162, 74, 0.3); border-radius: 2px; }

/* ------------------------------------------------------------ buttons */
.btn {
  appearance: none; border: 1px solid rgba(201, 162, 74, 0.35);
  background: linear-gradient(180deg, rgba(58, 40, 25, 0.92), rgba(34, 24, 16, 0.96));
  color: var(--pale); font-family: var(--serif); font-size: 19px; letter-spacing: 4px;
  padding: 14px 18px; border-radius: 3px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.10), 0 4px 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn-primary { border-color: rgba(201, 162, 74, 0.65); color: #ffe9bd; }
.btn-ghost { background: rgba(24, 17, 11, 0.55); color: var(--parch-2); }
.btn-danger { border-color: rgba(156, 49, 38, 0.7); color: #f0c9bd; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-sm { font-size: 14px; padding: 8px 14px; letter-spacing: 2px; }

/* ------------------------------------------------------------ map */
#scr-map { padding: 0; background: linear-gradient(180deg, #150e09, #0d0906); }
.map-hud {
  position: absolute; top: 0; left: 0; right: 0; height: 62px;
  display: flex; align-items: center; gap: 34px;
  padding: 0 26px;
  background: linear-gradient(180deg, rgba(20, 13, 8, 0.97), rgba(20, 13, 8, 0.55));
  border-bottom: 1px solid rgba(201, 162, 74, 0.14);
  font-size: 17px; color: var(--parch-2); z-index: 5;
}
.map-hud .hud-left { min-width: 120px; }
.map-hud #map-home { margin-left: auto; }
.hud-label { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.hud-candle { color: var(--flame); display: flex; align-items: baseline; gap: 4px; font-size: 21px; }
.hud-sub { font-size: 12px; color: var(--muted); margin: 0 2px; }
#map-act { font-size: 21px; color: var(--parch-3); margin: 0 4px; }
.hud-deck { font-size: 21px; color: var(--parch-3); }
#chapter-strip { position: absolute; top: 74px; left: 26px; right: 26px; display: flex; gap: 8px; z-index: 4; }
.chapter {
  flex: 1; text-align: center; font-size: 13px; letter-spacing: 1px;
  padding: 7px 4px; border: 1px solid rgba(201, 162, 74, 0.16); border-radius: 2px;
  color: #8e7c64; background: rgba(20, 14, 9, 0.55);
}
.chapter.active { color: #ffe9bd; border-color: rgba(201, 162, 74, 0.6); background: rgba(58, 40, 25, 0.6); }
.chapter.done { color: var(--copper); border-color: rgba(111, 143, 126, 0.4); }
#map-body { position: absolute; inset: 0; }
#map-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#map-nodes { position: absolute; inset: 0; }
.node {
  position: absolute; width: 88px; height: 88px; margin: -44px 0 0 -44px;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 74, 0.22);
  background: radial-gradient(circle at 50% 40%, #33241a, #1a120c 72%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 25px; cursor: default; pointer-events: auto;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.node .node-glyph { line-height: 1; }
.node .node-label { font-size: 10px; letter-spacing: 1px; margin-top: 3px; color: #8c7c66; max-width: 84px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.node.avail { border-color: rgba(201, 162, 74, 0.75); color: #ffe4b0; cursor: pointer; box-shadow: 0 0 18px rgba(224, 123, 60, 0.22); animation: nodePulse 2.6s ease-in-out infinite; }
.node.avail .node-label { color: var(--parch-2); }
.node.done { opacity: 0.34; }
.node.current { border-color: var(--flame); color: var(--flame); box-shadow: 0 0 22px rgba(255, 210, 125, 0.35); }
.node.boss { width: 104px; height: 104px; margin: -52px 0 0 -52px; font-size: 30px; border-color: rgba(156, 49, 38, 0.5); }
.node.boss.avail { border-color: #c25a3f; box-shadow: 0 0 26px rgba(194, 90, 63, 0.35); }
.node.elite { border-color: rgba(156, 49, 38, 0.38); }
.node.campfire { border-color: rgba(224, 123, 60, 0.4); }
.node.treasure { border-color: rgba(201, 162, 74, 0.4); }
.node.event { border-color: rgba(111, 143, 126, 0.42); }
@keyframes nodePulse {
  0%, 100% { box-shadow: 0 0 12px rgba(224, 123, 60, 0.16), 0 3px 10px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 0 26px rgba(224, 123, 60, 0.34), 0 3px 10px rgba(0, 0, 0, 0.5); }
}
#map-tip { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 30px 16px; text-align: center; font-size: 13px; color: #8f7d66; letter-spacing: 1px; background: linear-gradient(0deg, rgba(10, 7, 4, 0.92), transparent); }

/* ------------------------------------------------------------ panels */
.panel {
  margin: auto; width: 860px; max-height: 640px; overflow-y: auto;
  background: linear-gradient(180deg, rgba(231, 217, 186, 0.98), rgba(214, 196, 159, 0.98));
  color: #241a12; border-radius: 3px; border: 1px solid #6d5942;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.65), inset 0 0 60px rgba(120, 88, 50, 0.22);
  padding: 26px 30px; position: relative;
}
.panel::before { content: ''; position: absolute; inset: 7px; border: 1px solid rgba(90, 68, 44, 0.35); border-radius: 2px; pointer-events: none; }
.panel-title { margin: 0 0 6px; font-size: 30px; letter-spacing: 5px; text-align: center; font-weight: 600; color: #2a1d13; }
.panel-sub { margin: 0 0 18px; font-size: 15px; line-height: 1.7; text-align: center; color: #5a4632; letter-spacing: 0.5px; }
.panel-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.panel .btn { border-color: rgba(90, 68, 44, 0.55); background: linear-gradient(180deg, #3a2a1c, #241810); color: var(--parch-3); }
.panel .btn-ghost { background: rgba(58, 42, 28, 0.12); color: #3d2c1d; border-color: rgba(90, 68, 44, 0.45); }

/* ------------------------------------------------------------ cards */
.card-row { display: flex; gap: 14px; justify-content: center; align-items: stretch; }
.card-pick { flex: 0 1 220px; display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: transform 0.12s ease; }
.card-pick:hover { transform: translateY(-5px); }
.card-pick canvas { width: 176px; height: 246px; display: block; border-radius: 3px; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.42); }
.card-pick .pick-name { font-size: 17px; color: #2a1d13; margin-top: 7px; letter-spacing: 1px; }
.card-pick .pick-meta { font-size: 12px; color: #5a4632; margin-top: 4px; text-align: center; line-height: 1.5; }
.card-pick.rare .pick-name { color: #7c4a12; }
/* game.js 在 pointerdown 时给奖励卡加 .press，长按 520ms 看完整卡面：按下就下沉一点，手感对得上 */
.card-pick.press { transform: translateY(2px) scale(0.98); }
.rarity-tag { font-size: 10px; color: #7c4a12; border: 1px solid rgba(124, 74, 18, 0.4); padding: 0 4px; border-radius: 2px; margin-left: 4px; }

/* ------------------------------------------------------------ choices */
.choice-col { display: flex; flex-direction: column; gap: 10px; }
.choice {
  text-align: left; border: 1px solid rgba(90, 68, 44, 0.4); background: rgba(58, 42, 28, 0.07);
  color: #2a1d13; padding: 13px 16px; border-radius: 2px; cursor: pointer; font-family: var(--serif);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.choice:active, .choice:hover { background: rgba(58, 42, 28, 0.16); }
.choice .choice-label { font-size: 18px; letter-spacing: 2px; display: block; }
.choice .choice-desc { font-size: 13px; color: #6a5540; margin-top: 4px; display: block; line-height: 1.5; }
.choice:disabled { opacity: 0.4; }
.event-result { font-size: 14px; line-height: 1.8; color: #3d2c1d; border-left: 2px solid rgba(124, 74, 18, 0.4); padding-left: 12px; margin: 14px 0 0; }
.deck-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; max-height: 280px; overflow-y: auto; }
.deck-item {
  border: 1px solid rgba(90, 68, 44, 0.35); padding: 8px 6px; border-radius: 2px;
  font-size: 12px; color: #3d2c1d; cursor: pointer; text-align: center; background: rgba(58, 42, 28, 0.05);
  font-family: var(--serif);
}
.deck-item:hover { background: rgba(58, 42, 28, 0.18); }
.deck-item b { display: block; font-size: 13px; margin-bottom: 3px; }

/* ------------------------------------------------------------ stats / end */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; margin: 14px 0 2px; font-size: 14px; color: #4b3826; }
.stats div { display: flex; justify-content: space-between; border-bottom: 1px dotted rgba(90, 68, 44, 0.3); padding-bottom: 4px; }
.stats b { color: #2a1d13; }

/* ------------------------------------------------------------ codex */
#scr-codex { background: linear-gradient(180deg, #150e09, #0a0705); padding: 0; }
.codex-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 26px;
  background: linear-gradient(180deg, rgba(24, 16, 10, 0.98), rgba(18, 12, 8, 0.88));
  border-bottom: 1px solid rgba(201, 162, 74, 0.18); z-index: 3;
}
.codex-title h2 { margin: 0; font-size: 26px; letter-spacing: 5px; color: var(--parch-3); font-weight: 600; }
.codex-title p { margin: 2px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.codex-head input {
  flex: 1; min-width: 180px; margin-left: 20px; padding: 10px 14px; font-family: var(--serif); font-size: 15px;
  background: rgba(12, 8, 5, 0.85); color: var(--parch-2); border: 1px solid rgba(201, 162, 74, 0.28); border-radius: 2px;
}
.codex-head select {
  padding: 9px 8px; font-family: var(--serif); font-size: 13px; background: rgba(24, 17, 11, 0.9);
  color: var(--parch-2); border: 1px solid rgba(201, 162, 74, 0.28); border-radius: 2px;
}
#codex-grid {
  flex: 1; overflow-y: auto; padding: 16px 26px 26px;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px 12px; align-content: start;
}
.codex-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px 10px;
  background: rgba(22, 15, 10, 0.72); border: 1px solid rgba(201, 162, 74, 0.14); border-radius: 3px;
  color: var(--parch-2); font-family: var(--serif); cursor: pointer; text-align: center;
  transition: border-color 0.12s ease, transform 0.12s ease, background 0.12s ease;
}
.codex-item:hover { border-color: rgba(201, 162, 74, 0.55); transform: translateY(-3px); background: rgba(34, 23, 15, 0.9); }
.codex-item canvas { width: 120px; height: 168px; display: block; border-radius: 2px; }
.codex-item strong { font-size: 14px; letter-spacing: 1px; font-weight: 600; }
.codex-item small { font-size: 11px; color: var(--muted); line-height: 1.4; }
.codex-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 0; font-size: 15px; letter-spacing: 2px; }

/* ------------------------------------------------------------ modal */
.modal {
  position: absolute; inset: 0; z-index: 40; pointer-events: auto;
  background: rgba(6, 4, 2, 0.74);
  display: flex; align-items: center; justify-content: center; padding: 30px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 420px; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, #efe3c6, #dccbaa);
  color: #241a12; border: 1px solid #6d5942; border-radius: 3px;
  padding: 22px 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}
.modal-card h3 { margin: 0 0 14px; font-size: 24px; letter-spacing: 4px; text-align: center; font-weight: 600; }
.modal-card .row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid rgba(90, 68, 44, 0.2); font-size: 16px; }
.toggle { font-family: var(--serif); font-size: 14px; letter-spacing: 2px; background: rgba(58, 42, 28, 0.12); border: 1px solid rgba(90, 68, 44, 0.4); color: #3d2c1d; padding: 6px 16px; border-radius: 2px; cursor: pointer; }
.toggle.on { background: #3a2a1c; color: #ffe9bd; border-color: #3a2a1c; }
.modal-note { font-size: 13px; color: #6a5540; line-height: 1.6; min-height: 16px; margin: 10px 0 0; }
.modal-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.modal .btn { border-color: rgba(90, 68, 44, 0.55); background: linear-gradient(180deg, #3a2a1c, #241810); color: var(--parch-3); }
.modal .btn-ghost { background: rgba(58, 42, 28, 0.1); color: #3d2c1d; }

/* 设置面板：接近满屏、字号放大，内容超高时面板内滚动 */
#modal-settings .modal-card {
  width: 86%; height: 86%; max-height: 86%;
  padding: 22px 38px 20px; overflow-y: auto;
  display: flex; flex-direction: column;
}
#modal-settings .modal-card h3 { font-size: 32px; letter-spacing: 8px; margin-bottom: 10px; }
#modal-settings .row { font-size: 20px; padding: 10px 0; }
#modal-settings .toggle { font-size: 17px; padding: 9px 24px; }
#modal-settings .set-body { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 44px; align-items: start; }
#modal-settings .set-sec { min-width: 0; }
#modal-settings .modal-note { margin-top: auto; }
#modal-settings .modal-actions { margin-top: 14px; }
#modal-settings .set-h { margin: 0 0 6px; font-size: 14px; letter-spacing: 5px; color: #6a5540; font-weight: 600; }
#modal-settings .vol-row {
  display: grid; grid-template-columns: 130px minmax(0, 1fr) 60px;
  align-items: center; gap: 14px; padding: 9px 0;
  font-size: 19px; color: #2a1d13;
}
#modal-settings .vol-val { font-size: 15px; color: #6a5540; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
#modal-settings .vol { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; margin: 0; background: transparent; }
#modal-settings .vol::-webkit-slider-runnable-track { height: 7px; border-radius: 4px; background: linear-gradient(90deg, #9c3126, #c9a24a); border: 1px solid rgba(90, 68, 44, 0.45); }
#modal-settings .vol::-webkit-slider-thumb {
  -webkit-appearance: none; width: 32px; height: 32px; margin-top: -14px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #ffe9bd, #c9a24a 68%, #6d4a1c);
  border: 1px solid #4b3620; box-shadow: 0 2px 7px rgba(0, 0, 0, 0.55);
}
#modal-settings .vol::-moz-range-track { height: 7px; border-radius: 4px; background: linear-gradient(90deg, #9c3126, #c9a24a); }
#modal-settings .vol::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: #c9a24a; border: 1px solid #4b3620; }
#modal-settings .vol:active::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(201, 162, 74, 0.25), 0 2px 7px rgba(0, 0, 0, 0.55); }

/* ------------------------------------------------------------ detail */
/* 两栏：卡面固定占一列，其余字段按自身高度一行一行排下来；内容超高时整张弹窗内滚动。
   旧写法 grid + canvas grid-row:1/span 20 会凭空拉出 20 行、把字段挤没并裁掉卡面。 */
#modal-detail .detail-card { width: 720px; max-height: 86%; padding: 20px 24px 24px; position: relative; }
#detail-close { position: absolute; right: 18px; top: 14px; z-index: 2; }
/* 文字列在右、卡面在左固定，行高随内容走（不再拿 grid 行假装高度） */
#detail-body { position: relative; margin-top: 34px; padding-left: 216px; min-height: 274px; }
#detail-body h2 { margin: 0 0 8px; font-size: 26px; letter-spacing: 3px; }
#detail-body canvas { position: absolute; left: 0; top: 0; width: 196px; height: 274px; border-radius: 3px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); }
#detail-body p { margin: 0 0 9px; font-size: 14.5px; line-height: 1.75; color: #3d2c1d; }
#detail-body p b { color: #2a1d13; }
.detail-tag { display: inline-block; font-size: 11px; border: 1px solid rgba(90, 68, 44, 0.4); border-radius: 2px; padding: 1px 6px; margin: 0 5px 5px 0; color: #5a4632; }

/* ------------------------------------------------------------ tutorial */
#tutorial-bar {
  position: absolute; left: 300px; right: 300px; top: 8px; padding: 9px 14px;
  background: rgba(26, 36, 30, 0.94); border: 1px solid #8caa89; z-index: 30;
  pointer-events: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--parch);
  border-radius: 3px;
}
#tutorial-bar[hidden] { display: none; }
#tutorial-bar b { color: #cfe3c8; letter-spacing: 1px; white-space: nowrap; }
#tutorial-hint { flex: 1; color: #dfe8d8; }
#tutorial-bar .btn { padding: 6px 10px; font-size: 12px; }

/* ------------------------------------------------------------ intro */
#intro {
  position: absolute; inset: 0; background: #000; z-index: 60;
  display: flex; align-items: center; justify-content: center; pointer-events: auto;
}
#intro[hidden] { display: none; }
#intro-copy { color: #f4ead6; font-size: 40px; letter-spacing: 10px; opacity: 0; text-align: center; transition: opacity 0.45s ease; }
#intro-skip { position: absolute; right: 40px; bottom: 30px; background: none; border: 1px solid #4c4136; padding: 8px 20px; color: #9a8a75; cursor: pointer; font-family: var(--serif); font-size: 13px; letter-spacing: 2px; }

/* ------------------------------------------------------------ toast */
#toast {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(8px);
  background: rgba(16, 11, 7, 0.94); border: 1px solid rgba(201, 162, 74, 0.3);
  color: var(--parch-2); font-size: 15px; letter-spacing: 1px;
  padding: 10px 22px; border-radius: 2px; pointer-events: none; opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease; max-width: 680px; text-align: center; z-index: 70;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

body.reduced * { animation: none !important; transition: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(201, 162, 74, 0.25); border-radius: 4px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }

.codex-pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 10px 26px 16px; font-size: 13px; color: var(--muted); }
.codex-pager .btn { padding: 6px 14px; font-size: 13px; }

#codex-grid, #scr-codex, .panel, .modal-card, #detail-body, .deck-grid, #reward-cards, .card-pick { touch-action: pan-y; }
/* small viewports: keep touch targets usable (logical px are scaled down) */
body.compact .btn { min-height: var(--touch-min); font-size: 21px; padding: 14px 16px; }
body.compact .btn-sm { min-height: var(--touch-min); font-size: 15px; }
body.compact .choice { min-height: 66px; }
body.compact .node { width: 104px; height: 104px; margin: -52px 0 0 -52px; }
body.compact .node.boss { width: 120px; height: 120px; margin: -60px 0 0 -60px; }
body.compact .title-right { width: 360px; gap: 10px; }
body.compact .codex-head { gap: 8px; padding: 12px 16px; }
body.compact .codex-item canvas { width: 96px; height: 134px; }
body.compact .card-pick canvas { width: 148px; height: 207px; }
@media (max-width: 980px) {
  .title-layout { padding: 0 46px; }
  .logo-cn { font-size: 110px; letter-spacing: 12px; }
  .tagline { font-size: 18px; }
  .panel { width: 92%; }
  #codex-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-height: 560px) {
  .logo-cn { font-size: 96px; }
  .title-foot { margin-top: 22px; }
}
