/* ============================================================
   PRISM ATLAS — 棱镜星图
   A quiet night sky, cut from glass.
   ============================================================ */
:root {
  --bg: #050817;
  --ink: #eaf2ff;
  --muted: #91a7c8;
  --dim: #5a6e90;
  --gold: #f5cf8d;
  --gold-deep: #c9954c;
  --cyan: #8feaff;
  --violet: #b6a2ff;
  --rose: #ff9fce;
  --line: rgba(158, 200, 255, .14);
  --line-strong: rgba(186, 224, 255, .28);
  --glass: rgba(12, 24, 46, .64);
  --glass-deep: rgba(7, 15, 30, .92);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

html { color-scheme: dark; }

body {
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  background:
    radial-gradient(115% 75% at 82% -12%, rgba(87, 65, 148, .34), transparent 62%),
    radial-gradient(90% 70% at 4% 104%, rgba(14, 80, 98, .28), transparent 60%),
    linear-gradient(180deg, #050817 0%, #060b1c 52%, #040712 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 28% at 22% 68%, rgba(32, 92, 130, .12), transparent 70%),
    radial-gradient(30% 24% at 78% 34%, rgba(91, 62, 140, .12), transparent 70%);
  filter: blur(30px);
  animation: nebulaDrift 38s ease-in-out infinite alternate;
}

button {
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

button:focus-visible {
  outline: 1px solid rgba(246, 207, 141, .38);
  outline-offset: 2px;
}

.win-card:focus { outline: none; }

::selection { background: rgba(246, 207, 141, .25); }

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 38%, rgba(2, 5, 14, .5) 100%);
}

.app {
  position: relative;
  z-index: 2;
  height: 100vh;
  height: 100dvh;
}

.hidden { display: none !important; }

.noscript {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  background: #050817;
  color: #dfeafb;
  text-align: center;
  font-family: var(--sans);
  line-height: 1.9;
}

.noscript strong {
  font-family: var(--serif);
  font-size: 26px;
  letter-spacing: .12em;
  color: var(--gold);
}

.noscript p {
  max-width: 380px;
  margin: 0;
  color: #9db0cc;
  font-size: 13px;
}

.noscript b { color: #f0d6a8; }

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

.icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: none;
}

.icon-star {
  fill: currentColor;
  width: 15px;
  height: 15px;
}

.kicker {
  margin: 0;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ================= SCREENS ================= */
.screen {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .4s ease;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ================= BUTTONS ================= */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(16, 31, 58, .58);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .12em;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform .25s ease, border-color .25s ease, background .25s ease, box-shadow .25s ease;
}

.btn:hover {
  border-color: rgba(170, 230, 255, .4);
  background: rgba(24, 44, 78, .7);
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
}

.btn:active { transform: translateY(0) scale(.985); }

.btn-primary {
  color: #1b1206;
  border-color: rgba(255, 236, 196, .7);
  background: linear-gradient(135deg, #ffe5b1 0%, #f0c379 58%, #dba85e 100%);
  box-shadow: 0 12px 36px rgba(223, 166, 84, .18), inset 0 1px rgba(255, 255, 255, .55);
}

.btn-primary:hover {
  border-color: rgba(255, 247, 220, .95);
  background: linear-gradient(135deg, #fff0c9 0%, #f7cf8c 58%, #e7b76e 100%);
  box-shadow: 0 16px 44px rgba(223, 166, 84, .26);
}

.btn-ghost {
  color: #cddcf4;
  background: rgba(12, 24, 45, .42);
}

.btn-danger {
  color: #2a0b0b;
  border-color: rgba(255, 192, 180, .55);
  background: linear-gradient(135deg, #ffc5b6, #e98776);
}

.btn-wide { width: 100%; }

.btn-arrow {
  font-size: 17px;
  line-height: 1;
  transition: transform .3s ease;
}

.btn:hover .btn-arrow { transform: translateX(3px); }

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(160, 205, 255, .12);
  background: rgba(10, 22, 42, .42);
  color: #b9cce9;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color .25s ease, border-color .25s ease, background .25s ease, transform .25s ease;
}

.icon-btn:hover {
  color: #f3f9ff;
  border-color: rgba(170, 230, 255, .35);
  background: rgba(20, 38, 68, .6);
}

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

.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .12em;
  padding: 8px 6px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(145, 167, 200, .3);
  text-underline-offset: 4px;
  transition: color .25s ease;
}

.link-btn:hover { color: var(--gold); }

/* ================= TITLE ================= */
.screen-title {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(24px + var(--safe-top)) 24px calc(20px + var(--safe-bottom));
  overflow-y: auto;
}

.screen-title::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(760px, 120vw);
  height: min(760px, 120vw);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(76, 143, 190, .13), transparent 62%);
  pointer-events: none;
}

.title-inner {
  position: relative;
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  animation: titleRise 1.1s cubic-bezier(.16, .84, .3, 1) both;
}

.prism-stage {
  width: clamp(132px, 22vh, 180px);
  margin-bottom: clamp(6px, 1.5vh, 18px);
  animation: prismFloat 9s ease-in-out infinite;
}

.prism-mark {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 0 34px rgba(104, 224, 255, .18));
  overflow: visible;
}

