html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #070b1a; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body { font-family: "Trebuchet MS", system-ui, sans-serif; color: #fff; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

.num { font-weight: 900; color: #fff; text-shadow: -2px -2px 0 #061026, 2px -2px 0 #061026, -2px 2px 0 #061026, 2px 2px 0 #061026, 0 3px 0 #061026; letter-spacing: 0.02em; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 50%; transform: translateX(-50%); width: min(100%, 620px); box-sizing: border-box; pointer-events: none; z-index: 10; padding: calc(10px + env(safe-area-inset-top, 0px)) 64px 0 calc(10px + env(safe-area-inset-left, 0px)); }
.hud-row { display: flex; gap: 8px; align-items: stretch; }
.panel { display: flex; align-items: center; gap: 8px; padding: 6px 12px; min-height: 44px; box-sizing: border-box;
  background: linear-gradient(180deg, rgba(14, 34, 64, 0.88), rgba(6, 14, 34, 0.88)); border: 2px solid #39e6d4; border-radius: 12px;
  box-shadow: 0 0 0 2px rgba(6, 16, 38, 0.8), 0 4px 0 rgba(0, 0, 0, 0.35), inset 0 0 12px rgba(57, 230, 212, 0.2); }
#threat { flex: 1 1 auto; min-width: 0; transition: border-color .2s, box-shadow .2s; }
#threat.danger { border-color: #ff3b6b; box-shadow: 0 0 0 2px rgba(40, 6, 16, 0.8), 0 0 16px rgba(255, 40, 90, 0.7); animation: dangerPulse 0.6s infinite alternate; }
@keyframes dangerPulse { from { transform: scale(1); } to { transform: scale(1.03); } }
.hud-icon { width: 30px; height: 30px; object-fit: contain; flex: 0 0 auto; filter: drop-shadow(0 2px 0 #061026); }
#threatBar { flex: 1 1 auto; display: flex; gap: 4px; min-width: 40px; }
#threatBar .seg { flex: 1 1 0; height: 14px; border-radius: 4px; background: rgba(57, 230, 212, 0.18); border: 1px solid rgba(57, 230, 212, 0.5); transition: background .2s; }
#threatBar .seg.on { background: linear-gradient(180deg, #ff6b8e, #d4103f); border-color: #ffb3c4; box-shadow: 0 0 8px rgba(255, 40, 90, 0.8); }
#threatNum { font-size: 20px; flex: 0 0 auto; }
#wavebox { flex: 0 0 auto; flex-direction: column; gap: 0; justify-content: center; padding: 3px 12px; min-width: 64px; }
#waveNum { font-size: 18px; color: #ffb648; line-height: 1.05; white-space: nowrap; }
#waveTime { font-size: 16px; line-height: 1.05; }
#score { text-align: center; font-size: 34px; margin-top: 6px; color: #fff; transition: transform .12s; }
#score.bump { transform: scale(1.18); }
#bossbar { margin: 2px auto 0; width: 72%; }
#bossName { text-align: center; font-size: 14px; color: #ff8aa6; line-height: 1.2; margin-bottom: 2px; }
#bossTrack { height: 12px; border-radius: 6px; border: 2px solid #ff3b6b; background: rgba(30, 4, 14, 0.85); overflow: hidden; box-shadow: 0 0 10px rgba(255, 40, 90, 0.5); }
#bossfill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff2a55, #ff9a3c); transition: width .15s; }
#buffs { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }
.buff { display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px; border-radius: 16px; background: rgba(6, 14, 34, 0.8); border: 2px solid #ffd24a; font-size: 16px; }
.buff img { width: 26px; height: 26px; object-fit: contain; }

#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0; background: radial-gradient(ellipse at center, rgba(255, 0, 60, 0) 45%, rgba(255, 0, 60, 0.55) 100%); }

#toasts { position: fixed; left: 0; right: 0; top: 30%; z-index: 12; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { font-size: 22px; padding: 4px 14px; animation: toastIn 1.6s ease-out forwards; text-align: center; max-width: 90%; }
.toast.good { color: #6dffa8; }
.toast.bad { color: #ff5f86; }
.toast.warn { color: #ffd24a; }
.toast.info { color: #bff8ff; font-size: 18px; }
@keyframes toastIn { 0% { transform: scale(0.4); opacity: 0; } 12% { transform: scale(1.15); opacity: 1; } 22% { transform: scale(1); } 80% { opacity: 1; transform: translateY(-8px); } 100% { opacity: 0; transform: translateY(-24px); } }

#banner { position: fixed; left: 0; right: 0; top: 38%; z-index: 13; pointer-events: none; text-align: center; }
#bannerText { display: inline-block; font-size: 44px; padding: 8px 28px; background: linear-gradient(90deg, rgba(6, 14, 34, 0), rgba(6, 14, 34, 0.9) 20%, rgba(6, 14, 34, 0.9) 80%, rgba(6, 14, 34, 0)); border-top: 3px solid #39e6d4; border-bottom: 3px solid #39e6d4; max-width: 92%; box-sizing: border-box; }
#banner.red #bannerText { color: #ff6b8e; border-color: #ff3b6b; }
#banner.emerg #bannerText { color: #ffb648; border-color: #ff8a1f; font-size: 34px; background: repeating-linear-gradient(-45deg, rgba(40, 18, 4, 0.92) 0 14px, rgba(20, 10, 4, 0.92) 14px 28px); animation: emergBlink 0.35s steps(2) 4; }
#banner.emerg #bannerSub { color: #fff; }
@keyframes emergBlink { 50% { border-color: #fff3c4; color: #fff; } }
#bannerSub { font-size: 22px; margin-top: 8px; color: #ffd24a; padding: 0 12px; }
#banner.show { animation: slam 0.45s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes slam { 0% { transform: scale(2.4); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

#subtitle { position: fixed; left: 50%; top: 150px; transform: translateX(-50%); z-index: 14; pointer-events: none; width: max-content; max-width: min(88%, 560px); box-sizing: border-box; padding: 5px 12px; font-size: 15px; font-weight: 700; text-align: center; line-height: 1.35;
  background: rgba(6, 14, 34, 0.78); border-left: 4px solid #39e6d4; border-radius: 8px; animation: subIn 0.22s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes subIn { from { transform: translateX(-50%) translateY(-8px) scale(0.92); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

/* ---------- Title ---------- */
#title { position: fixed; inset: 0; z-index: 30; overflow: hidden; cursor: pointer; }
#titleArt { position: absolute; inset: -3%; background: #070b1a url("../assets/cover-bg.webp") center / cover no-repeat; animation: drift 14s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.02) translateY(0); } to { transform: scale(1.07) translateY(-1.2%); } }
#logo { position: absolute; left: 50%; top: 6%; width: 84%; max-height: 30%; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6)); animation: logoIn 0.7s cubic-bezier(.34, 1.56, .64, 1) both, floaty 3.2s 0.7s ease-in-out infinite alternate; }
@keyframes logoIn { from { transform: translateX(-50%) translateY(-60px) scale(0.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes floaty { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(-8px); } }
#tagline { position: absolute; left: 6%; right: 6%; top: 36%; text-align: center; font-size: 17px; font-weight: 800; color: #bff8ff; text-shadow: -2px -2px 0 #061026, 2px -2px 0 #061026, -2px 2px 0 #061026, 2px 2px 0 #061026; animation: fadeIn 0.6s 0.5s both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
#titleBottom { position: absolute; left: 0; right: 0; bottom: calc(5% + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; align-items: center; gap: 18px; }
#prompt { font-size: 22px; font-weight: 900; color: #fff; text-shadow: -2px -2px 0 #061026, 2px -2px 0 #061026, -2px 2px 0 #061026, 2px 2px 0 #061026, 0 0 14px rgba(57, 230, 212, 0.8); animation: pulse 1.3s ease-in-out infinite; text-align: center; padding: 0 12px; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.96); } }

.plate-btn { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; min-width: 120px; padding: 6px 24px; cursor: pointer;
  border-style: solid; border-width: 14px 22px; border-image: url("../assets/ui-button.webp") 40% 30% fill / 14px 22px stretch;
  font-weight: 900; font-size: 19px; color: #fff; text-shadow: -2px -2px 0 #061026, 2px -2px 0 #061026, -2px 2px 0 #061026, 2px 2px 0 #061026; transition: transform .09s, filter .12s; -webkit-tap-highlight-color: transparent; }
.plate-btn:hover, .plate-btn:focus-visible { filter: brightness(1.18) drop-shadow(0 0 8px #39e6d4); transform: scale(1.04); }
.plate-btn:active { transform: scale(0.94); }
.plate-btn span { pointer-events: none; }
.plate-btn svg { color: #ffd24a; filter: drop-shadow(0 2px 0 #061026); }

/* ---------- Intro ---------- */
#intro { position: fixed; inset: 0; z-index: 40; background: #000 url("../assets/cover-bg.webp") center / cover no-repeat; }
#introVideo { width: 100%; height: 100%; object-fit: cover; display: block; }
#skipBtn { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; min-width: 96px; font-size: 17px; }
#introSub { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); width: 86%; text-align: center; font-size: 19px; font-weight: 800; text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000; min-height: 1em; }

/* ---------- Help ---------- */
#help { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.panel9 { box-sizing: border-box; border-style: solid; border-width: 30px; border-image: url("../assets/ui-panel.webp") 22% fill / 30px stretch; }
#helpPanel { width: min(360px, 92%); padding: 6px 4px; animation: popIn 0.28s cubic-bezier(.34, 1.56, .64, 1); display: flex; flex-direction: column; align-items: center; }
@keyframes popIn { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.h-title { font-size: 26px; font-weight: 900; color: #ffb648; text-shadow: -2px -2px 0 #061026, 2px -2px 0 #061026, -2px 2px 0 #061026, 2px 2px 0 #061026; margin-bottom: 8px; }
#helpPanel ul { margin: 0 0 14px; padding: 0 0 0 18px; font-size: 14px; line-height: 1.4; color: #e6fbff; }
#helpPanel li { margin: 5px 0; }

#fade { position: fixed; inset: 0; z-index: 60; background: #050814; opacity: 0; pointer-events: none; transition: opacity .35s; }
#fade.on { opacity: 1; }
