:root {
  --panel-img: url(assets/ui-panel.webp); --panel-slice: 22%; --panel-border: 22px;
  --btn-img: url(assets/ui-button.webp); --btn-slice: 30%; --btn-border: 14px;
  --cream: #fff4d6; --gold: #ffd27a; --ink: #2a1606; --lapis: #14307a;
}
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; overflow: hidden; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: absolute; inset: 0; pointer-events: none; color: var(--cream); font-weight: 900; font-size: 16px;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 2px 0 var(--ink); overflow: hidden; }
#ui * { box-sizing: border-box; }
#ui .small { font-size: 12px; -webkit-text-stroke: 2px var(--ink); font-weight: 800; }
#ui .gold { color: var(--gold); }
#ui img { -webkit-text-stroke: 0; }

.screen { position: absolute; inset: 0; display: none; }
.screen.on { display: block; }
.screen.full { pointer-events: auto; }

.panel { border: var(--panel-border) solid #d9a441; border-image: var(--panel-img) var(--panel-slice) fill / var(--panel-border) stretch;
  background: linear-gradient(#1c3f94, #0d1f56); pointer-events: auto; }
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px;
  padding: 2px 10px; border: var(--btn-border) solid #c98a2b; border-image: var(--btn-img) var(--btn-slice) fill / var(--btn-border) stretch;
  background: linear-gradient(#f0b94a, #b87a1c); pointer-events: auto; cursor: pointer; text-align: center; line-height: 1.1;
  transition: transform .12s cubic-bezier(.3,1.6,.5,1), filter .12s; }
.btn.round { width: 48px; height: 48px; padding: 0; border-radius: 50%; border: 2px solid var(--gold); border-image: none;
  background: rgba(16,36,96,.7); }
.btn.blue { border-image: none; border: 3px solid var(--gold); border-radius: 12px; background: linear-gradient(#1c3f94, #0d1f56); }
.btn:active { transform: scale(.92); }
@media (hover:hover) { .btn:hover { filter: brightness(1.15); transform: scale(1.04); } .btn:active { transform: scale(.92); } }
.btn.focus, .card.focus { filter: brightness(1.2) drop-shadow(0 0 6px #fff4a0) drop-shadow(0 0 2px #fff); transform: scale(1.06); }
.btn.dis { filter: grayscale(.8) brightness(.7); }
.btn.dis:active { transform: none; }
.btn img.ic { width: 22px; height: 22px; object-fit: contain; }
.hide { display: none !important; }
.pop { animation: pop .26s cubic-bezier(.3,1.5,.5,1) both; }
.slideup { animation: slideup .25s cubic-bezier(.3,1.3,.5,1) both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* title */
#scr-title { background: #000 url(assets/cover-bg.webp) center / cover no-repeat; animation: fadein .3s both; }
#scr-title .logo { position: absolute; top: 5%; left: 50%; max-width: 82%; max-height: 30%; transform: translateX(-50%); object-fit: contain;
  animation: logodrop .7s cubic-bezier(.3,1.5,.5,1) both, float 3.2s ease-in-out .7s infinite; -webkit-text-stroke: 0; filter: drop-shadow(0 4px 6px #000a); }
@keyframes logodrop { from { transform: translate(-50%,-80%); opacity: 0; } to { transform: translate(-50%,0); opacity: 1; } }
@keyframes float { 0%,100% { transform: translate(-50%,0); } 50% { transform: translate(-50%,8px); } }
#scr-title .prompt { position: absolute; bottom: 12%; left: 0; right: 0; text-align: center; font-size: 20px; color: var(--gold); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .55; transform: scale(.97); } 50% { opacity: 1; transform: scale(1.04); } }
#scr-title .trophy { position: absolute; top: 10px; right: 10px; }

/* class / level select */
.bg { background: linear-gradient(rgba(10,18,52,.45), rgba(6,10,32,.88)), url(assets/sky-renaissance.webp) center / cover no-repeat, #0a1233; }
.hdr { position: absolute; top: 10px; left: 70px; right: 70px; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.hdr .ttl { font-size: 20px; line-height: 1.1; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; min-height: 30px; border: 2px solid var(--gold); border-radius: 16px; background: rgba(10,18,50,.8); }
.chip img { width: 20px; height: 20px; object-fit: contain; }
.topl { position: absolute; top: 10px; left: 70px; }
.subbar { position: absolute; top: 66px; left: 14px; right: 14px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.grid { position: absolute; top: 112px; bottom: 14px; left: 12px; right: 12px; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(110px, 1fr); gap: 10px; overflow-y: auto; pointer-events: auto; padding: 4px; }
.card { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px; text-align: center;
  border: 16px solid #d9a441; border-image: var(--panel-img) var(--panel-slice) fill / 16px stretch; background: none; cursor: pointer; transition: transform .12s, filter .12s; animation: pop .3s both; }
.card:active { transform: scale(.95); }
.card .em { width: 62px; height: 62px; object-fit: contain; -webkit-text-stroke: 0; }
.card.lk .em { filter: grayscale(.7) brightness(.6); }
.card .nm { font-size: 17px; }
.card .ps { font-size: 12px; color: var(--gold); font-weight: 800; -webkit-text-stroke: 2px var(--ink); }
.card .lkb { position: absolute; top: 4px; right: 6px; font-size: 14px; display: flex; align-items: center; gap: 2px; }
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); pointer-events: auto; animation: fadein .2s both; }
.sheet { position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 5; padding: 6px; }
.sheet .in { padding: 4px 6px; }
.row { display: flex; align-items: center; gap: 8px; }
.sp { flex: 1; min-width: 0; }
.detail .em { width: 84px; height: 84px; object-fit: contain; -webkit-text-stroke: 0; }
.desc { font-size: 14px; font-weight: 700; line-height: 1.25; -webkit-text-stroke: 2px var(--ink); color: var(--cream); }

.lvl-wrap { position: absolute; top: 110px; bottom: 14px; left: 0; right: 0; overflow-y: auto; pointer-events: auto; padding: 8px 0 20px; }
.node { position: relative; width: 210px; min-height: 64px; margin: 0 0 16px; display: flex; align-items: center; gap: 8px; padding: 0 4px; border: 14px solid #d9a441; border-image: var(--panel-img) var(--panel-slice) fill / 14px stretch;
  background: none; cursor: pointer; transition: transform .12s, filter .12s; }
.node:nth-child(odd) { margin-left: 18%; } .node:nth-child(even) { margin-left: calc(82% - 210px); }
.node:active { transform: scale(.95); }
.node.lk { filter: grayscale(.8) brightness(.65); cursor: default; }
.node.focus { filter: brightness(1.2) drop-shadow(0 0 6px #fff4a0); transform: scale(1.05); }
.node .no { width: 38px; height: 38px; border-radius: 50%; background: radial-gradient(#ffd27a, #b87a1c); display: flex; align-items: center; justify-content: center; font-size: 18px; flex: none; }
.node .nn { font-size: 14px; line-height: 1.1; }
.node .st { font-size: 15px; color: #ffcf40; }
.node .st i { color: #4a5578; font-style: normal; }
.tag { position: absolute; top: -9px; right: -6px; padding: 0 8px; border-radius: 8px; background: #b3202a; border: 2px solid var(--gold); font-size: 12px; }

/* HUD */
#hud { position: absolute; top: 8px; left: 70px; right: 70px; display: none; }
#hud.on { display: block; }
#hud .bar { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 2px 4px; pointer-events: none; border-width: 12px; }
#hud .bar span.c { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; font-size: 16px; }
#hud .bar img, #hud .bar svg { width: 20px; height: 20px; flex: none; }
#hud .w { font-size: 14px !important; }
#speed { position: absolute; top: 70px; right: 10px; min-width: 56px; font-size: 18px; }
#boss { position: absolute; top: 70px; left: 70px; right: 80px; display: none; text-align: center; font-size: 14px; }
#boss .tr { height: 14px; margin-top: 2px; border: 2px solid var(--gold); border-radius: 8px; background: #200; overflow: hidden; }
#boss .fl { height: 100%; width: 100%; background: linear-gradient(#ff5a4a, #a0121c); }
#waveBtn { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: 60%; min-width: 150px; min-height: 56px; font-size: 20px; padding: 2px 16px; }
#waveBtn.early { font-size: 15px; min-height: 48px; }
#waveBtn.pulse { animation: wpulse 1.2s ease-in-out infinite; }
@keyframes wpulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.2); } }

.bgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 4px; }
.bc { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 1px; min-height: 66px; border: 2px solid var(--gold); border-radius: 10px; background: linear-gradient(#1f4296, #0c1c52); cursor: pointer; pointer-events: auto; font-size: 12px; transition: transform .12s, filter .12s; }
.bc.sel { border-color: #fff; background: linear-gradient(#3a6ad0, #1c3a8a); transform: scale(1.04); }
.bc.dim { filter: grayscale(.7) brightness(.65); }
.bc.focus { filter: brightness(1.25) drop-shadow(0 0 5px #fff4a0); }
.bc .th { width: 38px; height: 38px; border-radius: 6px; background-size: contain; background-repeat: no-repeat; background-position: center; }
.bc .cs { display: flex; align-items: center; gap: 1px; font-size: 13px; }
.bc .cs img { width: 13px; height: 13px; }
.sh-hdr { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.sh-hdr .btn.round { width: 44px; height: 44px; font-size: 22px; }
.stats { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; font-weight: 800; color: var(--gold); }
.stars { font-size: 18px; color: #ffcf40; letter-spacing: 2px; } .stars i { color: #4a5578; font-style: normal; }
.dtl { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.dtl .th { width: 52px; height: 52px; flex: none; background-size: contain; background-repeat: no-repeat; background-position: center; border-radius: 8px; }
.arrow { font-size: 20px; color: var(--gold); }
.warn { color: #ff9a8a; font-size: 13px; }

/* overlays */
.overlay { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); pointer-events: auto; animation: fadein .2s both; }
.big { width: min(86%, 340px); padding: 6px; text-align: center; }
.big .in { padding: 6px 8px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ban { font-size: 38px; color: var(--gold); -webkit-text-stroke: 6px var(--ink); animation: slam .5s cubic-bezier(.3,1.6,.5,1) both; }
.ban.red { color: #ff6a5a; }
@keyframes slam { from { transform: scale(2.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bigstars { display: flex; gap: 6px; font-size: 52px; line-height: 1; }
.bigstars span { color: #4a5578; transform: scale(.5); opacity: .5; }
.bigstars span.lit { color: #ffcf40; animation: starpop .45s cubic-bezier(.3,1.8,.5,1) both; }
@keyframes starpop { from { transform: scale(2.4) rotate(-30deg); opacity: 0; } to { transform: none; opacity: 1; } }
.btns { display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: stretch; }
.btns .btn { width: 100%; font-size: 17px; }
.btns .rowb { display: flex; gap: 8px; } .btns .rowb .btn { flex: 1; }
.btns .btn img.ic { width: 24px; height: 24px; }
.help { width: min(92%, 360px); max-height: 82%; display: flex; }
.help .in { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; width: 100%; padding: 6px 8px; }
.help p { margin: 0; font-size: 14px; line-height: 1.35; font-weight: 700; -webkit-text-stroke: 2px var(--ink); text-align: left; }

#banner { position: absolute; left: 0; right: 0; top: 40%; text-align: center; font-size: 40px; color: var(--gold); -webkit-text-stroke: 7px var(--ink); pointer-events: none; z-index: 9; display: none; padding: 0 12px; line-height: 1.1; }
#banner.red { color: #ff6a5a; } #banner.info { font-size: 28px; color: var(--cream); }
#banner.on { display: block; animation: slam .45s cubic-bezier(.3,1.6,.5,1) both; }
#banner.out { animation: bout .3s both; } @keyframes bout { to { opacity: 0; transform: translateY(-20px); } }
#sub { position: absolute; left: 0; right: 0; top: 124px; margin: 0 auto; pointer-events: none; width: max-content; max-width: 90%; padding: 6px 14px; background: rgba(0,0,0,.6); border-radius: 10px; text-align: center; font-size: 15px; display: none; z-index: 9; -webkit-text-stroke: 2px var(--ink); }
#sub.on { display: block; animation: fadein .2s both; }

#intro { position: absolute; inset: 0; z-index: 20; background: #000 url(assets/cover-bg.webp) center / cover; pointer-events: auto; }
#intro video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#intro .skip { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); }
.fring { outline: none; }