.prism-rays path {
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  animation: drawBeam 1.1s ease-out .1s forwards;
}
.prism-rays path:nth-child(2) { animation-delay: .22s; }
.prism-rays path:nth-child(3) { animation-delay: .32s; }
.prism-rays path:nth-child(4) { animation-delay: .42s; }

.title-copy { display: flex; flex-direction: column; align-items: center; }

.title-copy .kicker {
  margin-bottom: 16px;
  color: #7f96b9;
}

.logo-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(52px, 12.5vw, 76px);
  line-height: 1.08;
  letter-spacing: .08em;
  background: linear-gradient(180deg, #fff8e8 0%, #f4d49b 46%, #cfa05e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 24px rgba(242, 188, 103, .18));
}

.logo-en {
  margin: 12px 0 0;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .52em;
  text-indent: .52em;
  color: #91a6c7;
}

.tagline {
  margin: 30px 0 0;
  color: #b9c9e3;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: .14em;
  line-height: 1.9;
}

.title-menu {
  width: min(330px, 100%);
  margin-top: clamp(30px, 5vh, 48px);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.title-menu-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.title-foot {
  width: min(430px, 100%);
  margin-top: clamp(30px, 5vh, 48px);
  padding-top: 18px;
  border-top: 1px solid rgba(152, 192, 255, .1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #657a9c;
  font-size: 10px;
  letter-spacing: .1em;
}

.title-stars {
  color: #b8a27b;
  white-space: nowrap;
  letter-spacing: .08em;
}

/* ================= MAP ================= */
.screen-map {
  padding-top: var(--safe-top);
}

.map-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 16px clamp(16px, 4vw, 34px) 10px;
}

.map-title { flex: 1; }
.map-title h2 {
  margin: 3px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 27px;
  letter-spacing: .18em;
}

.total-stars {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(232, 194, 132, .18);
  background: rgba(26, 26, 28, .28);
  color: #d9bd8a;
  font-size: 12px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.total-stars .icon-star {
  width: 13px;
  height: 13px;
  filter: drop-shadow(0 0 8px rgba(246, 207, 141, .35));
}

.map-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 clamp(16px, 4vw, 34px) calc(46px + var(--safe-bottom));
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 190, 255, .2) transparent;
}

.map-scroll::-webkit-scrollbar { width: 6px; }
.map-scroll::-webkit-scrollbar-thumb { background: rgba(150, 190, 255, .18); border-radius: 99px; }

.map-intro {
  width: min(760px, 100%);
  margin: 12px auto 24px;
  color: #8399ba;
  font-size: 12.5px;
  line-height: 2;
  letter-spacing: .06em;
}

.chapter-list {
  width: min(760px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chapter-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(150deg, rgba(18, 35, 64, .72), rgba(7, 15, 30, .62));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .12), inset 0 1px rgba(255, 255, 255, .045);
  transition: border-color .4s ease, transform .4s ease;
}

