/* 飞龙凯恩：横版射击闯关。关卡选择页沿用乐园 Q 版风格（天空蓝主色）；游戏层全屏深色，画面 16:9 等比缩放，
   HUD 与触屏按钮用容器单位（cqh）随画面大小缩放。手机防闪屏：按钮去点击高亮、禁用双击缩放与长按菜单，
   悬停效果只给鼠标设备。 */
.kaine-page .fun-main { width: min(100% - 20px, 1180px); }
.kaine-page .fun-title img { width: 40px; height: 40px; object-fit: contain; }

/* ---------- 横幅 ---------- */
.kaine-banner {
  position: relative; display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: center;
  margin-bottom: 18px; padding: 18px 22px; overflow: hidden; color: #fff;
  background: radial-gradient(circle at 14% 40%, rgba(150, 230, 255, .55), transparent 48%),
    linear-gradient(135deg, #1d3f93 0%, #2c78c9 48%, #3fc2d8 100%);
  border: 4px solid #fff; border-radius: 28px; box-shadow: var(--shadow-lg);
}
.kaine-banner::after {
  content: ""; position: absolute; right: -50px; bottom: -70px; width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 65%); pointer-events: none;
}
.kb-art { width: 280px; object-fit: contain; filter: drop-shadow(0 10px 18px rgba(0, 20, 60, .45)); animation: kb-fly 3.4s ease-in-out infinite; }
@keyframes kb-fly { 50% { transform: translate(6px, -9px) rotate(-2deg); } }
.kb-kicker { margin: 0; color: #fff27a; font-size: 13px; font-weight: 800; letter-spacing: 3px; }
.kb-text h2 { margin: 2px 0 6px; font-family: var(--font-title); font-size: clamp(30px, 5vw, 46px); letter-spacing: 6px; text-shadow: 0 4px 0 rgba(0, 20, 60, .3); }
.kb-desc { margin: 0 0 12px; color: rgba(255, 255, 255, .9); font-size: 14px; line-height: 1.75; }
.kb-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.kb-bar { position: relative; flex: 1 1 240px; height: 26px; overflow: hidden; background: rgba(0, 20, 60, .3); border: 2px solid rgba(255, 255, 255, .75); border-radius: 999px; }
.kb-bar i { display: block; width: var(--p, 0%); height: 100%; background: linear-gradient(90deg, #fff27a, #ffb238); border-radius: 999px; transition: width .8s var(--out); }
.kb-bar span { position: absolute; inset: 0; font-size: 13px; font-weight: 800; line-height: 22px; text-align: center; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.kb-reward .rewards { gap: 6px; }
.kb-reward .reward { color: var(--ink); }
.kb-reward .done { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; color: #1f6e4d; font-weight: 800; background: #d9ffe9; border-radius: 999px; }
.kaine-banner .hint { color: rgba(255, 255, 255, .78); }
@media (max-width: 720px) {
  .kaine-banner { grid-template-columns: 1fr; text-align: center; }
  .kb-art { justify-self: center; width: 220px; }
}

/* ---------- 能量胶囊说明 ---------- */
.kaine-caps { margin-bottom: 18px; }
.kaine-caps h2 small, .kaine-keys h2 small { color: var(--muted); font-size: 13px; font-weight: 700; }
.cap-list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.cap-list li {
  display: grid; justify-items: center; gap: 4px; padding: 10px 8px 12px; text-align: center; background: #f2f9ff;
  border: 3px solid #d9ecff; border-radius: 18px; animation: fun-rise .5s var(--out) both; animation-delay: var(--d, 0s);
}
.cap-list canvas { width: 48px; height: 48px; }
.cap-list b { font-size: 14px; }
.cap-list span { color: var(--muted); font-size: 12px; line-height: 1.5; }
@media (max-width: 900px) { .cap-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- 关卡卡片 ---------- */
.kaine-stages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stage-card {
  position: relative; display: flex; flex-direction: column; min-height: 250px; padding: 12px; overflow: hidden;
  color: #fff; text-align: left; background: var(--bg, none) center / cover no-repeat, var(--sky, #2a4f96); border: 4px solid #fff;
  border-radius: 22px; box-shadow: var(--shadow); cursor: pointer; font: inherit; isolation: isolate;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform .25s var(--jelly), box-shadow .25s;
  animation: fun-rise .5s var(--out) both; animation-delay: var(--d, 0s);
}
.stage-card::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 20, 50, .05) 20%, rgba(10, 16, 40, .82) 100%); }
.stage-card .sc-no { align-self: flex-start; padding: 2px 10px; color: #0d3a6b; font-size: 12px; font-weight: 900; background: #aee8ff; border-radius: 999px; box-shadow: 0 3px 0 #4a9fd0; }
.stage-card .sc-boss { display: block; width: 100%; height: 96px; margin: 8px 0 4px; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .45)); }
.stage-card h3 { margin: auto 0 2px; font-family: var(--font-title); font-size: 20px; letter-spacing: 2px; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.stage-card .sc-bossname { margin: 0; color: #d6f1ff; font-size: 12px; font-weight: 700; }
.stage-card .sc-best { margin: 2px 0 0; color: #fff27a; font-size: 12px; font-weight: 800; }
.stage-card .sc-state { margin-top: 8px; padding: 6px 8px; font-size: 12.5px; font-weight: 800; text-align: center; background: rgba(255, 255, 255, .18); border-radius: 12px; }
.stage-card.open .sc-state { color: #3a2400; background: linear-gradient(180deg, #ffe066, #ffb238); box-shadow: 0 3px 0 #c9771b; }
.stage-card.done .sc-state { color: #0f5a3d; background: #c8f7df; }
.stage-card.locked { cursor: not-allowed; }
.stage-card.locked > * { opacity: .55; }
.stage-card.locked .sc-state { opacity: 1; background: rgba(0, 0, 0, .45); }
.stage-card .sc-gems { display: flex; gap: 4px; margin-top: 6px; }
.stage-card .sc-gems i { width: 14px; height: 14px; background: #fff; border-radius: 3px; transform: rotate(45deg) scale(.8); opacity: .35; }
.stage-card .sc-gems i.on { background: linear-gradient(135deg, #fff6b0, #ff9adf); box-shadow: 0 0 6px #ffe680; opacity: 1; }
.sky-grass { --sky: linear-gradient(180deg, #6cc6ff, #bff0ff); }
.sky-forest { --sky: linear-gradient(180deg, #1f5a52, #6bb58a); }
.sky-volcano { --sky: linear-gradient(180deg, #4a1320, #d0582a); }
.sky-ice { --sky: linear-gradient(180deg, #2a4a8a, #a8e4ff); }
.sky-temple { --sky: linear-gradient(180deg, #1b1035, #6a3a92); }
@media (hover: hover) and (pointer: fine) {
  .stage-card:not(.locked):hover { transform: translateY(-6px) rotate(-.6deg); box-shadow: var(--shadow-lg); }
}
@media (max-width: 900px) { .kaine-stages { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .kaine-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-card { min-height: 220px; }
}

.kaine-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .kaine-grid { grid-template-columns: 1fr; } }
.key-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.key-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: 13.5px; }
.key-list span { margin-left: 6px; color: var(--muted); }
kbd {
  display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 7px; color: var(--ink);
  font: 800 12px var(--font-body); background: #fff; border: 2px solid #d6e6f7; border-bottom-width: 4px; border-radius: 8px;
}

/* ---------- 游戏层 ---------- */
.kaine-play {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: #060a18;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none;
}
.kp-stage {
  position: relative; width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; overflow: hidden;
  container-type: size; background: #000;
}
@supports (height: 100dvh) { .kp-stage { width: min(100vw, calc(100dvh * 16 / 9)); } }
#kaine-cv { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--font-body); color: #fff; }
.hud-me { position: absolute; left: 1.6cqh; top: 1.6cqh; display: flex; align-items: center; gap: 1.2cqh; }
.hud-face {
  display: grid; place-items: center; width: 9cqh; height: 9cqh; overflow: hidden;
  background: radial-gradient(circle at 40% 30%, #d8f4ff, #3f9ae8); border: .6cqh solid #fff; border-radius: 50%;
  box-shadow: 0 .6cqh 0 rgba(0, 0, 0, .35);
}
.hud-face img { width: 130%; height: 130%; object-fit: contain; image-rendering: auto; }
.hud-stat { display: grid; gap: .6cqh; }
.hud-armor { display: flex; gap: .5cqh; }
.hud-armor i {
  width: 3.4cqh; height: 3.4cqh; background: linear-gradient(180deg, #aef0ff, #2fa0e8); border: .35cqh solid #fff;
  border-radius: .9cqh .9cqh 1.7cqh 1.7cqh; box-shadow: 0 .3cqh 0 rgba(0, 0, 0, .35);
}
.hud-armor i.lost { background: rgba(0, 0, 0, .5); border-color: rgba(255, 255, 255, .5); }
.hud-armor.hit { animation: armor-hit .4s steps(2) 2; }
@keyframes armor-hit { 50% { filter: brightness(2) hue-rotate(160deg); } }
.hud-lives { display: flex; align-items: center; gap: .5cqh; font-size: 2.2cqh; font-weight: 900; text-shadow: 0 1px 2px #000; }
.hud-lives img { width: 4cqh; height: 4cqh; object-fit: contain; }
.hud-mid { position: absolute; left: 50%; top: 1.4cqh; display: grid; justify-items: center; transform: translateX(-50%); text-shadow: 0 .3cqh 0 rgba(0, 0, 0, .55); }
.hud-mid b { font-family: var(--font-title); font-size: 3.2cqh; letter-spacing: .3cqh; }
.hud-mid > span { font-size: 3.2cqh; font-weight: 900; font-variant-numeric: tabular-nums; color: #fff27a; }
.hud-gems { display: flex; align-items: center; gap: .5cqh; font-style: normal; }
.hud-gems i { width: 2.4cqh; height: 2.4cqh; background: linear-gradient(135deg, #fff6b0, #ff9adf); border: .25cqh solid #fff; border-radius: .5cqh; transform: rotate(45deg); }
.hud-gems span { font-size: 2.1cqh; font-weight: 800; }
.hud-gems.pop { animation: gem-pop .45s var(--jelly); }
@keyframes gem-pop { 40% { transform: scale(1.4); } }
.hud-btns { position: absolute; right: 1.6cqh; top: 1.6cqh; display: flex; gap: 1cqh; pointer-events: auto; }
.hud-btn {
  display: grid; place-items: center; width: 7cqh; height: 7cqh; padding: 0; color: #fff; font-size: 3cqh; font-weight: 900;
  background: rgba(0, 0, 0, .45); border: .4cqh solid rgba(255, 255, 255, .8); border-radius: 50%; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
/* 火力栏：五格，拥有的强化亮起 */
.hud-power { position: absolute; left: 50%; bottom: 1.4cqh; display: flex; gap: .8cqh; transform: translateX(-50%); }
.pw {
  position: relative; display: grid; justify-items: center; width: 9cqh; padding: .4cqh 0 .5cqh; background: rgba(0, 10, 30, .55);
  border: .35cqh solid rgba(255, 255, 255, .35); border-radius: 1.4cqh; opacity: .55;
}
.pw img { width: 4.6cqh; height: 4.6cqh; object-fit: contain; }
.pw b { font-size: 1.8cqh; line-height: 1.2; }
.pw.on { opacity: 1; border-color: #fff27a; box-shadow: 0 0 1.4cqh rgba(255, 240, 120, .6); }
.pw.pop { animation: gem-pop .45s var(--jelly); }
.hud-boss { position: absolute; left: 50%; top: 14.5cqh; width: 60cqh; transform: translateX(-50%); animation: boss-in .6s var(--out); }
@keyframes boss-in { from { opacity: 0; transform: translate(-50%, -3cqh); } }
.hb-name { display: flex; align-items: baseline; justify-content: center; gap: 1cqh; margin-bottom: .6cqh; text-shadow: 0 .3cqh 0 #000; }
.hb-name b { font-family: var(--font-title); font-size: 3.2cqh; letter-spacing: .3cqh; }
.hb-name small { color: #bfe8ff; font-size: 1.9cqh; font-weight: 800; }
.boss-bar { position: relative; height: 2.6cqh; overflow: hidden; background: rgba(0, 0, 0, .6); border: .4cqh solid #fff; border-radius: 99px; box-shadow: 0 0 2cqh rgba(255, 60, 90, .45); }
.boss-bar i { position: absolute; inset: 0 auto 0 0; width: var(--p, 100%); background: linear-gradient(180deg, #ff6b8b, #c3143a); }
.boss-bar i.lag { background: #ffd9a8; transition: width .8s ease-out .25s; }
.hud-auto {
  position: absolute; left: 1.6cqh; top: 12.6cqh; padding: .3cqh 1.2cqh; color: #0d3a1f; font-size: 1.9cqh; font-weight: 900;
  background: #9dffc8; border-radius: 99px; box-shadow: 0 .3cqh 0 rgba(0, 0, 0, .35);
}
.hud-banner {
  position: absolute; left: 50%; top: 32%; padding: 1.4cqh 5cqh; color: #fff; font-family: var(--font-title);
  font-size: 6.4cqh; letter-spacing: .8cqh; white-space: nowrap;
  background: linear-gradient(90deg, transparent, rgba(0, 20, 60, .62) 20%, rgba(0, 20, 60, .62) 80%, transparent);
  transform: translateX(-50%); text-shadow: 0 .5cqh 0 rgba(0, 0, 0, .4); animation: banner-in .5s var(--jelly);
}
.hud-banner small { display: block; color: #aee8ff; font-family: var(--font-body); font-size: 2.6cqh; font-weight: 800; letter-spacing: .5cqh; text-align: center; }
.hud-banner.warn { color: #ffdf5a; background: linear-gradient(90deg, transparent, rgba(160, 10, 30, .72) 20%, rgba(160, 10, 30, .72) 80%, transparent); }
@keyframes banner-in { from { opacity: 0; transform: translateX(-50%) scale(1.6); } }

/* ---------- 触屏：相对摇杆 + 自动射击开关 ---------- */
.touch { position: absolute; inset: 0; pointer-events: none; }
.stick-zone { position: absolute; left: 0; top: 12%; width: 72%; height: 88%; pointer-events: auto; touch-action: none; }
.stick {
  position: absolute; left: var(--sx, 18cqh); top: var(--sy, 70%); width: 20cqh; height: 20cqh; margin: -10cqh 0 0 -10cqh;
  background: radial-gradient(circle, rgba(255, 255, 255, .08), rgba(255, 255, 255, .2)); border: .45cqh solid rgba(255, 255, 255, .45);
  border-radius: 50%; opacity: .6;
}
.stick.on { opacity: 1; }
.stick i {
  position: absolute; left: 50%; top: 50%; width: 9cqh; height: 9cqh; margin: -4.5cqh 0 0 -4.5cqh;
  background: radial-gradient(circle at 40% 35%, #fff, #bfe6ff); border-radius: 50%; box-shadow: 0 .6cqh 1.2cqh rgba(0, 0, 0, .4);
  transform: translate(var(--kx, 0), var(--ky, 0));
}
.tb {
  position: absolute; display: grid; place-items: center; padding: 0; color: #fff; font: 900 2.4cqh/1.2 var(--font-body);
  border: .5cqh solid rgba(255, 255, 255, .85); border-radius: 50%; pointer-events: auto; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.tb-fire { right: 5cqh; bottom: 7cqh; width: 18cqh; height: 18cqh; background: rgba(40, 60, 90, .55); }
.tb-fire.on { background: rgba(60, 200, 130, .6); box-shadow: 0 0 2.6cqh rgba(120, 255, 180, .6); }
.tb-fire.down { transform: scale(.92); }

/* ---------- 遮罩层 ---------- */
.ov { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 3cqh; background: rgba(6, 10, 26, .62); }
.ov-card {
  width: min(92%, 86cqh); max-height: 94cqh; overflow: auto; padding: 3cqh 4cqh; color: var(--ink); text-align: center;
  background: var(--card); border: .8cqh solid #fff; border-radius: 4cqh; box-shadow: var(--shadow-lg); animation: fun-pop .4s var(--jelly);
}
.ov-card h3 { margin: 0 0 1.6cqh; font-family: var(--font-title); font-size: 5cqh; letter-spacing: .5cqh; }
.ov-kicker { margin: 0; color: #2c78c9; font-size: 2.4cqh; font-weight: 800; letter-spacing: .4cqh; }
.ov-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.6cqh; margin-top: 2cqh; }
.ov-actions .btn { height: 7.6cqh; padding: 0 3.4cqh; font-size: 2.8cqh; }
.load-bar { height: 2.4cqh; overflow: hidden; background: #e2f0fb; border-radius: 99px; }
.load-bar i { display: block; width: var(--p, 0%); height: 100%; background: linear-gradient(90deg, #7be0ff, #2c78c9); transition: width .2s; }
.ov-result .res-grade {
  display: grid; place-items: center; width: 14cqh; height: 14cqh; margin: -1cqh auto 1cqh; color: #fff; font-family: var(--font-title);
  font-size: 9cqh; background: radial-gradient(circle at 35% 30%, #ffe27a, #ff8a1c); border: .6cqh solid #fff; border-radius: 50%;
  box-shadow: 0 .8cqh 0 #c95f0a; animation: grade-in .7s var(--jelly);
}
.ov-result .res-grade.g-A { background: radial-gradient(circle at 35% 30%, #c9f0ff, #3b9cf3); box-shadow: 0 .8cqh 0 #256fb8; }
.ov-result .res-grade.g-B { background: radial-gradient(circle at 35% 30%, #d8ffe9, #22c3a3); box-shadow: 0 .8cqh 0 #178b74; }
.ov-result .res-grade.g-C { background: radial-gradient(circle at 35% 30%, #eee, #9a8aa8); box-shadow: 0 .8cqh 0 #6e6178; }
.ov-result .res-grade.g-X { background: radial-gradient(circle at 35% 30%, #ddd, #555); box-shadow: 0 .8cqh 0 #333; font-size: 6cqh; }
@keyframes grade-in { from { transform: scale(2.4) rotate(-20deg); opacity: 0; } }
.res-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(15cqh, 1fr)); gap: 1.2cqh; margin: 0 0 1.6cqh; padding: 0; list-style: none; }
.res-stats li { padding: 1.2cqh; background: #eef6fd; border-radius: 2cqh; }
.res-stats b { display: block; font-size: 3.6cqh; }
.res-stats span { color: var(--muted); font-size: 2cqh; font-weight: 700; }
#res-reward .rewards { justify-content: center; }
.rotate-tip { position: absolute; inset: 0; z-index: 9; display: none; place-items: center; color: #fff; text-align: center; background: #060a18; }
.rotate-tip b { display: block; font-size: 60px; animation: rot-tip 1.6s ease-in-out infinite; }
@keyframes rot-tip { 50% { transform: rotate(90deg); } }
@media (orientation: portrait) and (pointer: coarse) {
  .kaine-play .rotate-tip { display: grid; }
}
