/* ===========================================================
 * 《不服来通关 · 魔性蛙泳大作战》国漫手绘卡通风 UI 样式表
 * 风格参考：《不服来通关》粗黑描边 + 糖果立体高光 + 森林草坡动画风
 * =========================================================== */

:root {
  --ink: #1b2419;            /* 漫画粗黑描边色 */
  --ink-soft: #2e3b29;
  --cream: #fffaf0;          /* 羊皮奶油底色 */
  --cream-2: #fff2d6;
  --wood: #8c5228;
  --grass-dark: #256e3a;
  --grass-mid: #4eb857;
  --grass-light: #8fd95f;
  --sky-top: #3298e8;
  --sky-bot: #9be8ff;
  --gold-top: #fff394;
  --gold-mid: #ffd038;
  --gold-bot: #f59316;
  --coral: #ff4769;
  --coral-dark: #c92042;
  --cyan: #1ec8e8;
  --purple: #9b51e0;
  --green: #2cc96b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Rounded Mplus 1c", system-ui, sans-serif;
  color: var(--ink);
  /* 柔和森林漫画草坡远景背景（绝不刺眼） */
  background:
    radial-gradient(circle at 50% 42%, #8ed973 0%, #56ab54 52%, #2c6b3b 100%);
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ===========================================================
 * 1. 国漫动画风开屏 (1:1 致敬《不服来通关》手绘插画开屏)
 * =========================================================== */
.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #2d95e6 0%, #68c6f7 36%, #b5f2ec 62%, #7cc95b 62%, #4c9c38 100%);
  overflow: hidden;
  transition: opacity 0.42s ease, transform 0.42s ease;
}
.boot-loader.loaded {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.boot-ver {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 6;
  font-weight: 900;
  font-size: 14px;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink), 0 -1px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink);
}

/* 蓝天白云 */
.boot-sky {
  position: absolute;
  inset: 0 0 42% 0;
  pointer-events: none;
  overflow: hidden;
}
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 99px;
  box-shadow: 0 4px 0 rgba(45, 149, 230, 0.25);
}
.cloud.c1 { width: 120px; height: 36px; top: 14%; left: 8%; animation: drift 12s ease-in-out infinite alternate; }
.cloud.c2 { width: 150px; height: 42px; top: 22%; right: 7%; animation: drift 15s ease-in-out infinite alternate-reverse; }
.cloud.c3 { width: 95px; height: 28px; top: 42%; left: 16%; opacity: 0.7; }
@keyframes drift {
  from { transform: translateX(-10px); }
  to { transform: translateX(14px); }
}

/* 顶部《不服来通关》立体卡通大 Logo */
.boot-logo-wrap {
  position: relative;
  z-index: 4;
  margin-top: clamp(14px, 3.2vh, 34px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-peek-bug {
  width: clamp(86px, 13vh, 114px);
  height: clamp(72px, 11vh, 96px);
  margin-bottom: -26px;
  margin-left: -95px;
  z-index: 2;
  transform: rotate(-10deg);
  animation: bugShiver 0.35s ease-in-out infinite alternate;
}
@keyframes bugShiver {
  from { transform: rotate(-12deg) translateY(0); }
  to { transform: rotate(-8deg) translateY(-3px); }
}
.svg-toon { width: 100%; height: 100%; overflow: visible; }

.logo-bush {
  position: relative;
  padding: 16px 34px 18px;
  background: radial-gradient(circle at 50% 35%, #469c52 0%, #265931 100%);
  border: 5px solid var(--ink);
  border-radius: 48px;
  box-shadow:
    0 8px 0 var(--ink),
    0 0 0 6px #fff,
    0 12px 24px rgba(0, 0, 0, 0.28);
}

/* 灌木丛右上角偷看的小眼睛 */
.bush-eyes {
  position: absolute;
  top: -16px;
  right: 26px;
  display: flex;
  gap: 5px;
}
.bush-eyes span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--ink);
  display: grid;
  place-items: center;
}
.bush-eyes span i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff2e55;
}

