:root {
  --orange: #FF8A3D;
  --orange-deep: #F4681F;
  --gold: #FFC46B;
  --cyan: #6FE3FF;
  --ink: #F8F4EA;
  --muted: rgba(230, 238, 255, .62);
  --glass-bg: linear-gradient(160deg, rgba(20, 29, 58, .72), rgba(8, 12, 27, .58));
  --glass-line: rgba(255, 255, 255, .13);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #04060E;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(ellipse 60% 42% at 78% 8%, rgba(255, 112, 40, .12), transparent 70%),
    radial-gradient(ellipse 55% 45% at 12% 85%, rgba(63, 105, 255, .12), transparent 70%),
    radial-gradient(ellipse at 50% 0%, #121935 0%, #070A17 46%, #03040A 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; }

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #05070F;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.fx-vignette,
.fx-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.fx-vignette {
  z-index: 3;
  background:
    radial-gradient(ellipse at 50% 44%, transparent 38%, rgba(2, 4, 12, .28) 74%, rgba(2, 4, 12, .62) 100%),
    linear-gradient(180deg, rgba(3, 6, 16, .34) 0%, transparent 16%, transparent 82%, rgba(3, 6, 16, .4) 100%);
}

.fx-scan {
  z-index: 4;
  opacity: .055;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .9) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}

/* ---------- glass ---------- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-line);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  padding: calc(var(--safe-top) + 12px) 16px 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .4s ease, transform .4s cubic-bezier(.2, .7, .3, 1);
}

.hud.is-on {
  opacity: 1;
  transform: none;
  visibility: visible;
}

.hud:not(.is-on) {
  visibility: hidden;
}

.hud-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.score-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 106px;
  padding: 8px 14px 9px;
  border-radius: 16px;
}

.hud-cap {
  font-size: 9px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .28em;
  color: rgba(255, 196, 107, .82);
}

.score-num {
  font-size: 27px;
  line-height: 1.05;
  font-weight: 850;
  letter-spacing: .01em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(255, 138, 61, .5);
  transform-origin: 20% 50%;
}

.score-num.pop { animation: scorePop .3s ease; }

.best-mini {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  line-height: 1;
  color: rgba(226, 235, 255, .55);
  font-variant-numeric: tabular-nums;
}

.best-mini .mp-icon {
  width: 11px;
  height: 11px;
  color: var(--gold);
}

.best-mini b { font-weight: 700; }

.wave-badge {
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 210, 160, .16);
  background: rgba(8, 12, 26, .46);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .22em;
  line-height: 1;
  color: rgba(255, 214, 165, .82);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.wave-badge.pop { animation: wavePop .55s cubic-bezier(.2, .8, .3, 1); }

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.hull-card {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  padding: 8px 12px 9px;
  border-radius: 16px;
}

.lives {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 15px;
}

.lives .heart {
  width: 15px;
  height: 15px;
  color: #FF6B6B;
  filter: drop-shadow(0 0 6px rgba(255, 80, 90, .6));
  transition: color .25s ease, transform .25s ease, filter .25s ease, opacity .25s ease;
}

.lives .heart.lost {
  color: rgba(255, 255, 255, .16);
  filter: none;
  transform: scale(.84);
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: rgba(240, 245, 255, .84);
  cursor: pointer;
  transition: transform .1s ease, background .2s ease, color .2s ease;
}

.icon-btn .mp-icon {
  width: 20px;
  height: 20px;
  grid-area: 1 / 1;
}

.icon-btn:active { transform: scale(.9); }

.icon-btn .sound-off { display: none; }
.icon-btn.is-muted .sound-on { display: none; }
.icon-btn.is-muted .sound-off { display: inline-block; }
.icon-btn.is-muted { color: rgba(255, 196, 107, .9); }

.drag-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 28px);
  transform: translate(-50%, 10px);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .11);
  background: rgba(8, 13, 28, .56);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 12px;
  letter-spacing: .02em;
  color: rgba(232, 240, 255, .7);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .45s ease, transform .45s cubic-bezier(.2, .8, .3, 1);
}

.drag-hint.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.drag-hint .mp-icon {
  width: 16px;
  height: 16px;
  color: var(--orange);
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  transition: opacity .45s ease, visibility .45s ease;
}

.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ---------- start ---------- */
.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 44px) 22px calc(var(--safe-bottom) + 26px);
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 38% at 50% 50%, transparent 30%, rgba(3, 5, 14, .1) 68%, rgba(3, 5, 14, .55) 100%),
    linear-gradient(180deg, rgba(3, 6, 18, .82) 0%, rgba(3, 6, 18, .28) 20%, rgba(3, 6, 18, 0) 34%, rgba(3, 6, 18, 0) 55%, rgba(3, 5, 14, .74) 82%, rgba(3, 5, 14, .93) 100%);
}

