:root {
  --paper: #fff2d6;
  --paper-bright: #fffaf0;
  --ink: #17394b;
  --ink-soft: #315c6d;
  --coral: #e96445;
  --gold: #f3c85b;
  --mint: #8dd8c4;
  --glass: rgba(255, 246, 220, .82);
  --line: rgba(23, 57, 75, .34);
  --shadow: rgba(21, 58, 77, .24);
  --crystal-progress: 0%;
}

* { box-sizing: border-box; }

body {
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, rgba(19, 56, 75, .035) 0, rgba(19, 56, 75, .035) 1px, transparent 1px, transparent 4px),
    linear-gradient(110deg, rgba(255, 242, 214, .12), transparent 34%, transparent 72%, rgba(233, 100, 69, .08));
  mix-blend-mode: multiply;
}

button { font: inherit; }
.hidden { display: none !important; }

#ui-frame {
  position: fixed;
  inset: 12px;
  z-index: 9;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 62px;
  height: 62px;
  opacity: .66;
}

.corner::before,
.corner::after {
  content: "";
  position: absolute;
  background: var(--ink);
}

.corner::before { width: 100%; height: 1px; }
.corner::after { width: 1px; height: 100%; }
.corner-tl { top: 0; left: 0; }
.corner-tr { top: 0; right: 0; transform: rotate(90deg); }
.corner-bl { bottom: 0; left: 0; transform: rotate(-90deg); }
.corner-br { right: 0; bottom: 0; transform: rotate(180deg); }

.sky-panel {
  background:
    repeating-linear-gradient(0deg, rgba(23, 57, 75, .035) 0, rgba(23, 57, 75, .035) 1px, transparent 1px, transparent 5px),
    var(--glass);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 6px 7px 0 rgba(23, 57, 75, .11), 0 12px 30px var(--shadow);
  backdrop-filter: blur(12px) saturate(.86);
}

#hud {
  position: fixed;
  top: 28px;
  left: 30px;
  z-index: 10;
  width: 294px;
  padding: 16px 18px 17px;
  color: var(--ink);
  text-shadow: none;
  pointer-events: none;
  animation: hud-arrive .7s cubic-bezier(.2, .8, .2, 1) both;
}

#hud::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 92px;
  height: 5px;
  background: var(--coral);
}

.hud-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font: 700 10px/1.2 Georgia, serif;
  letter-spacing: 2.2px;
  text-transform: uppercase;
}

.hud-kicker::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

#title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 2px;
}

.title-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--paper-bright);
  font: 700 15px/1 Georgia, serif;
  letter-spacing: 0;
}

.title-mark::before {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: -1;
  background: var(--coral);
  border: 1px solid rgba(23, 57, 75, .38);
  transform: rotate(45deg);
}

.hud-rule {
  height: 1px;
  margin: 13px 0 11px;
  background: var(--line);
}

.count-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.count-label {
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 1.5px;
}

#count {
  margin: 0;
  color: var(--ink);
  font: 700 20px/1.1 Georgia, "Songti SC", serif;
  letter-spacing: 1px;
  white-space: nowrap;
}

#crystal-track {
  position: relative;
  height: 9px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--ink);
  background: rgba(255, 250, 240, .42);
}

#crystal-fill {
  width: var(--crystal-progress);
  height: 100%;
  background: var(--coral);
  transition: width .45s cubic-bezier(.2, .8, .2, 1), background-color .3s;
}

#crystal-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), rgba(23, 57, 75, .48) calc(10% - 1px), rgba(23, 57, 75, .48) 10%);
}

#crystal-note {
  min-height: 18px;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.55;
}

body.route-complete #crystal-fill { background: var(--gold); }

#mission {
  position: fixed;
  top: 102px;
  right: 30px;
  z-index: 10;
  width: 236px;
  padding: 14px 15px 15px;
  pointer-events: none;
  animation: mission-arrive .7s .1s cubic-bezier(.2, .8, .2, 1) both;
}

#mission::after {
  content: "ROUTE 01";
  position: absolute;
  right: -1px;
  top: -25px;
  padding: 5px 9px 4px;
  color: var(--paper-bright);
  background: var(--ink);
  font: 700 9px/1 Georgia, serif;
  letter-spacing: 1.6px;
}

.mission-heading {
  margin: 0 0 11px;
  color: var(--ink);
  font-family: "Songti SC", "STSong", serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
}

.mission-row {
  display: grid;
  grid-template-columns: 10px 23px 1fr auto;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  border-top: 1px solid rgba(23, 57, 75, .17);
  color: rgba(23, 57, 75, .6);
  font-size: 11px;
}

.mission-row:first-of-type { border-top-color: var(--line); }
.mission-index { color: var(--ink-soft); font: 700 9px/1 Georgia, serif; }

.mission-status {
  width: 8px;
  height: 8px;
  border: 1px solid var(--ink-soft);
  transform: rotate(45deg);
}

.mission-row.is-current { color: var(--ink); }
.mission-row.is-current .mission-status { border-color: var(--coral); background: var(--coral); }
.mission-row.is-done { color: var(--ink); }
.mission-row.is-done .mission-status { border-color: var(--mint); background: var(--mint); }
#mission-count { font: 700 11px/1 Georgia, serif; }

#mute {
  position: fixed;
  top: 28px;
  right: 30px;
  z-index: 11;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--glass);
  box-shadow: 4px 5px 0 rgba(23, 57, 75, .12);
  backdrop-filter: blur(12px);
  font-size: 18px;
  cursor: pointer;
  transition: transform .18s, background-color .18s, box-shadow .18s;
}

#mute:hover {
  transform: translateY(-2px);
  background: var(--paper-bright);
  box-shadow: 4px 7px 0 rgba(23, 57, 75, .12);
}

#mute:active {
  transform: translateY(1px);
  box-shadow: 2px 2px 0 rgba(23, 57, 75, .12);
}

#mute:focus-visible,
#win button:focus-visible,
#memory-preview button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

#hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 10;
  width: max-content;
  max-width: calc(100vw - 48px);
  min-height: 34px;
  padding: 9px 18px 8px 35px;
  color: var(--paper-bright);
  background: rgba(23, 57, 75, .78);
  border: 1px solid rgba(255, 242, 214, .52);
  border-radius: 3px;
  box-shadow: 5px 6px 0 rgba(23, 57, 75, .16);
  text-align: center;
  text-shadow: none;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: .5px;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
}

#hint::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  background: var(--coral);
  transform: translateY(-50%) rotate(45deg);
}

body.touch-mode #hint {
  bottom: max(126px, calc(env(safe-area-inset-bottom) + 112px));
  max-width: calc(100% - 32px);
  white-space: normal;
}

#toast {
  position: fixed;
  top: 20%;
  left: 50%;
  z-index: 30;
  max-width: min(520px, calc(100vw - 36px));
  padding: 11px 18px 10px 42px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  box-shadow: 7px 8px 0 rgba(23, 57, 75, .15);
  text-shadow: none;
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  transform: translateX(-50%) rotate(-1deg);
}

#toast::before {
  content: "*";
  position: absolute;
  left: 17px;
  top: 50%;
  color: var(--coral);
  font: 700 20px/1 Georgia, serif;
  transform: translateY(-43%);
}

#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: none;
  pointer-events: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#touch-controls.visible { display: block; }

#stick-base {
  position: absolute;
  display: none;
  width: 112px;
  height: 112px;
  border: 1px solid rgba(23, 57, 75, .68);
  border-radius: 50%;
  background: rgba(255, 242, 214, .35);
  box-shadow: inset 0 0 0 8px rgba(255, 242, 214, .13), 4px 6px 0 rgba(23, 57, 75, .12);
  backdrop-filter: blur(5px);
  transform: translate(-50%, -50%);
}