.title-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.02;
}
.title-row {
  font-weight: 900;
  letter-spacing: 3px;
  font-family: "PingFang SC", "STHeiti", "Microsoft YaHei", sans-serif;
  -webkit-text-stroke: 3.5px var(--ink);
  paint-order: stroke fill;
  filter: drop-shadow(0 5px 0 var(--ink));
}
.title-row.row-top {
  font-size: clamp(42px, 7.2vh, 66px);
  color: #fffdf5;
  background: linear-gradient(180deg, #ffffff 0%, #ffe6b8 65%, #f5b963 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.title-row.row-bot {
  font-size: clamp(38px, 6.4vh, 58px);
  margin-top: -2px;
  color: #ffd43b;
  background: linear-gradient(180deg, #fff58c 0%, #ffc82c 55%, #f08c11 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-bush .star {
  position: absolute;
  font-size: 24px;
  color: #ffc82c;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  filter: drop-shadow(0 3px 0 var(--ink));
}
.logo-bush .star.s-left { bottom: 14px; left: 10px; transform: rotate(-15deg); }
.logo-bush .star.s-right { top: 24px; right: 10px; transform: rotate(15deg); }

/* 中部深色描边公告横幅 */
.boot-banner {
  position: relative;
  z-index: 5;
  width: 100%;
  margin: 6px 0;
  padding: 6px 12px;
  background: rgba(34, 18, 42, 0.88);
  border-top: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  color: #fff;
  text-align: center;
  font-size: clamp(11.5px, 1.8vh, 14px);
  font-weight: 900;
  letter-spacing: 0.5px;
}

/* 中景大虫子 + 草坡插画 */
.boot-scene {
  position: relative;
  z-index: 3;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 150px;
}
.boss-worm {
  width: clamp(165px, 25vh, 235px);
  height: auto;
  margin-bottom: -24px;
  z-index: 2;
  animation: bossFloat 1.8s ease-in-out infinite alternate;
}
@keyframes bossFloat {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-6px) scale(1.02); }
}