.chapter-card:not(.is-locked):hover {
  border-color: rgba(172, 218, 255, .24);
}

.chapter-card.is-locked {
  background: linear-gradient(150deg, rgba(14, 25, 46, .55), rgba(6, 12, 24, .5));
}

.chapter-card.is-complete {
  border-color: rgba(239, 195, 123, .26);
}

.chapter-card.is-current {
  border-color: rgba(246, 207, 141, .2);
}

.chapter-art {
  position: absolute;
  right: -18px;
  top: -18px;
  width: 188px;
  height: 108px;
  opacity: .2;
  pointer-events: none;
  mask-image: linear-gradient(120deg, black 0%, black 36%, transparent 88%);
  -webkit-mask-image: linear-gradient(120deg, black 0%, black 36%, transparent 88%);
}

.chapter-art line {
  stroke: rgba(242, 199, 132, .45);
  stroke-width: .55;
}

.chapter-art circle {
  fill: rgba(255, 239, 205, .92);
}

.chapter-card.is-locked .chapter-art { opacity: .08; }

.chapter-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chapter-num {
  margin-top: 2px;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .16em;
  color: #756b58;
  writing-mode: vertical-rl;
  line-height: 1;
  padding: 2px 0;
  border-left: 1px solid rgba(233, 195, 130, .18);
  padding-left: 8px;
}

.chapter-meta { flex: 1; min-width: 0; }

.chapter-kicker {
  margin: 0 0 5px;
  font-size: 9px;
  letter-spacing: .22em;
  color: #6f84a5;
  text-transform: uppercase;
}

.chapter-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(21px, 4.4vw, 27px);
  letter-spacing: .1em;
  color: #f0e5cf;
}

.chapter-epigraph {
  margin: 7px 0 0;
  color: #7f94b3;
  font-size: 11.5px;
  line-height: 1.8;
  letter-spacing: .03em;
}

.chapter-stars {
  flex: none;
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #c9ad7c;
  font-size: 10px;
  letter-spacing: .06em;
}

.chapter-stars .icon-star {
  width: 11px;
  height: 11px;
}

.chapter-progress {
  position: relative;
  z-index: 1;
  height: 1px;
  margin: 15px 0 16px;
  background: rgba(156, 196, 255, .1);
  overflow: hidden;
}

.chapter-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, rgba(246, 207, 141, .2), rgba(246, 207, 141, .85));
  box-shadow: 0 0 8px rgba(246, 207, 141, .28);
  transition: width .8s cubic-bezier(.2, .8, .2, 1);
}

.chapter-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.chapter-card.is-locked .chapter-grid { opacity: .28; }

.level-node {
  position: relative;
  min-width: 0;
  aspect-ratio: 1.06;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 2px;
  border-radius: 13px;
  border: 1px solid rgba(152, 196, 255, .11);
  background: rgba(8, 18, 36, .5);
  color: #a7b9d4;
  cursor: pointer;
  transition: border-color .25s ease, background .25s ease, transform .25s ease, color .25s ease;
}

.level-node:hover {
  border-color: rgba(180, 226, 255, .35);
  background: rgba(24, 44, 76, .65);
  transform: translateY(-1px);
}

.level-node:active { transform: scale(.96); }

.level-node.is-done {
  color: #f0ddb9;
  border-color: rgba(235, 194, 128, .3);
  background: linear-gradient(160deg, rgba(58, 48, 34, .42), rgba(11, 21, 38, .5));
}

.level-node.is-current {
  border-color: rgba(246, 207, 141, .5);
  color: #fff1d3;
}

.level-node.is-current::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 16px;
  border: 1px solid rgba(246, 207, 141, .3);
  animation: nodePulse 2.8s ease-in-out infinite;
  pointer-events: none;
}

.level-node.is-locked {
  color: #50617e;
  cursor: not-allowed;
  background: rgba(6, 13, 26, .3);
}