.start-top {
  width: 100%;
  text-align: center;
  animation: riseIn .7s cubic-bezier(.2, .8, .3, 1) both;
}

.brand-kicker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .36em;
  color: rgba(255, 196, 107, .82);
  text-shadow: 0 0 18px rgba(255, 138, 61, .35);
}

.brand-kicker em {
  display: block;
  width: 26px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 170, 100, .75));
}

.brand-kicker em:last-child {
  background: linear-gradient(90deg, rgba(255, 170, 100, .75), transparent);
}

.logo-cn {
  margin: 14px 0 0;
  font-size: clamp(44px, 12.8vw, 60px);
  line-height: 1.04;
  font-weight: 900;
  letter-spacing: .1em;
  padding-left: .1em;
  background: linear-gradient(180deg, #FFF9EE 8%, #FFE0B4 46%, #FF9A4D 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 26px rgba(255, 122, 47, .38)) drop-shadow(0 2px 0 rgba(100, 30, 0, .22));
}

.logo-en {
  margin-top: 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .54em;
  padding-left: .54em;
  color: rgba(255, 216, 170, .68);
}

.tagline {
  margin: 15px 0 0;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: .08em;
  color: rgba(230, 238, 255, .62);
}

.start-bottom {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  pointer-events: none;
  animation: riseIn .7s .12s cubic-bezier(.2, .8, .3, 1) both;
}

.feature-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.feat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: linear-gradient(165deg, rgba(20, 29, 58, .56), rgba(8, 12, 27, .42));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: rgba(231, 238, 255, .74);
}

.feat .mp-icon {
  width: 18px;
  height: 18px;
  color: var(--orange);
  filter: drop-shadow(0 0 7px rgba(255, 138, 61, .4));
}

.btn-primary {
  pointer-events: auto;
  position: relative;
  width: 100%;
  min-height: 58px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 19px;
  cursor: pointer;
  overflow: hidden;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: .12em;
  color: #2B1204;
  background: linear-gradient(180deg, #FFD08A 0%, #FFA151 38%, #FF7A2F 100%);
  box-shadow:
    0 15px 36px rgba(255, 108, 38, .34),
    0 4px 12px rgba(0, 0, 0, .28),
    inset 0 1px 0 rgba(255, 255, 255, .6),
    inset 0 -2px 0 rgba(140, 40, 0, .25);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: -2px;
  background: linear-gradient(110deg, transparent 32%, rgba(255, 255, 255, .42) 48%, transparent 64%);
  transform: translateX(-130%);
  animation: shine 3.6s ease-in-out infinite;
  pointer-events: none;
}

.btn-primary:active {
  transform: scale(.972);
  filter: brightness(1.04);
  box-shadow:
    0 8px 20px rgba(255, 108, 38, .3),
    inset 0 1px 0 rgba(255, 255, 255, .5);
}

.btn-ico {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(60, 22, 0, .16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}

.btn-ico .mp-icon {
  width: 19px;
  height: 19px;
  color: #3A1703;
}

.record-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .11);
  background: rgba(10, 16, 34, .52);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 12px;
  letter-spacing: .04em;
  color: rgba(232, 239, 255, .66);
}

.record-pill .mp-icon {
  width: 15px;
  height: 15px;
  color: var(--gold);
}

.record-pill b {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ---------- overlays / panels ---------- */
.overlay {
  display: grid;
  place-items: center;
  padding: 26px 20px;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(6, 10, 24, .32), rgba(3, 5, 14, .84) 74%);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.panel {
  position: relative;
  width: 100%;
  max-width: 332px;
  padding: 27px 22px 22px;
  border-radius: 27px;
  text-align: center;
  background:
    radial-gradient(ellipse 100% 60% at 50% 0%, rgba(255, 138, 61, .11), transparent 62%),
    linear-gradient(168deg, rgba(25, 34, 66, .96), rgba(9, 13, 28, .98));
  border: 1px solid rgba(255, 178, 110, .2);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, .6),
    inset 0 1px 0 rgba(255, 255, 255, .1);
}

.screen:not(.is-hidden) .panel {
  animation: panelIn .42s cubic-bezier(.2, .8, .3, 1) both;
}

.panel-emblem {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--orange);
  background: linear-gradient(160deg, rgba(255, 138, 61, .2), rgba(255, 138, 61, .05));
  border: 1px solid rgba(255, 168, 96, .28);
  box-shadow: 0 0 26px rgba(255, 120, 40, .22), inset 0 1px 0 rgba(255, 255, 255, .12);
}

.panel-emblem .mp-icon {
  width: 27px;
  height: 27px;
}

