/* ============================================================
   泡泡奇兵 · 水境大冒险
   原创卡通 UI / 无需外部资源
   ============================================================ */

:root {
  --ink: #123b4b;
  --ink-soft: #4a7180;
  --cream: #fffdf4;
  --aqua: #3fdcd6;
  --aqua-deep: #0e9aa9;
  --aqua-dark: #0b6d7f;
  --sun: #ffd45c;
  --sun-deep: #e39a24;
  --coral: #ff7d72;
  --purple: #7d6bff;
  --line: #cfe9ee;
  --panel-w: 660px;
  --hud-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  color: #eafcff;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  background:
    radial-gradient(ellipse at 12% -5%, rgba(34, 157, 173, .55) 0%, transparent 52%),
    radial-gradient(ellipse at 92% 8%, rgba(52, 96, 190, .45) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 112%, rgba(20, 111, 131, .6) 0%, transparent 62%),
    linear-gradient(160deg, #071f2d 0%, #082b3e 48%, #061c2b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(146, 245, 255, .09) 1px, transparent 1.6px);
  background-size: 26px 26px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, .85), transparent 70%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, .85), transparent 70%);
  z-index: 0;
}

[hidden] { display: none !important; }

button { font-family: inherit; }

/* ---------- 环境装饰 ---------- */
.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.amb { position: absolute; display: block; }

.bubble {
  border-radius: 50%;
  border: 1px solid rgba(174, 255, 251, .22);
  background: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .26), rgba(90, 226, 255, .05) 52%, rgba(20, 70, 120, .02) 70%);
  box-shadow: inset -8px -10px 24px rgba(5, 40, 70, .22), 0 0 30px rgba(75, 220, 240, .08);
  animation: drift 13s ease-in-out infinite;
}

.ab1 { width: 150px; height: 150px; left: 3%; top: 14%; animation-duration: 16s; }
.ab2 { width: 54px; height: 54px; left: 9%; top: 68%; animation-duration: 11s; animation-delay: -3s; }
.ab3 { width: 210px; height: 210px; right: 1%; top: 22%; animation-duration: 19s; animation-delay: -6s; }
.ab4 { width: 74px; height: 74px; right: 12%; top: 70%; animation-duration: 12s; animation-delay: -2s; }
.ab5 { width: 32px; height: 32px; left: 22%; top: 36%; animation-duration: 9s; animation-delay: -5s; }
.ab6 { width: 110px; height: 110px; right: 20%; top: 4%; animation-duration: 15s; animation-delay: -8s; }

.glow {
  border-radius: 50%;
  filter: blur(70px);
  opacity: .5;
}

.ag1 { width: 360px; height: 360px; left: -120px; bottom: -110px; background: rgba(19, 170, 180, .35); }
.ag2 { width: 300px; height: 300px; right: -90px; top: -80px; background: rgba(75, 102, 220, .3); }

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  33% { transform: translate3d(10px, -26px, 0) scale(1.04); }
  66% { transform: translate3d(-8px, 14px, 0) scale(.97); }
}

/* ---------- 页面骨架 ---------- */
.game-shell {
  position: relative;
  z-index: 2;
  width: min(94vw, 940px, calc((100vh - 176px) * 1.15385));
  width: min(94vw, 940px, calc((100svh - 176px) * 1.15385));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  user-select: none;
}

.brand-mark {
  position: relative;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, #ffffff 0%, #b6fff9 14%, #46e4de 42%, #1599b1 76%, #0b607e 100%);
  box-shadow: inset -5px -6px 10px rgba(4, 55, 90, .35), 0 0 18px rgba(73, 231, 229, .45);
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 5px;
  width: 8px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  transform: rotate(-28deg);
  filter: blur(.3px);
}

.brand-mark i {
  position: absolute;
  right: -3px;
  top: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #8ef7ec 45%, #22b3bd);
  border: 1px solid rgba(255, 255, 255, .5);
}

.brand-text {
  display: flex;
  flex-direction: column;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 1.5px;
  line-height: 1.05;
  color: #eaffff;
  text-shadow: 0 2px 8px rgba(0, 30, 45, .5);
}

.brand-text small {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2.4px;
  color: rgba(151, 226, 236, .62);
  margin-top: 3px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-btn {
  width: 33px;
  height: 33px;
  border-radius: 11px;
  border: 1px solid rgba(172, 246, 255, .2);
  background: rgba(9, 45, 63, .55);
  color: #c9f8ff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn .qmark { font-weight: 900; font-size: 16px; line-height: 1; }
.icon-btn:hover { background: rgba(24, 91, 116, .8); border-color: rgba(130, 244, 255, .45); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(1px) scale(.96); }
.icon-btn.is-off .sound-wave { display: none; }
.icon-btn:not(.is-off) .sound-slash { display: none; }
.icon-btn.is-disabled { opacity: .32; pointer-events: none; }

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: var(--hud-h);
  padding: 8px 14px;
  border-radius: 15px;
  border: 1px solid rgba(154, 236, 250, .18);
  background: linear-gradient(180deg, rgba(12, 53, 72, .76), rgba(7, 37, 53, .62));
  box-shadow: 0 10px 26px -14px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: opacity .3s ease, filter .3s ease;
}

.hud.is-dim { opacity: .45; filter: saturate(.5); }

.hud-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 0 13px;
  border-right: 1px solid rgba(145, 219, 236, .13);
  min-width: 0;
}