.level-num {
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1;
  letter-spacing: .02em;
}

.level-mini {
  display: flex;
  gap: 1px;
  height: 6px;
  line-height: 1;
  font-size: 6px;
  color: rgba(255, 255, 255, .1);
}

.level-mini span.on { color: var(--gold); }

.chapter-lock {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 13px;
  color: #8e7f65;
  font-size: 10.5px;
  letter-spacing: .08em;
}

.chapter-lock .icon { width: 13px; height: 13px; }

.chapter-locked-note { display: none; }
.chapter-card.is-locked .chapter-locked-note { display: flex; }

.map-foot {
  width: min(760px, 100%);
  margin: 30px auto 0;
  padding-top: 20px;
  border-top: 1px solid rgba(154, 196, 255, .09);
  text-align: center;
}

.map-completion {
  margin: 0 0 8px;
  color: #a28c6b;
  font-size: 11px;
  letter-spacing: .14em;
  line-height: 1.8;
}

.map-credit {
  margin: 12px 0 4px;
  color: #637898;
  font-size: 10px;
  letter-spacing: .08em;
  line-height: 1.8;
}

.map-version {
  margin: 0;
  color: #40526d;
  font-size: 9px;
  letter-spacing: .18em;
}

/* ================= GAME ================= */
.screen-game {
  padding: calc(8px + var(--safe-top)) clamp(12px, 3vw, 28px) calc(10px + var(--safe-bottom));
  align-items: center;
}

.game-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(980px, 100%);
  height: 58px;
}

.game-heading {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.game-heading .kicker {
  font-size: 8px;
  letter-spacing: .24em;
}

.game-heading h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(19px, 4.2vw, 26px);
  letter-spacing: .12em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-heading h2 #game-name-en {
  margin-left: 9px;
  font-family: var(--sans);
  font-size: .44em;
  font-weight: 400;
  letter-spacing: .16em;
  color: #768cac;
}

.screen-game .icon-sound-off { display: none; }
body.is-muted .screen-game .icon-sound-on { display: none; }
body.is-muted .screen-game .icon-sound-off { display: block; }

.game-objective {
  flex: none;
  width: min(980px, 100%);
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
  color: #7f95b6;
  font-size: 11px;
  letter-spacing: .06em;
}

.objective-left, .objective-right {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.target-pips {
  display: flex;
  align-items: center;
  gap: 3px;
}

.star-pip {
  width: 13px;
  height: 13px;
  fill: currentColor;
  color: rgba(244, 208, 147, .18);
  transition: color .35s ease, transform .35s ease, filter .35s ease;
}

.star-pip.on {
  color: var(--gold);
  filter: drop-shadow(0 0 7px rgba(246, 207, 141, .55));
}

.star-pip.pulse { animation: pipPop .55s cubic-bezier(.2, 1.7, .5, 1); }

.target-label { white-space: nowrap; }

.stat-divider { color: #3f5574; }

.move-count, .par-count { white-space: nowrap; }
.move-count.at-par { color: var(--gold); }

.tiny-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(160, 200, 255, .14);
  background: transparent;
  color: #7086a7;
  cursor: pointer;
  padding: 0;
}

.tiny-btn .icon { width: 14px; height: 14px; }
.tiny-btn:hover { color: var(--gold); border-color: rgba(246, 207, 141, .3); }

.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: min(980px, 100%);
  margin: 0 auto;
  touch-action: manipulation;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: default;
  touch-action: manipulation;
}

#stage.is-interactive { cursor: pointer; }

