:root {
  --ink: #f8fbff;
  --yellow: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #060914;
}

.app {
  width: 100%;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 0;
}

.game-shell {
  width: min(100vw, calc(100svh * 420 / 680));
  height: min(100svh, calc(100vw * 680 / 420));
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #101722;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111827;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.power-item-gif,
.crash-gif {
  position: absolute;
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.power-item-gif {
  z-index: 2;
  width: clamp(44px, 13.5%, 64px);
  mix-blend-mode: screen;
  will-change: left, top, transform;
  animation: power-item-hover 640ms ease-in-out infinite alternate;
}

.crash-gif {
  z-index: 4;
  width: min(62%, 250px);
  mix-blend-mode: screen;
  filter: saturate(1.25) contrast(1.08);
}

.power-gif {
  position: absolute;
  z-index: 4;
  width: min(48%, 190px);
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(180deg);
  mix-blend-mode: screen;
  will-change: left, top;
}

.boss-sprite,
.fire-shot-gif,
.enemy-fire-gif {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  will-change: left, top, transform;
}

.boss-sprite {
  z-index: 3;
  image-rendering: auto;
  filter:
    saturate(1.35)
    brightness(1.16)
    contrast(1.16)
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.72))
    drop-shadow(0 0 12px rgba(255, 209, 102, 0.72))
    drop-shadow(0 7px 10px rgba(0, 0, 0, 0.62));
}

.boss-hit {
  opacity: 0.72;
}

.boss-low {
  filter:
    saturate(1.45)
    brightness(1.18)
    contrast(1.18)
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.75))
    drop-shadow(0 0 12px rgba(255, 176, 32, 0.78))
    drop-shadow(0 7px 10px rgba(0, 0, 0, 0.64));
}

.boss-medium {
  filter:
    saturate(1.48)
    brightness(1.18)
    contrast(1.2)
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.78))
    drop-shadow(0 0 13px rgba(255, 75, 110, 0.82))
    drop-shadow(0 7px 10px rgba(0, 0, 0, 0.64));
}

.boss-high {
  filter:
    saturate(1.52)
    brightness(1.2)
    contrast(1.22)
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.86))
    drop-shadow(0 0 15px rgba(255, 239, 106, 0.86))
    drop-shadow(0 9px 13px rgba(0, 0, 0, 0.68));
}

.boss-eye {
  filter:
    saturate(1.65)
    brightness(1.22)
    contrast(1.24)
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.88))
    drop-shadow(0 0 16px rgba(56, 216, 255, 0.9))
    drop-shadow(0 8px 12px rgba(0, 0, 0, 0.7));
}

.boss-sprite.boss-shielded {
  animation: boss-shield-pulse 620ms ease-in-out infinite alternate;
  filter:
    saturate(1.85)
    brightness(1.34)
    contrast(1.2)
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.92))
    drop-shadow(0 0 18px rgba(255, 209, 102, 0.95))
    drop-shadow(0 0 28px rgba(56, 216, 255, 0.36))
    drop-shadow(0 8px 12px rgba(0, 0, 0, 0.68));
}

.bomb-power-gif {
  filter:
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.82))
    drop-shadow(0 0 11px rgba(255, 75, 31, 0.78));
}

.egg-power-gif {
  filter:
    brightness(1.12)
    saturate(1.35)
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.86))
    drop-shadow(0 0 14px rgba(191, 255, 232, 0.82));
}

.fire-shot-gif,
.enemy-fire-gif,
.boss-explosion-gif,
.bomb-explosion-gif {
  z-index: 4;
  mix-blend-mode: screen;
}

.enemy-fire-gif {
  z-index: 4;
  filter:
    hue-rotate(-18deg)
    saturate(1.8)
    brightness(1.3)
    drop-shadow(0 0 10px rgba(255, 75, 31, 0.78));
}

.boss-explosion-gif,
.bomb-explosion-gif {
  position: absolute;
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  will-change: opacity, transform;
}

.bomb-explosion-gif {
  z-index: 6;
  filter:
    brightness(1.42)
    saturate(1.55)
    contrast(1.16)
    drop-shadow(0 0 18px rgba(255, 209, 102, 0.8))
    drop-shadow(0 0 34px rgba(255, 75, 31, 0.48));
}

.hud {
  position: absolute;
  top: max(6px, env(safe-area-inset-top));
  left: 50%;
  z-index: 3;
  display: grid;
  transform: translateX(-50%);
  pointer-events: none;
}

.hud > span:not(:first-child) {
  display: none;
}