#stick-base::before,
#stick-base::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(23, 57, 75, .23);
  transform: translate(-50%, -50%);
}

#stick-base::before { width: 68%; height: 1px; }
#stick-base::after { width: 1px; height: 68%; }

#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 3px 4px 0 rgba(23, 57, 75, .16);
  transform: translate(-50%, -50%);
}

#jump-touch {
  position: absolute;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  width: 82px;
  height: 82px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  color: var(--paper-bright);
  background: rgba(233, 100, 69, .82);
  box-shadow: 4px 6px 0 rgba(23, 57, 75, .16);
  backdrop-filter: blur(5px);
  font: 700 16px/1 "Songti SC", "STSong", serif;
  letter-spacing: 2px;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#jump-touch:active {
  background: rgba(233, 100, 69, .95);
  box-shadow: 2px 2px 0 rgba(23, 57, 75, .16);
  transform: translateY(2px) scale(.96);
}

#hud,
#mission,
#hint,
#mute,
#ui-frame,
#touch-controls {
  transition: opacity .25s, visibility .25s;
}

body.cinematic #hud,
body.cinematic #mission,
body.cinematic #hint,
body.cinematic #mute,
body.cinematic #ui-frame,
body.cinematic #touch-controls {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.minigame {
  overflow: hidden;
}

body.minigame canvas {
  touch-action: none;
}

body.minigame #hud,
body.minigame #mission,
body.minigame #hint,
body.minigame #ui-frame,
body.minigame #touch-controls,
body.minigame #mg-start,
body.minigame #heart-start {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.minigame #mute {
  top: max(20px, env(safe-area-inset-top));
  right: max(82px, calc(env(safe-area-inset-right) + 82px));
  z-index: 32;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#mg-start {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 18;
  min-width: 148px;
  min-height: 48px;
  padding: 12px 24px;
  color: var(--paper-bright);
  background: rgba(23, 57, 75, .9);
  border: 0;
  clip-path: polygon(5% 8%, 96% 0, 100% 76%, 91% 100%, 3% 91%, 0 24%);
  filter: drop-shadow(5px 7px 7px rgba(21, 58, 77, .24));
  font-family: "Songti SC", "STSong", serif;
  font-weight: 700;
  letter-spacing: 2px;
  transform: translateX(-50%);
  touch-action: none;
}

#mg-start:active {
  transform: translateX(-50%) translateY(2px) scale(.98);
}

#heart-start {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 19;
  min-width: 190px;
  min-height: 48px;
  padding: 12px 24px;
  color: var(--paper-bright);
  background: rgba(34, 90, 104, .94);
  border: 1px solid rgba(159, 232, 255, .78);
  clip-path: polygon(5% 8%, 96% 0, 100% 76%, 91% 100%, 3% 91%, 0 24%);
  filter: drop-shadow(0 0 10px rgba(63, 212, 255, .48)) drop-shadow(5px 7px 7px rgba(21, 58, 77, .24));
  font-family: "Songti SC", "STSong", serif;
  font-weight: 700;
  letter-spacing: 2px;
  transform: translateX(-50%);
  touch-action: none;
}

#heart-start:focus-visible {
  outline: 2px solid rgba(255, 250, 240, .92);
  outline-offset: 4px;
}

#heart-start:active {
  transform: translateX(-50%) translateY(2px) scale(.98);
}

#mg-hud {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 22;
  width: min(330px, calc(100vw - 136px));
  padding: 13px 18px 15px;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(23, 57, 75, .03) 0, rgba(23, 57, 75, .03) 1px, transparent 1px, transparent 5px),
    rgba(255, 242, 214, .88);
  clip-path: polygon(3% 8%, 95% 0, 100% 20%, 97% 88%, 86% 100%, 5% 94%, 0 72%);
  filter: drop-shadow(8px 10px 9px rgba(21, 58, 77, .2));
  transform: translateX(-50%) rotate(-.35deg);
  pointer-events: none;
}

.mg-kicker,
.mg-result-kicker {
  color: var(--coral);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.mg-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin: 4px 0 8px;
}

#mg-layers {
  font: 800 25px/1.1 "Songti SC", "STSong", serif;
}

#mg-combo {
  color: rgba(23, 57, 75, .72);
  font-size: 11px;
  letter-spacing: .5px;
}

.mg-energy-pips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin: -1px 1px 8px;
}

.mg-energy-pips i {
  display: block;
  height: 7px;
  background: rgba(23, 57, 75, .13);
  border: 1px solid rgba(23, 57, 75, .12);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .26);
  transition: background-color .12s, box-shadow .12s, transform .12s;
}

.mg-energy-pips i.lit {
  background: #f3c85b;
  border-color: rgba(230, 151, 39, .48);
  box-shadow: 0 0 8px rgba(243, 200, 91, .72);
  transform: scaleY(1.08);
}

.mg-energy-pips.danger i.lit {
  background: #ef6f62;
  box-shadow: 0 0 9px rgba(239, 111, 98, .76);
}

.mg-judgments {
  position: fixed;
  left: 50%;
  top: 30%;
  z-index: 24;
  width: min(300px, calc(100vw - 48px));
  height: 84px;
  transform: translateX(-50%);
  pointer-events: none;
}

.mg-judgments span {
  position: absolute;
  inset: 26px 0 auto;
  color: #fff7d6;
  font: 800 18px/1 "Songti SC", "STSong", serif;
  letter-spacing: 1.2px;
  text-align: center;
  text-shadow: 0 2px 10px rgba(14, 41, 57, .9);
  opacity: 0;
}

.mg-judgments span.perfect,
.mg-judgments span.quick,
.mg-judgments span.good { color: #ffe08c; }
.mg-judgments span.miss,
.mg-judgments span.whiff { color: #ff9c9c; }

#mg-combo.near-best {
  color: var(--gold) !important;
  text-shadow: 0 0 10px rgba(214, 166, 63, .48) !important;
}

.mg-stability {
  height: 5px;
  overflow: hidden;
  background: rgba(23, 57, 75, .14);
  transform: skewX(-12deg);
}

#mg-stability-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width .18s, background-color .18s;
}

#mg-guide {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 23;
  max-width: calc(100vw - 42px);
  padding: 10px 17px;
  color: var(--paper-bright);
  background: rgba(23, 57, 75, .78);
  clip-path: polygon(3% 8%, 96% 0, 100% 70%, 91% 100%, 4% 90%, 0 35%);
  font-size: 12px;
  letter-spacing: .8px;
  transform: translateX(-50%);
  pointer-events: none;
}

#mg-exit {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 31;
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--ink);
  background: rgba(255, 242, 214, .86);
  border: 0;
  border-radius: 50%;
  filter: drop-shadow(4px 6px 7px rgba(21, 58, 77, .2));
  font-size: 19px;
  line-height: 48px;
  touch-action: none;
}

#mg-result {
  position: fixed;
  inset: 0;
  z-index: 29;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 49, 66, .42);
  backdrop-filter: blur(7px) saturate(.78);
}

#mg-result .panel {
  position: relative;
  width: min(500px, calc(100vw - 36px));
  padding: 36px 40px 32px;
  overflow: hidden;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(23, 57, 75, .035) 0, rgba(23, 57, 75, .035) 1px, transparent 1px, transparent 5px),
    rgba(255, 242, 214, .97);
  clip-path: polygon(2% 5%, 94% 0, 100% 13%, 97% 88%, 86% 100%, 7% 96%, 0 82%, 1% 21%);
  filter: drop-shadow(14px 18px 20px rgba(12, 40, 57, .28));
  text-align: left;
  animation: result-arrive .45s cubic-bezier(.2, .85, .2, 1) both;
}

