/* 《裂隙勇者》样式 — 手机自适应（设计文档第 2 章为验收红线）
   流式布局 + 安全区 + 100dvh；HUD/按钮不写死坐标，横屏靠 .landscape 重排 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: #05060c;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #e5e7eb; touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
button { font-family: inherit; border: none; cursor: pointer; color: inherit; }
.hidden { display: none !important; }

#game-root {
  position: fixed; inset: 0; height: 100dvh; overflow: hidden; background: #141828;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
/* 电脑端（鼠标设备）：不再限成竖框——窗口横着全屏宽屏；窗口竖着则压成居中横版舞台（高=宽/1.6），尽可能横版 */
@media (pointer: fine) {
  #game-root { box-shadow: 0 0 60px rgba(232,179,75,.15); }
}
@media (pointer: fine) and (orientation: portrait) {
  #game-root { height: calc(100vw / 1.6); margin: auto; }
}
#game-canvas { position: absolute; inset: 0; display: block; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 8px; left: 10px; right: 10px; z-index: 10;
  display: flex; align-items: flex-start; gap: 8px; pointer-events: none;
}
.hud-left { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; }
.avatar {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f59e0b, #b45309);
  border: 2px solid #e8b34b; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff7ed; font-size: 17px;
}
.bars { flex: 1; min-width: 148px; max-width: 240px; display: flex; flex-direction: column; gap: 3px; }
.bar { position: relative; height: 15px; border-radius: 8px; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.25); overflow: hidden; }
.bar > div { height: 100%; width: 100%; transition: width .15s; }
.bar.hp > div { background: linear-gradient(#4ade80, #16a34a); }
.bar.hp.low > div { background: linear-gradient(#f87171, #dc2626); }
.bar.mp { height: 11px; } .bar.mp > div { background: linear-gradient(#60a5fa, #2563eb); }
.bar.exp { height: 5px; border: none; } .bar.exp > div { background: #c4b5fd; width: 0; }
.bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; letter-spacing: .3px; white-space: nowrap; text-shadow: 0 1px 2px #000, 0 0 3px rgba(0,0,0,.9), 1px 0 1px #000, -1px 0 1px #000; }
.hud-mid { text-align: center; pointer-events: none; }
#hud-wave { font-weight: 800; font-size: 13px; color: #fde68a; text-shadow: 0 1px 3px #000; white-space: nowrap; }
#hud-sub { font-size: 11px; color: #cbd5e1; text-shadow: 0 1px 2px #000; margin-top: 2px; white-space: nowrap; }
.hud-btns { display: flex; gap: 6px; pointer-events: auto; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; font-size: 17px;
  background: rgba(13,16,32,.72); border: 1px solid rgba(255,255,255,.3);
}

/* ---------- 横幅 / 提示 ---------- */
#banner {
  position: absolute; top: 22%; left: 0; right: 0; z-index: 15; text-align: center;
  font-size: 30px; font-weight: 900; letter-spacing: 4px; color: #fde68a;
  text-shadow: 0 2px 0 #92400e, 0 4px 14px rgba(0,0,0,.8); pointer-events: none;
  animation: bannerIn .3s ease-out;
}
@keyframes bannerIn { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#toast {
  position: absolute; bottom: 31%; left: 50%; transform: translateX(-50%); z-index: 15;
  background: rgba(13,16,32,.85); border: 1px solid #e8b34b; color: #fde68a;
  padding: 7px 14px; border-radius: 999px; font-size: 13px; white-space: nowrap; pointer-events: none;
}

/* ---------- 摇杆 ---------- */
#joy-zone { position: absolute; left: 0; bottom: 0; width: 52%; height: 46%; z-index: 8; touch-action: none; }
#joy-base {
  display: none; position: fixed; width: 116px; height: 116px; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none; z-index: 9;
  background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.28);
}
#joy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.5), rgba(255,255,255,.16));
  border: 2px solid rgba(255,255,255,.45);
}

/* ---------- 技能按钮 ---------- */
#controls {
  position: absolute; right: 12px; bottom: 16px; z-index: 10;
  display: flex; align-items: flex-end; gap: 10px; touch-action: none;
}
.btn-col { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.skill-btn {
  position: relative; overflow: hidden; border-radius: 50%;
  width: 60px; height: 60px; min-width: 44px; min-height: 44px;
  background: radial-gradient(circle at 35% 30%, #3b4566, #1c2338);
  border: 2px solid rgba(255,255,255,.4); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  touch-action: none;
}
.skill-btn .s-name { font-size: 13px; font-weight: 800; line-height: 1.1; }
@keyframes skillPulse { 0% { box-shadow: 0 0 0 0 rgba(255,220,120,.95); transform: scale(1); } 40% { box-shadow: 0 0 0 10px rgba(255,220,120,0); transform: scale(1.14); } 100% { box-shadow: 0 0 0 0 rgba(255,220,120,0); transform: scale(1); } }
.skill-btn.pulse { animation: skillPulse .5s ease-out; border-color: #fde68a; }
.skill-btn .s-sub { font-size: 9px; color: #93c5fd; }
.skill-btn.atk { width: 82px; height: 82px; border-color: #e8b34b; background: radial-gradient(circle at 35% 30%, #92600f, #5c3a06); }
.skill-btn.atk .s-name { font-size: 17px; }
.skill-btn.ult { width: 68px; height: 68px; border-color: #fb923c; background: radial-gradient(circle at 35% 30%, #9a3412, #571f04); }
.skill-btn.ult .s-sub { color: #fdba74; }
.skill-btn.pressed { transform: scale(.9); filter: brightness(1.35); }
.skill-btn .cd {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: conic-gradient(from 0deg, rgba(0,0,0,.66) calc(var(--cdf, 0) * 1turn), rgba(0,0,0,0) 0turn);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 6px rgba(0,0,0,.8);
}
.skill-btn.nomp { filter: grayscale(.8) brightness(.7); }

/* ---------- 开始页 ---------- */
#start-screen {
  position: absolute; inset: 0; z-index: 20; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px 20px; text-align: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(35,44,84,.88), rgba(10,12,24,.96) 70%);
}
.logo { font-size: 44px; font-weight: 900; letter-spacing: 6px; color: #e8b34b; text-shadow: 0 3px 0 #92400e, 0 8px 28px rgba(232,179,75,.35); }
.tagline { color: #cbd5e1; font-size: 14px; letter-spacing: 2px; }
.job-cards { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; }
.job-card { border: 2px solid rgba(255,255,255,.16); border-radius: 14px; padding: 12px 14px; background: rgba(255,255,255,.05); text-align: left; position: relative; }
.job-card.active { border-color: #e8b34b; background: rgba(232,179,75,.10); }
.job-card.locked { opacity: .5; }
.job-ico { font-size: 24px; position: absolute; right: 14px; top: 12px; }
.job-name { font-size: 18px; font-weight: 800; }
.job-desc { font-size: 12px; color: #cbd5e1; margin-top: 3px; }
.job-star { font-size: 11px; color: #fbbf24; margin-top: 4px; }
#btn-start {
  margin-top: 6px; padding: 15px 64px; font-size: 21px; font-weight: 900; letter-spacing: 4px;
  color: #451a03; border-radius: 999px;
  background: linear-gradient(#fcd34d, #d97706); border: 2px solid #fde68a;
  box-shadow: 0 6px 24px rgba(217,119,6,.5);
}
#btn-start:active { transform: scale(.96); }
.howto { font-size: 12px; color: #94a3b8; line-height: 1.7; }
.best { font-size: 12px; color: #fbbf24; min-height: 16px; }
.ver { font-size: 11px; color: #64748b; }

/* ---------- 弹窗（暂停/结算） ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20; background: rgba(5,6,12,.72);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.panel {
  width: 100%; max-width: 340px; background: #171b2e; border: 2px solid #e8b34b;
  border-radius: 18px; padding: 22px 20px; text-align: center;
  display: flex; flex-direction: column; gap: 10px;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel h2 { color: #fde68a; font-size: 26px; letter-spacing: 3px; margin-bottom: 4px; }
.panel button { padding: 12px; border-radius: 12px; font-size: 16px; font-weight: 700; background: #2a3050; border: 1px solid rgba(255,255,255,.22); }
.panel button.primary { background: linear-gradient(#fcd34d, #d97706); color: #451a03; border-color: #fde68a; }
#end-stats { font-size: 14px; line-height: 1.9; color: #e2e8f0; }
#end-equips { font-size: 13px; line-height: 1.7; max-height: 130px; overflow-y: auto; }
#end-equips .eq { font-weight: 700; }

/* ---------- 选关 ---------- */
#level-screen {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 20%, rgba(35,44,84,.94), rgba(10,12,24,.98) 75%);
  padding: 14px 14px 10px;
}
.lv-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.lv-title { font-size: 21px; font-weight: 900; letter-spacing: 3px; color: #fde68a; flex: 1; }
.lv-progress { font-size: 12px; color: #fbbf24; }
#level-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding-bottom: 14px; }
.lv-chapter { font-size: 14px; font-weight: 800; color: #e8b34b; letter-spacing: 2px; margin: 14px 2px 8px; }
.lv-chapter:first-child { margin-top: 2px; }
.lv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.lv-item {
  text-align: left; border-radius: 13px; padding: 10px 12px; position: relative;
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.16); color: #e5e7eb;
}
.lv-item .lv-no { font-size: 11px; color: #fbbf24; font-weight: 800; }
.lv-item .lv-name { font-size: 16px; font-weight: 800; margin: 2px 0; }
.lv-item .lv-meta { font-size: 11px; color: #94a3b8; }
.lv-item .lv-stars { color: #fbbf24; font-size: 12px; letter-spacing: 1px; }
.lv-item.boss { border-color: rgba(192,132,252,.55); }
.lv-item.locked { opacity: .42; }
.lv-item.current { border-color: #e8b34b; box-shadow: 0 0 12px rgba(232,179,75,.35); }
#end-stars { font-size: 26px; color: #fbbf24; letter-spacing: 6px; min-height: 30px; text-align: center; }

/* ---------- 存档槽位 / 排行榜 ---------- */
.sub-btn {
  margin-top: 10px; padding: 10px 26px; font-size: 15px; font-weight: 700; color: #fde68a;
  background: rgba(255,255,255,.08); border: 2px solid rgba(232,179,75,.5); border-radius: 999px;
}
.save-bar { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.mini-btn {
  padding: 6px 12px; font-size: 13px; color: #e5e7eb; border-radius: 999px;
  background: rgba(255,255,255,.07); border: 1.5px solid rgba(255,255,255,.22);
}
.mini-btn.danger { color: #fca5a5; border-color: rgba(248,113,113,.45); }
.slot-group { display: flex; gap: 6px; }
.slot-btn {
  padding: 6px 11px; font-size: 12.5px; color: #cbd5e1; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1.5px solid rgba(255,255,255,.18);
}
.slot-btn.active { color: #1c1917; background: #e8b34b; border-color: #e8b34b; font-weight: 800; }
#lb-screen {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 20%, rgba(35,44,84,.94), rgba(10,12,24,.98) 75%);
  padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
}
#lb-my {
  background: rgba(232,179,75,.10); border: 1.5px solid rgba(232,179,75,.4); border-radius: 13px;
  padding: 10px 14px; font-size: 14px; color: #fde68a; margin-bottom: 12px; line-height: 1.7;
}
.lb-row {
  display: grid; grid-template-columns: 40px 1fr auto auto; gap: 8px; align-items: center;
  padding: 8px 12px; border-radius: 11px; background: rgba(255,255,255,.05);
  border: 1.5px solid rgba(255,255,255,.10); margin-bottom: 7px; font-size: 14px; color: #e5e7eb;
}
.lb-row.me { border-color: #e8b34b; background: rgba(232,179,75,.12); }
.lb-row .rk { font-weight: 900; color: #fbbf24; text-align: center; }
.lb-row .sc { font-weight: 800; color: #fff; }
.lb-row .st { color: #fbbf24; font-size: 12px; }
.lb-best-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; padding: 6px 12px;
  font-size: 13px; color: #cbd5e1; border-bottom: 1px solid rgba(255,255,255,.07);
}
.lb-best-row .st { color: #fbbf24; }

/* ---------- 横屏重排（文档 §2.3） ---------- */
#game-root.landscape #controls { bottom: 10px; right: 14px; }
#game-root.landscape #joy-zone { height: 72%; width: 42%; }
#game-root.landscape #banner { top: 16%; font-size: 26px; }
#game-root.landscape #toast { bottom: 38%; }
#game-root.landscape .bars { max-width: 300px; }
#game-root.landscape .job-cards { flex-direction: row; max-width: 640px; }
#game-root.landscape .job-card { flex: 1; }
#game-root.landscape .logo { font-size: 34px; }
#game-root.landscape #start-screen { gap: 8px; padding: 12px 20px; }

/* ===== 正式版新增：职业锁/章节锁/复活/存档槽锁/模拟广告 ===== */
.job-lock { font-size: 11px; color: #fca5a5; margin-top: 5px; font-weight: 700; }
.job-lock button, .ch-unlock { margin-left: 6px; font-size: 11px; font-weight: 800; color: #1c1917; background: #fcd34d; border: 1px solid #fde68a; border-radius: 999px; padding: 3px 10px; }
.job-card { cursor: pointer; }
.job-card.locked { cursor: default; }
.slot-btn.locked { opacity: .55; border-style: dashed; }
.ch-unlock { margin: 0 0 0 8px; vertical-align: 1px; }
#revive-row { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
#revive-row.hidden { display: none; }
#btn-revive-ad { border-color: #fcd34d; color: #fde68a; }
#ad-sim { position: fixed; inset: 0; z-index: 99; background: rgba(2,6,16,.92); display: flex; align-items: center; justify-content: center; }
.ad-sim-card { width: min(86vw, 340px); background: #111a2e; border: 2px solid #fcd34d; border-radius: 16px; padding: 20px 18px; text-align: center; color: #e2e8f0; }
.ad-sim-tag { font-size: 11px; color: #fcd34d; font-weight: 700; }
.ad-sim-body { font-size: 17px; font-weight: 800; margin: 16px 0; }
.ad-sim-bar { height: 8px; background: rgba(255,255,255,.14); border-radius: 99px; overflow: hidden; }
.ad-sim-fill { height: 100%; width: 0; background: linear-gradient(90deg, #f59e0b, #fcd34d); }
.ad-sim-count { font-size: 13px; margin: 10px 0; color: #cbd5e1; }
.ad-sim-get { width: 100%; padding: 12px; font-size: 16px; font-weight: 900; border-radius: 999px; background: linear-gradient(#fcd34d, #d97706); color: #451a03; border: 2px solid #fde68a; }
.ad-sim-skip { margin-top: 10px; background: none; border: none; color: #94a3b8; font-size: 12px; text-decoration: underline; }

/* 冷却中：技能名/蓝耗让位，只显示居中秒数 */
.skill-btn.cooling .s-name, .skill-btn.cooling .s-sub { opacity: 0; }

.job-ico img { width: 46px; height: 46px; image-rendering: pixelated; display: block; }

/* ===== 强制横屏：竖屏时整屏旋转 90°，横过来拿即正向宽屏 ===== */
#game-root.force-land {
  inset: auto; left: 50%; top: 50%;
  width: 100dvh; height: 100dvw; max-width: none;
  transform: translate(-50%, -50%) rotate(90deg);
}
body.fl-on #ad-sim {
  width: 100dvh; height: 100dvw; left: 50%; top: 50%; right: auto; bottom: auto;
  transform: translate(-50%, -50%) rotate(90deg);
}

/* ===== 横版定版布局优化：宽屏排版，不再是将就的竖版旋转 ===== */
#game-root.landscape #start-screen { justify-content: flex-start; overflow-y: auto; gap: 7px; padding: 10px 22px; }
#game-root.landscape .logo { font-size: 32px; }
#game-root.landscape .tagline { font-size: 12px; margin-top: -4px; }
#game-root.landscape .job-cards { flex-direction: row; max-width: 680px; gap: 8px; }
#game-root.landscape .job-card { flex: 1; padding: 9px 12px; }
#game-root.landscape #btn-start { padding: 11px 52px; font-size: 19px; margin-top: 2px; }
#game-root.landscape .howto { display: none; }
#game-root.landscape .ver { font-size: 10px; }
#game-root.landscape .lv-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
#game-root.landscape .lv-item { padding: 8px 9px; }
#game-root.landscape #level-screen, #game-root.landscape #lb-screen { padding-left: 18px; padding-right: 18px; }
#game-root.landscape #lb-list, #game-root.landscape #lb-best, #game-root.landscape #lb-my { max-width: 780px; margin-left: auto; margin-right: auto; width: 100%; }
#game-root.landscape #hud { top: 6px; }
#game-root.landscape .overlay .panel { max-width: 430px; }

/* ===== 选关页章节签：一次只看一章，不再 50 关一面墙 ===== */
.ch-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.ch-chips::-webkit-scrollbar { display: none; }
.ch-chip { flex: 0 0 auto; padding: 8px 15px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #cbd5e1; background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.16); white-space: nowrap; }
.ch-chip.active { color: #1c1917; background: linear-gradient(#fcd34d, #d97706); border-color: #fde68a; font-weight: 900; }
.ch-chip.locked { opacity: .55; }
.ch-detail-head { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 900; color: #fde68a; margin: 2px 0 4px; }
.ch-detail-head .ch-stars { font-size: 12px; color: #cbd5e1; font-weight: 700; }
.ch-lock-tip { font-size: 12px; color: #94a3b8; margin-bottom: 8px; }

/* ===== 诊断错误框：容器里没控制台，报错直接上屏（点一下关闭） ===== */
#errbox { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); width: min(92vw, 560px); z-index: 200;
  background: rgba(127,29,29,.96); color: #fff; font: 12px/1.55 ui-monospace, monospace; white-space: pre-wrap; word-break: break-all;
  padding: 10px 12px; border-radius: 10px; border: 2px solid #fca5a5; }
body.fl-on #errbox { top: 50%; width: min(92dvh, 560px); transform: translate(-50%, -50%) rotate(90deg); }

/* ===== 横版弹窗紧凑化：结算/复活/暂停面板（390 高横屏里不再溢出显大） ===== */
#game-root.landscape .overlay .panel { max-width: 400px; padding: 12px 16px; gap: 6px; max-height: 96%; overflow-y: auto; border-radius: 14px; }
#game-root.landscape .panel h2 { font-size: 20px; letter-spacing: 2px; margin-bottom: 0; }
#game-root.landscape .panel button { padding: 8px 10px; font-size: 14px; border-radius: 10px; }
#game-root.landscape #end-stats { font-size: 12.5px; line-height: 1.55; }
#game-root.landscape #end-stars { font-size: 20px; line-height: 1.1; }
#game-root.landscape #end-equips { font-size: 12px; line-height: 1.5; }
#game-root.landscape #revive-row { flex-direction: row; gap: 6px; margin: 2px 0; }
#game-root.landscape #revive-row button { flex: 1; }
#game-root.landscape .overlay { padding: 8px; }

/* ===== 首页大厅式布局：左上角色名 / 右上排行榜 / 中上游戏名，其余居中收拢，不再竖排溢出 ===== */
#start-screen { justify-content: flex-start; }
.home-top { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; }
.home-top .home-corner { padding: 7px 13px; font-size: 13px; border-radius: 999px; white-space: nowrap; }
.home-left { display: flex; gap: 8px; justify-self: start; align-items: flex-start; }
.home-right { min-width: 76px; } /* 右上角留给平台（小游戏关闭按钮）占位，界面元素不进这个角 */
.home-title { text-align: center; }
.home-title .logo { margin: 0; }
.home-title .tagline { margin: 2px 0 0; }
#game-root.landscape .home-top .logo { font-size: 30px; }
#game-root.landscape #start-screen { gap: 9px; }
.save-bar { flex-wrap: wrap; justify-content: center; }

/* 首页再收紧：390 高横屏一屏放下不滚动 */
#game-root.landscape #start-screen { gap: 7px; padding: 8px 18px; }
#game-root.landscape .home-title .logo { font-size: 28px; }
#game-root.landscape .job-card { padding: 8px 10px; }
#game-root.landscape #btn-start { padding: 10px 48px; }
.job-desc { padding-right: 44px; }

/* 首页左上两钮同高同线：抹掉 mini/sub 原始边距差，统一 36px 高、垂直居中 */
.home-left { align-items: center; }
.home-top .home-corner { margin: 0; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0 13px; line-height: 1; box-sizing: border-box; }