.hud-block:first-child { padding-left: 1px; }
.hud-block:last-child { border-right: 0; padding-right: 1px; }

.hud-label {
  font-size: 9px;
  letter-spacing: 2.2px;
  color: rgba(152, 214, 226, .72);
  font-weight: 700;
  white-space: nowrap;
}

.hud-stage-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.hud-stage-main b {
  font-size: 14px;
  color: #f5ffff;
  letter-spacing: .5px;
}

.hud-stage-main span {
  font-size: 11px;
  color: rgba(160, 226, 236, .75);
}

.hud-stats {
  flex: 1;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
}

.hearts {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 4px;
}

.heart {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  filter: drop-shadow(0 2px 3px rgba(117, 16, 30, .35));
}

.heart svg { width: 100%; height: 100%; display: block; }
.heart.is-empty { opacity: .3; filter: grayscale(1); }

.hud-stat {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 25px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .065);
  border: 1px solid rgba(185, 245, 255, .08);
  color: #eaffff;
  font-size: 12px;
  font-weight: 800;
}

.hud-stat svg { width: 16px; height: 16px; display: block; }
.hud-stat b { font-size: 12px; min-width: 8px; text-align: center; }

.hud-time b,
.hud-score b {
  font-size: 17px;
  line-height: 1.05;
  letter-spacing: .4px;
  font-variant-numeric: tabular-nums;
  color: #f6ffff;
}

.hud-time { min-width: 90px; }
.hud-score { min-width: 82px; }
.hud-score b { color: var(--sun); text-shadow: 0 0 14px rgba(255, 212, 92, .25); }

.hud-time.is-danger b {
  color: #ff8c86;
  text-shadow: 0 0 16px rgba(255, 96, 90, .45);
  animation: dangerPulse .85s ease-in-out infinite;
}

@keyframes dangerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .62; transform: scale(1.04); }
}

/* ---------- 游戏画面 ---------- */
.stage-wrap {
  position: relative;
  width: 100%;
  padding: 5px;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(105, 245, 239, .9), rgba(27, 103, 139, .55) 28%, rgba(65, 66, 145, .55) 72%, rgba(148, 115, 255, .65));
  box-shadow:
    0 30px 60px -24px rgba(0, 0, 0, .85),
    0 0 0 1px rgba(255, 255, 255, .16),
    0 0 42px -12px rgba(46, 220, 218, .38),
    inset 0 0 22px rgba(255, 255, 255, .18);
}

.stage-wrap::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 26px;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .5), transparent 28%, transparent 70%, rgba(255, 255, 255, .24));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 1px;
  opacity: .45;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 720 / 624;
  border-radius: 19px;
  background: #082a38;
  box-shadow: inset 0 0 60px rgba(2, 20, 32, .55);
  touch-action: none;
  outline: none;
}

.glass-line {
  position: absolute;
  z-index: 3;
  top: 11px;
  left: 28px;
  right: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .28), transparent);
  pointer-events: none;
}

/* ---------- 弹层 ---------- */
.overlay {
  position: absolute;
  inset: 5px;
  z-index: 30;
  border-radius: 19px;
  padding: clamp(10px, 3vw, 28px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(28, 106, 130, .36), transparent 60%),
    rgba(3, 19, 31, .62);
  -webkit-backdrop-filter: blur(6px) saturate(.85);
  backdrop-filter: blur(6px) saturate(.85);
  animation: fadeIn .18s ease-out;
}