#mg-result h1 {
  margin: 8px 0 10px;
  font: 800 clamp(28px, 7vw, 42px)/1.08 "Songti SC", "STSong", serif;
  letter-spacing: 1px;
}

#mg-result-summary,
#mg-result-best {
  margin: 7px 0;
  color: rgba(23, 57, 75, .78);
  line-height: 1.55;
}

#mg-result-stars {
  margin: 17px 0 10px;
  color: var(--gold);
  font: 800 30px/1 Georgia, serif;
  letter-spacing: 7px;
}

#mg-result .actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

#mg-result button {
  min-height: 44px;
  padding: 10px 18px;
  color: var(--ink);
  background: rgba(255, 250, 240, .76);
  border: 0;
  clip-path: polygon(4% 8%, 96% 0, 100% 78%, 91% 100%, 3% 91%, 0 25%);
  font-weight: 700;
  letter-spacing: 1px;
}

#mg-retry {
  color: var(--paper-bright) !important;
  background: var(--coral) !important;
}

#mg-result button:focus-visible,
#mg-start:focus-visible,
#mg-exit:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

#win {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 49, 66, .42);
  backdrop-filter: blur(7px) saturate(.78);
}

#win.hidden { display: none; }

#win .panel {
  position: relative;
  width: min(560px, calc(100vw - 36px));
  padding: 38px 42px 34px;
  overflow: hidden;
  text-align: left;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(23, 57, 75, .035) 0, rgba(23, 57, 75, .035) 1px, transparent 1px, transparent 5px),
    rgba(255, 242, 214, .96);
  border: 1px solid var(--ink);
  border-radius: 4px;
  box-shadow: 12px 14px 0 rgba(23, 57, 75, .22), 0 30px 70px rgba(12, 40, 57, .3);
  animation: result-arrive .55s cubic-bezier(.2, .85, .2, 1) both;
}

#win .panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 8px;
  background: repeating-linear-gradient(135deg, var(--coral) 0, var(--coral) 13px, var(--paper-bright) 13px, var(--paper-bright) 20px);
}

.win-kicker {
  color: var(--coral);
  font: 700 10px/1 Georgia, serif;
  letter-spacing: 2.4px;
  text-transform: uppercase;
}

#win h1 {
  margin: 8px 0 12px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(27px, 5vw, 38px);
  line-height: 1.15;
  letter-spacing: 2px;
}

#win p {
  max-width: 430px;
  margin: 0 0 15px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.8;
}

#win-stats {
  margin: 0 0 24px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 250, 240, .5);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font: 700 14px/1.4 Georgia, "Songti SC", serif;
  letter-spacing: 1px;
}

#win .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 9px;
}

#win button {
  min-height: 42px;
  margin: 0;
  padding: 10px 17px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  color: var(--ink);
  background: var(--paper-bright);
  box-shadow: 3px 4px 0 rgba(23, 57, 75, .13);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform .16s, box-shadow .16s, background-color .16s;
}

#win button:hover {
  transform: translateY(-2px);
  box-shadow: 3px 6px 0 rgba(23, 57, 75, .13);
}

#win button:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(23, 57, 75, .13);
}

#save-shot { color: var(--paper-bright); background: var(--coral); }
#keep { color: var(--paper-bright); background: var(--ink); }
/* 「重新开始」会清档：降到次要样式、放在末位，不许长得像主按钮 */
#again {
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(23, 57, 75, .28);
  opacity: .78;
}
#again.armed {
  color: var(--paper-bright);
  background: var(--coral);
  border-color: transparent;
  opacity: 1;
}

#memory-preview {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px;
  color: var(--paper-bright);
  background: rgba(13, 39, 54, .96);
}

#memory-preview img {
  max-width: 100%;
  max-height: calc(100% - 82px);
  object-fit: contain;
  border: 1px solid rgba(255, 242, 214, .58);
  box-shadow: 9px 11px 0 rgba(0, 0, 0, .2);
}

#memory-preview button {
  min-height: 40px;
  padding: 8px 19px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-bright);
  border-radius: 3px;
  cursor: pointer;
}

@keyframes hud-arrive {
  from { opacity: 0; transform: translate(-12px, -8px); }
  to { opacity: 1; transform: none; }
}

@keyframes mission-arrive {
  from { opacity: 0; transform: translate(12px, -8px); }
  to { opacity: 1; transform: none; }
}

@keyframes result-arrive {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) {
  #ui-frame { inset: 8px; }
  .corner { width: 36px; height: 36px; }
  #hud {
    top: 16px;
    left: 16px;
    width: min(278px, calc(100vw - 84px));
    padding: 12px 14px 13px;
  }
  .hud-kicker { margin-bottom: 3px; font-size: 8px; }
  #title { font-size: 20px; }
  .title-mark { width: 24px; height: 24px; font-size: 12px; }
  .hud-rule { margin: 9px 0 8px; }
  #count { font-size: 17px; }
  #mission { display: none; }
  #mute { top: 16px; right: 16px; width: 44px; height: 44px; }
  body.minigame #mute {
    top: max(76px, calc(env(safe-area-inset-top) + 76px));
    right: max(8px, env(safe-area-inset-right));
  }
  #hint {
    bottom: 14px;
    max-width: calc(100vw - 28px);
    padding: 8px 12px 7px 28px;
    white-space: normal;
  }
  #hint::before { left: 11px; }
  #toast { top: 18%; font-size: 15px; line-height: 1.45; }
  #win .panel { padding: 32px 20px 24px; }
  #win h1 { letter-spacing: 1px; }
  #win p { line-height: 1.65; }
  #win .actions { display: grid; grid-template-columns: 1fr 1fr; }
  #win button { width: 100%; padding: 9px 10px; }
  #save-shot { grid-column: 1 / -1; }
  #mg-hud { top: 14px; width: min(282px, calc(100vw - 124px)); padding: 11px 15px 13px; }
  #mg-layers { font-size: 21px; }
  #mg-exit { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
  #mg-result .panel { padding: 31px 21px 25px; }
  #mg-result .actions { display: grid; grid-template-columns: 1fr 1fr; }
  #mg-result button { width: 100%; padding: 10px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
}

#ui-frame { display: none; }

.sky-panel {
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

#hud {
  isolation: isolate;
  padding: 16px 19px 18px;
}

#hud::before {
  top: -2px;
  left: 16px;
  width: 62px;
  height: 7px;
  z-index: -1;
  border-radius: 58% 42% 62% 38%;
  transform: rotate(-2deg) skewX(-18deg);
}

#hud::after {
  content: "";
  position: absolute;
  inset: -4px -11px -8px -7px;
  z-index: -2;
  background:
    repeating-linear-gradient(0deg, rgba(23, 57, 75, .03) 0, rgba(23, 57, 75, .03) 1px, transparent 1px, transparent 5px),
    rgba(255, 242, 214, .84);
  clip-path: polygon(2% 8%, 89% 1%, 100% 18%, 96% 82%, 83% 100%, 7% 94%, 0 72%);
  filter: drop-shadow(7px 10px 10px rgba(21, 58, 77, .17));
  backdrop-filter: blur(9px) saturate(.82);
}

.hud-rule {
  width: 48px;
  height: 4px;
  margin: 12px 0 10px;
  border-radius: 55% 45% 40% 60%;
  background: var(--coral);
  opacity: .82;
  transform: rotate(-1deg) skewX(-24deg);
}