.hud > span {
  display: grid;
  min-width: 138px;
  justify-items: center;
  gap: 1px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(6, 9, 20, 0.82);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}

.hud small {
  color: var(--yellow);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.hud strong {
  font-size: 16px;
  line-height: 1;
}

.stage-toast,
.pause-badge,
.fire-hint {
  position: absolute;
  left: 50%;
  z-index: 5;
  width: max-content;
  max-width: 82%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 209, 102, 0.45);
  border-radius: 8px;
  background: rgba(6, 9, 20, 0.78);
  color: #f8fbff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
  pointer-events: none;
  text-align: center;
}

.stage-toast {
  top: 38%;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stage-toast.show {
  animation: stage-pop 1300ms ease-out both;
}

.pause-badge {
  top: 44%;
  padding: 10px 16px;
  font-size: 20px;
  font-weight: 950;
  text-transform: uppercase;
}

.fire-hint {
  top: 52%;
  padding: 9px 12px;
  color: #fff7ad;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.fire-hint.show {
  animation: hint-pop 3600ms ease-out both;
}

.hidden-actions {
  display: none;
}

.mobile-action-buttons {
  display: none;
}

button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  padding: 0 10px;
  background: linear-gradient(180deg, #ffe08a, var(--yellow));
  color: #111827;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 950;
  touch-action: manipulation;
}

.mobile-action-buttons {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(92px, env(safe-area-inset-bottom));
  z-index: 7;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.mobile-action-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 209, 102, 0.48);
  border-radius: 50%;
  background: rgba(6, 9, 20, 0.82);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.34),
    inset 0 0 16px rgba(255, 209, 102, 0.08);
  color: #ffd166;
}

.mobile-action-btn.is-active {
  border-color: rgba(56, 216, 255, 0.92);
  background: rgba(9, 26, 36, 0.9);
  box-shadow:
    0 0 0 2px rgba(56, 216, 255, 0.16),
    0 0 18px rgba(56, 216, 255, 0.4),
    inset 0 0 14px rgba(56, 216, 255, 0.18);
}

.mobile-action-btn.is-empty {
  opacity: 0.48;
  filter: grayscale(0.35);
}

.auto-fire-icon,
.bomb-action-icon {
  position: relative;
  display: block;
  width: 25px;
  height: 25px;
}

.auto-fire-icon::before,
.auto-fire-icon::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.auto-fire-icon::before {
  inset: 4px;
  border: 3px solid currentColor;
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.55);
}

.auto-fire-icon::after {
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.auto-fire-icon {
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.bomb-action-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ff4b1f;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.14),
    0 0 13px rgba(255, 75, 31, 0.78);
}

.bomb-action-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 1px;
  width: 12px;
  height: 12px;
  border-top: 3px solid #ffd166;
  border-right: 3px solid #ffd166;
  border-radius: 2px;
  transform: rotate(18deg);
}

@media (pointer: coarse), (max-width: 720px) {
  .mobile-action-buttons {
    display: flex;
  }
}

.name-field {
  display: grid;
  width: min(270px, 88%);
  gap: 5px;
  color: var(--yellow);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.name-field input {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(255, 209, 102, 0.48);
  border-radius: 7px;
  padding: 0 10px;
  background: rgba(6, 9, 20, 0.78);
  color: #f8fbff;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  outline: none;
  text-align: center;
  text-transform: none;
}

.name-field input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.18);
}

.score-board {
  display: grid;
  width: min(280px, 92%);
  gap: 5px;
}

.score-board-title {
  margin: 0;
  color: var(--yellow);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.score-board ol {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.score-board li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(6, 9, 20, 0.55);
  color: #dce6f4;
  font-size: 11px;
  font-weight: 800;
}

.score-board li span:first-child {
  color: var(--yellow);
}

.score-board li span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-board li strong {
  color: #f8fbff;
  white-space: nowrap;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 22px;
  text-align: center;
  background:
    linear-gradient(rgba(7, 11, 19, 0.82), rgba(7, 11, 19, 0.94)),
    repeating-linear-gradient(90deg, transparent 0 82px, rgba(255, 255, 255, 0.06) 82px 84px),
    linear-gradient(180deg, #182131, #070b13);
}

.tag {
  margin: 0;
  color: var(--yellow);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay h2 {
  margin: 0;
  max-width: 320px;
  font-size: clamp(34px, 13vw, 56px);
  line-height: 0.9;
  text-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
}

.overlay p:not(.tag) {
  margin: 0;
  max-width: 270px;
  color: #dce6f4;
  font-size: 12px;
  line-height: 1.35;
}

.overlay p.score-board-title {
  max-width: none;
  color: var(--yellow);
  font-size: 9px;
  line-height: 1;
}

.hidden {
  display: none;
}

@keyframes stage-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.94);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%) scale(0.98);
  }
}