.overlay::-webkit-scrollbar { width: 8px; }
.overlay::-webkit-scrollbar-thumb { background: rgba(137, 228, 240, .25); border-radius: 999px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  position: relative;
  width: min(var(--panel-w), 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(18px, 3.4vw, 32px);
  color: var(--ink);
  text-align: center;
  border-radius: 26px;
  border: 3px solid rgba(255, 255, 255, .95);
  background:
    radial-gradient(circle at 9% 2%, rgba(111, 240, 229, .2), transparent 26%),
    radial-gradient(circle at 96% 4%, rgba(255, 210, 107, .16), transparent 24%),
    linear-gradient(180deg, #fffdf5 0%, #f3fdff 62%, #e9f9fb 100%);
  box-shadow:
    0 28px 60px rgba(0, 0, 0, .42),
    inset 0 -7px 0 rgba(33, 121, 139, .08),
    inset 0 2px 0 rgba(255, 255, 255, .95);
  animation: panelPop .3s cubic-bezier(.2, 1.25, .4, 1);
}

.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: rgba(15, 122, 145, .22); border-radius: 999px; }

@keyframes panelPop {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel > * { position: relative; z-index: 2; }

.panel--title { --panel-w: 680px; }
.panel--stage { --panel-w: 580px; }
.panel--result { --panel-w: 560px; }
.panel--help { --panel-w: 640px; text-align: left; }

/* 标题页 */
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid #b8eeeb;
  background: rgba(219, 252, 250, .8);
  color: #0d7d88;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2.1px;
  text-transform: uppercase;
}

.kicker::before,
.kicker::after {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #2bc1c2;
}

.logo-wrap { position: relative; margin: 15px 0 8px; }

.logo {
  position: relative;
  z-index: 2;
  margin: 0;
  font-size: clamp(48px, 9.2vw, 80px);
  font-weight: 900;
  line-height: .98;
  letter-spacing: 1px;
  color: #e9ffff;
  -webkit-text-stroke: 2.5px #0c4a63;
  paint-order: stroke fill;
  text-shadow:
    0 4px 0 #39c6cf,
    0 8px 0 #0b7c94,
    0 14px 20px rgba(2, 45, 63, .28);
  transform: rotate(-2deg);
  animation: logoBob 4.2s ease-in-out infinite;
}

.logo span { display: inline-block; }
.logo span:nth-child(1) { transform: rotate(-3deg) translateY(-2px); }
.logo span:nth-child(2) { transform: rotate(1deg) translateY(2px); color: #c8fbff; }
.logo span:nth-child(3) { transform: rotate(-1deg) translateY(-3px); color: #ffe270; }
.logo span:nth-child(4) { transform: rotate(2deg) translateY(2px); color: #ff9f8f; }

@keyframes logoBob {
  0%, 100% { transform: rotate(-2deg) translateY(0); }
  50% { transform: rotate(-1deg) translateY(-6px); }
}

.logo-sub {
  position: relative;
  z-index: 2;
  display: inline-block;
  margin-top: 5px;
  padding: 6px 23px 7px;
  border-radius: 9px;
  background: linear-gradient(180deg, #155f78, #0b3d55);
  color: #eaffff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 7px;
  text-indent: 7px;
  transform: rotate(-2deg);
  box-shadow: 0 4px 0 #062b3d, 0 8px 18px rgba(5, 44, 62, .22);
}

.logo-wrap::before,
.logo-wrap::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .9), rgba(80, 230, 228, .38) 40%, rgba(24, 157, 179, .08) 72%);
  border: 1px solid rgba(38, 179, 191, .22);
}

.logo-wrap::before { width: 56px; height: 56px; left: 7%; top: -12px; animation: drift 8s ease-in-out infinite; }
.logo-wrap::after { width: 28px; height: 28px; right: 9%; bottom: 0; animation: drift 6s ease-in-out infinite reverse; }

.tagline {
  max-width: 430px;
  margin: 12px auto 15px;
  color: #527481;
  font-size: 13px;
  line-height: 1.75;
  font-weight: 500;
}

.stage-picks {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 0 auto 16px;
  flex-wrap: wrap;
}

.stage-pick {
  width: 65px;
  min-height: 48px;
  padding: 5px 4px 4px;
  border-radius: 12px;
  border: 2px solid #d3e9ed;
  background: linear-gradient(180deg, #ffffff, #f3fbfc);
  color: #275767;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  position: relative;
  box-shadow: 0 3px 0 #dceef1;
}

.stage-pick b { font-size: 16px; line-height: 1; font-weight: 900; }
.stage-pick small { font-size: 8px; color: #6f939e; letter-spacing: .4px; white-space: nowrap; }
.stage-pick:hover:not(:disabled) { transform: translateY(-2px); border-color: #8ee0e2; }
.stage-pick.is-active {
  border-color: #13a5b3;
  color: #ffffff;
  background: linear-gradient(180deg, #58e5df, #1cb5c4);
  box-shadow: 0 4px 0 #0a7d90, 0 8px 16px rgba(13, 144, 161, .25);
}
.stage-pick.is-active small { color: rgba(255, 255, 255, .85); }
.stage-pick:disabled { cursor: not-allowed; opacity: .52; filter: grayscale(.4); }
.stage-pick:disabled::after {
  content: "🔒";
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 8px;
  filter: grayscale(1);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 30px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: .5px;
  color: #ffffff;
  cursor: pointer;
  background: linear-gradient(180deg, #51e5df, #1cb4c4);
  box-shadow: 0 6px 0 #0a7c90, 0 12px 20px rgba(9, 133, 150, .25);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  touch-action: manipulation;
  user-select: none;
}

.btn:hover { filter: brightness(1.05) saturate(1.03); transform: translateY(-1px); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0a7c90, 0 5px 10px rgba(9, 133, 150, .2); }
.btn:focus-visible { outline: 3px solid #0c697d; outline-offset: 3px; }

.btn--hero {
  min-width: 235px;
  padding: 15px 42px;
  font-size: 20px;
  color: #573900;
  background: linear-gradient(180deg, #ffe27b, #ffb93e);
  box-shadow: 0 7px 0 #cf7c17, 0 15px 26px rgba(213, 128, 17, .32), inset 0 2px 0 rgba(255, 255, 255, .65);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.btn--hero:active { box-shadow: 0 2px 0 #cf7c17, 0 6px 12px rgba(213, 128, 17, .25); }
.btn--hero .play-tri { font-size: 15px; margin-right: 6px; display: inline-block; transform: translateY(-1px); }

.btn--ghost {
  background: linear-gradient(180deg, #f7fdfe, #e4f3f5);
  color: #245b6b;
  box-shadow: 0 4px 0 #bfd9de, 0 8px 14px rgba(30, 89, 101, .1);
  border: 1px solid #d4e9ed;
}
.btn--ghost:active { box-shadow: 0 1px 0 #bfd9de; }

.btn--sm { font-size: 13px; padding: 9px 20px; }

.btn-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.title-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  color: #b4ced4;
  font-size: 12px;
}

.link-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px;
  color: #55818d;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(85, 129, 141, .28);
  text-underline-offset: 3px;
}
.link-btn:hover { color: #0b7f91; }

.record {
  margin: 15px 0 0;
  color: #7f9ca4;
  font-size: 11px;
  letter-spacing: .4px;
}
.record b { color: #d08a14; font-size: 13px; }

.tiny {
  margin: 7px 0 0;
  font-size: 10px;
  color: #9eb5bb;
}

/* 关卡介绍 */
.stage-banner {
  position: relative;
  overflow: hidden;
  padding: 18px 20px 17px;
  border-radius: 18px;
  color: #ffffff;
  text-align: left;
  background:
    radial-gradient(circle at 85% 5%, rgba(255, 255, 255, .25), transparent 30%),
    linear-gradient(120deg, var(--accent, #18a9b7), var(--accent2, #0e607a));
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .13), 0 10px 22px -12px rgba(4, 65, 85, .5);
}

.stage-banner::after {
  content: "";
  position: absolute;
  right: -32px;
  bottom: -54px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 22px solid rgba(255, 255, 255, .09);
  box-shadow: 0 0 0 18px rgba(255, 255, 255, .05);
}

.stage-banner .stage-no {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .25);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 2.4px;
}

.stage-banner h2 {
  position: relative;
  z-index: 2;
  margin: 7px 0 4px;
  font-size: clamp(25px, 4.6vw, 34px);
  line-height: 1.15;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 rgba(0, 40, 55, .25), 0 5px 14px rgba(0, 30, 40, .2);
}

.stage-banner p {
  position: relative;
  z-index: 2;
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  color: rgba(240, 255, 255, .83);
  max-width: 430px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 13px 0 0;
}

.info-card {
  padding: 9px 8px;
  border-radius: 12px;
  border: 1px solid #d9edf0;
  background: #f7fdfe;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.info-card span { font-size: 9px; letter-spacing: 1.4px; color: #83a1a8; font-weight: 800; }
.info-card b { font-size: 13px; color: #1d5262; }
.info-card .mini-hearts { color: #ff6f78; letter-spacing: 1px; font-size: 14px; }

.enemy-list {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin: 13px 0 0;
}

.enemy-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  background: #eef9fb;
  border: 1px solid #d8edf1;
  color: #42707d;
  font-size: 10px;
  font-weight: 800;
}

.enemy-chip i {
  width: 17px;
  height: 17px;
  border-radius: 50% 50% 46% 46%;
  background: var(--enemy-color, #4fc3f7);
  box-shadow: inset -2px -3px 0 rgba(0, 0, 0, .12), inset 2px 2px 0 rgba(255, 255, 255, .35);
  display: block;
  position: relative;
}
.enemy-chip i::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #123444;
  box-shadow: 6px 0 0 #123444;
}
.enemy-chip b { color: #1f5361; font-size: 10px; }

.tip-line {
  margin: 13px auto 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff9e8;
  border: 1px dashed #f1d895;
  color: #896824;
  font-size: 11px;
  line-height: 1.6;
  text-align: left;
}

.stage-actions { display: flex; justify-content: center; margin-top: 16px; }

/* 结算 */
.result-kicker { margin-bottom: 2px; }

.clear-stars {
  margin: 10px 0 0;
  font-size: clamp(34px, 7vw, 48px);
  letter-spacing: 8px;
  line-height: 1;
  color: #ffc93c;
  text-shadow: 0 3px 0 #d18a15, 0 8px 18px rgba(218, 156, 26, .3);
}

.clear-stars .off {
  color: #dcebed;
  text-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 2px 0 #c9dadd;
}

.result-title {
  margin: 7px 0 0;
  font-size: clamp(24px, 4.5vw, 32px);
  letter-spacing: 1px;
  color: #124a5b;
}

.result-sub {
  margin: 6px 0 0;
  color: #71909a;
  font-size: 12px;
  line-height: 1.6;
}

.result-table {
  margin: 15px auto 0;
  width: 100%;
  border-radius: 14px;
  border: 1px solid #d9edf0;
  background: #f7fdfe;
  overflow: hidden;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 15px;
  font-size: 12px;
  color: #688892;
  border-bottom: 1px dashed #e0eff2;
}
.result-row:last-child { border-bottom: 0; }
.result-row b { color: #1b5362; font-size: 13px; font-variant-numeric: tabular-nums; }
.result-row.is-total {
  background: #e8fbfa;
  padding-top: 10px;
  padding-bottom: 10px;
  color: #0d7684;
  font-weight: 800;
}
.result-row.is-total b { font-size: 20px; color: #e2951e; }

.result-actions { display: flex; flex-direction: column; align-items: center; gap: 9px; margin-top: 16px; }
.result-actions .btn { min-width: 210px; }

.big-mark {
  width: 68px;
  height: 68px;
  margin: 0 auto 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 34px;
  background: radial-gradient(circle at 35% 28%, #ffffff, #d8fbff 45%, #a8e9f1);
  border: 2px solid #ffffff;
  box-shadow: 0 8px 18px rgba(19, 107, 126, .18), inset 0 -5px 0 rgba(26, 130, 150, .1);
}
.big-mark.lose { background: radial-gradient(circle at 35% 28%, #ffffff, #ffe3e0 45%, #ffc1ba); }

/* 暂停 / 帮助 */
.pause-copy { margin: 8px 0 17px; color: #6e909a; font-size: 13px; line-height: 1.7; }
.panel--help h2 { margin: 0 0 4px; font-size: 26px; color: #123f50; }
.panel--help .help-kicker { margin-bottom: 10px; }
.help-section { margin-top: 14px; }
.help-section h3 {
  margin: 0 0 7px;
  font-size: 12px;
  letter-spacing: 1.6px;
  color: #0c7d8d;
  display: flex;
  align-items: center;
  gap: 7px;
}
.help-section h3::before { content: ""; width: 14px; height: 3px; border-radius: 999px; background: #38cfd0; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.help-card {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #d9edf1;
  border-radius: 10px;
  background: #f8fdfe;
  font-size: 11px;
  color: #547985;
  line-height: 1.45;
}
.help-card b { display: block; color: #1b4f5e; font-size: 12px; }
.help-card .hk {
  flex: none;
  min-width: 38px;
  height: 30px;
  padding: 0 6px;
  border-radius: 7px;
  background: #ffffff;
  border: 1px solid #cfe2e7;
  box-shadow: 0 2px 0 #dbe9ec;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
  color: #35616d;
  white-space: nowrap;
}
.item-dot {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .08);
}
.help-foot { margin-top: 16px; display: flex; justify-content: center; }
.help-note { margin-top: 10px; font-size: 10.5px; color: #8aa5ac; line-height: 1.65; }

/* 失败 / 胜利 */
.fail-copy { color: #7b929a; font-size: 12.5px; margin: 6px 0 0; line-height: 1.7; }
.boss-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 9px;
  border-radius: 6px;
  background: #fff1e4;
  border: 1px solid #ffd5b0;
  color: #b26818;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.6px;
}

.victory-panel {
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 220, 103, .34), transparent 30%),
    radial-gradient(circle at 90% 6%, rgba(89, 231, 225, .3), transparent 28%),
    linear-gradient(180deg, #fffdf3, #f1feff 70%, #e6fbfa);
}
.victory-crown { font-size: 48px; line-height: 1; margin-bottom: 2px; filter: drop-shadow(0 6px 8px rgba(192, 133, 12, .25)); }
.victory-panel .result-title { color: #0d6c7c; }

.confetti-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.confetti {
  position: absolute;
  top: -18px;
  width: 7px;
  height: 12px;
  border-radius: 2px;
  opacity: .85;
  animation: confettiFall var(--dur, 3.6s) linear var(--delay, 0s) infinite;
}
@keyframes confettiFall {
  0% { transform: translate3d(0, -20px, 0) rotate(0deg); opacity: 0; }
  8% { opacity: .9; }
  100% { transform: translate3d(var(--drift, 20px), 560px, 0) rotate(620deg); opacity: .15; }
}

/* ---------- 提示条 ---------- */
.toast {
  position: absolute;
  z-index: 40;
  top: 15px;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(5, 31, 45, .88);
  border: 1px solid rgba(144, 236, 248, .26);
  color: #e9ffff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .3);
  max-width: 86%;
  text-align: center;
}

.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 触屏控制 ---------- */
.touch-controls { display: none; }

/* ---------- 页脚 ---------- */
.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
  color: rgba(188, 232, 240, .58);
  font-size: 10.5px;
  letter-spacing: .1px;
  min-height: 17px;
}

.foot kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(159, 220, 232, .24);
  background: rgba(10, 49, 65, .6);
  color: rgba(219, 249, 255, .82);
  font-family: inherit;
  font-size: 9.5px;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset;
}

.foot .dot { opacity: .35; }
.foot-mobile { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  :root { --hud-h: 52px; }
  .game-shell { width: 95vw; gap: 6px; }
  .hud { padding: 7px 10px; border-radius: 13px; }
  .hud-block { padding: 0 9px; }
  .hud-stage-main { gap: 5px; }
  .hud-stage-main b { font-size: 12px; }
  .hud-stage-main span { display: none; }
  .hud-stats { gap: 5px; padding: 0 8px; }
  .hud-stat { padding: 0 6px; height: 23px; gap: 2px; }
  .hud-stat svg { width: 14px; height: 14px; }
  .hud-stat b { font-size: 11px; }
  .heart { width: 15px; height: 15px; }
  .hud-time { min-width: 72px; }
  .hud-time b, .hud-score b { font-size: 14px; }
  .hud-score { min-width: 66px; }
  .hud-label { font-size: 8px; letter-spacing: 1.3px; }
  .topbar { min-height: 30px; }
  .brand-mark { width: 25px; height: 25px; }
  .brand-text { font-size: 13px; }
  .brand-text small { font-size: 7px; }
  .icon-btn { width: 30px; height: 30px; border-radius: 9px; }
  .overlay { padding: 8px; }
  .panel { border-radius: 20px; padding: 17px 14px 18px; }
  .logo { -webkit-text-stroke-width: 2px; }
  .tagline { font-size: 12px; margin: 9px auto 12px; }
  .stage-pick { width: 56px; min-height: 44px; }
  .stage-pick b { font-size: 14px; }
  .stage-pick small { font-size: 7px; }
  .btn { font-size: 15px; padding: 11px 24px; }
  .btn--hero { min-width: 200px; padding: 13px 32px; font-size: 18px; }
  .info-grid { gap: 5px; }
  .info-card { padding: 7px 4px; }
  .info-card b { font-size: 11px; }
  .enemy-list { gap: 5px; }
  .help-grid { grid-template-columns: 1fr; }
  .result-row { padding: 7px 12px; font-size: 11px; }
  .result-actions .btn { min-width: 180px; }
  .foot { font-size: 9px; gap: 4px; }
  .foot kbd { font-size: 8.5px; padding: 0 4px; }
}

@media (max-width: 560px) {
  .game-shell { width: 96vw; }
  /* The title/help panels are taller than the 15:13 board on phones, so let
     dialogs use the full viewport instead of being clipped inside the stage. */
  .overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    padding: 10px 8px;
    border-radius: 0;
    background: rgba(3, 16, 27, .74);
  }
  .panel { max-height: calc(100svh - 20px); }
  .hud { flex-wrap: wrap; gap: 5px 0; }
  .hud-stage { flex: 1; order: 1; border-right: 0; min-width: 100px; }
  .hud-time { order: 2; border-right: 0; min-width: 68px; align-items: flex-end; text-align: right; }
  .hud-score { order: 3; min-width: 60px; align-items: flex-end; text-align: right; }
  .hud-stats {
    order: 4;
    flex-basis: 100%;
    justify-content: flex-start;
    border-right: 0;
    border-top: 1px solid rgba(145, 219, 236, .12);
    padding: 6px 0 0;
    margin-top: 1px;
  }
  .hud-label { font-size: 8px; }
  .hud-stage-main b { font-size: 12px; }
  .hud-time b, .hud-score b { font-size: 15px; }
  .hud { min-height: 78px; padding: 6px 10px 7px; }
  .stage-picks { gap: 5px; }
  .stage-pick { width: 52px; }
  .logo-wrap::before { left: 1%; width: 40px; height: 40px; }
  .logo-wrap::after { right: 1%; width: 22px; height: 22px; }
  .title-links { margin-top: 11px; }
  .record { margin-top: 11px; }
  .foot { display: none; }
  .topbar { min-height: 28px; }
  .overlay { padding: 6px; }
  .panel { padding: 15px 12px 16px; border-width: 2px; }
  .big-mark { width: 58px; height: 58px; font-size: 28px; }
  .stage-banner { padding: 13px 14px; }
  .stage-banner h2 { font-size: 24px; }
  .btn-row { gap: 8px; }
}

/* ---------- 星火之章：角色、地图、仓库 ---------- */
.hud { position: relative; overflow: hidden; }
.hud-lv {
  font-style: normal;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .4px;
  padding: 2px 6px;
  border-radius: 999px;
  color: #ffe8a6;
  background: rgba(255, 211, 110, .12);
  border: 1px solid rgba(255, 211, 110, .22);
  white-space: nowrap;
}

.xp-ribbon {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 3px;
  height: 2px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(150, 215, 230, .13);
  pointer-events: none;
}
.xp-ribbon i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5ce1d4, #ffe27b);
  box-shadow: 0 0 8px rgba(255, 226, 123, .55);
  transition: width .35s ease;
}

.hp-mini { display: flex; flex-direction: column; gap: 3px; min-width: 98px; }
.hp-row { display: flex; align-items: baseline; justify-content: space-between; gap: 7px; }
.hp-name { color: #ffe3a3; font-size: 11px; font-weight: 900; letter-spacing: .5px; }
.hp-num { color: #f6ffff; font-size: 11px; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hp-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(4, 17, 28, .7);
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .4);
}
.hp-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff9b85, #ffd36e);
  box-shadow: 0 0 9px rgba(255, 164, 115, .4);
  transition: width .2s ease, background .2s ease;
}
.hp-mini.is-low .hp-fill { background: linear-gradient(90deg, #ff5c63, #ff9b85); animation: hpWarn .8s ease-in-out infinite; }
@keyframes hpWarn { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.hero-picks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 530px;
  margin: 4px auto 14px;
}
.hero-pick {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 7px 10px 7px 7px;
  border-radius: 15px;
  border: 2px solid #d9eaee;
  background: linear-gradient(180deg, #ffffff, #f2fbfc);
  color: #244f5d;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 0 #dfecef;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.hero-pick:hover { transform: translateY(-2px); border-color: #9bdfe2; }
.hero-pick.is-active {
  border-color: var(--hero, #ffd36e);
  background: linear-gradient(135deg, #fffdf4, #effcff);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--hero, #ffd36e) 38%, #b7d6dc), 0 9px 18px rgba(17, 103, 118, .13);
}
.hero-portrait { width: 44px; height: 44px; flex: none; display: block; border-radius: 50%; box-shadow: 0 2px 7px rgba(7, 45, 58, .2); }
.hero-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hero-copy b { font-size: 14px; font-weight: 900; line-height: 1.15; letter-spacing: .4px; }
.hero-copy em { font-style: normal; font-size: 9px; font-weight: 800; color: #168b96; letter-spacing: 1.2px; }
.hero-copy small { font-size: 9px; color: #647f89; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-perk { margin-left: auto; align-self: stretch; display: flex; align-items: center; max-width: 74px; font-size: 8px; line-height: 1.3; font-weight: 700; color: #a26b20; text-align: right; }

.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; max-width: 560px; margin: 0 auto 14px; }
.map-card {
  appearance: none;
  position: relative;
  min-height: 76px;
  padding: 9px 11px 8px 15px;
  border-radius: 14px;
  border: 2px solid #d9eaee;
  background: linear-gradient(180deg, #ffffff, #f1fafb);
  color: #244f5d;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 3px 0 #dfecef;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.map-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--map, #3ed6c9);
}
.map-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--map, #8edfe3); box-shadow: 0 5px 0 #d4e7ea, 0 10px 20px rgba(19, 92, 106, .12); }
.map-card.is-locked { opacity: .5; filter: grayscale(.55); cursor: not-allowed; }
.map-card.is-cleared { background: linear-gradient(180deg, #fffef5, #f4fff8); border-color: #bfe6cf; }
.map-no { display: inline-block; font-size: 9px; font-weight: 900; letter-spacing: 1px; color: #138a96; margin-right: 5px; }
.map-name { font-size: 14px; font-weight: 900; color: #1d4d5b; }
.map-desc { display: block; margin-top: 3px; font-size: 9px; color: #6b8790; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.map-boss { font-size: 9px; font-weight: 800; color: #b07b32; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-stars { font-size: 11px; letter-spacing: 1px; color: #ffc94e; flex: none; }
.map-lock { font-size: 9px; color: #91a6ad; }

.story-sheet { text-align: left; }
.story-banner {
  padding: 18px 18px 16px;
  border-radius: 17px;
  color: #efffff;
  background:
    radial-gradient(circle at 84% 12%, rgba(255, 224, 150, .22), transparent 38%),
    linear-gradient(135deg, #123a55, #2a2352 54%, #5b2b56);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 10px 24px -12px rgba(18, 31, 56, .55);
}
.story-banner .kicker { color: #ffe8ad; border-color: rgba(255, 232, 173, .3); background: rgba(255, 232, 173, .07); }
.story-banner .kicker::before, .story-banner .kicker::after { background: #ffd36e; }
.story-banner h2 { margin: 10px 0 6px; font-size: 26px; line-height: 1.2; letter-spacing: 1px; color: #fff8e6; }
.story-banner .story-sub { margin: 0; font-size: 11px; line-height: 1.65; color: rgba(231, 246, 255, .72); }
.story-body { margin: 12px 0 0; color: #385a66; font-size: 12px; line-height: 1.8; }
.story-body p { margin: 0 0 7px; }
.story-body strong { color: #1b596b; }
.story-quote {
  margin: 11px 0 0;
  padding: 9px 12px;
  border-left: 3px solid #ffca5c;
  border-radius: 0 8px 8px 0;
  background: #fff8e7;
  color: #8a5d19;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.7;
}
.story-heroes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.story-heroes span { font-size: 9px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: #eef8f9; border: 1px solid #d8ecee; color: #39707c; }

.bag-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 4px 10px;
  border-radius: 13px;
  border: 1px solid rgba(145, 219, 236, .16);
  background: linear-gradient(180deg, rgba(11, 44, 62, .76), rgba(6, 29, 44, .62));
  box-shadow: 0 8px 22px -14px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #dffbff;
}
.bag-title { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 900; letter-spacing: 1.5px; color: #9fdae4; flex: none; }
.bag-title i { width: 13px; height: 12px; border-radius: 3px 3px 5px 5px; border: 1.5px solid #8ecfd8; background: linear-gradient(180deg, rgba(142, 207, 216, .18), rgba(142, 207, 216, .04)); position: relative; }
.bag-title i::before { content: ""; position: absolute; left: 2.5px; top: -4px; width: 5px; height: 4px; border: 1.5px solid #8ecfd8; border-bottom: 0; border-radius: 3px 3px 0 0; }
.bag-slots { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.bag-slot {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  min-width: 74px;
  padding: 0 7px;
  border-radius: 8px;
  border: 1px solid rgba(167, 230, 239, .2);
  background: rgba(255, 255, 255, .06);
  color: #eaffff;
  cursor: pointer;
  font: inherit;
  transition: background .12s ease, border-color .12s ease, transform .1s ease;
}
.bag-slot:hover:not(.is-empty) { background: rgba(92, 225, 212, .16); border-color: rgba(136, 242, 230, .55); transform: translateY(-1px); }
.bag-slot:active:not(.is-empty) { transform: translateY(1px); }
.bag-slot.is-empty { opacity: .38; cursor: default; }
.bag-glyph { width: 17px; height: 17px; border-radius: 50%; flex: none; background: radial-gradient(circle at 32% 28%, #fff, var(--item-color, #67e4d3) 48%, rgba(9, 77, 89, .8)); box-shadow: 0 0 8px color-mix(in srgb, var(--item-color, #67e4d3) 55%, transparent); }
.bag-slot[data-item="heal"] .bag-glyph { border-radius: 5px; background: linear-gradient(180deg, #ffbfc2, #ff6478); }
.bag-slot[data-item="bombUp"] .bag-glyph, .bag-slot[data-item="powerUp"] .bag-glyph, .bag-slot[data-item="speedUp"] .bag-glyph { border-radius: 50% 50% 45% 45%; }
.bag-name { font-size: 9px; font-weight: 800; white-space: nowrap; }
.bag-count { font-size: 9px; color: #ffe39a; font-weight: 900; margin-left: auto; }
.bag-key { font-size: 8px; color: rgba(178, 223, 232, .55); padding-left: 2px; }
.bag-hint { flex: none; font-size: 9px; color: rgba(160, 211, 222, .55); }
.bag-empty-note { font-size: 9px; color: rgba(160, 211, 222, .48); }

.enemy-chip.is-boss { border-color: #ffd98b; background: #fff8e3; color: #9a6617; }
.enemy-chip.is-boss i { box-shadow: 0 0 0 2px #ffe7b2, 0 0 9px color-mix(in srgb, var(--enemy-color, #ffd36e) 55%, transparent); }

@media (max-width: 720px) {
  .hero-perk { display: none; }
  .map-desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

@media (max-width: 560px) {
  .hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "stage time score" "stats stats stats";
    gap: 2px 0;
    padding: 6px 9px 8px;
  }
  .hud-stage { grid-area: stage; border-right: 0; padding-left: 1px; }
  .hud-time { grid-area: time; min-width: 0; padding: 0 8px; }
  .hud-score { grid-area: score; min-width: 0; padding: 0 0 0 8px; }
  .hud-stats {
    grid-area: stats;
    justify-content: flex-start;
    gap: 5px;
    padding: 5px 0 0;
    border-top: 1px solid rgba(145, 219, 236, .13);
  }
  .hud-stage-main { gap: 5px; }
  .hud-stage-main b { font-size: 15px; }
  .hud-stage-main span { font-size: 10px; max-width: 86px; overflow: hidden; text-overflow: ellipsis; }
  .hud-lv { font-size: 8px; padding: 1px 5px; }
  .hud-stat { height: 22px; padding: 0 5px 0 4px; gap: 2px; }
  .hud-stat svg { width: 13px; height: 13px; }
  .hud-stat b { font-size: 10px; }
  .hud-time b, .hud-score b { font-size: 15px; }
  .hp-mini { min-width: 82px; gap: 2px; }
  .hp-name { font-size: 10px; }
  .hp-num { font-size: 10px; }
  .hp-track { height: 6px; }
  .xp-ribbon { left: 9px; right: 9px; bottom: 3px; }

  .hero-picks { gap: 6px; margin-bottom: 10px; }
  .hero-pick { padding: 5px 7px 5px 5px; gap: 6px; border-radius: 12px; }
  .hero-portrait { width: 36px; height: 36px; }
  .hero-copy b { font-size: 12px; }
  .hero-copy em { font-size: 8px; letter-spacing: .6px; }
  .hero-copy small { font-size: 8px; }
  .map-grid { gap: 6px; }
  .map-card { min-height: 68px; padding: 7px 8px 7px 12px; }
  .map-name { font-size: 12px; }
  .map-desc { font-size: 8px; }
  .map-boss { font-size: 8px; }
  .story-banner { padding: 14px 13px 12px; }
  .story-banner h2 { font-size: 21px; }
  .story-body { font-size: 11px; line-height: 1.75; }
  .bag-bar { min-height: 36px; padding: 3px 7px; gap: 6px; }
  .bag-title { display: none; }
  .bag-slot { min-width: 58px; height: 28px; padding: 0 5px; gap: 3px; }
  .bag-glyph { width: 14px; height: 14px; }
  .bag-name { font-size: 8px; }
  .bag-count { font-size: 8px; }
  .bag-key, .bag-hint { display: none; }
}

@media (max-width: 560px) and (hover: none) and (pointer: coarse) {
  /* Reserve a console strip under the board so thumbs never hide the player. */
  .stage-wrap { padding-bottom: 114px; }
}

@media (hover: none) and (pointer: coarse) {
  .touch-controls {
    position: absolute;
    z-index: 20;
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .dpad {
    display: grid;
    grid-template-columns: repeat(3, 43px);
    grid-template-rows: repeat(2, 43px);
    grid-template-areas:
      ". up ."
      "left down right";
    gap: 5px;
    pointer-events: none;
  }

  .dbtn {
    pointer-events: auto;
    border: 1px solid rgba(210, 255, 255, .3);
    background: rgba(5, 38, 53, .42);
    color: rgba(235, 255, 255, .9);
    border-radius: 12px;
    font-size: 12px;
    display: grid;
    place-items: center;
    padding: 0;
    touch-action: none;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
  }

  .dbtn:active, .dbtn.is-pressed { background: rgba(53, 212, 210, .65); border-color: rgba(255, 255, 255, .6); }
  .dbtn-up { grid-area: up; }
  .dbtn-left { grid-area: left; }
  .dbtn-down { grid-area: down; }
  .dbtn-right { grid-area: right; }

  .bomb-btn {
    pointer-events: auto;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .55);
    background: radial-gradient(circle at 35% 28%, rgba(255, 255, 255, .42), rgba(63, 220, 214, .55) 45%, rgba(8, 108, 134, .72));
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    touch-action: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .28), inset 0 -4px 0 rgba(0, 45, 60, .25);
  }

  .bomb-btn:active { transform: scale(.94); filter: brightness(1.15); }
  .bomb-glyph {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 26%, #ffffff, #b8fff8 22%, #2bc2c9 55%, #0c7c9b);
    box-shadow: inset -3px -3px 5px rgba(0, 40, 70, .3);
    border: 1px solid rgba(255, 255, 255, .7);
  }
}

@media (max-height: 520px) {
  .game-shell { width: min(96vw, calc((100svh - 88px) * 1.15385)); }
  .hud { min-height: 40px; padding: 4px 10px; }
  .hud-label { display: none; }
  .hud-stats { padding-top: 0; border-top: 0; }
  .hud-stage-main span { display: none; }
  .topbar { min-height: 24px; }
  .foot { display: none; }
  .overlay { padding: 6px; }
  .panel { padding: 12px 14px; }
  .logo { font-size: 42px; }
  .logo-sub { font-size: 11px; padding: 4px 16px 5px; }
  .tagline { margin: 7px auto 9px; font-size: 11px; }
  .stage-picks { margin-bottom: 9px; }
  .stage-pick { min-height: 38px; }
  .record { margin-top: 8px; }
  .title-links { margin-top: 8px; }
  .btn--hero { padding: 10px 28px; font-size: 16px; min-width: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
