* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 10px; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #04030c; color: #e8f6ff;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
.hidden { display: none !important; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }

/* 9-slice art */
.panel9 { border-style: solid; border-color: transparent; border-width: 1rem;
  border-image: url(../assets/ui-panel.webp) 22% fill / 1rem stretch; }
.btn9 { border-style: solid; border-color: transparent; border-width: 1rem 1.2rem;
  border-image: url(../assets/ui-button.webp) 30% 22% fill / 1rem 1.2rem stretch;
  background: none; color: #e8f6ff; font: inherit; font-weight: 900; cursor: pointer; padding: 0;
  transition: transform .12s, filter .12s; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  text-shadow: 0 0 .6rem #00e5ff, 0 2px 0 #08051c; position: relative; }
.btn9:hover { filter: brightness(1.25) drop-shadow(0 0 .6rem #00e5ffaa); transform: scale(1.04); }
.btn9:active { transform: scale(.92); }
.btn9.on { filter: brightness(1.35) drop-shadow(0 0 .8rem #ff3df5); }
.btn9.dim { filter: grayscale(.8) brightness(.6); }
.btn9 img { width: 2.6rem; height: 2.6rem; object-fit: contain; pointer-events: none; }

.out { -webkit-text-stroke: 0; text-shadow: -1px -1px 0 #08051c, 1px -1px 0 #08051c, -1px 1px 0 #08051c, 1px 1px 0 #08051c, 0 0 .8rem #00e5ff; }

/* HUD */
#game-ui { position: fixed; inset: 0; pointer-events: none; }
#game-ui > * { pointer-events: auto; }
#hud { position: absolute; left: 50%; top: .4rem; transform: translateX(-50%); min-width: 17rem; padding: 0 .6rem;
  display: flex; align-items: center; gap: 1.2rem; }
#hud .cred { display: flex; align-items: center; gap: .6rem; font-size: 2.2rem; font-weight: 900; line-height: 1.1;
  text-shadow: -1px -1px 0 #08051c, 1px 1px 0 #08051c, 0 0 1rem #00e5ff; color: #bff8ff; }
.cr-ico { width: 1.9rem; height: 1.9rem; display: inline-block; flex: none;
  background: radial-gradient(circle at 40% 35%, #fff 0 12%, #4ff3ff 30%, #0a7ea8 70%, #06204a 100%);
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); filter: drop-shadow(0 0 4px #00e5ff); }
#hud .sub { display: flex; gap: 1rem; align-items: center; font-size: 1.4rem; font-weight: 700; color: #ffb3fb;
  text-shadow: 0 0 .5rem #ff3df5, 0 1px 0 #000; }
#gold-wrap { display: inline-flex; align-items: center; gap: .3rem; color: #ffe08a; text-shadow: 0 0 .5rem #ffb800, 0 1px 0 #000; }
#gold-wrap img { width: 1.8rem; height: 1.8rem; }

#topbtns { position: absolute; right: 6.6rem; top: .6rem; display: flex; gap: .8rem; }
.btn9.wide { height: 4.8rem; min-width: 10rem; padding: 0 .6rem; font-size: 1.5rem; }
.badge { position: absolute; right: -.8rem; top: -.8rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: #ff3df5;
  color: #fff; font-style: normal; font-size: 1.3rem; line-height: 1.8rem; text-align: center; box-shadow: 0 0 .8rem #ff3df5;
  animation: pulse 1s infinite alternate; text-shadow: none; }
.ico { display: inline-block; width: 2.4rem; height: 2.4rem; background-size: contain; background-repeat: no-repeat; background-position: center; }
.ico-tech { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300e5ff' stroke-width='2'%3E%3Ccircle cx='5' cy='12' r='2.5'/%3E%3Ccircle cx='19' cy='5' r='2.5'/%3E%3Ccircle cx='19' cy='19' r='2.5'/%3E%3Cpath d='M7.5 12h4M11.5 5v14M11.5 5h5M11.5 19h5'/%3E%3C/svg%3E"); }

#orders { position: absolute; left: .6rem; top: 7rem; width: 11.6rem; display: flex; flex-direction: column; gap: .6rem; }
.order { position: relative; padding: .2rem; min-height: 6.4rem; transition: transform .25s; }
.order.pop { animation: popin .35s cubic-bezier(.3,1.6,.5,1); }
.order.done { filter: brightness(1.5) drop-shadow(0 0 1rem #ffe08a); }
.order .top { display: flex; align-items: center; gap: .3rem; }
.order .pl { width: 2.8rem; height: 2.8rem; }
.order .it { width: 3rem; height: 3rem; filter: drop-shadow(0 0 4px #fff6); }
.order .q { font-size: 1.5rem; font-weight: 900; text-shadow: 0 0 .5rem #00e5ff, 0 1px 0 #000; margin-right: auto; }
.order .bar { height: .5rem; background: #1a1440; border-radius: .3rem; overflow: hidden; margin: .3rem 0 .2rem; }
.order .bar i { display: block; height: 100%; background: linear-gradient(90deg, #00e5ff, #ff3df5); box-shadow: 0 0 6px #ff3df5; }
.order .rw { font-size: 1.2rem; font-weight: 700; color: #ffe08a; display: flex; gap: .4rem; align-items: center; white-space: nowrap; }
.order .rw img { width: 1.4rem; height: 1.4rem; }
.order .pb { position: absolute; right: -.3rem; top: -.5rem; font-style: normal; font-size: 1.1rem; font-weight: 900; color: #ffe08a;
  background: rgba(60, 10, 70, .9); border: 1px solid #ff3df5; border-radius: .6rem; padding: 0 .35rem; text-shadow: 0 1px 0 #000; }

#side { position: absolute; right: .8rem; top: 6.4rem; display: flex; flex-direction: column; gap: .6rem; }
.btn9.sq { width: 5.4rem; height: 5.4rem; flex-direction: column; gap: 0; font-size: 1.2rem; }
#side .btn9.sq { width: 5.6rem; height: 5rem; border-width: .9rem .6rem; }
#side .btn9.sq .cnt { font-size: 1.05rem; white-space: nowrap; letter-spacing: -.02em; }
.btn9.sq img, .btn9.sq .ico { width: 2.6rem; height: 2.6rem; }
.btn9.sq .badge { right: -.6rem; top: -.6rem; }
.btn9.sq .cnt { font-size: 1.2rem; line-height: 1.2; }
.cnt.ad { color: #ffe08a; }
.btn9.sq-s { width: 4.4rem; height: 4.4rem; font-size: 1.8rem; }

#od-bar { position: absolute; left: 50%; top: 6.2rem; transform: translateX(-50%); padding: .5rem 1.4rem; border-radius: 2rem;
  background: rgba(60, 20, 0, .7); border: 2px solid #ffb800; color: #ffe08a; font-weight: 900; font-size: 1.5rem;
  box-shadow: 0 0 1.2rem #ff9a00; text-shadow: 0 1px 0 #000; pointer-events: none; white-space: nowrap; }

#toolbar { position: absolute; left: .6rem; bottom: .6rem; display: flex; gap: .5rem; align-items: flex-end; }
#toolbar { gap: .35rem; }
.tool { width: 4.8rem; height: 5.6rem; flex-direction: column; gap: 0; font-size: 1.2rem; border-width: 1rem .7rem; }
.tool .tico { width: 2.8rem; height: 2.8rem; object-fit: contain; background-size: contain; background-repeat: no-repeat; background-position: center; pointer-events: none; }
.tool .tcost { font-size: 1.2rem; line-height: 1.1; color: #bff8ff; white-space: nowrap; }
.tool .tcost.no { color: #ff6b8a; }
.tool .key { position: absolute; left: -.4rem; top: -.6rem; font-size: 1.1rem; color: #8fa6d8; text-shadow: 0 1px 0 #000; }
.tool.sel { filter: brightness(1.4) drop-shadow(0 0 .8rem #ff3df5); transform: translateY(-.4rem); }
.tool.pop { animation: popin .4s cubic-bezier(.3,1.6,.5,1); }

#nova { position: absolute; right: .6rem; bottom: .2rem; display: flex; align-items: flex-end; justify-content: flex-end; pointer-events: none !important;
  animation: slidein .3s cubic-bezier(.3,1.4,.5,1); }
#nova-cv { width: 7rem; height: 7rem; filter: drop-shadow(0 0 .8rem #00e5ff88); order: 2; }
#nova-bubble { order: 1; max-width: 21rem; margin-right: -.6rem; margin-bottom: 1rem; padding: .7rem 1rem; font-size: 1.4rem; line-height: 1.3;
  background: rgba(10, 6, 34, .86); border: 2px solid #00e5ff; border-radius: 1.2rem 1.2rem .2rem 1.2rem; box-shadow: 0 0 1.2rem #00e5ff66, inset 0 0 1rem #ff3df522;
  text-shadow: 0 1px 0 #000; }
#nova-bubble b { color: #ff9cf8; }

#toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); pointer-events: none !important; text-align: center;
  font-size: 2rem; font-weight: 900; opacity: 0; transition: opacity .25s; white-space: nowrap;
  text-shadow: -1px -1px 0 #08051c, 1px 1px 0 #08051c, 0 0 1rem #ff3df5; }
#toast.show { opacity: 1; animation: popin .3s cubic-bezier(.3,1.6,.5,1); }
#toast.err { color: #ff8aa4; font-size: 1.6rem; }

#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.fl { position: absolute; font-weight: 900; font-size: 1.5rem; color: #ffe08a; transform: translate(-50%, -50%);
  text-shadow: -1px -1px 0 #1a0a00, 1px 1px 0 #1a0a00, 0 0 .6rem #ffb800; animation: rise 1s ease-out forwards; white-space: nowrap; }
.fl.big { font-size: 2.2rem; color: #fff; text-shadow: 0 0 1rem #ff3df5, 0 2px 0 #000; }

/* title */
#title { position: fixed; inset: 0; cursor: pointer; overflow: hidden; }
#title-bg { position: absolute; inset: -3%; background: #04030c url(../assets/title-bg.webp) center / cover no-repeat; animation: drift 24s ease-in-out infinite alternate; }
#title-logo { position: absolute; left: 6%; top: 8%; width: 48%; max-height: 38%; object-fit: contain; object-position: left center;
  filter: drop-shadow(0 0 1.4rem #ff3df5aa); animation: logoin .7s cubic-bezier(.3,1.5,.5,1) both, float 4s ease-in-out .7s infinite; }
#title-start { position: absolute; left: 8%; right: 8%; bottom: 11%; text-align: center; font-size: 2.4rem; font-weight: 900; letter-spacing: .1em;
  color: #e8fdff; text-shadow: -1px -1px 0 #08051c, 1px 1px 0 #08051c, 0 0 1.2rem #00e5ff; animation: pulse 1.1s ease-in-out infinite alternate; }
#title-keys { position: absolute; left: 0; right: 0; bottom: 5%; text-align: center; font-size: 1.3rem; color: #9fb4e8; text-shadow: 0 1px 0 #000; }

/* intro */
#intro { position: fixed; inset: 0; background: #000 url(../assets/title-bg.webp) center / cover; z-index: 20; }
#intro video { width: 100%; height: 100%; object-fit: cover; }
#intro-sub { position: absolute; left: 16%; right: 16%; bottom: 22%; text-align: center; font-size: 2rem; font-weight: 700;
  text-shadow: 0 0 .8rem #00e5ff, 0 2px 0 #000; }
#intro-skip { position: absolute; right: 2rem; bottom: 2rem; height: 4.8rem; min-width: 10rem; font-size: 1.6rem; }

/* tech tree */
#tech, #popup { position: fixed; inset: 0; background: rgba(2, 0, 12, .62); z-index: 10; display: flex; align-items: center; justify-content: center; }
#tech-panel { width: min(96vw, 120rem); height: 96vh; display: flex; flex-direction: column; animation: popin .28s cubic-bezier(.3,1.5,.5,1); }
#tech-head { display: flex; align-items: center; gap: 1.2rem; padding: 0 .4rem; }
#tech-head h2 { margin: 0; font-size: 2.2rem; font-weight: 900; color: #e8fdff; text-shadow: 0 0 1rem #ff3df5, 0 2px 0 #000; }
#tech-cred { font-size: 1.8rem; font-weight: 900; color: #bff8ff; display: flex; gap: .5rem; align-items: center; margin-right: auto; text-shadow: 0 0 .6rem #00e5ff; }
#tech-tree { position: relative; flex: 1; margin: .4rem 0; }
#tech-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tnode { position: absolute; transform: translate(-50%, -50%); width: 11.4%; height: 23.5%; min-width: 6.4rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: .2rem;
  background: rgba(14, 10, 44, .9); border: 2px solid #3b3a78; border-radius: .9rem; cursor: pointer;
  font-size: 1.15rem; font-weight: 700; text-align: center; line-height: 1.05; transition: transform .12s, box-shadow .12s; color: #c9d4f5; overflow: hidden; }
.tnode img, .tnode .tico { width: 2.1rem; height: 2.1rem; flex: none; object-fit: contain; background-size: contain; background-repeat: no-repeat; background-position: center; }
.tnode .tc { color: #8fdcff; font-size: 1.2rem; }
.tnode.avail { border-color: #00e5ff; box-shadow: 0 0 .8rem #00e5ff88; color: #fff; }
.tnode.afford { animation: glow 1s infinite alternate; }
.tnode.owned { border-color: #ff3df5; background: rgba(60, 10, 70, .9); color: #ffd3fb; }
.tnode.owned .tc { color: #ff9cf8; }
.tnode.locked { opacity: .45; }
.tnode.focus { transform: translate(-50%, -50%) scale(1.1); outline: 3px solid #fff; outline-offset: 2px; }
#tech-detail { min-height: 6.4rem; display: flex; align-items: center; gap: 1.2rem; padding: .4rem .6rem; border-top: 1px solid #3b3a78; }
#tech-detail .dname { font-size: 1.8rem; font-weight: 900; color: #fff; text-shadow: 0 0 .6rem #ff3df5; }
#tech-detail .ddesc { font-size: 1.4rem; color: #c9d4f5; }
#tech-detail .dtxt { flex: 1; }
#tech-detail .btn9 { height: 5rem; min-width: 13rem; font-size: 1.6rem; padding: 0 .6rem; }

/* popup */
#popup-panel { background: rgba(8, 5, 32, .9); background-clip: padding-box; min-width: 30rem; max-width: 52rem; padding: .6rem 1rem; text-align: center; animation: popin .28s cubic-bezier(.3,1.5,.5,1); }
#popup-panel h2 { margin: .2rem 0 .6rem; font-size: 2.4rem; font-weight: 900; color: #fff; text-shadow: 0 0 1rem #ff3df5, 0 2px 0 #000; }
#popup-panel .pbody { font-size: 1.5rem; line-height: 1.5; color: #d8e4ff; margin-bottom: 1rem; text-align: left; }
#popup-panel .pbody.c { text-align: center; }
#popup-panel .pbtns { display: flex; gap: 1rem; justify-content: center; margin: .4rem 0 .2rem; }
#popup-panel .pbtns .btn9 { height: 5rem; min-width: 12rem; font-size: 1.6rem; padding: 0 .6rem; }
#popup-panel .big { font-size: 3rem; font-weight: 900; color: #ffe08a; text-shadow: 0 0 1rem #ffb800, 0 2px 0 #000; }
#popup-panel .btn9.focus { filter: brightness(1.4) drop-shadow(0 0 .8rem #ff3df5); }

/* chapter goal in the HUD */
#goal { display: flex; align-items: center; gap: .4rem; font-size: 1.5rem; font-weight: 900; color: #bff8ff; white-space: nowrap;
  padding-left: 1rem; border-left: 1px solid #3b3a78; text-shadow: 0 0 .5rem #00e5ff, 0 1px 0 #000; }
#goal .gl { font-size: 1.2rem; color: #9fb4e8; }
#goal img, #goal svg { width: 2.2rem; height: 2.2rem; object-fit: contain; filter: drop-shadow(0 0 4px #fff6); }
#goal.done { color: #ffe08a; text-shadow: 0 0 .7rem #ffb800, 0 1px 0 #000; }

/* hand-mining ring */
#mine-ring { position: absolute; width: 5.6rem; height: 5.6rem; transform: translate(-50%, -50%); pointer-events: none !important; z-index: 3;
  border-radius: 50%; background: conic-gradient(#3ff8ff calc(var(--p, 0) * 1%), rgba(0, 229, 255, .16) 0);
  -webkit-mask: radial-gradient(circle, transparent 54%, #000 56%); mask: radial-gradient(circle, transparent 54%, #000 56%);
  filter: drop-shadow(0 0 .6rem #00e5ff) drop-shadow(0 0 .2rem #fff); }
#mine-ring i { display: none; }

/* chapter select */
#chapters { position: fixed; inset: 0; z-index: 5; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-bottom: 4.6rem;
  animation: popin .3s cubic-bezier(.3,1.4,.5,1); }
#ch-bg { position: absolute; inset: -3%; background: #04030c url(../assets/title-bg.webp) center / cover no-repeat; filter: brightness(.45) saturate(1.2);
  animation: drift 24s ease-in-out infinite alternate; }
#ch-title { position: relative; margin: 0 0 1rem; font-size: 3rem; font-weight: 900; letter-spacing: .08em; color: #e8fdff;
  text-shadow: -1px -1px 0 #08051c, 1px 1px 0 #08051c, 0 0 1.4rem #ff3df5, 0 0 .6rem #00e5ff; }
#ch-row { position: relative; display: flex; gap: 1rem; padding: 0 2rem; max-width: 100%; }
.chc { width: 12.6rem; height: 22.4rem; flex: none; display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: 0 0 .5rem;
  background: rgba(8, 5, 32, .88); background-clip: padding-box; color: #e8f6ff; font: inherit; cursor: pointer; text-align: center;
  transition: transform .15s, filter .15s; animation: popin .35s cubic-bezier(.3,1.6,.5,1) both; }
.chc .thumb { position: relative; width: 100%; height: 7.4rem; flex: none; border-radius: .6rem; background-size: cover; background-position: center;
  box-shadow: inset 0 0 1.2rem #000a; display: flex; align-items: center; justify-content: center; }
.chc .lk { font-size: 3rem; filter: drop-shadow(0 0 .6rem #000); }
.chc .cn { font-size: 1.2rem; font-weight: 700; color: #9fb4e8; letter-spacing: .1em; }
.chc .nm { font-size: 1.6rem; font-weight: 900; line-height: 1.15; color: #fff; text-shadow: 0 0 .7rem #ff3df5, 0 1px 0 #000; min-height: 3.7rem;
  display: flex; align-items: center; }
.chc .gl { font-size: 1.2rem; line-height: 1.25; color: #bff8ff; flex: 1; display: flex; align-items: center; padding: 0 .2rem; }
.chc .st { font-size: 2rem; line-height: 1; min-height: 2.2rem; }
.chc .tag { font-size: 1.2rem; font-weight: 900; color: #08051c; background: #3ff8ff; border-radius: 1rem; padding: .15rem .7rem; box-shadow: 0 0 .6rem #00e5ff; }
.chc .bt { font-size: 1.1rem; color: #ffe08a; }
.chc:hover:not(.locked) { transform: translateY(-.4rem) scale(1.03); filter: brightness(1.2); }
.chc.focus { transform: translateY(-.6rem) scale(1.06); filter: brightness(1.25) drop-shadow(0 0 1rem #ff3df5); }
.chc.clear .nm { color: #ffe08a; }
.chc.locked { cursor: default; }
.chc.locked .thumb { filter: grayscale(1) brightness(.35); }
.chc.locked .nm, .chc.locked .gl, .chc.locked .cn { opacity: .5; }
.chc .st span:not(.tag) { color: #ffd84a; text-shadow: 0 0 .7rem #ffb800, 0 1px 0 #000; }
.chc .st span.off { color: #2c2a5c; text-shadow: none; }
.stars span { color: #ffd84a; text-shadow: 0 0 .7rem #ffb800, 0 1px 0 #000; margin: 0 .1rem; }
.stars span.off { color: #2c2a5c; text-shadow: none; }
#popup-panel .stars { font-size: 4rem; text-align: center; line-height: 1.1; margin-bottom: .4rem; }
#popup-panel .stars span { display: inline-block; animation: popin .4s cubic-bezier(.3,1.8,.5,1) both; }
#popup-panel .stars span:nth-child(2) { animation-delay: .15s; }
#popup-panel .stars span:nth-child(3) { animation-delay: .3s; }
.nb { display: inline-block; font-size: 1.2rem; font-weight: 900; color: #08051c; background: #ffd84a; border-radius: 1rem; padding: 0 .6rem;
  box-shadow: 0 0 .8rem #ffb800; animation: pulse .8s ease-in-out infinite alternate; }
#ch-back { position: absolute; left: 1rem; bottom: 1rem; height: 4.8rem; min-width: 11rem; font-size: 1.6rem; padding: 0 .6rem; }

@keyframes pulse { from { opacity: .55; transform: scale(.97); } to { opacity: 1; transform: scale(1.02); } }
@keyframes popin { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slidein { from { transform: translateX(30%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -4rem; } }
@keyframes drift { from { transform: scale(1) translateX(0); } to { transform: scale(1.06) translateX(-1.5%); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-1.2%); } }
@keyframes logoin { from { transform: scale(.4) translateY(-30%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes glow { from { box-shadow: 0 0 .4rem #00e5ff88; } to { box-shadow: 0 0 1.4rem #00e5ff; } }