.tip-bubble {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 4;
  width: min(92%, 520px);
  padding: 13px 42px 13px 16px;
  border-radius: 15px;
  border: 1px solid rgba(160, 210, 255, .18);
  background: rgba(7, 17, 34, .93);
  color: #c8d9f2;
  font-size: 12px;
  line-height: 1.8;
  letter-spacing: .04em;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .4s ease, transform .4s cubic-bezier(.2, .8, .2, 1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
}

.tip-bubble.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.tip-bubble p { margin: 0; }

.tip-dismiss {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #7188a8;
  cursor: pointer;
}

.tip-dismiss .icon { width: 13px; height: 13px; }
.tip-dismiss:hover { color: #d8e8ff; }

.game-toast {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 5;
  transform: translate(-50%, 10px);
  max-width: 90%;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(170, 220, 255, .18);
  background: rgba(8, 18, 36, .92);
  color: #cfe0f7;
  font-size: 11px;
  letter-spacing: .08em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  backdrop-filter: blur(12px);
}

.game-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.game-controls {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: min(980px, 100%);
  margin: 6px auto 0;
  padding-top: 4px;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 92px;
  height: 46px;
  padding: 0 17px;
  border-radius: 999px;
  border: 1px solid rgba(158, 201, 255, .13);
  background: rgba(11, 24, 46, .56);
  color: #a9bddb;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .1em;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color .25s ease, border-color .25s ease, background .25s ease, transform .2s ease;
}

.control-btn .icon { width: 17px; height: 17px; }

.control-btn:hover {
  color: #f0f7ff;
  border-color: rgba(175, 226, 255, .32);
  background: rgba(21, 40, 70, .7);
}

.control-btn:active { transform: scale(.96); }

.control-btn.is-off {
  opacity: .32;
  pointer-events: none;
}

.control-hint {
  color: #d7bb88;
  border-color: rgba(238, 195, 127, .2);
}

.control-hint:hover {
  color: #ffe3ad;
  border-color: rgba(246, 207, 141, .45);
}

/* ================= OVERLAYS ================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
}

.overlay[hidden] { display: none; }

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 14, .72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn .4s ease both;
}

.win-card, .settings-card, .confirm-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  border-radius: 26px;
  border: 1px solid rgba(192, 226, 255, .16);
  background:
    linear-gradient(160deg, rgba(19, 35, 63, .98), rgba(6, 13, 27, .99));
  box-shadow: 0 34px 90px rgba(0, 0, 0, .55), inset 0 1px rgba(255, 255, 255, .07);
  animation: cardIn .55s cubic-bezier(.16, .84, .3, 1) both;
  overflow: hidden;
}

.win-card {
  padding: 30px 26px 22px;
  text-align: center;
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.win-card::before {
  content: "";
  position: absolute;
  inset: -30% -20% auto;
  height: 70%;
  background: radial-gradient(ellipse at center, rgba(246, 203, 133, .12), transparent 65%);
  pointer-events: none;
}

.win-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 24%, rgba(255, 255, 255, .35) 0 1px, transparent 1.5px),
    radial-gradient(circle at 86% 17%, rgba(255, 255, 255, .25) 0 1px, transparent 1.4px),
    radial-gradient(circle at 74% 76%, rgba(255, 255, 255, .2) 0 1px, transparent 1.4px),
    radial-gradient(circle at 26% 84%, rgba(255, 255, 255, .22) 0 1px, transparent 1.4px);
  opacity: .7;
}

.win-card > * { position: relative; z-index: 1; }

.win-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  height: 46px;
  margin: 12px 0 4px;
}

.win-star {
  width: 34px;
  height: 34px;
  fill: currentColor;
  color: rgba(255, 255, 255, .1);
  opacity: .8;
  transform: scale(.8);
}

.win-star.on {
  color: var(--gold);
  animation: winStarPop .75s cubic-bezier(.16, 1.5, .4, 1) both;
  filter: drop-shadow(0 0 12px rgba(246, 207, 141, .5));
}

#win-title {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 27px;
  letter-spacing: .2em;
  text-indent: .2em;
  color: #f6e7c9;
}

.win-name {
  margin: 7px 0 0;
  color: #a29378;
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.win-note {
  margin: 19px auto 0;
  max-width: 300px;
  color: #a9bcd8;
  font-size: 12px;
  line-height: 1.9;
  letter-spacing: .04em;
}

.win-unlock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 14px auto 0;
  padding: 6px 14px;
  border: 1px solid rgba(246, 207, 141, .22);
  border-radius: 999px;
  background: rgba(246, 207, 141, .055);
  color: #e0c18b;
  font-size: 10px;
  letter-spacing: .12em;
  line-height: 1.5;
}

.win-unlock[hidden] { display: none; }

.win-stats {
  margin: 17px auto 0;
  color: #7e94b4;
  font-size: 11px;
  letter-spacing: .08em;
}

.win-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.win-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}

.win-actions-row .btn {
  flex: 1;
  min-height: 42px;
  font-size: 12px;
}

.win-actions-row .link-btn { flex: none; }

/* settings */
.settings-card {
  padding: 24px 24px 20px;
  max-height: min(88dvh, 720px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sheet-head h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 25px;
  letter-spacing: .16em;
}

.settings-list { margin-top: 10px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid rgba(152, 196, 255, .09);
}

.setting-name {
  display: block;
  color: #dfeafb;
  font-size: 13px;
  letter-spacing: .06em;
}

.setting-sub {
  display: block;
  margin-top: 3px;
  color: #6f84a4;
  font-size: 10px;
  line-height: 1.5;
}

.switch {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(161, 201, 255, .18);
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
  transition: background .3s ease, border-color .3s ease;
}

.switch-knob {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #8fa4c3;
  transition: transform .28s cubic-bezier(.2, .9, .2, 1), background .28s ease;
}

.switch[aria-checked="true"] {
  background: linear-gradient(90deg, rgba(241, 195, 121, .9), rgba(246, 216, 160, .95));
  border-color: rgba(255, 235, 195, .6);
}

.switch[aria-checked="true"] .switch-knob {
  transform: translateX(20px);
  background: #241806;
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid rgba(160, 200, 255, .14);
  background: rgba(255, 255, 255, .04);
}

.segment {
  min-width: 50px;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #899db9;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .06em;
  cursor: pointer;
}

.segment.is-active {
  background: rgba(246, 207, 141, .92);
  color: #211605;
}

.settings-about {
  margin-top: 20px;
  padding: 14px 15px;
  border-radius: 14px;
  border: 1px solid rgba(150, 195, 255, .09);
  background: rgba(4, 10, 20, .4);
  color: #7287a6;
  font-size: 10.5px;
  line-height: 1.8;
}

.settings-about p { margin: 0; }

.settings-version {
  margin-top: 8px !important;
  color: #4b5f7d;
  font-size: 9px;
  letter-spacing: .12em;
}

.danger-link {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  border: 0;
  background: none;
  color: #8a6461;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: .1em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(138, 100, 97, .3);
}

.danger-link:hover { color: #e79a8f; }

/* confirm */
.confirm-card {
  width: min(370px, 100%);
  padding: 27px 24px 20px;
  text-align: center;
}

.confirm-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: .12em;
  color: #f1dfc1;
}

.confirm-card p {
  margin: 13px 0 22px;
  color: #8ea2c0;
  font-size: 12px;
  line-height: 1.9;
}

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

.confirm-actions .btn { padding: 0 12px; font-size: 12px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(30px + var(--safe-bottom));
  z-index: 90;
  transform: translate(-50%, 14px);
  max-width: calc(100vw - 36px);
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid rgba(176, 222, 255, .2);
  background: rgba(8, 18, 36, .94);
  color: #d3e3f8;
  font-size: 11.5px;
  letter-spacing: .06em;
  line-height: 1.6;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .3);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ================= ENDING ================= */
.screen-ending {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(26px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  background: radial-gradient(ellipse at 50% 46%, rgba(21, 49, 83, .18), transparent 62%);
}

.ending-inner {
  width: min(540px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: titleRise 1.2s cubic-bezier(.16, .84, .3, 1) both;
}

.ending-title {
  margin: 16px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(44px, 11vw, 68px);
  letter-spacing: .14em;
  text-indent: .14em;
  background: linear-gradient(180deg, #fff9ea, #f0ca8b 58%, #c6985c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 28px rgba(240, 190, 110, .2));
}

.ending-line {
  margin: 18px 0 0;
  max-width: 420px;
  color: #b0c2dc;
  font-size: 13px;
  line-height: 2.1;
  letter-spacing: .07em;
  white-space: pre-line;
}

.ending-stat {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 28px 0 0;
  color: #8fa4c2;
  font-size: 10px;
  letter-spacing: .12em;
}

.ending-stat span:nth-child(1),
.ending-stat span:nth-child(4) {
  font-family: var(--serif);
  font-size: 26px;
  color: #e7c891;
}

.ending-stat i {
  width: 1px;
  height: 18px;
  margin: 0 8px;
  background: rgba(200, 220, 245, .18);
}

.ending-quote {
  margin: 30px 0 0;
  color: #7589a8;
  font-family: var(--serif);
  font-size: 12px;
  line-height: 2;
  letter-spacing: .08em;
  white-space: pre-line;
}

.screen-ending .btn {
  margin-top: 30px;
  min-width: 190px;
}

.ending-credit {
  margin: 26px 0 0;
  color: #455872;
  font-size: 9px;
  letter-spacing: .18em;
}

/* ================= ANIMATION ================= */
@keyframes titleRise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes prismFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes drawBeam {
  0% { stroke-dashoffset: 120; opacity: .12; }
  100% { stroke-dashoffset: 0; opacity: .9; }
}

@keyframes nebulaDrift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to { transform: translate3d(1.5%, 1.5%, 0) scale(1.05); }
}

@keyframes nodePulse {
  0%, 100% { opacity: .18; transform: scale(1); }
  50% { opacity: .55; transform: scale(1.02); }
}

@keyframes pipPop {
  0% { transform: scale(.4); }
  60% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes starPop {
  0% { transform: scale(.3) rotate(-20deg); opacity: 0; }
  70% { transform: scale(1.18) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes winStarPop {
  0% { transform: scale(.2) rotate(-28deg); opacity: 0; }
  65% { transform: scale(1.18) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ================= RESPONSIVE ================= */
@media (min-width: 760px) {
  .chapter-card { padding: 24px 26px; }
  .chapter-grid { gap: 10px; }
  .level-num { font-size: 14px; }
  .game-head { height: 66px; }
  .game-objective { height: 34px; font-size: 12px; }
  .control-btn { min-width: 108px; height: 48px; font-size: 12px; }
  .tip-bubble { font-size: 13px; }
}

@media (max-width: 380px) {
  .chapter-card { padding: 15px; border-radius: 19px; }
  .chapter-grid { gap: 6px; }
  .level-num { font-size: 12px; }
  .chapter-epigraph { font-size: 10.5px; }
  .level-mini { font-size: 5px; gap: 0; }
  .control-btn { min-width: 80px; padding: 0 12px; }
  .target-label { font-size: 10px; }
  .game-objective { gap: 6px; }
  .objective-right { gap: 6px; }
}

@media (max-height: 660px) and (min-width: 480px) {
  .prism-stage { width: 104px; }
  .logo-title { font-size: 48px; }
  .tagline { margin-top: 18px; }
  .title-menu { margin-top: 22px; }
  .title-foot { margin-top: 22px; }
}

@media (orientation: landscape) and (max-height: 540px) {
  .screen-game { padding-top: calc(4px + var(--safe-top)); padding-bottom: calc(4px + var(--safe-bottom)); }
  .game-head { height: 44px; }
  .game-heading h2 { font-size: 18px; }
  .game-objective { height: 24px; }
  .game-controls { margin-top: 2px; }
  .control-btn { height: 38px; min-width: 84px; }
  .icon-btn { width: 36px; height: 36px; }
  .logo-title { font-size: 42px; }
  .title-menu { margin-top: 18px; }
  .title-foot { margin-top: 18px; }
  .screen-title { overflow-y: auto; justify-content: flex-start; }
}

/* ================= ACCESSIBILITY / MOTION ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .screen { transition-duration: .001ms; }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
}

body.reduced-motion #bg-canvas { opacity: .82; }
