:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --ink: #061d29;
  --panel: rgba(4, 35, 47, 0.9);
  --panel-2: rgba(8, 53, 64, 0.92);
  --cyan: #27f1e4;
  --cyan-2: #7ffff5;
  --lime: #58f05d;
  --yellow: #ffe126;
  --magenta: #e23875;
  --muted: #89b6bb;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #031823;
  overscroll-behavior: none;
}

button { font: inherit; }
button, canvas { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
[hidden] { display: none !important; }

body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(36, 178, 177, 0.25), transparent 42%),
    #03131d;
}

.game-shell {
  position: relative;
  width: min(100vw, 480px);
  height: 100dvh;
  max-height: 1040px;
  overflow: hidden;
  background: #063543 url("assets/biofield-background.png") center / cover no-repeat;
  box-shadow: 0 0 80px rgba(29, 247, 224, 0.18);
  isolation: isolate;
  user-select: none;
}

.game-shell::after {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  content: "";
  opacity: 0.12;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.08) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
}

.screen { position: absolute; inset: 0; }
.home-screen { overflow: hidden; }
.home-screen::before {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(to bottom, rgba(3, 34, 46, .15), rgba(14, 133, 126, .16) 55%, rgba(1, 23, 34, .4));
}

.resource-bar {
  position: absolute;
  z-index: 2;
  top: max(16px, env(safe-area-inset-top));
  left: 20px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.resource {
  display: flex;
  min-width: 76px;
  height: 42px;
  padding: 0;
  align-items: center;
  gap: 7px;
  color: white;
  border: 0;
  background: transparent;
  text-shadow: 0 2px 6px #00191f;
}
.resource strong { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }

.coin-icon {
  position: relative;
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 4px solid #fff47a;
  border-radius: 50%;
  color: #e49a00;
  background: radial-gradient(circle at 35% 28%, #fffeb0 0 13%, #ffe523 15% 51%, #ffc400 53% 70%, #ffea32 72%);
  box-shadow: 0 0 0 2px #e8a900, 0 2px 8px rgba(255, 213, 0, .45);
}
.coin-icon span { font-weight: 1000; transform: translateY(-1px); }
.coin-icon-large { width: 54px; height: 54px; border-width: 5px; font-size: 24px; }
.coin-icon-small { width: 27px; height: 27px; border-width: 3px; font-size: 14px; }
.coin-icon-tiny { width: 18px; height: 18px; border-width: 2px; font-size: 9px; box-shadow: 0 0 0 1px #e8a900; }

.plus-badge {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid rgba(55, 247, 112, .5);
  border-radius: 8px;
  color: #43f36e;
  background: rgba(7, 70, 72, .72);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.energy-icon {
  width: 28px;
  height: 38px;
  flex: 0 0 auto;
  clip-path: polygon(33% 0, 100% 0, 62% 42%, 91% 42%, 19% 100%, 38% 55%, 0 55%);
  background: linear-gradient(145deg, #b8ffff, #32c9ff 46%, #1998f2);
  filter: drop-shadow(0 0 7px #5eeaff);
}
.gem-icon {
  width: 32px;
  height: 28px;
  flex: 0 0 auto;
  clip-path: polygon(20% 0, 80% 0, 100% 35%, 50% 100%, 0 35%);
  background: linear-gradient(145deg, #fff, #a9f5ff 35%, #8b86ef 67%, #dffaff);
  filter: drop-shadow(0 0 6px rgba(194, 244, 255, .6));
}

.side-menu-button {
  position: absolute;
  z-index: 3;
  top: 25%;
  left: -10px;
  display: grid;
  width: 59px;
  height: 110px;
  place-content: center;
  gap: 8px;
  border: 1px solid rgba(40, 230, 225, .2);
  border-radius: 0 17px 17px 0;
  background: rgba(4, 31, 43, .86);
  box-shadow: 0 0 20px rgba(0, 0, 0, .22);
}
.side-menu-button span { display: block; width: 28px; height: 5px; border-radius: 3px; background: #eafcff; }

.brand-lockup {
  position: absolute;
  z-index: 1;
  top: 10.5%;
  left: 50%;
  width: 66%;
  transform: translateX(-50%) skewX(-7deg);
  text-align: center;
  filter: drop-shadow(8px 10px 0 rgba(2, 39, 53, .72));
}
.brand-kicker {
  display: inline-block;
  margin-bottom: -4px;
  padding: 3px 12px;
  color: #001d27;
  background: var(--cyan);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 4px;
}
.brand-lockup h1 {
  margin: 0;
  color: #f5ffff;
  font-family: "Arial Black", "Microsoft YaHei", sans-serif;
  font-size: clamp(39px, 11vw, 58px);
  font-weight: 1000;
  line-height: .88;
  letter-spacing: -4px;
  text-shadow: 0 0 18px rgba(108, 255, 245, .24);
}
.brand-lockup h1 span { display: block; color: #54ee5a; transform: translateX(17%); }

.stage-picker {
  position: absolute;
  z-index: 2;
  top: 29.5%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
}
.stage-picker button {
  display: grid;
  width: 55px;
  height: 55px;
  place-items: center;
  color: #52efdb;
  border: 2px solid rgba(54, 250, 224, .72);
  background: rgba(10, 87, 88, .42);
  font-size: 24px;
  font-weight: 900;
  clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%);
  filter: drop-shadow(0 0 8px rgba(48, 253, 228, .32));
}
.stage-picker button.active { width: 82px; height: 82px; color: #8affef; font-size: 38px; background: rgba(20, 129, 124, .55); }
.stage-picker::before, .stage-picker::after { width: 18px; height: 25px; content: ""; background: rgba(62, 239, 220, .56); clip-path: polygon(0 0, 60% 50%, 0 100%, 40% 100%, 100% 50%, 40% 0); }

.launch-zone { position: absolute; inset: 38% 0 24%; z-index: 1; text-align: center; }
.launch-zone > p { margin: 0; color: white; font-size: 20px; font-weight: 700; text-shadow: 0 2px 12px #08333b; animation: breathe 1.8s ease-in-out infinite; }
.launch-button { position: absolute; inset: 15% 21% 0; border: 0; color: white; background: transparent; cursor: pointer; }
.launch-button img { display: block; width: min(54vw, 230px); margin: auto; filter: drop-shadow(0 13px 10px rgba(1, 19, 32, .35)); animation: ship-float 2.1s ease-in-out infinite; }
.launch-button span { display: inline-block; margin-top: -18px; padding: 8px 16px; border: 1px solid rgba(89,255,238,.35); border-radius: 18px; background: rgba(2, 37, 48, .62); font-weight: 800; }

.home-rail { position: absolute; z-index: 2; top: 45%; right: 10px; display: grid; width: 72px; }
.home-rail button { border: 0; color: white; background: transparent; }
.reward-card { display: grid; justify-items: center; gap: 5px; padding: 9px 5px !important; border: 2px solid #e2b723 !important; border-radius: 14px; background: rgba(9, 54, 61, .78) !important; }
.reward-card strong { font-size: 22px; }
.reward-card small { white-space: nowrap; font-size: 11px; }
.reward-card.claimed { opacity: .5; filter: grayscale(.7); }

.upgrade-panel { position: absolute; z-index: 4; right: 0; bottom: 74px; left: 0; display: grid; gap: 5px; padding: 8px; border-top: 2px solid rgba(28, 220, 231, .5); background: rgba(3, 29, 41, .93); opacity: 0; visibility: hidden; transform: translateY(calc(100% + 12px)); pointer-events: none; transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .18s ease, visibility 0s linear .3s; }
.upgrade-panel.open { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; transition-delay: 0s; }
.upgrade-row { display: grid; min-height: 66px; grid-template-columns: 1fr 50px 126px; align-items: center; gap: 9px; padding: 8px 9px 8px 20px; background: linear-gradient(90deg, rgba(4, 46, 58, .92), rgba(7, 36, 49, .92)); box-shadow: inset 0 0 18px rgba(43, 244, 231, .04); }
.upgrade-row div { display: grid; gap: 3px; }
.upgrade-row div strong { color: #6ff9ff; font-size: 20px; }
.upgrade-row div small { color: #70aab2; font-size: 11px; }
.upgrade-row > b { text-align: center; font-size: 29px; }
.upgrade-row button { display: flex; height: 48px; align-items: center; justify-content: space-around; border: 3px solid #70fff7; border-radius: 8px; color: white; background: #13c5c7; box-shadow: inset 0 -5px 0 rgba(0, 89, 113, .18); }
.upgrade-row button:disabled { opacity: .48; filter: grayscale(.55); }
.upgrade-row button em { font-style: normal; font-size: 20px; font-weight: 900; }

.bottom-tabs { position: absolute; z-index: 5; right: 0; bottom: 0; left: 0; display: grid; height: 74px; grid-template-columns: repeat(3, 1fr); border-top: 2px solid #21cbd6; background: #092b3a; }
.bottom-tabs button { position: relative; display: grid; grid-template-columns: 45px auto; place-content: center; align-items: center; gap: 3px; overflow: hidden; border: 0; border-right: 1px solid #5f7e82; color: #b5cdd0; background: rgba(9, 43, 54, .8); font-size: 11px; }
.bottom-tabs button.active { color: white; background: linear-gradient(#136a79, #0b3345); box-shadow: inset 0 3px 0 #35eaff; }
.bottom-tabs img { width: 48px; height: 48px; object-fit: contain; }

.battle-screen { z-index: 20; touch-action: none; background: #063543 url("assets/biofield-background.png") center / cover no-repeat; }
#battle-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.battle-hud { position: absolute; z-index: 3; top: max(14px, env(safe-area-inset-top)); right: 64px; left: 64px; pointer-events: none; }
.battle-stage-track { display: flex; height: 31px; justify-content: center; align-items: center; gap: 3px; }
.battle-stage-track span { display: grid; width: 28px; height: 28px; place-items: center; color: var(--cyan-2); border: 1px solid var(--cyan); clip-path: polygon(25% 4%,75% 4%,100% 50%,75% 96%,25% 96%,0 50%); background: rgba(4, 53, 62, .72); font-weight: 900; }
.battle-stage-track span.active { width: 38px; height: 38px; color: #fff; font-size: 19px; }
.progress-track { height: 8px; overflow: hidden; border: 2px solid rgba(164, 255, 244, .72); border-radius: 8px; background: rgba(1, 20, 28, .86); }
.progress-track span { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #70ff69, #c8ff60); box-shadow: 0 0 8px #62ff6b; transition: width .16s linear; }
.battle-meta { display: flex; padding: 7px 12px; justify-content: space-between; color: #dffffa; font-size: 12px; text-shadow: 0 1px 3px #00161f; }
.battle-meta > span { display: flex; align-items: center; gap: 6px; }
.battle-meta strong { color: #85ff77; }
.pause-button { position: absolute; z-index: 4; top: 23px; right: 18px; display: flex; width: 42px; height: 42px; align-items: center; justify-content: center; gap: 5px; border: 0; border-radius: 50%; background: rgba(3, 29, 40, .65); }
.pause-button span { width: 5px; height: 18px; border-radius: 2px; background: white; }
.battle-message { position: absolute; z-index: 4; top: 27%; right: 0; left: 0; pointer-events: none; color: white; text-align: center; font-size: 22px; font-weight: 800; text-shadow: 0 2px 9px #041823; opacity: 0; transform: translateY(10px); transition: opacity .24s, transform .24s; }
.battle-message.show { opacity: 1; transform: none; }
.buff-bar { position: absolute; z-index: 4; top: 99px; right: 18px; display: grid; gap: 6px; pointer-events: none; }
.buff-chip { padding: 5px 9px; border: 1px solid #64fff4; border-radius: 14px; color: #b7fff8; background: rgba(3, 42, 54, .78); font-size: 11px; box-shadow: 0 0 12px rgba(72, 255, 238, .18); }
.shield-timer { position: absolute; z-index: 4; top: 112px; left: 16px; padding: 5px 9px; border: 1px solid #7edfff; border-radius: 12px; color: #c9ffff; background: rgba(0, 71, 101, .66); font-size: 11px; }

.modal-layer { position: absolute; z-index: 50; inset: 0; display: grid; place-items: center; padding: 25px; background: rgba(1, 14, 21, .72); backdrop-filter: blur(4px); }
.revive-card { display: grid; width: 220px; justify-items: center; gap: 12px; padding: 20px 18px 16px; border: 2px solid #ffe378; color: white; background: #f3a13a; box-shadow: 0 16px 45px rgba(0, 0, 0, .34); }
.revive-card > strong { color: #fff377; font-size: 21px; }
.revive-card > button:not(.text-button) { width: 100%; padding: 10px; border: 0; color: white; background: rgba(255,255,255,.12); font-size: 18px; font-weight: 900; }
.video-mark { display: grid; width: 32px; height: 24px; place-items: center; border: 3px solid white; border-radius: 4px; }
.video-mark i { width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid white; }
.countdown-track { position: relative; width: 100%; height: 19px; overflow: hidden; background: #982d43; text-align: center; }
.countdown-track span { position: absolute; inset: 0; transform-origin: left; background: #c94052; }
.countdown-track b { position: relative; z-index: 2; }
.text-button { border: 0; color: rgba(255,255,255,.9); background: transparent; font-size: 12px; text-decoration: underline; }
.result-card { width: min(100%, 340px); padding: 26px; border: 1px solid rgba(68, 255, 236, .66); border-radius: 20px; color: white; background: linear-gradient(160deg, rgba(8, 77, 86, .98), rgba(3, 31, 43, .98)); box-shadow: 0 0 40px rgba(30, 243, 226, .2); }
.result-card small { color: var(--cyan-2); font-weight: 800; letter-spacing: 4px; }
.result-card h2 { margin: 6px 0 23px; font-size: 34px; }
.result-stat { display: flex; margin-bottom: 24px; padding: 14px; justify-content: space-between; border-top: 1px solid rgba(116,255,243,.23); border-bottom: 1px solid rgba(116,255,243,.23); }
.result-stat strong { color: var(--yellow); font-size: 22px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.result-actions.vertical { grid-template-columns: 1fr; }
.result-actions button { min-height: 46px; border: 1px solid #5ee7df; border-radius: 10px; color: #cafffa; background: rgba(5, 44, 54, .8); font-weight: 800; }
.result-actions button.primary { color: #032b35; background: var(--cyan); }
.result-card.compact h2 { font-size: 24px; }

.drawer { position: absolute; z-index: 80; inset: 0 auto 0 0; width: min(80%, 340px); padding: max(28px, env(safe-area-inset-top)) 18px 20px; color: white; background: rgba(3, 27, 38, .98); box-shadow: 20px 0 50px rgba(0,0,0,.42); }
.drawer header { display: flex; margin-bottom: 22px; align-items: center; justify-content: space-between; }
.drawer header strong { font-size: 25px; }
.drawer button { display: flex; width: 100%; min-height: 52px; padding: 0 12px; align-items: center; justify-content: space-between; border: 0; border-bottom: 1px solid rgba(93, 241, 229, .16); color: white; background: transparent; }
.drawer header button { width: auto; color: var(--cyan-2); }
.drawer button b { color: var(--cyan); }
.drawer button.danger b { color: #ff778d; }

.info-layer { z-index: 90; }
.info-card { position: relative; width: min(100%, 380px); max-height: 80%; overflow: auto; padding: 25px; border: 1px solid rgba(83,255,240,.45); border-radius: 18px; color: #eafffd; background: #052d3a; }
.info-card h2 { margin: 0 0 15px; }
.info-card p, .info-card li { color: #b9d7d9; line-height: 1.65; }
.close-info { position: absolute; top: 14px; right: 14px; border: 0; color: var(--cyan); background: transparent; }

.toast { position: absolute; z-index: 120; bottom: 95px; left: 50%; max-width: 82%; padding: 10px 16px; border: 1px solid rgba(100,255,241,.45); border-radius: 22px; color: white; background: rgba(2, 26, 36, .9); box-shadow: 0 8px 30px rgba(0,0,0,.3); opacity: 0; transform: translate(-50%, 18px); transition: .22s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes ship-float { 50% { transform: translateY(-10px); filter: drop-shadow(0 23px 13px rgba(1, 19, 32, .25)); } }
@keyframes breathe { 50% { opacity: .58; transform: scale(.98); } }

@media (max-height: 740px) {
  .brand-lockup { top: 9%; transform: translateX(-50%) skewX(-7deg) scale(.78); }
  .stage-picker { top: 25%; transform: translateX(-50%) scale(.8); }
  .launch-zone { inset: 32% 0 31%; }
  .launch-button img { width: 150px; }
  .home-rail { top: 40%; }
  .upgrade-panel { bottom: 64px; }
  .upgrade-row { min-height: 54px; grid-template-columns: 1fr 45px 116px; }
  .upgrade-row div strong { font-size: 17px; }
  .bottom-tabs { height: 64px; }
}

@media (min-width: 481px) {
  .game-shell { border: 1px solid rgba(73, 245, 229, .25); }
}
