:root {
  color-scheme: dark;
  font-family: Bahnschrift, "Microsoft YaHei", "Trebuchet MS", sans-serif;
  background: #011827;
  color: #f4fdff;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; margin: 0; overflow: hidden; }

body {
  background:
    radial-gradient(circle at 50% 12%, rgba(0, 210, 232, .24), transparent 30%),
    repeating-linear-gradient(115deg, rgba(255,255,255,.018) 0 1px, transparent 1px 12px),
    #011827;
}

button { font: inherit; }

.page-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 0;
}

.game-frame {
  --joystick-accent: #72edf2;
  position: relative;
  width: min(100vw, calc(100dvh * 390 / 844));
  height: min(100dvh, calc(100vw * 844 / 390));
  max-width: 390px;
  max-height: 844px;
  overflow: hidden;
  isolation: isolate;
  background: #043a62;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .58), 0 0 0 1px rgba(126, 240, 255, .2);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.safe-top {
  position: absolute;
  z-index: 7;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  pointer-events: none;
  background: linear-gradient(#032b48aa, transparent);
}

.mode-home {
  position: absolute;
  z-index: 15;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  min-width: 96px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px 0 12px;
  border: 1px solid rgba(172, 245, 255, .42);
  border-radius: 8px 16px 8px 16px;
  color: #eaffff;
  background:
    linear-gradient(135deg, rgba(5, 80, 105, .86), rgba(1, 32, 58, .78)),
    repeating-linear-gradient(115deg, transparent 0 8px, rgba(255,255,255,.04) 8px 9px);
  box-shadow: inset 0 0 14px rgba(89, 236, 242, .08), 0 7px 20px rgba(0, 17, 38, .34);
  backdrop-filter: blur(7px);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-decoration: none;
  touch-action: manipulation;
  transition: transform 120ms ease, border-color 120ms ease, filter 120ms ease;
}

.mode-home i {
  width: 10px;
  height: 10px;
  border-left: 2px solid #a8f7f4;
  border-bottom: 2px solid #a8f7f4;
  transform: rotate(45deg);
  filter: drop-shadow(0 0 5px rgba(99, 245, 242, .65));
}

.mode-home:active {
  transform: scale(.95);
  border-color: rgba(205, 255, 255, .8);
  filter: brightness(1.16);
}

@media (prefers-reduced-motion: reduce) {
  .mode-home { transition: none; }
}

.hud {
  position: absolute;
  z-index: 5;
  inset: max(14px, env(safe-area-inset-top)) 14px auto;
  height: 62px;
  display: grid;
  grid-template-columns: 1fr 92px 1fr;
  align-items: start;
  pointer-events: none;
  filter: drop-shadow(0 3px 7px rgba(0,0,0,.35));
}

.hud[hidden] { display: none; }

.stage-chip, .goal-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 11px 7px;
  border: 1px solid rgba(159, 244, 255, .35);
  background: linear-gradient(145deg, rgba(1, 42, 68, .9), rgba(0, 120, 148, .62));
  backdrop-filter: blur(8px);
  transform: skewX(-6deg);
}