.title-mark::before {
  border: 0;
  clip-path: polygon(48% 0, 100% 42%, 71% 100%, 10% 84%, 0 31%);
  transform: rotate(17deg);
}

#crystal-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 18px;
  margin: 6px 2px 0;
  overflow: visible;
  border: 0;
  background: none;
}

#crystal-track::after { display: none; }
#crystal-fill { display: none; }

.crystal-point {
  display: block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: rgba(23, 57, 75, .24);
  clip-path: polygon(50% 0, 100% 44%, 70% 100%, 10% 78%, 0 31%);
  transform: rotate(15deg);
  transition: background-color .25s, transform .25s, filter .25s;
}

.crystal-point:nth-child(2n) { transform: rotate(42deg) scale(.82); }
.crystal-point:nth-child(3n) { transform: rotate(-8deg) scale(1.08); }
.crystal-point.is-lit {
  background: var(--coral);
  filter: drop-shadow(0 2px 3px rgba(233, 100, 69, .36));
  transform: rotate(28deg) scale(1.22);
}

#mission {
  top: 96px;
  width: 218px;
  padding: 14px 7px 13px 20px;
  isolation: isolate;
  text-shadow: 0 1px 4px rgba(255, 250, 240, .9);
}

#mission::before {
  content: "";
  position: absolute;
  inset: -5px -10px -7px -15px;
  z-index: -1;
  background: rgba(255, 242, 214, .62);
  clip-path: polygon(7% 6%, 94% 0, 100% 29%, 91% 91%, 66% 100%, 4% 88%, 0 32%);
  filter: drop-shadow(5px 8px 9px rgba(21, 58, 77, .13));
  backdrop-filter: blur(7px) saturate(.8);
}

#mission::after {
  top: -14px;
  right: 7px;
  padding: 0;
  color: var(--ink-soft);
  background: none;
  text-shadow: 0 1px 4px rgba(255, 250, 240, .9);
  transform: rotate(2deg);
}

.mission-heading {
  margin: 0 0 8px 12px;
  transform: rotate(-1.2deg);
}

.mission-row {
  min-height: 30px;
  border: 0;
}

#mission-crystals { transform: translateX(-7px) rotate(-1deg); }
#mission-heart { transform: translateX(14px) rotate(1.2deg); }

.mission-status {
  border: 0;
  background: rgba(23, 57, 75, .24);
  clip-path: polygon(50% 0, 100% 44%, 70% 100%, 10% 78%, 0 31%);
}

#mute {
  border: 0;
  background: rgba(255, 242, 214, .68);
  box-shadow: none;
  filter: drop-shadow(3px 5px 7px rgba(21, 58, 77, .18));
  clip-path: circle(48% at 50% 50%);
}

#mute:hover {
  background: rgba(255, 250, 240, .9);
  box-shadow: none;
}

#hint {
  border: 0;
  border-radius: 0;
  background: rgba(23, 57, 75, .72);
  box-shadow: none;
  clip-path: polygon(3% 9%, 96% 0, 100% 64%, 91% 100%, 4% 89%, 0 39%);
}

#toast {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  clip-path: polygon(3% 7%, 93% 0, 100% 58%, 88% 100%, 5% 89%, 0 31%);
  filter: drop-shadow(7px 9px 8px rgba(23, 57, 75, .16));
}

#stick-base,
#stick-knob,
#jump-touch {
  border: 0;
  box-shadow: none;
  filter: drop-shadow(3px 5px 6px rgba(21, 58, 77, .18));
}

#stick-base { background: rgba(255, 242, 214, .28); }
#stick-knob { background: rgba(255, 242, 214, .78); }
#jump-touch { background: rgba(233, 100, 69, .84); }

#win .panel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  clip-path: polygon(2% 5%, 94% 0, 100% 13%, 97% 88%, 86% 100%, 7% 96%, 0 82%, 1% 21%);
  filter: drop-shadow(14px 18px 20px rgba(12, 40, 57, .26));
}

#win .panel::before {
  left: 28px;
  right: auto;
  top: 9px;
  width: 84px;
  height: 6px;
  border-radius: 55% 45% 60% 40%;
  background: var(--coral);
  transform: rotate(-2deg) skewX(-20deg);
}

#win-stats {
  padding: 4px 0 9px;
  border: 0;
  background: none;
}

#win button {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  clip-path: polygon(4% 8%, 96% 0, 100% 78%, 91% 100%, 3% 91%, 0 25%);
}

#win button:hover { box-shadow: none; }
#keep { background: rgba(255, 250, 240, .72); }

#memory-preview img,
#memory-preview button {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) {
  #hud { padding: 12px 15px 13px; }
  #hud::after { inset: -3px -8px -7px -5px; }
  .hud-rule { margin: 8px 0 7px; }
  #crystal-track { height: 15px; margin-top: 4px; gap: 5px; }
  .crystal-point { width: 6px; height: 6px; }
}

/* 主界面直接列出已上线小游戏，避免入口只藏在远处岛屿里。 */
#minigame-dock {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid rgba(92, 134, 156, .2);
  pointer-events: auto;
}

.minigame-dock-label {
  display: block;
  margin-bottom: 7px;
  color: rgba(45, 79, 91, .68);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .18em;
}

.minigame-dock-actions {
  display: grid;
  grid-template-columns: .78fr 1.22fr;
  gap: 7px;
}

.minigame-dock-actions button {
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid rgba(74, 115, 128, .2);
  border-radius: 9px;
  color: #355865;
  background: rgba(232, 241, 227, .76);
  box-shadow: 0 5px 13px rgba(57, 85, 91, .08);
  font: 700 11px/1.15 "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: .04em;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

/* 未发现的挑战：锁定态可见，让玩家知道"这里还有内容" */
.minigame-dock-actions button.is-locked {
  color: rgba(53, 88, 101, .5);
  background: rgba(232, 241, 227, .32);
  border-style: dashed;
  box-shadow: none;
  letter-spacing: .18em;
}

.minigame-dock-actions button:hover,
.minigame-dock-actions button:focus-visible {
  transform: translateY(-1px);
  outline: none;
  background: rgba(245, 248, 236, .96);
  box-shadow: 0 7px 16px rgba(57, 85, 91, .13);
}

.minigame-dock-actions button:active {
  transform: translateY(1px);
}

.minigame-dock-actions .is-featured {
  color: #f7fff3;
  border-color: rgba(50, 112, 87, .38);
  background: linear-gradient(135deg, rgba(71, 142, 103, .94), rgba(69, 126, 139, .94));
  box-shadow: 0 7px 17px rgba(40, 100, 83, .2);
}

.minigame-dock-actions .is-featured:hover,
.minigame-dock-actions .is-featured:focus-visible {
  background: linear-gradient(135deg, rgba(79, 156, 112, .98), rgba(72, 139, 150, .98));
}

body.cinematic #minigame-dock,
body.minigame #minigame-dock {
  pointer-events: none;
}

/* 蘑菇微谷：紫青荧光只在玩法运行时接管通用 HUD，不污染其他挑战。 */
.minigame-dock-actions button.is-spore {
  border-color: rgba(198, 156, 255, .62);
  background: linear-gradient(145deg, rgba(88, 48, 119, .9), rgba(35, 101, 91, .9));
  color: #f5eaff;
}

/* 断塔遗迹：冷青光脉与暖金出口保持同屏可辨。 */
.minigame-dock-actions button.is-ruin {
  border-color: rgba(112, 216, 255, .64);
  background: linear-gradient(145deg, rgba(35, 56, 82, .94), rgba(69, 65, 101, .92));
  color: #e8faff;
}