.panel-emblem.danger {
  color: #FF8C7A;
  background: linear-gradient(160deg, rgba(255, 92, 74, .2), rgba(255, 92, 74, .04));
  border-color: rgba(255, 120, 96, .3);
  box-shadow: 0 0 28px rgba(255, 80, 60, .22), inset 0 1px 0 rgba(255, 255, 255, .12);
}

.panel-kicker {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .34em;
  color: rgba(255, 196, 107, .68);
}

.panel h2 {
  margin: 7px 0 0;
  font-size: 25px;
  font-weight: 850;
  letter-spacing: .08em;
  color: #FFF6EA;
}

.panel-sub {
  margin: 9px 0 20px;
  font-size: 12px;
  letter-spacing: .05em;
  color: rgba(230, 238, 255, .55);
}

.panel .btn-primary {
  min-height: 54px;
  font-size: 16px;
  border-radius: 17px;
  margin-top: 20px;
}

.panel-note {
  margin: 14px 0 0;
  font-size: 10px;
  letter-spacing: .08em;
  color: rgba(230, 238, 255, .34);
}

.new-record {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .2em;
  color: #2B1204;
  background: linear-gradient(180deg, #FFD08A, #FF9A4D);
  box-shadow: 0 0 18px rgba(255, 138, 61, .35);
}

.final-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 13px 0 15px;
}

.final-score span {
  font-size: 54px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #FFF9EE 10%, #FFD49C 55%, #FF8A3D 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 20px rgba(255, 122, 47, .3));
}

.final-score small {
  font-size: 10px;
  letter-spacing: .2em;
  color: rgba(230, 238, 255, .46);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: rgba(255, 255, 255, .07);
}

.result-grid > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 4px 10px;
  background: rgba(9, 13, 28, .72);
}

.result-grid span {
  font-size: 9px;
  letter-spacing: .08em;
  color: rgba(230, 238, 255, .42);
}

.result-grid b {
  font-size: 16px;
  font-weight: 800;
  color: #FFF1DE;
  font-variant-numeric: tabular-nums;
}

.noscript {
  position: absolute;
  inset: 0;
  z-index: 99;
  display: grid;
  place-items: center;
  padding: 30px;
  background: #070A17;
  color: #FFC46B;
  font-size: 14px;
  text-align: center;
}

/* ---------- keyframes ---------- */
@keyframes shine {
  0%, 54% { transform: translateX(-130%); }
  76%, 100% { transform: translateX(130%); }
}

@keyframes scorePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

@keyframes wavePop {
  0% { transform: translateX(-50%) scale(.78); opacity: .2; }
  55% { transform: translateX(-50%) scale(1.08); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- responsive ---------- */
@media (min-width: 600px) {
  .stage {
    width: auto;
    height: 92vh;
    height: 92dvh;
    max-width: 96vw;
    aspect-ratio: 9 / 19;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, .1);
    box-shadow:
      0 40px 100px rgba(0, 0, 0, .68),
      0 0 0 10px rgba(255, 255, 255, .02),
      0 0 90px rgba(255, 110, 40, .07);
  }
}

@media (max-height: 700px) {
  .start-screen {
    padding-top: calc(var(--safe-top) + 27px);
    padding-bottom: calc(var(--safe-bottom) + 18px);
  }

  .logo-cn { font-size: clamp(39px, 11.5vw, 52px); }
  .logo-en { margin-top: 5px; }
  .tagline { margin-top: 10px; font-size: 12px; }
  .start-bottom { gap: 12px; }
  .feat { flex-direction: row; gap: 6px; padding: 8px 5px; font-size: 10px; }
  .btn-primary { min-height: 53px; }
  .brand-kicker { font-size: 8px; }
}

@media (max-height: 580px) {
  .tagline { display: none; }
  .feature-row { display: none; }
  .logo-cn { font-size: 38px; }
  .start-screen { padding-top: calc(var(--safe-top) + 20px); }
  .panel { padding: 20px 18px 18px; }
  .panel-emblem { width: 44px; height: 44px; margin-bottom: 10px; }
  .panel-emblem .mp-icon { width: 22px; height: 22px; }
  .panel h2 { font-size: 21px; }
  .final-score span { font-size: 44px; }
  .panel .btn-primary { margin-top: 14px; min-height: 48px; }
}

@media (max-height: 480px) {
  .start-screen { justify-content: flex-end; }
  .start-top { position: absolute; top: calc(var(--safe-top) + 14px); }
  .logo-cn { font-size: 32px; }
  .logo-en, .brand-kicker, .tagline { display: none; }
  .feat span { display: none; }
  .feat { padding: 7px; }
  .start-bottom { max-width: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary::after { animation: none; }
  .start-top, .start-bottom { animation: none; }
  .screen:not(.is-hidden) .panel { animation: none; }
  .score-num.pop, .wave-badge.pop { animation: none; }
}
