@font-face {
  font-family: "Upheaval";
  src: url("./assets/fonts/upheavtt.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #11131b;
  font-family: "Upheaval", system-ui, sans-serif;
  color: #f4f4f4;
  text-rendering: optimizeSpeed;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  -ms-touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

img,
svg,
canvas {
  -webkit-user-drag: none;
  user-select: none;
}

button {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #11131b;
}

.stage {
  --bg-pulse: 0;
  --bg-crit-pulse: 0;
  --bg-base: #120f1b;
  --bg-grid-dark: #241c34;
  --bg-particle: rgba(173, 129, 255, 0.24);
  --bg-particle-strong: rgba(123, 220, 255, 0.28);
  --bg-hit-flash: rgba(220, 150, 255, 0.18);
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.bg,
.vignette,
.bg-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bg {
  z-index: 0;
  background-color: var(--bg-base);
  background-image:
    linear-gradient(45deg, var(--bg-grid-dark) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-grid-dark) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-grid-dark) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-grid-dark) 75%);
  background-size: 72px 72px;
  background-position: 0 0, 0 36px, 36px -36px, -36px 0;
  filter: brightness(calc(1 + var(--bg-pulse) * 0.06 + var(--bg-crit-pulse) * 0.1));
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: calc(0.42 + var(--bg-pulse) * 0.16 + var(--bg-crit-pulse) * 0.12);
  background:
    radial-gradient(circle at 18% 22%, rgba(139, 108, 214, 0.16), transparent 24%),
    radial-gradient(circle at 76% 18%, rgba(110, 203, 255, 0.12), transparent 18%),
    radial-gradient(circle at 62% 74%, rgba(176, 121, 255, 0.12), transparent 20%),
    linear-gradient(180deg, rgba(31, 20, 52, 0.2), rgba(8, 6, 16, 0.22));
  mix-blend-mode: screen;
}

.bg-particles {
  z-index: 0;
  overflow: hidden;
}

.bg-particles span {
  position: absolute;
  bottom: -18%;
  width: 12px;
  aspect-ratio: 1;
  background: var(--bg-particle);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
  opacity: calc(0.26 + var(--bg-pulse) * 0.12 + var(--bg-crit-pulse) * 0.08);
  animation: bg-square-rise linear infinite;
}

.bg-particles span:nth-child(2n) {
  background: var(--bg-particle-strong);
}

.bg-particles span:nth-child(1) { left: 4%; width: 10px; animation-duration: 11s; animation-delay: -5s; }
.bg-particles span:nth-child(2) { left: 12%; width: 14px; animation-duration: 13s; animation-delay: -1s; }
.bg-particles span:nth-child(3) { left: 20%; width: 9px; animation-duration: 9.5s; animation-delay: -8s; }
.bg-particles span:nth-child(4) { left: 29%; width: 16px; animation-duration: 12.5s; animation-delay: -4s; }
.bg-particles span:nth-child(5) { left: 38%; width: 11px; animation-duration: 10.8s; animation-delay: -6s; }
.bg-particles span:nth-child(6) { left: 47%; width: 8px; animation-duration: 8.8s; animation-delay: -2s; }
.bg-particles span:nth-child(7) { left: 58%; width: 13px; animation-duration: 12.2s; animation-delay: -9s; }
.bg-particles span:nth-child(8) { left: 68%; width: 10px; animation-duration: 9.8s; animation-delay: -3s; }
.bg-particles span:nth-child(9) { left: 77%; width: 15px; animation-duration: 14s; animation-delay: -7s; }
.bg-particles span:nth-child(10) { left: 85%; width: 9px; animation-duration: 10.2s; animation-delay: -1.5s; }
.bg-particles span:nth-child(11) { left: 92%; width: 12px; animation-duration: 11.4s; animation-delay: -10s; }
.bg-particles span:nth-child(12) { left: 97%; width: 7px; animation-duration: 8.4s; animation-delay: -4.5s; }

.vignette {
  z-index: 0;
  background: radial-gradient(circle at center, transparent 0%, rgba(4, 3, 10, 0.32) 54%, rgba(0, 0, 0, 0.76) 100%);
}

@keyframes bg-square-rise {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(16px, -125vh, 0) rotate(180deg);
  }
}