/* 余烬秋庭：暖橙火光与安全盆的奶油青形成明确风险二选一。 */
.minigame-dock-actions button.is-ember {
  border-color: rgba(255, 143, 79, .7);
  background: linear-gradient(145deg, rgba(108, 43, 37, .94), rgba(112, 72, 39, .92));
  color: #fff2d1;
}

/* 绿洲花园：青蓝水脉与花粉暖粉形成可读的路线／目标对照。 */
.minigame-dock-actions button.is-oasis {
  border-color: rgba(98, 216, 195, .72);
  background: linear-gradient(145deg, rgba(25, 83, 91, .95), rgba(82, 67, 92, .92));
  color: #effff9;
}

/* 风车云镇：青色安全风环与金色冒险环维持明确二选一。 */
.minigame-dock-actions button.is-glide {
  border-color: rgba(142, 233, 225, .72);
  background: linear-gradient(145deg, rgba(32, 91, 111, .95), rgba(70, 83, 113, .92));
  color: #f2fffd;
}

body.minigame.mg-glide #mg-hud {
  border-color: rgba(142, 233, 225, .7);
  box-shadow: 0 16px 40px rgba(20, 69, 88, .36), inset 0 0 28px rgba(255, 213, 106, .08);
}

body.minigame.mg-glide #mg-stability-fill {
  background: linear-gradient(90deg, #47b9c8, #8ee9e1 58%, #ffd56a);
  box-shadow: 0 0 14px rgba(92, 222, 216, .68);
}

body.minigame.mg-glide #mg-guide {
  border-color: rgba(142, 233, 225, .5);
  background: rgba(27, 63, 82, .9);
}

@media (max-width: 680px) {
  body.minigame.mg-glide #mg-hud {
    top: max(8px, env(safe-area-inset-top));
    left: 50%;
    width: min(266px, calc(100vw - 124px));
    padding: 9px 12px 11px;
  }

  body.minigame.mg-glide .mg-score-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    margin: 2px 0 6px;
  }

  body.minigame.mg-glide #mg-layers,
  body.minigame.mg-glide #mg-combo {
    white-space: nowrap;
  }
}

body.minigame.mg-oasis #mg-hud {
  border-color: rgba(98, 216, 195, .68);
  box-shadow: 0 16px 40px rgba(18, 65, 72, .38), inset 0 0 28px rgba(255, 168, 207, .08);
}

body.minigame.mg-oasis #mg-stability-fill {
  background: linear-gradient(90deg, #4fc8c2, #9ce9d5 58%, #ffa8cf);
}

body.minigame.mg-ember #mg-hud {
  border-color: rgba(255, 143, 79, .64);
  box-shadow: 0 16px 40px rgba(70, 27, 20, .36), inset 0 0 28px rgba(255, 209, 102, .1);
}

body.minigame.mg-ember #mg-stability-fill {
  background: linear-gradient(90deg, #ff754f, #ffad58 58%, #ffe39a);
  box-shadow: 0 0 14px rgba(255, 122, 71, .76);
}

body.minigame.mg-ember #mg-guide {
  border-color: rgba(255, 181, 105, .52);
  background: rgba(67, 29, 27, .9);
}

@media (max-width: 680px) {
  body.minigame.mg-ember #mg-hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    width: min(260px, calc(100vw - 124px));
    padding: 9px 12px 11px;
    transform: rotate(-.28deg);
  }

  body.minigame.mg-ember .mg-score-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    margin: 2px 0 6px;
  }

  body.minigame.mg-ember #mg-layers { font-size: 18px; white-space: nowrap; }
  body.minigame.mg-ember #mg-combo {
    overflow: hidden;
    font-size: 9px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.minigame.mg-ember #mg-stability-fill,
  .minigame-dock-actions button.is-ember { transition: none; }
}

body.minigame.mg-ruin #mg-hud {
  border-color: rgba(112, 216, 255, .62);
  box-shadow: 0 16px 40px rgba(19, 29, 52, .38), inset 0 0 28px rgba(255, 217, 120, .08);
}

body.minigame.mg-ruin #mg-stability-fill {
  background: linear-gradient(90deg, #70d8ff, #b5a9ff 62%, #ffd978);
  box-shadow: 0 0 14px rgba(112, 216, 255, .72);
}

body.minigame.mg-ruin #mg-guide {
  border-color: rgba(112, 216, 255, .5);
  background: rgba(25, 31, 50, .9);
}

@media (max-width: 680px) {
  body.minigame.mg-ruin #mg-hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    width: min(258px, calc(100vw - 124px));
    padding: 9px 12px 11px;
    transform: rotate(-.35deg);
  }

  body.minigame.mg-ruin .mg-score-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    margin: 2px 0 6px;
  }

  body.minigame.mg-ruin #mg-layers {
    font-size: 18px;
    white-space: nowrap;
  }

  body.minigame.mg-ruin #mg-combo {
    overflow: hidden;
    font-size: 9px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.minigame.mg-ruin #mg-stability-fill,
  .minigame-dock-actions button.is-ruin { transition: none; }
}

body.minigame.mg-spore #mg-hud {
  border-color: rgba(198, 156, 255, .6);
  box-shadow: 0 16px 40px rgba(32, 14, 55, .34), inset 0 0 28px rgba(143, 255, 213, .08);
}

body.minigame.mg-spore #mg-stability-fill {
  background: linear-gradient(90deg, #8fffd5, #c69cff 62%, #ffe783);
  box-shadow: 0 0 14px rgba(198, 156, 255, .7);
}

body.minigame.mg-spore #mg-guide {
  border-color: rgba(143, 255, 213, .45);
  background: rgba(28, 20, 47, .88);
}

@media (max-width: 680px) {
  body.minigame.mg-spore #mg-hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    width: min(258px, calc(100vw - 124px));
    padding: 9px 12px 11px;
    transform: rotate(-.35deg);
  }

  body.minigame.mg-spore .mg-score-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    margin: 2px 0 6px;
  }

  body.minigame.mg-spore #mg-layers {
    font-size: 18px;
    white-space: nowrap;
  }

  body.minigame.mg-spore #mg-combo {
    overflow: hidden;
    font-size: 9px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.minigame.mg-spore #mg-stability-fill,
  .minigame-dock-actions button.is-spore {
    transition: none;
  }
}

@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) {
  #minigame-dock {
    margin-top: 9px;
    padding-top: 8px;
  }

  .minigame-dock-actions button {
    min-height: 32px;
    padding: 6px 7px;
    font-size: 10px;
  }
}

/* ---------- 天空航图投影 v2 ---------- */

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#sky-route-overlay {
  position: fixed;
  inset: 0;
  z-index: 9;
  width: 100vw;
  height: 100vh;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  transition: opacity .28s ease;
}

#sky-route-overlay.is-visible { opacity: .92; }

.sky-route-path {
  fill: none;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.sky-route-shadow {
  stroke: rgba(23, 57, 75, .44);
  stroke-width: 4px;
  filter: blur(2px);
}

.sky-route-coral {
  stroke: var(--coral);
  stroke-width: 1.7px;
  stroke-dasharray: 48 52;
  filter: drop-shadow(0 0 4px rgba(233, 100, 69, .58));
}

.sky-route-mint {
  stroke: var(--mint);
  stroke-width: 1.7px;
  stroke-dasharray: 57 43;
  stroke-dashoffset: -46;
  filter: drop-shadow(0 0 4px rgba(141, 216, 196, .54));
}

body.cinematic #sky-route-overlay,
body.minigame #sky-route-overlay,
body.route-complete #sky-route-overlay {
  opacity: 0;
}