.boot-hill {
  position: relative;
  width: 120%;
  height: clamp(95px, 16vh, 145px);
  background: linear-gradient(180deg, #9ce063 0%, #6dc24b 55%, #3f8f34 100%);
  border-top: 5px solid var(--ink);
  border-radius: 50% 50% 0 0 / 45% 45% 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
/* 草坡红蘑菇装饰 */
.mush {
  position: absolute;
  width: 26px;
  height: 22px;
  background: #e0533c;
  border: 3px solid var(--ink);
  border-radius: 16px 16px 6px 6px;
}
.mush::after {
  content: '';
  position: absolute;
  left: 5px;
  bottom: -10px;
  width: 10px;
  height: 9px;
  background: #b9d6c5;
  border: 3px solid var(--ink);
  border-radius: 0 0 5px 5px;
}
.mush.m1 { left: 16%; top: -8px; transform: rotate(-12deg); }
.mush.m2 { left: 23%; top: 10px; transform: scale(0.8); }
.mush.m3 { right: 18%; top: -6px; transform: rotate(10deg); }
.mush.m4 { right: 12%; top: 14px; transform: scale(0.78); }

.hero-mascot {
  width: clamp(150px, 23vh, 210px);
  height: auto;
  margin-top: -16px;
  animation: heroSwim 0.9s ease-in-out infinite alternate;
}
@keyframes heroSwim {
  from { transform: translateY(0); }
  to { transform: translateY(-5px); }
}

/* 底部卡通胶囊加载条与忠告 */
.boot-footer {
  position: relative;
  z-index: 5;
  width: 100%;
  padding: 8px 16px 14px;
  background: linear-gradient(180deg, #2d7a2d 0%, #16441c 100%);
  border-top: 4px solid var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.boot-bar-capsule {
  position: relative;
  width: min(460px, 90vw);
  height: 30px;
  border-radius: 99px;
  background: #175452;
  border: 3.5px solid var(--ink);
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.45), 0 3px 0 rgba(0,0,0,0.35);
  overflow: hidden;
}
.boot-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(180deg, #a6ffff 0%, #37d8f7 50%, #1098bd 100%);
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.65);
  transition: width 0.08s linear;
}
.boot-bar-text {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1.5px 0 var(--ink), 1.5px 0 0 var(--ink), -1.5px 0 0 var(--ink), 0 -1.5px 0 var(--ink);
}

.boot-counsel {
  text-align: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
  text-shadow: 0 1.5px 0 var(--ink), 1.5px 0 0 var(--ink), -1.5px 0 0 var(--ink);
}
.counsel-title {
  font-size: 13px;
  font-weight: 900;
  color: #ffe680;
  margin-bottom: 1px;
}
.counsel-sub {
  margin-top: 2px;
  color: #a6ff96;
  font-size: 11px;
}

/* ===========================================================
 * 2. 顶部卡通粗描边 HUD 甲板 + 左上角自由选关
 * =========================================================== */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 6px;
  pointer-events: none;
}

.brand {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  background: linear-gradient(180deg, #fffdf7 0%, #ffe9bf 100%);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  text-align: left;
  transition: transform .12s;
}
.brand:hover { transform: translateY(-2px); }
.brand:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }

.brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(180deg, #ff708d 0%, #ff3b61 100%);
  border: 2.5px solid var(--ink);
  display: grid;
  place-items: center;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.5);
}
.logo-glyph { font-size: 20px; }
.brand-name {
  font-weight: 900;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0.5px;
}
.brand small {
  display: block;
  font-size: 10.5px;
  color: #d62849;
  font-weight: 900;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pill {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  height: 44px;
  padding: 0 11px;
  background: linear-gradient(180deg, #fffef9 0%, #ffefd1 100%);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
}
.pill-clickable {
  pointer-events: auto;
  cursor: pointer;
  background: linear-gradient(180deg, #fff7a8 0%, #ffd23f 100%);
  transition: transform .12s;
}
.pill-clickable:hover { transform: translateY(-2px); }
.pill-val {
  display: flex;
  align-items: baseline;
  gap: 2px;
  white-space: nowrap;
}
.pill b {
  font-size: 17px;
  line-height: 1;
  font-weight: 900;
  font-family: "SF Mono", "JetBrains Mono", Menlo, monospace;
}
.pill-val small {
  font-size: 10px;
  color: var(--ink);
  font-weight: 900;
}
.pill-sub {
  font-size: 9.5px;
  color: var(--ink-soft);
  margin-top: 2px;
  font-weight: 900;
  white-space: nowrap;
}
.pill.bean b { color: #d91e41; }
.pill.score b { color: #c76b00; }

.spacer { flex: 1; }

.combo {
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, #ff6b4a 0%, #e02847 100%);
  border: 2.5px solid var(--ink);
  padding: 3px 10px;
  border-radius: 99px;
  box-shadow: 0 3px 0 var(--ink);
}
.combo:empty { display: none; }

.hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.icon-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(180deg, #fffdf7 0%, #ffe6b8 100%);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s;
}
.icon-btn:hover { transform: translateY(-2px); }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }

.level-quick-btn {
  width: 52px;
  font-size: 12.5px;
  color: #fff;
  background: linear-gradient(180deg, #ff6b8b 0%, #e62e56 100%);
}
.speed-btn {
  width: 50px;
  font-size: 13px;
  color: var(--ink);
  background: linear-gradient(180deg, #a8ff78 0%, #4cd964 100%);
}
.help-btn {
  width: 38px;
  font-size: 18px;
  background: linear-gradient(180deg, #bcecff 0%, #54c5ed 100%);
}

/* ===========================================================
 * 2.5 规则与 Buff 快速说明
 * =========================================================== */
.help-panel {
  position: fixed;
  inset: 0;
  z-index: 58;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  background: rgba(20, 34, 18, 0.52);
  backdrop-filter: blur(4px);
}
.help-panel.open { display: flex; animation: fadeIn .18s ease; }
.help-card {
  width: min(460px, 100%);
  max-height: min(72dvh, 520px);
  overflow-y: auto;
  padding: 16px;
  color: var(--ink);
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 8px 0 var(--ink), 0 18px 40px rgba(0,0,0,.38);
  animation: helpUp .22s cubic-bezier(.2, 1.15, .3, 1) both;
}
@keyframes helpUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
.help-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.help-head strong { font-size: 19px; font-weight: 900; }
.help-head p { margin-top: 2px; font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.help-close {
  width: 32px;
  height: 32px;
  flex: none;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  background: #ffb7c5;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}
.help-body { display: grid; gap: 8px; text-align: left; }
.help-rule, .help-good, .help-bad {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 800;
}
.help-rule { background: #fff3d1; }
.help-good { background: #dff7c7; }
.help-bad { background: #ffd7df; }
.help-rule b, .help-good b, .help-bad b { font-size: 12px; font-weight: 900; }
.help-bad b { color: #c92042; }

/* ===========================================================
 * 3. 左上角 1~10 关自由选关抽屉弹窗
 * =========================================================== */
.level-picker {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  background: rgba(20, 34, 18, 0.58);
  backdrop-filter: blur(6px);
  padding: 16px;
}
.level-picker.open { display: grid; animation: fadeIn .18s ease; }

.lp-card {
  width: min(530px, 96vw);
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 26px;
  padding: 20px;
  box-shadow: 0 10px 0 var(--ink), 0 24px 50px rgba(0, 0, 0, 0.45);
  color: var(--ink);
}
.lp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.lp-head strong {
  font-size: 19px;
  font-weight: 900;
  color: var(--ink);
  display: block;
}
.lp-head p {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 3px;
  font-weight: 800;
}
.lp-close {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 3px solid var(--ink);
  background: #ff5c77;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
}

.lp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.lp-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 11px 13px;
  border-radius: 15px;
  border: 3px solid var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform .12s;
}
.lp-item:hover {
  transform: translateY(-2px);
  background: #fff9db;
}
.lp-item.current {
  background: linear-gradient(180deg, #fff3a1 0%, #ffd449 100%);
}
.lp-item.cleared:not(.current) {
  background: linear-gradient(180deg, #e3ffcf 0%, #b8f294 100%);
}
.lp-item-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lp-num {
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
}
.lp-badge {
  font-size: 10px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 99px;
  border: 2px solid var(--ink);
  background: #eee;
  color: var(--ink);
}
.lp-item.current .lp-badge { background: #ff4769; color: #fff; }
.lp-item.cleared .lp-badge { background: #2cc96b; color: #fff; }
.lp-name {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
}
.lp-meta {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 800;
}

/* ===========================================================
 * 4. 顶部任务进度 + 6大Buff状态栏
 * =========================================================== */
.mission-pod {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(740px, 95vw);
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cream);
  border: 3px solid var(--ink);
  padding: 4px 12px;
  border-radius: 99px;
  box-shadow: 0 3px 0 var(--ink);
}
.progress-label {
  font-size: 11px;
  font-weight: 900;
  color: var(--ink);
}
.progress-track {
  flex: 1;
  height: 10px;
  background: #33422f;
  border: 2px solid var(--ink);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5ef275 0%, #ffe135 55%, #ff5277 100%);
  border-radius: 99px;
  transition: width .22s ease;
}
.progress-txt {
  font-size: 11.5px;
  color: #d62849;
  font-weight: 900;
  min-width: 34px;
  text-align: right;
}

.level-info {
  padding: 5px 12px;
  border-radius: 14px;
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.level-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.level-info strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}
.level-info p {
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 800;
}
.effects {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.effects span {
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 900;
  color: var(--ink);
  border: 2px solid var(--ink);
  background: #fff;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.effects #effectShield.on {
  color: #fff;
  background: #18a4e0;
}
.effects #effectPortal.on {
  color: #fff;
  background: #8e44ad;
}
.effects #effectMagnet.on {
  color: #fff;
  background: #e63946;
}
.effects #effectReverse.on {
  color: #fff;
  background: #ff006e;
  animation: pulseWarn 0.45s ease-in-out infinite alternate;
}
.effects #effectSlow.on {
  color: #fff;
  background: #2a9d8f;
}
.effects #effectDouble.on {
  color: var(--ink);
  background: #ffd166;
}
@keyframes pulseWarn {
  from { transform: scale(1); }
  to { transform: scale(1.07); }
}

/* ===========================================================
 * 5. 底部图例、蹬腿冲刺键与提示
 * =========================================================== */
.play-guide {
  position: fixed;
  z-index: 18;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 95vw);
  padding: 5px 12px;
  border-radius: 13px;
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 900;
  pointer-events: none;
}
.terrain-legend {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.terrain-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 2px solid var(--ink);
  display: inline-block;
}
.swatch.safe { background: #7cd456; }
.swatch.warning { background: #ffc425; }
.swatch.danger { background: #ff385c; }
.swatch.rock { background: #7d8590; }

.portal-key { color: #7b2cbf; }
.magnet-key { color: #d90429; }
.shield-key { color: #0077b6; }
.reverse-key { color: #d0006f; }

/* 悬浮可拖动的「蹬腿」冲刺键：按住加速，拖动换位 */
.boost-btn {
  position: fixed;
  z-index: 26;
  bottom: 14px;
  left: 16px;
  width: 86px;
  height: 62px;
  padding: 6px 8px 4px;
  color: var(--ink);
  background: linear-gradient(180deg, #fff58c 0%, #ffc82c 60%, #f08c11 100%);
  border: 3.5px solid var(--ink);
  border-radius: 20px;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: 0 5px 0 var(--ink), 0 10px 18px rgba(0, 0, 0, 0.28);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .1s, box-shadow .1s;
}
/* 顶部小握把：提示这个键可以拖着走 */
.boost-btn::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 3px;
  border-radius: 99px;
  background: rgba(27, 36, 25, 0.42);
  box-shadow: 0 5px 0 rgba(27, 36, 25, 0.42);
}
.boost-icon { font-size: 17px; line-height: 1; margin-top: 5px; }
.boost-main { font-size: 15px; font-weight: 900; letter-spacing: 1px; }
.boost-btn small {
  display: none;
}
.boost-btn.active {
  background: linear-gradient(180deg, #ff758f 0%, #ff2a55 100%);
  color: #fff;
  transform: translateY(3px) scale(0.97);
  box-shadow: 0 2px 0 var(--ink), 0 6px 14px rgba(255, 42, 85, 0.45);
}
.boost-btn.active small { color: #fff; }
.boost-btn.dragging {
  cursor: grabbing;
  transform: scale(1.06);
  box-shadow: 0 8px 0 var(--ink), 0 16px 26px rgba(0, 0, 0, 0.4);
}

/* 开局 2 秒无敌保护角标 */
.grace-badge {
  position: fixed;
  z-index: 27;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  bottom: calc(64px + env(safe-area-inset-bottom));
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 13px;
  border-radius: 99px;
  background: linear-gradient(180deg, #7bf7ff 0%, #18a4e0 100%);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}
.grace-badge.show { display: inline-flex; animation: graceIn .2s ease-out both; }
.grace-badge b {
  font-family: "SF Mono", "JetBrains Mono", Menlo, monospace;
  font-size: 13.5px;
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
}
@keyframes graceIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px) scale(.9); }
  to { opacity: 1; transform: translateX(-50%) translateY(6px) scale(1); }
}

.hint {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  font-size: 11px;
  font-weight: 900;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  padding: 4px 14px;
  border-radius: 99px;
  box-shadow: 0 3px 0 var(--ink);
  white-space: nowrap;
  max-width: 94vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hint-badge {
  display: inline-block;
  padding: 1px 7px;
  margin-right: 5px;
  border-radius: 99px;
  background: #ff4769;
  border: 2px solid var(--ink);
  color: #fff;
  font-weight: 900;
  font-size: 10px;
}
.hint-touch { display: none; }
.hint b { color: #d90429; }
.hint kbd {
  display: inline-block;
  padding: 0 5px;
  margin: 0 1px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  font-size: 10px;
  color: var(--ink);
  background: #ffe680;
  font-weight: 900;
}

/* ===========================================================
 * 6. 覆盖层弹窗 (《不服来通关》卡通木框羊皮卷风格)
 * =========================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  background: rgba(20, 36, 18, 0.56);
  backdrop-filter: blur(6px);
  padding: 16px;
}
.overlay.show { display: grid; animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.ov-box {
  position: relative;
  width: min(475px, 100%);
  background: var(--cream);
  border: 4.5px solid var(--ink);
  border-radius: 28px;
  padding: 22px 20px;
  text-align: center;
  max-height: calc(100dvh - 30px);
  overflow-y: auto;
  touch-action: pan-y;
  color: var(--ink);
  box-shadow:
    0 10px 0 var(--ink),
    0 24px 60px rgba(0, 0, 0, 0.45);
  animation: pop .25s cubic-bezier(.2, 1.2, .3, 1) both;
}
@keyframes pop {
  from { opacity: 0; transform: scale(.92) translateY(10px); }
  to { opacity: 1; transform: none; }
}

.ov-logo {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  background: #ffe066;
  border: 2.5px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  font-size: 11px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 8px;
}

.ov-icon { font-size: 42px; margin-bottom: 6px; line-height: 1; }

.ov-box h2 {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 6px;
  color: #ffd038;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  filter: drop-shadow(0 3px 0 var(--ink));
}
.ov-sub {
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.55;
  margin-bottom: 12px;
}
.ov-sub b { color: #d90429; font-size: 14px; font-weight: 900; }

.ov-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.ov-stats div {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 9px;
  box-shadow: 0 3px 0 var(--ink);
}
.ov-stats b {
  display: block;
  font-size: 22px;
  font-weight: 900;
  color: #d90429;
}
.ov-stats span { font-size: 11px; color: var(--ink-soft); font-weight: 900; }

/* 弹窗内嵌 1~10 关快速选关矩阵 */
.ov-level-bar {
  margin-bottom: 12px;
  text-align: left;
  background: #fff3d1;
  border: 3px solid var(--ink);
  border-radius: 15px;
  padding: 9px 11px;
  box-shadow: 0 3px 0 var(--ink);
}
.ov-level-bar-title {
  font-size: 11.5px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ov-level-bar-title small {
  color: #d90429;
  font-weight: 900;
}
.ov-level-chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.ov-lv-chip {
  height: 32px;
  border-radius: 9px;
  border: 2.5px solid var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  cursor: pointer;
}
.ov-lv-chip.active {
  background: linear-gradient(180deg, #ff708d 0%, #e62e56 100%);
  color: #fff;
}
.ov-lv-chip.done:not(.active) {
  background: #b8f294;
  color: var(--ink);
}

.ov-rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.rule {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 6px 9px;
  text-align: left;
  box-shadow: 0 2px 0 var(--ink);
}
.rk {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  background: #ffe066;
  border: 2px solid var(--ink);
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 900;
}
.rv { font-size: 11.5px; color: var(--ink); font-weight: 800; }
.rv em { font-style: normal; color: #d90429; font-weight: 900; }

.ov-note {
  font-size: 11.5px;
  font-weight: 900;
  color: var(--ink);
  background: #ffe8a3;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 7px 10px;
  margin-bottom: 9px;
  line-height: 1.55;
}
.ov-power-guide {
  font-size: 11px;
  font-weight: 900;
  line-height: 1.55;
  color: var(--ink);
  background: #e6f9d5;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 12px;
  text-align: left;
}

.ov-btn {
  width: 100%;
  height: 46px;
  border-radius: 15px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  background: #fff;
  border: 3.5px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  margin-bottom: 8px;
  transition: transform .12s;
}
.ov-btn:hover { transform: translateY(-2px); }
.ov-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.ov-btn.primary {
  color: var(--ink);
  background: linear-gradient(180deg, #fff58c 0%, #ffc82c 60%, #f08c11 100%);
}
.ov-tip { font-size: 11px; color: var(--ink-soft); font-weight: 800; margin-top: 2px; }

/* ===========================================================
 * 6.5 开局「3 · 2 · 1 · 开始！」倒计时遮罩层
 * =========================================================== */
.countdown-mask {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: none;
  place-items: center;
  background: rgba(20, 36, 18, 0.42);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.countdown-mask.show { display: grid; animation: fadeIn .16s ease; }

.cd-ring {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 46px 20px;
  background: var(--cream);
  border: 5px solid var(--ink);
  border-radius: 34px;
  box-shadow: 0 10px 0 var(--ink), 0 22px 50px rgba(0, 0, 0, 0.45);
  animation: cdPop .28s cubic-bezier(.2, 1.3, .3, 1) both;
}
@keyframes cdPop {
  from { opacity: 0; transform: scale(.7) rotate(-6deg); }
  to { opacity: 1; transform: none; }
}

.cd-num {
  font-size: clamp(72px, 16vh, 138px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffd038;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  filter: drop-shadow(0 7px 0 var(--ink));
}
.cd-num.go {
  color: #fff159;
  font-size: clamp(56px, 12vh, 108px);
  padding: 6px 10px 0;
}
.cd-num.pulse { animation: cdPulse .42s cubic-bezier(.2, 1.4, .3, 1); }
@keyframes cdPulse {
  0% { transform: scale(.55); opacity: .2; }
  55% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.cd-tip {
  font-size: clamp(13px, 2.1vh, 17px);
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
}

/* ===========================================================
 * 7. 移动端与横竖屏自适应
 * =========================================================== */
.dpad { display: none; }
/* 手机上全靠滑动操作，方向键不再占用屏幕空间（DOM 保留，桌面触屏仍可兜底启用） */
body.touch .dpad {
  display: none;
  position: fixed;
  z-index: 25;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(3, 42px);
  gap: 4px;
}
.dpad button {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 12px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}
.dpad button:active {
  background: #ffd038;
  transform: translateY(2px);
}
.dpad .empty { visibility: hidden; }
body.touch .hint { display: none; }
/* 手机端只留一句滑动提示，替代原来的上下左右方向键 */
body.touch .hint-touch { display: block; }
body.touch .hud { padding-top: calc(10px + env(safe-area-inset-top)); }
/* 手机端隐藏截图中标出的两块说明区，给棋盘让出完整高度 */
body.touch .mission-pod,
body.touch .play-guide { display: none; }
body.touch .boost-btn {
  width: 82px;
  height: 60px;
}

@media (max-width: 680px) {
  /* 小屏设备固定显示反向滑动提示，避免触屏能力检测差异导致提示消失 */
  .hint-touch { display: block; }
  .hint-touch {
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: max-content;
    max-width: calc(100vw - 20px);
    white-space: normal;
    text-align: center;
    line-height: 1.35;
    font-size: 10px;
    padding: 4px 9px;
  }
  /* 手机竖屏隐藏非核心说明区，但保留顶部核心数据和独立规则入口 */
  .mission-pod,
  .play-guide { display: none; }
  .hud {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "brand stats" "actions actions";
    align-items: center;
    padding: 8px 8px 0;
    gap: 5px 6px;
  }
  .brand { grid-area: brand; padding: 3px; border-radius: 12px; }
  .brand-txt { display: none; }
  .brand .logo { width: 32px; height: 32px; }
  .hud-stats { grid-area: stats; justify-content: flex-start; gap: 4px; min-width: 0; }
  .pill { min-width: 58px; height: 38px; padding: 0 6px; border-radius: 11px; border-width: 2.5px; }
  .pill b { font-size: 13px; }
  .pill-val small { font-size: 8.5px; }
  .pill-sub { font-size: 8px; margin-top: 1px; }
  .hud-actions {
    grid-area: actions;
    justify-content: flex-end;
    gap: 5px;
    min-height: 38px;
    padding-right: 2px;
  }
  .icon-btn { width: 36px; height: 34px; border-radius: 10px; font-size: 12px; border-width: 2.5px; }
  .level-quick-btn { width: 48px; font-size: 10.5px; }
  .speed-btn { width: 42px; font-size: 10.5px; }
  .help-btn { width: 36px; font-size: 17px; }
  .mission-pod { top: 52px; gap: 4px; }
  .progress-wrap { padding: 3px 10px; border-width: 2.5px; }
  .progress-label { display: none; }
  .level-info { padding: 4px 8px; justify-content: center; text-align: center; gap: 3px; border-width: 2.5px; }
  .level-head { justify-content: center; gap: 5px; }
  .level-info strong { font-size: 11.5px; }
  .level-info p { font-size: 10px; }
  .effects { justify-content: center; gap: 3px; }
  .effects span { font-size: 9px; padding: 1px 5px; }
  .lp-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) and (orientation: landscape) {
  .hud {
    grid-template-areas: "brand stats actions";
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding-top: calc(6px + env(safe-area-inset-top));
  }
  .hud-actions { justify-content: flex-end; padding: 0; }
}