.html-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.canvas-layer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--play-area-width, 100%);
  overflow: hidden;
  z-index: 1;
}

canvas {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 100%;
  height: 100%;
  transform: none;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: none;
}

.html-layer {
  z-index: 5;
  pointer-events: none;
  display: block;
  padding: 0;
}

.hud {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
}

.combat-stats {
  display: none;
}

.hud > div {
  flex: 1 1 0;
  min-width: 90px;
  max-width: 132px;
  padding: 10px 12px;
  border: 2px solid #2a2f42;
  background: #171b26cc;
  box-shadow: 0 8px 0 #0b0d13;
  text-align: center;
  font-family: "Upheaval", system-ui, sans-serif;
}

.label {
  display: block;
  font-size: 12px;
  letter-spacing: 0;
  color: #8f98b8;
  text-transform: uppercase;
}

strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: 0;
}

.enemy-card {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  width: max-content;
  min-width: 168px;
  max-width: min(280px, calc(100vw - 28px));
  padding: 3px;
  border: 2px solid #07080d;
  background: #07080d;
  box-shadow: 0 5px 0 #07080d;
  transform: translate3d(0, 0, 0) translate(-50%, -50%);
  pointer-events: none;
  overflow: hidden;
}

.enemy-namebox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  width: 100%;
  height: 27px;
  padding: 0 11px;
  background: #171b2bf5;
  color: #f5f7ff;
  white-space: nowrap;
  overflow: hidden;
}

.enemy-boss-icon {
  display: none;
  flex: 0 0 0;
  width: 0;
  height: 0;
  image-rendering: pixelated;
}

.enemy-namebox span,
.enemy-namebox strong {
  display: block;
  margin: 0;
  line-height: 1;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
}

.enemy-namebox span {
  flex: 1 1 auto;
  overflow: visible;
  text-overflow: clip;
}

.enemy-namebox strong {
  flex: 0 0 auto;
  font-size: 15px;
  color: #aeb8d8;
}

.enemy-card.is-boss .enemy-namebox span {
  color: #ffd166;
}

.enemy-card.is-boss .enemy-namebox {
  height: 36px;
  padding: 0 13px 0 9px;
}

.enemy-card.is-boss .enemy-boss-icon {
  display: block;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  margin-right: 2px;
  filter:
    drop-shadow(2px 2px 0 #090512)
    drop-shadow(0 0 7px rgba(255, 77, 109, 0.45));
}

.enemy-hp {
  position: relative;
  width: 100%;
  height: 12px;
  margin-top: 3px;
  overflow: hidden;
  background: #252a3d;
}

.enemy-hp span {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  width: 100%;
}

.enemy-hp-back {
  background: #5d4020;
}

.enemy-hp-mid {
  background: #ffb84a;
}

.enemy-hp-front {
  background: #35d07f;
}

.enemy-hp-shine {
  height: 2px;
  background: rgba(255, 255, 255, 0.55);
}

.bottom-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  pointer-events: none;
}

.sword-shop {
  display: flex;
  justify-content: center;
  gap: 7px;
  width: min(100%, 560px);
  pointer-events: auto;
}

.sword-option {
  width: 58px;
  min-width: 58px;
  min-height: 58px;
  padding: 5px;
  display: grid;
  place-items: center;
  gap: 2px;
  border-color: #2a2f42;
  background: #151a27;
  box-shadow: 0 5px 0 #0b0d13;
}

.sword-option img {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
}

.sword-option span {
  margin: 0;
  font-size: 10px;
  color: #aeb8d8;
}

.sword-option.is-active {
  border-color: #ffd166;
  background: #252037;
}

.sword-option.is-locked {
  opacity: 0.65;
}

button {
  pointer-events: auto;
  touch-action: manipulation;
  border: 2px solid #39415f;
  background: #1d2333;
  color: #ffffff;
  min-width: 210px;
  min-height: 58px;
  padding: 12px 18px;
  font-family: "Upheaval", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 8px 0 #0b0d13;
  image-rendering: pixelated;
  user-select: none;
}

button:hover {
  transform: translateY(-2px);
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #0b0d13;
}

button span {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  line-height: 1;
  color: #9ca7ca;
}

button.locked {
  opacity: 0.45;
}