#route-pointer {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 13;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 11px 7px 8px;
  color: var(--paper-bright);
  background: rgba(23, 57, 75, .82);
  border: 1px solid rgba(159, 232, 255, .72);
  border-radius: 18px;
  box-shadow: 0 5px 14px rgba(12, 40, 57, .3);
  font: 700 11px/1 "Songti SC", "STSong", "Microsoft YaHei", serif;
  letter-spacing: .06em;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

#route-pointer.hidden { display: none; }

.route-pointer-arrow {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #9fe8ff;
  font: 900 18px/1 system-ui, sans-serif;
  transform: rotate(var(--route-arrow-angle, 0deg));
  filter: drop-shadow(0 0 5px rgba(63, 212, 255, .75));
}

#route-pointer.is-onscreen .route-pointer-arrow {
  font-size: 0;
  transform: none;
}

#route-pointer.is-onscreen .route-pointer-arrow::after {
  content: "✦";
  font-size: 16px;
}

body.cinematic #route-pointer,
body.minigame #route-pointer,
body.route-complete #route-pointer {
  display: none;
}

/* ---------- 阶段 3：航线回响、岛屿发现与旅途总结 ---------- */

#stage-notice,
#island-discovery {
  position: fixed;
  z-index: 29;
  display: grid;
  gap: 4px;
  width: min(360px, calc(100vw - 36px));
  padding: 13px 17px 14px 20px;
  color: var(--paper-bright);
  background: rgba(23, 57, 75, .82);
  border-left: 4px solid var(--coral);
  box-shadow: 0 10px 28px rgba(12, 40, 57, .24);
  clip-path: polygon(2% 4%, 94% 0, 100% 18%, 97% 88%, 88% 100%, 4% 94%, 0 72%);
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .3s ease, transform .3s ease;
}

#stage-notice {
  top: 20%;
  left: 50%;
  border-left-color: var(--gold);
  transform: translateX(-50%);
  text-align: center;
}

#island-discovery {
  right: 28px;
  bottom: 70px;
}

/* 发现卡出现时只压暗引导条，不再整条隐藏：
   新手在第一座岛上正对着「WASD 移动」学操作，发现卡一来教学就消失了。 */
body.island-discovery-active #hint {
  opacity: .45;
}

#stage-notice.is-leaving {
  opacity: 0;
  transform: translate(-50%, -8px);
}

#island-discovery.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}

/* ---------- 阶段 4A：一次性轻机制教学 ---------- */

#mechanic-notice {
  position: fixed;
  left: 50%;
  bottom: 70px;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 14px;
  width: min(430px, calc(100vw - 36px));
  padding: 14px 14px 14px 20px;
  color: var(--paper-bright);
  background: rgba(23, 57, 75, .9);
  border-left: 4px solid var(--mint);
  box-shadow: 0 12px 30px rgba(12, 40, 57, .28);
  clip-path: polygon(2% 4%, 94% 0, 100% 18%, 97% 88%, 88% 100%, 4% 94%, 0 72%);
  pointer-events: none;
  opacity: 1;
  transform: translateX(-50%);
  transition: opacity .3s ease, transform .3s ease;
}

#mechanic-notice.is-leaving {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.mechanic-notice-kicker,
#mechanic-notice-title,
#mechanic-notice-copy {
  grid-column: 1;
}

.mechanic-notice-kicker {
  color: rgba(255, 250, 240, .7);
  font: 700 9px/1.2 Georgia, "Songti SC", serif;
  letter-spacing: .2em;
  text-transform: uppercase;
}

#mechanic-notice-title {
  font: 700 19px/1.35 "Songti SC", "STSong", "Microsoft YaHei", serif;
  letter-spacing: .08em;
}

#mechanic-notice-copy {
  color: rgba(255, 250, 240, .88);
  font-size: 12px;
  line-height: 1.55;
}

#mechanic-notice-close {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  min-width: 68px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 250, 240, .52);
  color: var(--paper-bright);
  background: rgba(255, 250, 240, .1);
  font: 700 12px/1.2 "Songti SC", "STSong", "Microsoft YaHei", serif;
  cursor: pointer;
  pointer-events: auto;
}

#mechanic-notice-close:hover,
#mechanic-notice-close:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  background: rgba(255, 250, 240, .2);
}

body.mechanic-notice-active #hint {
  opacity: 0;
  visibility: hidden;
}

body.cinematic #mechanic-notice,
body.minigame #mechanic-notice {
  display: none;
}

.stage-notice-kicker,
.island-discovery-kicker {
  color: rgba(255, 250, 240, .7);
  font: 700 9px/1.2 Georgia, "Songti SC", serif;
  letter-spacing: .2em;
  text-transform: uppercase;
}

#stage-notice-title,
#island-discovery-title {
  font: 700 19px/1.35 "Songti SC", "STSong", "Microsoft YaHei", serif;
  letter-spacing: .08em;
}

#stage-notice-copy,
#island-discovery-copy {
  color: rgba(255, 250, 240, .88);
  font-size: 12px;
  line-height: 1.55;
}

#win .panel {
  max-height: calc(100vh - 36px);
  overflow: auto;
}

#win-stats {
  display: grid;
  gap: 10px;
  text-align: left;
}

.journey-primary {
  color: #2f5f99;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.journey-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.journey-count {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  color: #4a6b96;
  background: rgba(220, 232, 247, .56);
  font-size: 11px;
}

.journey-count strong {
  color: #2a4d7c;
  font: 700 20px/1.1 Georgia, "Songti SC", serif;
}

.journey-challenges {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.journey-challenges li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 5px;
  border-top: 1px solid rgba(42, 77, 124, .15);
  color: #4a6b96;
  font-size: 12px;
}

.journey-challenges strong {
  color: #2a4d7c;
  font-weight: 700;
}

body.cinematic #stage-notice,
body.minigame #stage-notice,
body.cinematic #island-discovery,
body.minigame #island-discovery {
  display: none;
}

@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) {
  #stage-notice {
    top: max(148px, calc(env(safe-area-inset-top) + 134px));
    width: min(328px, calc(100vw - 28px));
  }

  #island-discovery {
    top: max(148px, calc(env(safe-area-inset-top) + 134px));
    right: 14px;
    bottom: auto;
    width: min(310px, calc(100vw - 28px));
  }

  #mechanic-notice {
    /* 提示始终位于触屏底部引导上方；保留 16px 呼吸，不依赖其淡出完成。 */
    bottom: max(176px, calc(env(safe-area-inset-bottom) + 162px));
    width: min(352px, calc(100vw - 28px));
  }

  #mechanic-notice-title { font-size: 17px; }

  #stage-notice-title,
  #island-discovery-title {
    font-size: 17px;
  }

  #win-stats { gap: 8px; }
  .journey-primary { font-size: 13px; }
  .journey-count { padding: 7px 8px; }
  .journey-count strong { font-size: 18px; }
  .journey-challenges li { font-size: 11px; }
}

/* 手机横屏低高度：发现卡横向让出右下跳跃按钮。 */
@media (orientation: landscape) and (max-height: 480px) {
  body.touch-mode #island-discovery {
    top: auto;
    right: max(124px, calc(env(safe-area-inset-right) + 112px));
    bottom: max(18px, env(safe-area-inset-bottom));
    width: min(340px, calc(100vw - 280px));
  }

  body.touch-mode #mechanic-notice {
    left: auto;
    right: max(124px, calc(env(safe-area-inset-right) + 112px));
    /* 横屏提示与跳跃键横向错开，并贴近安全底边，为上方引导留出间隙。 */
    bottom: max(12px, env(safe-area-inset-bottom));
    width: min(340px, calc(100vw - 280px));
    transform: none;
  }

  body.touch-mode #mechanic-notice.is-leaving {
    transform: translateY(8px);
  }
}

