html, body { margin: 0; padding: 0; width: 100%; height: 100%; background: #07141c; overflow: hidden; }
body { display: flex; align-items: center; justify-content: center; }
#frame {
  position: relative; overflow: hidden; background: #0d2a36;
  font-family: system-ui, sans-serif; color: #fff4dc;
  box-shadow: 0 0 40px rgba(0,0,0,.6);
}
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 20; }
.screen.dim { background: rgba(4, 14, 22, .62); backdrop-filter: blur(3px); }
#loading { background: #0d2a36; }
.loadtxt { font-size: 1.1em; letter-spacing: .1em; margin-bottom: .8em; }
#loadbar { width: 60%; height: .5em; border-radius: 1em; background: rgba(255,255,255,.15); overflow: hidden; }
#loadfill { height: 100%; width: 0; background: linear-gradient(90deg, #d9452b, #ffcc66); transition: width .2s; }

#title { justify-content: space-between; }
.titlebg, .mapbg { position: absolute; inset: 0; background: #164a5a center / cover no-repeat; }
.titlebg { background-image: url(../assets/title-art.png); animation: kenburns 30s ease-in-out infinite alternate; }
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.1) translateY(-1%); } }
.titlebox { position: relative; margin-top: 9%; text-align: center; padding: 0 .6em; }
.gametitle {
  font-size: 2.3em; font-weight: 900; letter-spacing: .04em; line-height: 1.15;
  color: #fff3d0; text-shadow: 0 .08em 0 #8b1d12, 0 .14em .4em rgba(0,0,0,.65), 0 0 1em rgba(255,180,80,.45);
}
.subtitle { margin-top: .5em; font-size: 1em; color: #ffe2a6; text-shadow: 0 2px 6px rgba(0,0,0,.8); letter-spacing: .08em; }
.titlebottom { position: relative; margin-bottom: 9%; display: flex; flex-direction: column; align-items: center; gap: .8em; width: 100%; }
.help { font-size: .72em; max-width: 86%; text-align: center; line-height: 1.5; background: rgba(5,20,30,.55); padding: .5em .9em; border-radius: .6em; }

.bigbtn {
  font-size: 1.3em; font-weight: 800; padding: .55em 1.6em; border-radius: 1em; min-width: 8em;
  border: .12em solid #ffd27a; background: linear-gradient(#c8392a, #7f1c14);
  box-shadow: 0 .25em 0 #4a0f0a, 0 .4em 1em rgba(0,0,0,.5); text-shadow: 0 2px 2px rgba(0,0,0,.5);
}
.bigbtn:active { transform: translateY(.15em); box-shadow: 0 .1em 0 #4a0f0a; }
.bigbtn:disabled { filter: grayscale(.8) brightness(.7); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.langbtn {
  font-size: .9em; padding: .45em 1.1em; border-radius: 2em; border: .1em solid rgba(255,230,170,.7);
  background: rgba(6,24,34,.7);
}
[data-nav].focus { outline: .18em solid #fff; outline-offset: .18em; }

#video { background: #000; }
#introvid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.skip { position: absolute; top: 4%; right: 4%; font-size: .95em; padding: .5em 1em; border-radius: 2em; border: .1em solid rgba(255,255,255,.6); background: rgba(0,0,0,.5); z-index: 2; }
.subtitle-box { position: absolute; left: 6%; right: 6%; bottom: 14%; text-align: center; font-size: .95em; line-height: 1.5; background: rgba(0,0,0,.55); padding: .6em .8em; border-radius: .6em; }
.subtitle-box:empty { display: none; }

.mapbg { background-image: url(../assets/map-bg.png); filter: brightness(.75) saturate(1.1); }
.panel {
  position: relative; background: linear-gradient(rgba(42, 24, 14, .9), rgba(24, 14, 10, .92));
  border: .14em solid #d9a54a; border-radius: .9em; box-shadow: 0 .5em 2em rgba(0,0,0,.6), inset 0 0 0 .25em rgba(217,165,74,.18);
  padding: 1.1em 1.1em; width: 84%; box-sizing: border-box; text-align: center;
}
.chap { font-size: .85em; color: #ffcc77; letter-spacing: .2em; }
.stagename { font-size: 1.8em; font-weight: 900; margin: .15em 0 .4em; color: #fff3d0; text-shadow: 0 .06em 0 #8b1d12; }
.desc { font-size: .88em; line-height: 1.6; text-align: left; color: #f4e3c4; }
.goaltxt { margin: .7em 0; font-size: .9em; color: #ffd27a; font-weight: 700; }
.uptitle { font-size: .85em; margin: .4em 0; color: #ffcc77; }
#upcards { display: flex; gap: .45em; justify-content: center; margin-bottom: .9em; }
.upcard {
  flex: 1 1 0; min-width: 0; padding: .5em .3em; border-radius: .6em; border: .1em solid rgba(217,165,74,.6);
  background: rgba(255,240,210,.08); display: flex; flex-direction: column; align-items: center; gap: .25em;
}
.upcard img { width: 2.6em; height: 2.6em; object-fit: contain; }
.upcard .un { font-size: .8em; font-weight: 800; color: #fff0c8; }
.upcard .ud { font-size: .66em; line-height: 1.35; color: #e8d3ad; }
.upcard.sel { background: rgba(200, 57, 42, .55); border-color: #ffd27a; box-shadow: 0 0 .8em rgba(255,200,100,.5); }

.menupanel { display: flex; flex-direction: column; align-items: stretch; gap: .6em; width: 78%; }
.paneltitle { font-size: 1.6em; font-weight: 900; color: #fff3d0; margin-bottom: .2em; }
.menubtn {
  font-size: 1.05em; font-weight: 700; padding: .6em .5em; border-radius: .6em;
  border: .1em solid #d9a54a; background: linear-gradient(#7f1c14, #561009);
}
#rportrait { width: 7em; height: 7em; align-self: center; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#topbar { position: absolute; top: calc(.6em + env(safe-area-inset-top, 0px)); left: .6em; right: 3.6em; display: flex; justify-content: space-between; align-items: flex-start; gap: .5em; }
#hpwrap { flex: 1 1 auto; max-width: 55%; }
.lbl { font-size: .7em; font-weight: 700; color: #ffe2a6; text-shadow: 0 1px 3px #000; }
#hpbar { height: .75em; border-radius: .4em; background: rgba(0,0,0,.5); border: .08em solid #d9a54a; overflow: hidden; margin-top: .15em; }
#hpfill { height: 100%; width: 100%; background: linear-gradient(90deg, #d9452b, #ffb347); transition: width .15s; }
#rightinfo { text-align: right; }
#score { font-size: .9em; font-weight: 800; text-shadow: 0 1px 3px #000; color: #ffe9b8; }
#fsrow { display: flex; gap: .2em; justify-content: flex-end; margin-top: .2em; }
#fsrow img, #fsrow .fsdot { width: 1.4em; height: 1.4em; object-fit: contain; }
#fsrow .off { opacity: .25; filter: grayscale(1); }
#goal { position: absolute; top: calc(2.8em + env(safe-area-inset-top, 0px)); left: .6em; font-size: .75em; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; background: rgba(0,0,0,.3); padding: .2em .6em; border-radius: .5em; }
#bossbar { position: absolute; top: calc(4.4em + env(safe-area-inset-top, 0px)); left: 8%; right: 8%; text-align: center; }
#bossname { font-size: .85em; font-weight: 900; color: #ffd27a; text-shadow: 0 1px 3px #000; }
#bossbg { height: .6em; border-radius: .3em; background: rgba(0,0,0,.55); border: .08em solid #ffd27a; overflow: hidden; margin-top: .15em; }
#bossfill { height: 100%; width: 100%; background: linear-gradient(90deg, #7a1a9a, #e04060); transition: width .15s; }
#dialog {
  position: absolute; top: calc(7.2em + env(safe-area-inset-top, 0px)); left: 4%; right: 4%; display: flex; gap: .5em; align-items: center;
  background: linear-gradient(rgba(42,24,14,.88), rgba(24,14,10,.9)); border: .1em solid #d9a54a; border-radius: .7em; padding: .35em .6em .35em .35em;
  animation: dlgin .3s ease-out;
}
@keyframes dlgin { from { opacity: 0; transform: translateY(-.6em); } }
#portrait { width: 4.6em; height: 4.6em; flex: 0 0 auto; border-radius: .5em; background: radial-gradient(#3a6b78, #142a33); }
#dlgname { font-size: .78em; font-weight: 900; color: #ffcc66; }
#dlgline { font-size: .84em; line-height: 1.45; }
#banner {
  position: absolute; top: 36%; left: 0; right: 0; text-align: center; font-size: 1.7em; font-weight: 900; color: #fff3d0;
  text-shadow: 0 .06em 0 #8b1d12, 0 .1em .5em rgba(0,0,0,.7); opacity: 0; transition: opacity .4s, transform .4s; transform: scale(.9); padding: 0 .5em;
}
#banner.show { opacity: 1; transform: scale(1); }
#banner small { display: block; font-size: .5em; color: #ffd27a; letter-spacing: .15em; }
#toasts { position: absolute; top: 48%; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: .3em; }
.toast { font-size: .9em; font-weight: 800; color: #fff; text-shadow: 0 1px 3px #000, 0 0 6px rgba(0,0,0,.6); animation: toast 1.6s ease-out forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(.6em); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-1em); } }
.arrow { position: absolute; width: 0; height: 0; border-left: .55em solid transparent; border-right: .55em solid transparent; border-bottom: 1em solid #ff5a3c; filter: drop-shadow(0 0 3px #000); margin: -.5em 0 0 -.55em; }
.arrow.boss { border-bottom-color: #c060ff; border-left-width: .75em; border-right-width: .75em; border-bottom-width: 1.3em; }
