/* ============ 京铁时光行 · 全局样式 ============ */
:root {
  --bg: #0a0a1e;
  --bg2: #12122e;
  --ink: #e8e8f0;
  --dim: #9a9ab8;
  --line1: #c23a2b;   /* 1号线 红 */
  --line2: #1e5fa8;   /* 2号线 蓝 */
  --line4: #2a8c5a;   /* 4号线 绿 */
  --line6: #c79a2a;   /* 6号线 金 */
  --line8: #2a9db8;   /* 8号线 青 */
  --line10: #2f66c4;  /* 10号线 淡蓝 */
  --line13: #8c5ab0;  /* 13号线 紫 */
  --gold: #ffd24a;
  --pixel-font: "Zpix", "SimSun", "MS Gothic", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.hidden { display: none !important; }

/* 输入框在全局 touch-action:none 下需恢复交互 */
input, textarea {
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
}

/* ============ 启动广告 ============ */
.splash-ad {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(180deg, #16204a 0%, #0d1230 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.splash-ad-inner { width: min(86vw, 420px); }
.splash-ad-tag {
  display: inline-block; font-size: 11px; color: var(--dim);
  border: 1px solid #3a3a6a; padding: 2px 8px; border-radius: 4px; margin-bottom: 14px;
}
.splash-ad-body {
  background: #1c2450; border: 2px solid #36408c; border-radius: 12px;
  padding: 42px 20px; text-align: center;
}
.splash-ad-art { font-size: 56px; margin-bottom: 16px; }
.splash-ad-title { font-size: 19px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.splash-ad-desc { font-size: 13px; color: var(--dim); }
.splash-ad-skip {
  margin-top: 16px; float: right; background: none; border: 1px solid #4a4a8a;
  color: var(--dim); font-size: 12px; padding: 6px 14px; border-radius: 999px;
}
.splash-ad-skip:not([disabled]) { color: #fff; border-color: #fff; }
.splash-ad-note { position: absolute; bottom: 18px; font-size: 10px; color: #55557a; width: 100%; text-align: center; }

/* ============ 开场视频 ============ */
.intro-video-wrap { position: fixed; inset: 0; z-index: 190; background: #000; }
#intro-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.intro-skip {
  position: absolute; right: 14px; top: 14px; z-index: 2;
  padding: 8px 16px; font-size: 13px; color: #fff;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px;
}

/* ============ 主容器与画布 ============ */
.app {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000;
  overflow: hidden;
}
#game-canvas {
  height: 100%; width: auto; max-width: 100%;
  aspect-ratio: 256 / 240;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  touch-action: none;
}
/* CRT 扫描线 + 暗角 */
.scanlines {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: repeating-linear-gradient(0deg,
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,.18) 3px, rgba(0,0,0,.18) 4px);
  mix-blend-mode: multiply;
}
.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,20,.38) 100%);
}

/* ============ FC 虚拟手柄 ============ */
.pad {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #1a1a2e 0%, #101020 100%);
  border-top: 2px solid #26264a;
}
.dpad { position: relative; width: 132px; height: 132px; }
.dpad-btn {
  position: absolute; width: 46px; height: 46px;
  background: #2a2a4a; border: 1px solid #3c3c6a; color: #b0b0d0;
  font-size: 16px; z-index: 2;
}
.dpad-btn.up    { left: 43px; top: 0; border-radius: 8px 8px 0 0; }
.dpad-btn.down  { left: 43px; bottom: 0; border-radius: 0 0 8px 8px; }
.dpad-btn.left  { left: 0; top: 43px; border-radius: 8px 0 0 8px; }
.dpad-btn.right { right: 0; top: 43px; border-radius: 0 8px 8px 0; }
.dpad-center { position: absolute; left: 43px; top: 43px; width: 46px; height: 46px; background: #2a2a4a; }
.dpad-btn.pressed, .pad-btn.pressed { background: #4a4a8a !important; color: #fff !important; transform: scale(.94); }

.pad-middle { display: flex; justify-content: center; }
.pad-select-start { display: flex; gap: 14px; align-items: center; }
.pad-btn {
  background: #2a2a4a; border: 1px solid #3c3c6a; color: #b0b0d0;
  font-family: inherit; font-size: 10px; letter-spacing: 1px;
}
.pad-btn.small { padding: 8px 10px; border-radius: 999px; }
.ab-group { display: flex; gap: 18px; align-items: center; }
.pad-btn.round {
  width: 58px; height: 58px; border-radius: 50%;
  font-size: 20px; font-weight: 800; color: #ffd8d8;
  background: radial-gradient(circle at 35% 30%, #d05050, #a02828);
  border: 3px solid #701818;
}
.pad-btn.round.b {
  background: radial-gradient(circle at 35% 30%, #d0a040, #a07018);
  border-color: #6a4810; color: #fff0d0;
}

/* ============ 顶部工具条 ============ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  background: linear-gradient(180deg, rgba(10,10,30,.92), rgba(10,10,30,.7));
  backdrop-filter: blur(4px);
}
.topbar-btn {
  background: #1c1c3c; border: 1px solid #3a3a6a; color: var(--ink);
  font-size: 13px; width: 34px; height: 30px; border-radius: 6px;
  font-family: inherit;
}
.topbar-btn.wide { width: auto; padding: 0 10px; font-size: 12px; }
.topbar-title {
  flex: 1; text-align: center; font-size: 12px; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============ 面板层（标题屏/选线/选站等） ============ */
.panel-layer {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 0 90px;
}
.panel { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 18px 16px 30px; }

/* 像素标题 */
.px-title { text-align: center; margin: 10px 0 4px; }
.px-title h1 {
  font-size: 30px; font-weight: 900; letter-spacing: 2px;
  background: linear-gradient(180deg, #ffe08a 30%, #e89b2c 85%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 3px 0 rgba(120,50,0,.55);
}
.px-title .sub { font-size: 13px; color: var(--dim); margin-top: 6px; letter-spacing: 4px; }
.px-slogan {
  margin: 14px 0 4px; font-size: 12px; color: #cfcfe8; text-align: center; line-height: 1.8;
  padding: 10px 14px; border-top: 1px solid #26264a; border-bottom: 1px solid #26264a;
}
.px-slogan b { color: var(--gold); }

/* 像素按钮 */
.px-btn {
  display: block; width: min(84vw, 340px); margin: 8px auto; padding: 13px 0;
  text-align: center; font-size: 16px; font-weight: 700; font-family: inherit;
  color: #fff; background: #b03226;
  border: none; border-radius: 4px; position: relative;
  box-shadow: 0 4px 0 #6a1a12, inset 0 2px 0 rgba(255,255,255,.25);
  letter-spacing: 2px;
}
.px-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #6a1a12; }
.px-btn.green { background: #2a8c4a; box-shadow: 0 4px 0 #14502a, inset 0 2px 0 rgba(255,255,255,.25); }
.px-btn.blue  { background: #2a5fa8; box-shadow: 0 4px 0 #143a6a, inset 0 2px 0 rgba(255,255,255,.25); }
.px-btn.gold  { background: #b8862a; box-shadow: 0 4px 0 #6a4c0e, inset 0 2px 0 rgba(255,255,255,.25); }
.px-btn.gray  { background: #44446a; box-shadow: 0 4px 0 #22223a; }
.px-btn.small { width: auto; display: inline-block; padding: 9px 18px; font-size: 13px; margin: 6px 4px; }
.px-btn:disabled { opacity: .4; }

/* 选线路 */
.line-grid { width: min(92vw, 380px); margin-top: 10px; }
.line-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: #16162e; border: 1px solid #2a2a52; border-radius: 10px;
  padding: 12px 12px; margin-bottom: 10px; text-align: left; font-family: inherit; color: var(--ink);
}
.line-card.locked { opacity: .45; }
.line-badge {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 900; color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.3);
}
.line-info { flex: 1; min-width: 0; }
.line-name { font-size: 15px; font-weight: 700; }
.line-theme { font-size: 11px; color: var(--dim); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-prog { font-size: 10px; color: var(--gold); margin-top: 3px; }

/* 选站 */
.station-head { width: min(92vw, 380px); display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.station-head .back { font-size: 22px; color: var(--dim); background: none; border: none; padding: 6px 10px 6px 0; font-family: inherit; }
.station-head h2 { font-size: 17px; flex: 1; }
.station-list { width: min(92vw, 380px); }
.stn-row {
  display: flex; align-items: center; gap: 10px;
  background: #14142c; border: 1px solid #26264a; border-radius: 8px;
  padding: 11px 12px; margin-bottom: 8px;
}
.stn-dot { width: 14px; height: 14px; border-radius: 3px; flex: 0 0 auto; box-shadow: 0 0 8px currentColor; }
.stn-name { flex: 1; font-size: 14px; }
.stn-name small { color: var(--dim); font-size: 10px; margin-left: 6px; }
.stn-state { font-size: 10px; color: var(--dim); }
.stn-state.done { color: #4ac46a; }
.stn-state .frag { color: var(--gold); }

/* 通用 section 标题 */
.sec-title {
  width: min(92vw, 380px); margin: 18px 0 8px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--gold); letter-spacing: 2px;
}
.sec-title::after { content: ""; flex: 1; height: 1px; background: #2a2a52; }

/* ============ 弹窗（题目/确认） ============ */
.modal-layer {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(4,4,16,.82);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 440px;
  background: #181834; border-top: 2px solid #3a3a7a;
  border-radius: 14px 14px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 86vh; overflow-y: auto;
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.q-tag { display: inline-block; font-size: 10px; padding: 3px 8px; border-radius: 4px; background: #2a2a52; color: var(--dim); margin-bottom: 10px; letter-spacing: 1px; }
.q-text { font-size: 16px; line-height: 1.7; margin-bottom: 14px; color: #fff; }
.q-hint { font-size: 12px; color: #7ac4e8; margin: -8px 0 12px; line-height: 1.6; }
.q-opts { display: flex; flex-direction: column; gap: 9px; }
.q-opt {
  background: #1e1e3c; border: 1px solid #34346a; border-radius: 8px;
  color: var(--ink); font-size: 14px; line-height: 1.5;
  padding: 12px 12px; text-align: left; font-family: inherit;
  display: flex; gap: 10px; align-items: flex-start;
}
.q-opt .key {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 4px;
  background: #2e2e5c; color: var(--gold); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.q-opt:active { background: #2c2c5c; }
.q-opt.right { background: #1c4a2c; border-color: #3aa05a; }
.q-opt.right .key { background: #2a7a44; color: #fff; }
.q-opt.wrong { background: #4a1e1e; border-color: #a03a3a; }
.q-opt.wrong .key { background: #7a2a2a; color: #fff; }
.q-explain {
  margin-top: 12px; font-size: 12px; color: #cfcfe8; line-height: 1.8;
  background: #101028; border-left: 3px solid var(--gold); padding: 10px 12px; border-radius: 0 6px 6px 0;
}
.q-explain b { color: var(--gold); }
.q-actions { margin-top: 14px; display: flex; flex-wrap: wrap; justify-content: center; }

/* 结算 */
.result-emoji { text-align: center; font-size: 52px; margin: 4px 0 6px; }
.result-title { text-align: center; font-size: 21px; font-weight: 900; margin-bottom: 4px; }
.result-sub { text-align: center; font-size: 12px; color: var(--dim); margin-bottom: 12px; }
.result-stats { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.stat-chip { background: #10102a; border: 1px solid #2c2c5c; border-radius: 8px; padding: 8px 12px; text-align: center; min-width: 76px; }
.stat-chip .v { font-size: 17px; font-weight: 800; color: var(--gold); }
.stat-chip .k { font-size: 10px; color: var(--dim); margin-top: 2px; }

/* 图鉴/画卷 */
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; width: min(92vw, 380px); }
.coll-cell {
  background: #12122a; border: 1px solid #26264a; border-radius: 8px;
  padding: 8px 6px; text-align: center;
}
.coll-cell.got { border-color: var(--gold); }
.coll-cell .ico { font-size: 26px; height: 40px; display: flex; align-items: center; justify-content: center; filter: grayscale(1) opacity(.3); }
.coll-cell.got .ico { filter: none; }
.coll-cell .nm { font-size: 10px; color: var(--dim); margin-top: 4px; line-height: 1.4; }
.coll-cell.got .nm { color: var(--ink); }

/* 图鉴：按线路折叠（懒加载） */
.coll-lines { width: min(92vw, 380px); }
.coll-line { margin-bottom: 6px; border-radius: 8px; overflow: hidden; background: #12122a; border: 1px solid #26264a; }
.coll-line-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; padding: 11px 12px;
  color: var(--ink); font-family: inherit; text-align: left;
}
.coll-line-head:active { background: #1a1a34; }
.coll-line-badge {
  flex: 0 0 auto; min-width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 900; color: #fff;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.3);
}
.coll-line-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coll-line-prog { font-size: 11px; color: var(--gold); }
.coll-line-chev { font-size: 12px; color: var(--dim); }
.coll-line-body { padding: 4px 10px 12px; }
.coll-line-body .coll-grid { width: 100%; }

/* 画卷 */
.scroll-pic { width: min(92vw, 380px); border: 3px solid #6a4a1a; border-radius: 6px; background: #f4e8cc; padding: 14px 10px; position: relative; }
.scroll-pic::before, .scroll-pic::after {
  content: ""; position: absolute; left: -3px; right: -3px; height: 8px;
  background: linear-gradient(180deg, #8a6428, #5a3c10); border-radius: 4px;
}
.scroll-pic::before { top: -8px; } .scroll-pic::after { bottom: -8px; }
.scroll-body { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; padding: 6px 0; min-height: 60px; }
.scroll-cell { font-size: 15px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 4px; background: rgba(0,0,0,.08); }
.scroll-cell.got { background: var(--gold); box-shadow: 0 0 6px rgba(255,210,74,.6); }
.scroll-desc { text-align: center; font-size: 11px; color: #6a5a3a; margin-top: 8px; line-height: 1.6; }

/* 证书 */
.cert {
  width: min(90vw, 360px); background: linear-gradient(160deg, #f8ecd0, #eed9a8);
  color: #4a3210; border: 4px double #a8842e; border-radius: 8px;
  padding: 26px 20px; text-align: center; position: relative;
}
.cert::before { content: "🏅"; position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 34px; }
.cert h3 { font-size: 20px; letter-spacing: 6px; margin: 8px 0 4px; color: #8a6414; }
.cert .who { font-size: 15px; margin: 12px 0; font-weight: 700; }
.cert .lvl { font-size: 17px; color: #a02818; font-weight: 800; margin: 8px 0; }
.cert .meta { font-size: 10px; color: #8a7048; margin-top: 14px; line-height: 1.8; }
.cert .seal {
  position: absolute; right: 14px; bottom: 14px; width: 58px; height: 58px; border-radius: 50%;
  border: 2px solid #b03024; color: #b03024; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; transform: rotate(-14deg);
  opacity: .85; line-height: 1.3;
}

/* 海报（求助/翻车/晒证） */
.poster {
  width: min(90vw, 360px); border-radius: 12px; overflow: hidden; position: relative;
  background: linear-gradient(180deg, #1a1a40, #101028);
  border: 1px solid #3a3a7a;
}
.poster-head { background: linear-gradient(90deg, #b03226, #d0602a); padding: 14px 14px 10px; }
.poster-head .t1 { font-size: 17px; font-weight: 900; color: #fff; letter-spacing: 2px; }
.poster-head .t2 { font-size: 10px; color: rgba(255,255,255,.75); margin-top: 3px; }
.poster-body { padding: 16px 14px; text-align: center; }
.poster-big { font-size: 40px; margin: 4px 0; }
.poster-line { font-size: 14px; line-height: 1.9; color: #e8e8f0; }
.poster-line b { color: var(--gold); font-size: 17px; }
.poster-foot { padding: 10px 14px 14px; border-top: 1px dashed #34346a; font-size: 11px; color: var(--dim); text-align: center; line-height: 1.8; }
.poster-qr {
  width: 88px; height: 88px; margin: 10px auto 2px; border-radius: 6px;
  background:
    repeating-linear-gradient(0deg, #e8e8f0 0 6px, transparent 6px 12px),
    repeating-linear-gradient(90deg, #e8e8f0 0 6px, #101028 6px 12px);
  border: 4px solid #e8e8f0;
}

/* 工龄测评 */
.age-bar { width: min(88vw, 360px); height: 14px; background: #101028; border-radius: 999px; overflow: hidden; border: 1px solid #2c2c5c; margin: 10px auto; }
.age-fill { height: 100%; background: linear-gradient(90deg, #2a8c4a, #ffd24a, #d05030); border-radius: 999px; transition: width .8s ease; }

/* 列表通用 */
.info-list { width: min(92vw, 380px); font-size: 13px; line-height: 2; color: #cfcfe8; }
.info-list b { color: var(--gold); }

/* 帮助 */
.help-sec { width: min(92vw, 380px); margin-bottom: 14px; }
.help-sec h4 { font-size: 14px; color: var(--gold); margin: 12px 0 6px; }
.help-sec p, .help-sec li { font-size: 12px; color: #cfcfe8; line-height: 1.9; }
.help-sec ul { padding-left: 18px; }
.kbd { display: inline-block; background: #2a2a52; border-radius: 4px; padding: 1px 7px; font-size: 11px; color: var(--gold); margin: 0 2px; }

/* ============ 底部横幅 ============ */
.home-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(12,12,28,.96); border-top: 1px solid #22224a;
  font-size: 11px; color: var(--dim);
}
.hb-dot { width: 6px; height: 6px; border-radius: 50%; background: #4ac46a; animation: hb 1.6s infinite; }
@keyframes hb { 50% { opacity: .3; } }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  z-index: 300; background: rgba(16,16,40,.95); color: #fff;
  border: 1px solid #3a3a7a; border-radius: 999px;
  padding: 10px 20px; font-size: 13px; white-space: nowrap;
  animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

.disclaimer {
  position: fixed; bottom: -30px; left: 0; right: 0; text-align: center;
  font-size: 9px; color: #33335a; z-index: 1; pointer-events: none;
}

/* 关卡内 HUD 覆盖（画布上方） */
.hud-tip {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 5; background: rgba(8,8,24,.8); border: 1px solid #3a3a6a;
  color: var(--gold); font-size: 11px; border-radius: 999px; padding: 5px 14px;
  pointer-events: none; white-space: nowrap; max-width: 92%;
  overflow: hidden; text-overflow: ellipsis;
}
.hud-quiz-flash { position: absolute; inset: 0; z-index: 6; pointer-events: none; background: #fff; opacity: 0; }
.hud-quiz-flash.on { animation: flash .3s ease-out; }
@keyframes flash { 0% { opacity: .55; } 100% { opacity: 0; } }

/* 桌面端适配 */
@media (min-width: 700px) {
  .app { flex-direction: row; }
  .stage { flex: 1; }
  .pad {
    flex-direction: column; width: 220px; gap: 18px; justify-content: center;
    border-top: none; border-left: 2px solid #26264a;
  }
  .pad-middle { order: 3; }
  .ab-group { flex-direction: row; }
  #game-canvas { height: auto; width: 100%; max-height: 100%; }
}