#hud {
  top: 31px;
  left: 38px;
  width: 356px;
  min-height: 292px;
  padding: 0;
  color: var(--paper-bright);
  isolation: isolate;
  text-shadow: 0 2px 8px rgba(12, 40, 57, .58);
  animation: sky-map-arrive .72s cubic-bezier(.2, .8, .2, 1) both;
}

#hud::before { display: none; }

#hud::after {
  content: "";
  position: absolute;
  top: 25px;
  left: -24px;
  z-index: -2;
  width: 328px;
  height: 154px;
  background: rgba(23, 57, 75, .17);
  clip-path: polygon(2% 37%, 10% 16%, 31% 6%, 63% 0, 100% 19%, 89% 42%, 74% 51%, 67% 85%, 48% 100%, 27% 82%, 11% 68%);
  transform: rotate(-2.4deg);
  filter: drop-shadow(0 2px 0 rgba(255, 250, 240, .12));
  backdrop-filter: none;
}

.hud-topography {
  position: absolute;
  top: 28px;
  left: -15px;
  z-index: -1;
  width: 306px;
  height: 143px;
  overflow: visible;
  fill: none;
  stroke: rgba(255, 250, 240, .19);
  stroke-width: 1;
  pointer-events: none;
  transform: rotate(-2.4deg);
}

.hud-kicker {
  gap: 9px;
  margin: 0;
  color: rgba(255, 250, 240, .86);
  font: 700 10px/1.2 Georgia, "Songti SC", serif;
  letter-spacing: .18em;
  text-shadow: 0 2px 7px rgba(12, 40, 57, .62);
}

.hud-kicker::after {
  max-width: 74px;
  background: rgba(255, 250, 240, .45);
}

#title {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 11px 0 0;
  color: var(--paper-bright);
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 39px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: .08em;
  text-shadow:
    0 2px 0 rgba(23, 57, 75, .35),
    0 5px 15px rgba(12, 40, 57, .58);
}

.title-mark {
  width: 27px;
  height: 27px;
  color: var(--paper-bright);
  font-size: 14px;
  filter: drop-shadow(0 0 6px rgba(233, 100, 69, .54));
}

.title-mark::before {
  inset: 3px;
  border: 1px solid rgba(255, 250, 240, .72);
  background: var(--coral);
  clip-path: polygon(50% 0, 100% 47%, 72% 100%, 11% 80%, 0 31%);
  transform: rotate(17deg);
}

.count-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 13px;
  margin-top: 26px;
}

.count-label {
  order: 2;
  margin-bottom: 8px;
  color: rgba(255, 250, 240, .78);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .15em;
  text-shadow: 0 2px 7px rgba(12, 40, 57, .62);
}

#count {
  color: var(--paper-bright);
  font: 700 43px/.9 Georgia, "Songti SC", serif;
  letter-spacing: .02em;
  text-shadow:
    0 2px 0 rgba(23, 57, 75, .3),
    0 6px 16px rgba(12, 40, 57, .58);
}

#crystal-track {
  position: absolute;
  top: 110px;
  left: 176px;
  display: block;
  width: 186px;
  height: 57px;
  margin: 0;
  overflow: visible;
  border: 0;
  background: none;
}

#crystal-track::after,
#crystal-fill { display: none; }

.crystal-point {
  position: absolute;
  display: block;
  width: 8px;
  height: 8px;
  background: rgba(164, 214, 224, .5);
  clip-path: polygon(50% 0, 100% 45%, 72% 100%, 10% 79%, 0 31%);
  transform: rotate(17deg);
  transition: background-color .3s ease, transform .3s ease, filter .3s ease;
}

.crystal-point:nth-child(1) { left: 0; top: 37px; }
.crystal-point:nth-child(2) { left: 19px; top: 34px; }
.crystal-point:nth-child(3) { left: 38px; top: 29px; }
.crystal-point:nth-child(4) { left: 57px; top: 24px; }
.crystal-point:nth-child(5) { left: 76px; top: 19px; }
.crystal-point:nth-child(6) { left: 95px; top: 14px; }
.crystal-point:nth-child(7) { left: 114px; top: 10px; }
.crystal-point:nth-child(8) { left: 133px; top: 7px; }
.crystal-point:nth-child(9) { left: 152px; top: 4px; }
.crystal-point:nth-child(10) { left: 171px; top: 2px; }

.crystal-point:nth-child(2n),
.crystal-point:nth-child(3n) {
  transform: rotate(17deg);
}

.crystal-point.is-lit {
  background: var(--coral);
  filter: drop-shadow(0 0 5px rgba(233, 100, 69, .72));
  transform: rotate(29deg) scale(1.18);
}

#crystal-note {
  min-height: 18px;
  margin-top: 7px;
  color: rgba(255, 250, 240, .9);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-shadow: 0 2px 7px rgba(12, 40, 57, .7);
}

#minigame-dock {
  width: 252px;
  margin-top: 24px;
  padding: 0;
  border: 0;
  pointer-events: auto;
}

.minigame-dock-label {
  margin-bottom: 8px;
  color: rgba(255, 250, 240, .68);
  font-size: 9px;
  letter-spacing: .2em;
  text-shadow: 0 2px 7px rgba(12, 40, 57, .68);
}

.minigame-dock-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 17px;
}

.minigame-dock-actions button {
  position: relative;
  width: 112px;
  min-height: 52px;
  padding: 9px 12px 11px;
  border: 0;
  border-radius: 0;
  color: var(--paper-bright);
  background: #665d43;
  box-shadow:
    inset 0 -3px 0 rgba(233, 100, 69, .76),
    0 7px 0 #3c3d2e,
    0 11px 18px rgba(12, 40, 57, .28);
  clip-path: polygon(6% 3%, 88% 0, 100% 22%, 92% 84%, 72% 100%, 8% 92%, 0 63%);
  font: 700 12px/1.1 "Songti SC", "STSong", "Microsoft YaHei", serif;
  letter-spacing: .08em;
  text-shadow: 0 2px 4px rgba(12, 30, 30, .72);
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease, background-color .16s ease;
}

.minigame-dock-actions .is-featured {
  color: var(--paper-bright);
  border: 0;
  background: #5a6241;
  box-shadow:
    inset 0 -3px 0 rgba(141, 216, 196, .78),
    0 7px 0 #343d2c,
    0 11px 18px rgba(12, 40, 57, .28);
}

.minigame-dock-actions .is-sakura {
  background: #755265;
  box-shadow:
    inset 0 -3px 0 rgba(246, 168, 200, .82),
    0 7px 0 #453441,
    0 11px 18px rgba(12, 40, 57, .28);
}

.minigame-dock-actions .is-beacon {
  background: #5c5f65;
  box-shadow:
    inset 0 -3px 0 rgba(255, 212, 94, .86),
    0 7px 0 #353944,
    0 11px 18px rgba(12, 40, 57, .28);
}

.minigame-dock-actions button:hover,
.minigame-dock-actions button:focus-visible,
.minigame-dock-actions .is-featured:hover,
.minigame-dock-actions .is-featured:focus-visible {
  outline: 2px solid rgba(255, 250, 240, .88);
  outline-offset: 3px;
  background: #74684a;
  box-shadow:
    inset 0 -3px 0 var(--coral),
    0 8px 0 #3c3d2e,
    0 13px 22px rgba(12, 40, 57, .34);
  filter: drop-shadow(0 0 7px rgba(243, 200, 91, .38));
  transform: translateY(-2px) rotate(-1deg);
}

