@font-face { font-family: 'Lilita One'; src: url('fonts/lilita-one-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 700; src: url('fonts/nunito-latin-700-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 800; src: url('fonts/nunito-latin-800-normal.woff2') format('woff2'); font-display: swap; }

:root {
  --gold: #ffc94a; --gold2: #ff9d2e; --ink: #0c0910; --paper: #f6ecd9; --mute: #b9ab9a;
  --red: #ff4d4d; --green: #5fe07a; --blue: #58b8ff; --rare: #58b8ff; --epic: #c77dff;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #040306; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--body); font-weight: 700; color: var(--paper);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
  display: flex; justify-content: center;
  background: radial-gradient(120% 80% at 50% 40%, #17111f 0%, #040306 70%);
}
#stage {
  position: relative; height: 100dvh; width: min(100vw, calc(100dvh * 0.62)); overflow: hidden;
  background: #07060b; container-type: size;
}
@media (min-aspect-ratio: 7/10) { #stage { box-shadow: 0 0 0 1px #ffffff14, 0 30px 120px #000; } }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }

#vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s;
  background: radial-gradient(ellipse at center, transparent 45%, #ff1a1acc 120%); }
#vignette.hit { opacity: 1; transition: none; }
#vignette.low { opacity: .55; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

#ftexts { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ftext { position: absolute; left: 0; top: 0; font-family: var(--display); font-size: 5.2cqw; color: #fff; white-space: nowrap;
  text-shadow: 0 .4cqw 0 #000a, 0 0 1cqw #000; will-change: transform, opacity; letter-spacing: .02em; }
.ftext.crit { color: #ffe14a; font-size: 7.4cqw; }
.ftext.hurt { color: #ff5c5c; font-size: 6.4cqw; }
.ftext.heal { color: #7dff9a; }
.ftext.dodge { color: #bfe9ff; font-size: 4.6cqw; }
.ftext.big { font-size: 7.6cqw; }
.ftext.gold { color: var(--gold); }

#stick { position: absolute; width: 30cqw; height: 30cqw; max-width: 150px; max-height: 150px; margin: 0; transform: translate(-50%, -50%);
  border-radius: 50%; border: 2px solid #ffffff38; background: radial-gradient(circle, #ffffff14, #ffffff05); pointer-events: none; opacity: 0; transition: opacity .15s; }
#stick.on { opacity: 1; }
#stick i { position: absolute; left: 50%; top: 50%; width: 44%; height: 44%; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #fff, #ffd98a 45%, #c98a2b); box-shadow: 0 4px 14px #0008; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 1; pointer-events: none; padding: calc(var(--sat) + 2.6cqw) 3.2cqw 0; }
.hud-top { display: flex; align-items: center; gap: 2.4cqw; }
.iconbtn { pointer-events: auto; width: 11cqw; height: 11cqw; max-width: 52px; max-height: 52px; flex: none; border-radius: 28%;
  background: #0b0810b8; border: 1.5px solid #ffffff26; display: grid; place-items: center; font-size: 5cqw; backdrop-filter: blur(6px); }
.iconbtn:active { transform: scale(.92); }
.pause-ic { width: 34%; height: 40%; border-left: .95cqw solid var(--paper); border-right: .95cqw solid var(--paper); }
.roominfo { flex: 1; text-align: center; min-width: 0; }
#chapName { font-family: var(--display); font-size: 4.6cqw; letter-spacing: .04em; text-shadow: 0 2px 0 #000c; }
#pips { display: flex; gap: 1.3cqw; justify-content: center; margin-top: .9cqw; }
#pips i { width: 2.4cqw; height: 2.4cqw; border-radius: 50%; background: #ffffff30; box-shadow: 0 1px 0 #0009; }
#pips i.done { background: var(--gold); }
#pips i.now { background: #fff; box-shadow: 0 0 0 .7cqw #ffffff40; }
#pips i.boss { border-radius: 22%; transform: rotate(45deg) scale(1.15); }
.coins { display: flex; align-items: center; gap: 1.6cqw; font-family: var(--display); font-size: 5cqw; padding: 1.4cqw 3cqw 1.4cqw 1.8cqw;
  background: #0b0810b8; border: 1.5px solid #ffffff26; border-radius: 99px; backdrop-filter: blur(6px); min-width: 17cqw; justify-content: flex-end; }
.coins.big { font-size: 5.6cqw; }
.coin { width: 1em; height: 1em; border-radius: 50%; display: inline-block; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff6c4, #ffc94a 45%, #c47a12); box-shadow: inset 0 0 0 .12em #b6710f, 0 1px 2px #0008; }
.coins.bump { animation: bump .25s; }
@keyframes bump { 40% { transform: scale(1.14); } }

.bars { margin-top: 2.6cqw; }
.bar { position: relative; height: 5.6cqw; border-radius: 99px; background: #0b0810cc; border: 1.5px solid #ffffff2e; overflow: hidden; }
.bar .fill, .bar .lag { position: absolute; inset: 0; width: 100%; transform-origin: left; border-radius: 99px; }
.bar .lag { background: #fff; opacity: .55; transition: transform .6s .25s ease-out; z-index: 0; }
.bar .fill { z-index: 1; transition: transform .12s; }
.bar.hp .fill { background: linear-gradient(#8dfc9c, #2fbf57 60%, #1f9a45); }
.bar.hp.low .fill { background: linear-gradient(#ff9a8a, #ff4d4d 60%, #c92a2a); }
.bar span { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; font-family: var(--display); font-size: 3.7cqw; text-shadow: 0 1px 0 #000, 0 0 4px #000; letter-spacing: .03em; }
.xprow { display: flex; align-items: center; gap: 2cqw; margin-top: 1.5cqw; }
#lvl { font-family: var(--display); font-size: 3.6cqw; color: var(--blue); text-shadow: 0 1px 0 #000; min-width: 9cqw; }
.bar.xp { flex: 1; height: 2.2cqw; }
.bar.xp .fill { background: linear-gradient(90deg, #3d8bff, #7fe0ff); transition: transform .3s; }
#bossBar { margin-top: 3cqw; text-align: center; animation: drop .5s cubic-bezier(.2, 1.4, .4, 1); }
#bossName { font-family: var(--display); font-size: 5cqw; color: #ffd9d0; text-shadow: 0 2px 0 #000, 0 0 12px #f005; letter-spacing: .05em; }
.bar.boss { height: 4.2cqw; margin-top: 1cqw; border-color: #ff8a7a66; }
.bar.boss .fill { background: linear-gradient(#ff8f6b, #e5383b 60%, #9d0208); transition: transform .2s; }
@keyframes drop { from { transform: translateY(-6cqw); opacity: 0; } }
#perkStrip { position: absolute; left: 3.2cqw; bottom: calc(var(--sab) + 3cqw); display: flex; flex-wrap: wrap; gap: 1.2cqw; max-width: 70cqw; opacity: .9; }
#perkStrip span { font-size: 4.2cqw; width: 7.4cqw; height: 7.4cqw; display: grid; place-items: center; border-radius: 28%; background: #0b0810b0; border: 1px solid #ffffff22; position: relative; }
#perkStrip span b { position: absolute; right: -.6cqw; bottom: -.8cqw; font-size: 2.8cqw; font-family: var(--display); color: var(--gold); text-shadow: 0 1px 0 #000; }
#hint { position: absolute; left: 0; right: 0; bottom: 9%; text-align: center; font-size: 4.4cqw; line-height: 1.5; color: #fff; text-shadow: 0 2px 6px #000; animation: breathe 2s ease-in-out infinite; }
#hint b { font-family: var(--display); font-weight: 400; font-size: 5.6cqw; color: var(--gold); letter-spacing: .03em; }
@keyframes breathe { 50% { opacity: .55; } }

#toast { z-index: 2; position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-family: var(--display); font-size: 9.5cqw; letter-spacing: .05em;
  color: var(--gold); text-shadow: 0 .6cqw 0 #5a2c00, 0 0 5cqw #ff9d2e88; pointer-events: none; opacity: 0; }
#toast.show { animation: toast 1.5s ease-out both; }
@keyframes toast { 0% { opacity: 0; transform: scale(.6); } 14% { opacity: 1; transform: scale(1.12); } 22% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-4cqw); } }

#card { z-index: 2; position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center;
  background: radial-gradient(ellipse at center, #000c 0%, #0000 70%); animation: card 2.8s ease both; }
#cardSub { font-size: 4.2cqw; letter-spacing: .5em; text-transform: uppercase; color: var(--gold); margin-right: -.5em; }
#cardName { font-family: var(--display); font-size: 12cqw; line-height: 1.05; margin: 1.5cqw 0; text-shadow: 0 .7cqw 0 #000; }
#cardLine { font-size: 4cqw; color: var(--mute); }
@keyframes card { 0% { opacity: 0; } 15% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; padding: calc(var(--sat) + 3cqw) 5cqw calc(var(--sab) + 5cqw); }
.screen.dim { background: #06040ad9; backdrop-filter: blur(5px); justify-content: center; gap: 3cqw; animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; } }
h2 { font-family: var(--display); font-weight: 400; font-size: 9cqw; margin: 0; letter-spacing: .03em; text-shadow: 0 .5cqw 0 #000; text-align: center; }
small { font-size: 3.6cqw; letter-spacing: .4em; text-transform: uppercase; color: var(--gold); }
p { margin: 0; font-size: 4.1cqw; line-height: 1.4; color: #dccfbd; text-align: center; text-wrap: balance; }

.cta { pointer-events: auto; width: 100%; max-width: 86cqw; padding: 4.2cqw 4cqw; border-radius: 4.5cqw; font-family: var(--display); font-size: 6.4cqw; letter-spacing: .04em; color: #3b1d00;
  background: linear-gradient(#ffe38a, #ffc94a 45%, #ff9d2e); box-shadow: 0 1.2cqw 0 #a85a08, 0 2.4cqw 5cqw #000a, inset 0 .5cqw 0 #fff8; transition: transform .08s, box-shadow .08s; }
.cta:active { transform: translateY(.8cqw); box-shadow: 0 .4cqw 0 #a85a08, 0 1cqw 3cqw #000a, inset 0 .5cqw 0 #fff8; }
.cta.locked { background: linear-gradient(#b9c2d6, #8a94ad 45%, #646d86); color: #151927; box-shadow: 0 1.2cqw 0 #3b4258, 0 2.4cqw 5cqw #000a, inset 0 .5cqw 0 #fff6; }
.cta .coin { vertical-align: -.12em; margin: 0 .15em 0 .3em; }
.ghost { pointer-events: auto; padding: 3cqw 6cqw; border-radius: 99px; font-size: 4.2cqw; color: var(--paper); border: 1.5px solid #ffffff30; background: #ffffff0d; min-width: 56cqw; }
.ghost:active { background: #ffffff22; }

#title { justify-content: space-between; pointer-events: none;
  background: linear-gradient(#06040acc 0%, #06040a00 30%, #06040a00 50%, #06040af2 78%); }
#title > * { pointer-events: auto; }
.title-top { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.logo { position: absolute; top: calc(var(--sat) + min(15cqw, 8cqh)); left: 0; right: 0; text-align: center; pointer-events: none !important; font-family: var(--display); line-height: .82; }
.logo span { display: block; font-size: min(25cqw, 12.5cqh); letter-spacing: .02em; color: var(--paper); text-shadow: 0 1.2cqw 0 #2a1a3d, 0 2.4cqw 0 #000, 0 0 12cqw #7a4dff66; }
.logo span + span { color: var(--gold); text-shadow: 0 1.2cqw 0 #8a4a05, 0 2.4cqw 0 #000, 0 0 12cqw #ff9d2e88; }
.logo em { display: block; margin-top: min(4.5cqw, 2.4cqh); font: 700 min(3.6cqw, 2cqh) var(--body); letter-spacing: .34em; text-transform: uppercase; color: #d9c9b2; text-shadow: 0 1px 4px #000; }
.logo.small { position: static; margin-top: 30cqh; }
.arrow { position: absolute; top: 48%; width: 13cqw; height: 18cqw; font-family: var(--display); font-size: 13cqw; line-height: 1; color: #fff; opacity: .85; text-shadow: 0 3px 0 #000; }
.arrow.left { left: 1cqw; } .arrow.right { right: 1cqw; }
.arrow:active { transform: scale(.85); }
.heropanel { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2.2cqw; }
#heroDots { display: flex; gap: 1.8cqw; }
#heroDots i { width: 2.2cqw; height: 2.2cqw; border-radius: 50%; background: #ffffff35; }
#heroDots i.on { background: var(--gold); transform: scale(1.3); }
#heroName { font-size: min(10cqw, 5.4cqh); }
#heroBlurb { min-height: 11.5cqw; max-width: 80cqw; }
.stats { display: flex; gap: 4cqw; width: 100%; max-width: 86cqw; margin: 1cqw 0 1.5cqw; }
.stats > div { flex: 1; }
.stats label { display: block; font-size: 3cqw; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); margin-bottom: 1cqw; }
.stat { height: 2cqw; border-radius: 99px; background: #ffffff1c; overflow: hidden; }
.stat i { display: block; height: 100%; width: 50%; border-radius: 99px; background: linear-gradient(90deg, var(--gold2), var(--gold)); transition: width .35s cubic-bezier(.2, 1.2, .4, 1); }
#best { font-size: 3.4cqw; color: var(--mute); min-height: 4.6cqw; letter-spacing: .04em; }

.perk-head { text-align: center; margin-bottom: 1cqw; }
#perkList { display: flex; flex-direction: column; gap: 3cqw; width: 100%; }
.perk { pointer-events: auto; display: flex; align-items: center; gap: 4cqw; text-align: left; padding: 3.6cqw 4cqw; border-radius: 5cqw; width: 100%;
  background: linear-gradient(135deg, #2a2233, #17121e); border: 2px solid #ffffff24; box-shadow: 0 1.2cqw 0 #00000080; animation: perkin .35s cubic-bezier(.2, 1.3, .4, 1) both; }
.perk:nth-child(2) { animation-delay: .07s; } .perk:nth-child(3) { animation-delay: .14s; }
@keyframes perkin { from { opacity: 0; transform: translateY(8cqw) scale(.94); } }
.perk:active, .perk.pick { transform: scale(.97); filter: brightness(1.25); }
.perk .ic { flex: none; width: 15cqw; height: 15cqw; border-radius: 30%; display: grid; place-items: center; font-size: 8cqw; background: #ffffff12; box-shadow: inset 0 0 0 2px #ffffff1a; }
.perk h3 { margin: 0 0 .6cqw; font: 400 5.4cqw var(--display); letter-spacing: .02em; }
.perk p { text-align: left; font-size: 3.7cqw; color: #cdbfae; }
.perk em { font-style: normal; font-size: 2.8cqw; letter-spacing: .2em; text-transform: uppercase; color: var(--mute); }
.perk.r1 { border-color: #58b8ff88; background: linear-gradient(135deg, #1c3350, #131a2a); } .perk.r1 em { color: var(--rare); }
.perk.r2 { border-color: #c77dffaa; background: linear-gradient(135deg, #3a2157, #1c1230); box-shadow: 0 1.2cqw 0 #00000080, 0 0 6cqw #c77dff40; } .perk.r2 em { color: var(--epic); }
.perk .lv { margin-left: auto; align-self: flex-start; font: 400 3.4cqw var(--display); color: var(--gold); white-space: nowrap; }

#pausePerks { display: flex; flex-wrap: wrap; gap: 1.6cqw; justify-content: center; max-width: 84cqw; min-height: 9cqw; margin-bottom: 2cqw; }
#pausePerks span { font-size: 3.4cqw; padding: 1.4cqw 2.6cqw; border-radius: 99px; background: #ffffff12; border: 1px solid #ffffff22; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2cqw; width: 100%; margin: 3cqw 0 4cqw; }
.summary div { background: #ffffff0f; border: 1px solid #ffffff1f; border-radius: 4cqw; padding: 3cqw 0; text-align: center; }
.summary b { display: block; font: 400 6.6cqw var(--display); color: var(--gold); }
.summary label { font-size: 2.8cqw; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
#over.win { background: linear-gradient(#04180ad9 0%, #0000 30%, #0000 52%, #06240fe6 76%); backdrop-filter: none; justify-content: flex-start; }
#over.win #overSub { margin-top: 7cqh; }
#over.win .summary { margin-top: auto; }
#over.win h2 { color: var(--gold); font-size: 10.5cqw; }

#fade { position: absolute; inset: 0; z-index: 4; background: #000; opacity: 0; pointer-events: none; transition: opacity .32s; }
#fade.on { opacity: 1; }
#fade.white { background: #fff; transition: opacity .08s; }

#loading { background: #07060b; justify-content: flex-start; gap: 5cqw; z-index: 5; transition: opacity .5s; }
#loading.out { opacity: 0; pointer-events: none; }
.loadbar { width: 62cqw; height: 2.4cqw; border-radius: 99px; background: #ffffff1a; overflow: hidden; margin-top: 8cqw; }
.loadbar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold2), var(--gold)); border-radius: 99px; transition: width .2s; }
#loadText { font-size: 3.6cqw; color: var(--mute); letter-spacing: .08em; }