.stage-chip { justify-self: start; border-radius: 8px 15px 8px 15px; }
.goal-chip { justify-self: end; align-items: flex-end; border-radius: 15px 8px 15px 8px; transform: skewX(6deg); }
.stage-chip span, .goal-chip span { color: #8ddbea; font-size: 9px; letter-spacing: .08em; }
.stage-chip strong, .goal-chip strong { font-size: 15px; line-height: 1; }

.power-readout {
  justify-self: center;
  width: 82px;
  min-height: 54px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 42% 32%, #fff9a1 0 5%, #ffbc25 32%, #ff6c15 70%, #9b1e08 100%);
  border: 3px solid rgba(255,255,255,.86);
  box-shadow: 0 0 0 3px rgba(5,79,105,.65), 0 8px 20px rgba(255,121,16,.36);
}

.power-readout span { font-size: 8px; line-height: 1; color: #712308; font-weight: 800; }
.power-readout strong { font-size: 24px; line-height: .95; text-shadow: 0 2px #9b250d; }

.goal-track {
  position: absolute;
  top: 58px;
  left: 50%;
  width: 178px;
  height: 7px;
  overflow: hidden;
  transform: translateX(-50%);
  border: 1px solid rgba(194,248,255,.52);
  border-radius: 999px;
  background: rgba(0,22,38,.6);
}

.goal-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #41f0d0, #eafe5c, #ffae2f);
  box-shadow: 0 0 10px #65ffe0;
  transition: width 220ms ease;
}

.mission {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(23px, calc(env(safe-area-inset-bottom) + 10px));
  transform: translateX(-50%);
  width: max-content;
  max-width: 88%;
  padding: 9px 15px;
  border: 1px solid rgba(176,248,255,.38);
  border-radius: 999px;
  background: rgba(0,39,66,.74);
  color: #d9fbff;
  font-size: 12px;
  letter-spacing: .03em;
  text-shadow: 0 1px 3px #00253d;
  backdrop-filter: blur(7px);
  pointer-events: none;
  animation: mission-in .5s ease both;
}

.screen {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: max(52px, env(safe-area-inset-top)) 28px max(44px, calc(env(safe-area-inset-bottom) + 30px));
  text-align: center;
  background:
    linear-gradient(180deg, rgba(1,19,39,.05) 30%, rgba(0,22,43,.83) 63%, rgba(0,13,28,.96) 100%);
}

.screen[hidden] { display: none; }

.start-screen::before {
  content: "";
  position: absolute;
  inset: 22% 0 auto;
  height: 290px;
  background: radial-gradient(ellipse, rgba(52,244,255,.28), transparent 67%);
  pointer-events: none;
}

.title-mark {
  position: absolute;
  top: 21%;
  width: 176px;
  height: 150px;
  filter: drop-shadow(0 12px 18px rgba(0,44,75,.5));
  animation: float 3.2s ease-in-out infinite;
}

.title-mark i, .title-mark b {
  position: absolute;
  display: block;
  width: 120px;
  height: 74px;
  left: 30px;
  top: 34px;
  border-radius: 58% 48% 50% 57%;
  transform: rotate(-6deg);
  background: radial-gradient(circle at 72% 36%, #fff 0 3px, #17212b 4px 8px, transparent 9px),
              linear-gradient(180deg, #ffb53e 0 40%, #f36b16 42% 100%);
  box-shadow: inset 0 -12px 18px rgba(153,28,5,.28), inset 0 8px 12px rgba(255,247,163,.45), 0 0 0 3px rgba(157,55,5,.45);
}

.title-mark b {
  width: 52px;
  height: 62px;
  left: 3px;
  top: 39px;
  border-radius: 8% 90% 12% 90%;
  background: linear-gradient(135deg, #ff9c25, #e74314);
  transform: rotate(45deg);
}

.title-mark span {
  position: absolute;
  left: 72px;
  top: 35px;
  width: 18px;
  height: 72px;
  border-radius: 50%;
  background: #fff5d5;
  box-shadow: 25px 1px 0 -2px #fff5d5;
  transform: rotate(-6deg);
}

.eyebrow { margin: 0 0 7px; color: #81e9ef; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1, h2 { margin: 0; font-weight: 900; letter-spacing: .04em; text-shadow: 0 4px 0 #094b71, 0 0 24px rgba(84,239,255,.42); }
h1 { font-size: clamp(42px, 12vw, 54px); }
h2 { font-size: 40px; }
.lede { margin: 9px 0 24px; color: #cbf8fc; font-size: 15px; }

.rule-strip {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 18px;
}

.rule-strip span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 4px 9px;
  border: 1px solid rgba(138,234,244,.27);
  border-radius: 13px;
  background: rgba(4,62,89,.58);
  color: #bceaf1;
  font-size: 9px;
}

.rule-strip b {
  align-self: center;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fef776, #ff8b1d);
  color: #4a2107;
  font-size: 16px;
  box-shadow: 0 3px 10px rgba(255,155,34,.34);
}

.primary-button {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  border: 0;
  border-radius: 18px 18px 26px 26px;
  color: #371800;
  background: linear-gradient(180deg, #fff478 0%, #ffc332 45%, #ff7d16 100%);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.7), inset 0 -5px 0 rgba(159,43,0,.28), 0 10px 25px rgba(255,101,14,.3);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: .08em;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.primary-button:hover { transform: scale(1.03); filter: brightness(1.04); }
.primary-button:active { transform: scale(.97); filter: brightness(.92); }
.primary-button b { font-size: 28px; line-height: 1; }
.touch-hint { margin: 12px 0 0; color: #7cc5d0; font-size: 10px; letter-spacing: .06em; }

.result-screen { justify-content: center; background: rgba(0,25,48,.86); backdrop-filter: blur(8px); }
.result-copy { max-width: 270px; margin: 11px 0 25px; color: #c6f5fa; line-height: 1.6; }
.result-stats { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 0 0 22px; }
.result-stats div { padding: 12px 3px; border: 1px solid rgba(146,240,249,.25); border-radius: 14px; background: rgba(0,75,104,.44); }
.result-stats dt { color: #86d5df; font-size: 9px; }
.result-stats dd { margin: 3px 0 0; font-size: 22px; font-weight: 900; }

.desktop-note { position: fixed; left: 20px; bottom: 14px; margin: 0; color: rgba(177,232,239,.48); font-size: 11px; letter-spacing: .08em; }

@keyframes float { 50% { transform: translateY(-10px) rotate(1deg); } }
@keyframes mission-in { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (max-width: 520px), (max-height: 880px) {
  .game-frame { width: 100vw; height: 100dvh; max-width: none; max-height: none; box-shadow: none; }
  .mission { bottom: max(151px, calc(env(safe-area-inset-bottom) + 139px)); }
  .desktop-note { display: none; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .game-frame::after {
    content: "请竖屏游玩";
    position: absolute;
    z-index: 10;
    inset: 0;
    display: grid;
    place-items: center;
    background: #032842;
    font-size: 22px;
    font-weight: 800;
  }
}
