@font-face { font-family: 'HorrorNightDrip'; src: url('../fonts/HorrorNightDrip-K7Jap.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Bauhaus93'; src: url('../fonts/BAUHS93.TTF') format('truetype'); font-display: block; }

:root {
  --bg: #05060b;
  --bone: #EFE7DA;
  --toxic: #95C623;
  --danger: #ff3b30;
  --blue: #49B6FF; --green: #5DFF6A; --purple: #C35BFF;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --banner: 0px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); touch-action: none; overscroll-behavior: none; }
body.ads { --banner: 56px; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#hud { position: fixed; inset: 0; pointer-events: none; color: var(--bone); }
.topbar { position: absolute; top: calc(var(--safe-top) + var(--banner) + 8px); right: 20px; text-align: right; }
.score { font-family: 'HorrorNightDrip', serif; font-size: clamp(44px, 12vw, 76px); line-height: 1; text-shadow: 0 0 18px rgba(0,0,0,.9); transition: transform .1s; transform-origin: right center; }
.score.bump { transform: scale(0.75); }
.life { font-family: 'Bauhaus93', sans-serif; font-size: 22px; color: var(--toxic); text-shadow: 0 0 8px #000; }
.life.danger { color: var(--danger); animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .35; } }

.controls { position: absolute; left: 0; right: 0; bottom: 0; height: 55%; display: flex; }
.zone { flex: 1; }

.level-flash { position: absolute; top: 38%; width: 100%; text-align: center; font-family: 'HorrorNightDrip', serif; font-size: 54px; color: #fff; opacity: 0; text-shadow: 0 0 24px #49B6FF; }
.level-flash.show { animation: levelflash 1.4s ease-out; }
@keyframes levelflash { 0% { opacity: 0; transform: scale(1.6); } 20% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }

.title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: calc(var(--safe-top) + 6vh); opacity: 0; transition: opacity .3s; }
.title.show { opacity: 1; }
.logo { width: min(92vw, 520px); transform: translateY(-120%); transition: transform 1s cubic-bezier(.34,1.56,.64,1); filter: drop-shadow(0 0 30px rgba(73,182,255,.35)); }
.title.show .logo { transform: translateY(0); }
.title.leaving .logo { transform: translateY(-140%); transition: transform .3s ease-in; }
.start { margin-top: auto; margin-bottom: calc(var(--safe-bottom) + 34vh); font-family: 'HorrorNightDrip', serif; font-size: 55px; color: #D9C7A9; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .35; transform: scale(.94); } }

.over { background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 55%, rgba(0,0,0,.6) 100%); position: absolute; inset: 0; transform: translateY(100%); transition: transform .5s cubic-bezier(.2,.9,.3,1.1); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.over.show { transform: translateY(0); }
/* Game over: blood-red dripping title over the live 3D graveyard scene */
.over-title { position: absolute; top: calc(var(--safe-top) + 9%); width: 100%; text-align: center; font-family: 'HorrorNightDrip', serif; font-size: clamp(54px, 16vw, 120px); line-height: .95; letter-spacing: 1px; white-space: nowrap;
  color: #d8190f; background: linear-gradient(180deg, #ff5a3c 0%, #d8190f 45%, #6e0503 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #2a0000) drop-shadow(0 0 22px rgba(255,30,10,.55)); animation: title-throb 2.4s ease-in-out infinite; }
@keyframes title-throb { 50% { filter: drop-shadow(0 4px 0 #2a0000) drop-shadow(0 0 34px rgba(255,30,10,.85)); } }
.over-score { position: absolute; top: 34%; width: 100%; text-align: center; font-family: 'HorrorNightDrip', serif; font-size: clamp(80px, 24vw, 140px); line-height: 1; color: var(--bone); text-shadow: 0 0 30px #000, 0 0 8px #000; }
.over-best-label { position: absolute; top: 58%; width: 100%; text-align: center; font-family: 'HorrorNightDrip', serif; font-size: clamp(38px, 11vw, 60px); color: #7CFF3A; text-shadow: 0 0 18px rgba(124,255,58,.6), 0 3px 0 #0b3a00; }
.over-best { position: absolute; top: 67%; width: 100%; text-align: center; font-family: 'HorrorNightDrip', serif; font-size: clamp(40px, 12vw, 64px); color: var(--bone); text-shadow: 0 0 16px #000; }
.over-restart { position: absolute; top: 90%; width: 100%; text-align: center; font-family: 'HorrorNightDrip', serif; font-size: 34px; color: #fff; text-shadow: 0 0 12px #000; animation: breathe 1.4s ease-in-out infinite; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .35s; z-index: 5; }
#fade.on { opacity: 1; }
body.over-up .topbar { visibility: hidden !important; }

/* Preloader (spec §1): dark vignette with faint slow fog */
#preloader { position: fixed; inset: 0; background: radial-gradient(ellipse at center, #10140f 0%, #050605 55%, #000 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity .7s; z-index: 10; }
#preloader.done { opacity: 0; pointer-events: none; }
#preloader canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#preloader .fog { position: absolute; inset: -20%; background:
  radial-gradient(ellipse 40% 20% at 30% 70%, rgba(160,180,160,.08), transparent 70%),
  radial-gradient(ellipse 50% 25% at 70% 40%, rgba(160,180,160,.07), transparent 70%),
  radial-gradient(ellipse 35% 18% at 50% 85%, rgba(160,180,160,.06), transparent 70%);
  animation: fogdrift 18s linear infinite alternate; }
#preloader .fog2 { opacity: .8; transform: scaleX(-1); animation: fogdrift2 23s linear infinite alternate; }
@keyframes fogdrift { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
@keyframes fogdrift2 { from { transform: scaleX(-1) translate(-8%, 2%); } to { transform: scaleX(-1) translate(8%, -2%); } }
#preloader .loading-text { position: absolute; top: 81%; font-family: 'HorrorNightDrip', serif; font-size: 34px; letter-spacing: 2px; color: #B6FF6A; text-shadow: 0 0 14px rgba(124,255,58,.6); }

/* ================= Queen Z 3.0 UI ================= */
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.icon-btn { pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; border-radius: 14px;
  background: rgba(10,8,12,.55); border: 1px solid rgba(255,255,255,.14); color: #e8dfcf; font-size: 22px; backdrop-filter: blur(4px); }
.icon-btn span { font-family: 'Bauhaus93', sans-serif; font-size: 12px; letter-spacing: .5px; opacity: .85; }
.pause-btn { position: absolute; top: calc(var(--safe-top) + var(--banner) + 10px); left: 14px; font-size: 16px; padding: 10px 14px; display: none; }
.title-buttons { position: absolute; bottom: calc(var(--safe-bottom) + 6vh); left: 0; right: 0; display: flex; justify-content: center; gap: 14px; pointer-events: none; visibility: hidden; }
body.title-up .title-buttons { visibility: visible; }

.combo { position: absolute; top: calc(var(--safe-top) + var(--banner) + 150px); left: 16px; font-family: 'HorrorNightDrip', serif; opacity: 0; transform: scale(.6); transition: opacity .2s, transform .2s; text-shadow: 0 0 14px #000; }
.combo.show { opacity: 1; transform: scale(1); }
.combo b { display: block; font-size: 52px; line-height: .9; color: #ffd23a; text-shadow: 0 0 18px rgba(255,180,0,.7), 0 0 4px #000; }
.combo[data-m="3"] b, .combo[data-m="4"] b { color: #ff7a1a; text-shadow: 0 0 24px rgba(255,90,0,.9); }
.combo[data-m="5"] b { color: #ff2a55; text-shadow: 0 0 30px rgba(255,0,60,1), 0 0 60px rgba(160,40,255,.8); animation: pulse .35s ease-in-out infinite alternate; }
.combo span { font-size: 20px; color: #eee; }
.combo.pop b { animation: pop .3s ease-out; }
@keyframes pop { 0% { transform: scale(1.8); } 100% { transform: scale(1); } }

.boss { position: absolute; top: calc(var(--safe-top) + var(--banner) + 64px); left: 50%; width: min(78vw, 420px); transform: translate(-50%, -20px); opacity: 0; transition: .3s; text-align: center; }
.boss.show { opacity: 1; transform: translate(-50%, 0); }
.boss-name { font-family: 'HorrorNightDrip', serif; font-size: 28px; color: #8fd8ff; text-shadow: 0 0 14px #49b6ff; }
.boss-track { height: 12px; border-radius: 6px; background: rgba(0,0,0,.6); border: 1px solid rgba(143,216,255,.5); overflow: hidden; }
.boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #1e5aff, #49b6ff, #c6f0ff); box-shadow: 0 0 12px #49b6ff; transition: width .25s; }
.boss-seq { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.boss-seq i { width: 14px; height: 14px; border-radius: 50%; display: block; transition: transform .2s; }

.power { position: absolute; bottom: calc(var(--safe-bottom) + 25vh); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 20px;
  background: rgba(0,0,0,.55); border: 1px solid var(--c); box-shadow: 0 0 16px var(--c); opacity: 0; transition: opacity .2s; font-family: 'Bauhaus93', sans-serif; color: #fff; }
.power.show { opacity: 1; }
.power-icon { font-size: 22px; } .power-name { font-size: 16px; letter-spacing: 1px; white-space: nowrap; }
.power-track { width: 70px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.power-fill { height: 100%; background: var(--c); }

.banner { position: absolute; top: 36%; width: 100%; text-align: center; font-family: 'HorrorNightDrip', serif; font-size: clamp(40px, 13vw, 76px); color: #fff; opacity: 0; text-shadow: 0 0 26px var(--c, #49B6FF), 0 0 6px #000; pointer-events: none; }
.banner.big { font-size: clamp(48px, 15vw, 96px); }
.banner.show { animation: levelflash 1.6s ease-out; }

.toasts { position: fixed; top: calc(var(--safe-top) + var(--banner) + 10px); left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 14px; background: rgba(12,10,8,.9); border: 1px solid #c9a24a; box-shadow: 0 0 20px rgba(201,162,74,.45);
  color: #f3e7c8; font-family: 'Bauhaus93', sans-serif; animation: toastin .35s ease-out; min-width: 240px; }
.toast b { display: block; font-size: 16px; color: #ffd36a; } .toast span { font-size: 12px; opacity: .85; } .toast-icon { font-size: 26px; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .5s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-14px); } }

.tutorial { position: absolute; inset: 0; opacity: 0; transition: opacity .3s; pointer-events: none; }
.tutorial.show { opacity: 1; }
.tut-zone { position: absolute; bottom: 0; width: 33.333%; height: 34%; border-radius: 22px 22px 0 0; background: radial-gradient(ellipse at 50% 70%, color-mix(in srgb, var(--c) 45%, transparent), transparent 70%);
  border: 2px solid var(--c); border-bottom: 0; box-shadow: 0 0 30px var(--c) inset; animation: breathe 1.1s ease-in-out infinite; transition: left .3s; }
.tut-hand { position: absolute; left: 50%; top: 42%; font-size: 48px; transform: translateX(-50%); animation: tap .9s ease-in-out infinite; }
@keyframes tap { 50% { transform: translate(-50%, 14px) scale(.9); } }
.tut-text { position: absolute; top: 24%; width: 100%; padding: 0 20px; text-align: center; font-family: 'HorrorNightDrip', serif; font-size: clamp(26px, 8vw, 40px); color: #fff; text-shadow: 0 0 16px #000, 0 0 4px #000; line-height: 1.15; }

.revive { position: absolute; top: 79%; left: 50%; transform: translate(-50%, -50%); display: none; }
.revive.show { display: block; }
.revive-btn { position: relative; pointer-events: auto; display: flex; flex-direction: column; align-items: center; padding: 14px 30px; border-radius: 40px;
  background: linear-gradient(180deg, #7CFF3A, #2a9a10); color: #062000; box-shadow: 0 0 30px rgba(124,255,58,.7); animation: breathe 1.2s ease-in-out infinite; overflow: hidden; }
.revive-btn b { font-family: 'HorrorNightDrip', serif; font-size: 38px; line-height: 1; } .revive-btn small { font-family: 'Bauhaus93', sans-serif; font-size: 12px; }
.revive-ring { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: #062000; transform-origin: left; }
.revive.expire .revive-ring { animation: drain 6s linear forwards; }
@keyframes drain { to { transform: scaleX(0); } }

.panel-wrap { position: fixed; inset: 0; z-index: 15; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.panel-wrap.show { display: flex; }
.panel { width: min(90vw, 420px); max-height: 86vh; display: flex; flex-direction: column; padding: 18px; border-radius: 22px; color: #eee5d6;
  background: linear-gradient(180deg, rgba(34,20,22,.97), rgba(12,9,12,.97)); border: 1px solid rgba(255,90,60,.35); box-shadow: 0 0 40px rgba(255,40,20,.25); font-family: 'Bauhaus93', sans-serif; }
.panel-title { font-family: 'HorrorNightDrip', serif; font-size: 44px; text-align: center; color: #e8261a; text-shadow: 0 0 18px rgba(255,30,10,.6); margin-bottom: 8px; }
.panel-body { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.menu-btn { padding: 13px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); font-size: 17px; text-align: center; }
.menu-btn.primary { background: linear-gradient(180deg, #e8261a, #8e0f08); border-color: #ff6a50; font-size: 20px; }
.menu-btn.close { margin-top: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 2px; }
.toggle { min-width: 64px; padding: 8px 12px; border-radius: 20px; background: rgba(255,255,255,.1); }
.toggle.on { background: #7CFF3A; color: #0b2a00; }
.seg { display: flex; gap: 4px; background: rgba(255,255,255,.06); border-radius: 12px; padding: 3px; }
.seg-btn { flex: 1; padding: 7px 9px; border-radius: 9px; font-size: 13px; }
.seg-btn.on { background: #e8261a; color: #fff; }
.tabs { margin-bottom: 4px; }
.version { text-align: center; font-size: 11px; opacity: .5; margin-top: 6px; }
.skins { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.skin { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 16px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); }
.skin.current { border-color: #7CFF3A; box-shadow: 0 0 14px rgba(124,255,58,.4); }
.skin.locked { opacity: .55; }
.skin small { font-size: 11px; opacity: .8; text-align: center; }
.skin-orb { width: 44px; height: 44px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, var(--f) 45%, transparent 72%); box-shadow: 0 0 22px var(--f); }
.list { display: flex; flex-direction: column; gap: 8px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.05); opacity: .55; }
.ach.got { opacity: 1; border: 1px solid rgba(201,162,74,.6); }
.ach i { font-style: normal; font-size: 24px; } .ach b { display: block; } .ach span { font-size: 12px; opacity: .8; }
.score-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.05); }
.score-row span { font-family: 'HorrorNightDrip', serif; font-size: 28px; } .score-row small { opacity: .6; }
.stats, .empty { font-size: 13px; opacity: .8; text-align: center; padding: 8px; }
.gpg { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