@keyframes hint-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.96);
  }
  12%,
  78% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -43%) scale(0.98);
  }
}

@keyframes power-item-hover {
  from {
    transform: translate(-50%, -52%) scale(0.94);
  }
  to {
    transform: translate(-50%, -48%) scale(1.04);
  }
}

@keyframes boss-shield-pulse {
  from {
    opacity: 0.88;
  }
  to {
    opacity: 1;
  }
}

.game-over {
  isolation: isolate;
}

.game-over > :not(.fire-explosion) {
  position: relative;
  z-index: 2;
}

.fire-explosion {
  position: absolute;
  left: 50%;
  top: 43%;
  z-index: 1;
  width: min(68%, 250px);
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: blur(0.2px) saturate(1.3);
  opacity: 0;
}

.game-over:not(.hidden) .fire-explosion {
  animation: fire-pop 1200ms ease-out both;
}

.fire-explosion::before,
.fire-explosion::after,
.fire-explosion span {
  content: "";
  position: absolute;
  inset: 13%;
  border-radius: 50%;
}

.fire-explosion::before {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 8%, rgba(255, 232, 128, 0.9) 9% 19%, rgba(255, 132, 31, 0.85) 20% 38%, rgba(224, 32, 18, 0.52) 39% 58%, transparent 61%);
  box-shadow:
    0 0 30px rgba(255, 209, 102, 0.75),
    0 0 58px rgba(255, 92, 28, 0.45);
  animation: flame-core 900ms ease-out both;
}

.fire-explosion::after {
  inset: 5%;
  background:
    conic-gradient(from 20deg, transparent, rgba(255, 88, 25, 0.9), transparent, rgba(255, 208, 64, 0.85), transparent, rgba(210, 22, 18, 0.72), transparent);
  mask-image: radial-gradient(circle, black 0 54%, transparent 65%);
  animation: flame-ring 1000ms ease-out both;
}

.fire-explosion span:nth-child(1) {
  inset: 2%;
  background:
    radial-gradient(circle at 50% 15%, rgba(255, 232, 128, 0.85) 0 8%, transparent 20%),
    radial-gradient(circle at 22% 45%, rgba(255, 94, 24, 0.8) 0 9%, transparent 22%),
    radial-gradient(circle at 78% 48%, rgba(255, 94, 24, 0.8) 0 9%, transparent 22%);
  animation: sparks-one 1050ms ease-out both;
}

.fire-explosion span:nth-child(2) {
  inset: 18%;
  border-radius: 35% 65% 42% 58%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.65), rgba(255, 180, 52, 0.72) 30%, rgba(255, 65, 26, 0.36) 56%, transparent 70%);
  animation: flame-wobble 760ms ease-out both;
}

.fire-explosion span:nth-child(3) {
  inset: -5%;
  background:
    radial-gradient(circle at 12% 22%, rgba(255, 219, 87, 0.95) 0 2%, transparent 5%),
    radial-gradient(circle at 82% 18%, rgba(255, 126, 29, 0.9) 0 2%, transparent 5%),
    radial-gradient(circle at 16% 82%, rgba(255, 126, 29, 0.8) 0 2%, transparent 5%),
    radial-gradient(circle at 84% 76%, rgba(255, 219, 87, 0.9) 0 2%, transparent 5%);
  animation: sparks-two 1150ms ease-out both;
}

@keyframes fire-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.18);
  }
  18% {
    opacity: 1;
  }
  70% {
    opacity: 0.82;
  }
  100% {
    opacity: 0.18;
    transform: translate(-50%, -50%) scale(1.35);
  }
}

@keyframes flame-core {
  0% {
    transform: scale(0.22);
  }
  55% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1.25);
  }
}

@keyframes flame-ring {
  0% {
    transform: rotate(0deg) scale(0.2);
  }
  100% {
    transform: rotate(80deg) scale(1.28);
  }
}

@keyframes flame-wobble {
  0% {
    transform: rotate(0deg) scale(0.24);
  }
  100% {
    transform: rotate(22deg) scale(1.1);
  }
}

@keyframes sparks-one {
  0% {
    transform: scale(0.25);
    opacity: 1;
  }
  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

@keyframes sparks-two {
  0% {
    transform: scale(0.2) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(1.75) rotate(-35deg);
    opacity: 0;
  }
}