.minigame-dock-actions button:active {
  transform: translateY(5px);
  box-shadow:
    inset 0 -2px 0 rgba(233, 100, 69, .76),
    0 2px 0 #3c3d2e;
}

#mission {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  padding: 0;
  pointer-events: none;
  animation: none;
  text-shadow: none;
}

#mission::before,
#mission::after { display: none; }

.mission-heading { display: none; }

.mission-row {
  position: absolute;
  left: -999px;
  top: -999px;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 0;
  padding: 0;
  border: 0;
  color: rgba(255, 250, 240, .9);
  font: 700 13px/1 "Songti SC", "STSong", "Microsoft YaHei", serif;
  letter-spacing: .08em;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translate(16px, -50%);
  transition: opacity .22s ease, visibility .22s ease;
}

.mission-row.is-projected {
  opacity: 1;
  visibility: visible;
}

#mission-crystals,
#mission-heart {
  transform: translate(16px, -50%);
}

.mission-label {
  text-shadow:
    0 1px 0 rgba(23, 57, 75, .9),
    0 2px 8px rgba(12, 40, 57, .82);
}

.mission-status {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(255, 250, 240, .88);
  background: rgba(164, 214, 224, .48);
  clip-path: polygon(50% 0, 100% 45%, 72% 100%, 10% 79%, 0 31%);
  transform: rotate(17deg);
  filter: drop-shadow(0 0 4px rgba(164, 214, 224, .48));
}

.mission-row.is-current { color: var(--paper-bright); }
.mission-row.is-current .mission-status {
  border-color: rgba(255, 250, 240, .88);
  background: var(--coral);
  filter: drop-shadow(0 0 6px rgba(233, 100, 69, .72));
}

.mission-row.is-done { color: rgba(255, 250, 240, .94); }
.mission-row.is-done .mission-status {
  border-color: rgba(255, 250, 240, .88);
  background: var(--mint);
  filter: drop-shadow(0 0 6px rgba(141, 216, 196, .72));
}

#mute {
  top: 25px;
  right: 26px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 250, 240, .56);
  color: var(--paper-bright);
  background: rgba(23, 57, 75, .66);
  box-shadow: none;
  filter: drop-shadow(0 4px 7px rgba(12, 40, 57, .28));
  clip-path: polygon(50% 0, 94% 23%, 100% 70%, 67% 100%, 17% 89%, 0 42%);
  backdrop-filter: none;
}

#mute:hover,
#mute:focus-visible {
  color: var(--paper-bright);
  background: rgba(23, 57, 75, .86);
  box-shadow: none;
  outline: 2px solid rgba(255, 250, 240, .82);
  outline-offset: 3px;
}

@keyframes sky-map-arrive {
  from { opacity: 0; transform: translate(-16px, 7px); }
  to { opacity: 1; transform: translate(0, 0); }
}

@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) {
  #sky-route-overlay,
  #mission {
    display: none;
  }

  #hud {
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
    width: 256px;
    min-height: 222px;
    padding: 0;
  }

  #hud::after {
    top: 24px;
    left: -18px;
    width: 240px;
    height: 113px;
  }

  .hud-topography {
    top: 27px;
    left: -12px;
    width: 224px;
    height: 105px;
  }

  .hud-kicker { font-size: 8px; }

  #title {
    gap: 8px;
    margin-top: 8px;
    font-size: 27px;
  }

  .title-mark {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }

  .count-row {
    gap: 8px;
    margin-top: 17px;
  }

  .count-label {
    margin-bottom: 5px;
    font-size: 8px;
  }

  #count { font-size: 31px; }

  #crystal-track {
    top: 81px;
    left: 126px;
    width: 132px;
    height: 42px;
    transform: scale(.72);
    transform-origin: left top;
  }

  #crystal-note {
    margin-top: 5px;
    font-size: 10px;
  }

  #minigame-dock {
    width: 224px;
    margin-top: 14px;
    padding: 0;
  }

  .minigame-dock-label {
    margin-bottom: 6px;
    font-size: 8px;
  }

  .minigame-dock-actions {
    gap: 12px;
  }

  .minigame-dock-actions button {
    width: 102px;
    min-height: 44px;
    padding: 8px 8px 10px;
    font-size: 10px;
  }
}

/* 坠落恢复的黑场：0.22s 淡出 → 瞬移 → 0.3s 淡入。
   旧版是自由落体近 2 秒后零过渡瞬移，新手的第一次失误被拉成一段死时间。 */
#fall-fade {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #16283a;
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}

/* ---------- 暂停与设置 ---------- */
/* 旧版全游戏没有暂停、没有任何设置项，触屏玩家连「回到存档点」都没有入口 */
#pause-open {
  position: fixed;
  top: 28px;
  right: 84px;
  z-index: 11;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--glass);
  box-shadow: 4px 5px 0 rgba(23, 57, 75, .12);
  backdrop-filter: blur(12px);
  font-size: 17px;
  cursor: pointer;
  transition: transform .18s, background-color .18s, box-shadow .18s;
}

#pause-open:hover { transform: translateY(-2px); background: var(--paper-bright); }
#pause-open:active { transform: translateY(1px); box-shadow: 2px 2px 0 rgba(23, 57, 75, .12); }
#pause-open:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
body.cinematic #pause-open,
body.minigame #pause-open,
body.result #pause-open { display: none; }

#pause {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 32, 46, .52);
  backdrop-filter: blur(6px);
}

#pause .panel {
  width: min(392px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px 24px 20px;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 8px 10px 0 rgba(23, 57, 75, .16), 0 24px 60px var(--shadow);
}

#pause h1 {
  margin: 2px 0 16px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
  letter-spacing: 2px;
}

.pause-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.pause-actions button {
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 700 13px/1.2 inherit;
  letter-spacing: 1px;
  cursor: pointer;
}

#pause-resume { color: var(--paper-bright); background: var(--ink); border-color: transparent; }
#pause-respawn { color: var(--ink); background: transparent; }
.pause-actions button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.pause-settings { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }

.pause-row {
  display: grid;
  grid-template-columns: 76px 1fr 46px;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  font-size: 12px;
  letter-spacing: .5px;
}

.pause-row input[type="range"] { width: 100%; accent-color: var(--coral); }
.pause-row select {
  width: 100%;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  font: inherit;
  font-size: 12px;
}
.pause-row output { color: var(--ink-soft); font: 700 11px/1 Georgia, serif; text-align: right; }

.pause-keys {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.7;
}

@media (max-width: 680px), (pointer: coarse) and (max-height: 540px) {
  #pause-open { top: 20px; right: 72px; width: 40px; height: 40px; }
  .pause-actions { grid-template-columns: 1fr; }
  .pause-row { grid-template-columns: 68px 1fr 42px; }
}

/* 已拿到星的挑战：按钮上直接印星级，让「玩得好」在主界面留下痕迹 */
.minigame-dock-actions button.is-starred {
  color: #6b4a12;
  background: rgba(243, 200, 91, .28);
  border-color: rgba(200, 150, 40, .5);
}

/* 旅程总结常驻入口：通关后一直挂在天空航图底部，纪念图不再是一次性的 */
#journey-open {
  width: 100%;
  margin-top: 11px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: rgba(255, 250, 240, .72);
  font: 700 11px/1.2 "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 1px;
  cursor: pointer;
  pointer-events: auto;
  transition: background .16s ease, transform .16s ease;
}
#journey-open:hover { transform: translateY(-1px); background: var(--paper-bright); }
#journey-open:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.journey-runbest {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: .5px;
}
