* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top, #1b022d 0%, #090012 55%, #020006 100%);
    color: #ffe9d8;
    font-family: "Montserrat", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    position: relative;
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: -25%;
    pointer-events: none;
    background: radial-gradient(circle at 18% 22%, rgba(255, 120, 46, 0.22) 0, transparent 32%),
    radial-gradient(circle at 78% 18%, rgba(140, 77, 255, 0.24) 0, transparent 30%),
    radial-gradient(circle at 65% 82%, rgba(255, 55, 123, 0.22) 0, transparent 30%),
    radial-gradient(circle at 28% 78%, rgba(255, 196, 67, 0.16) 0, transparent 26%);
    animation: nebulaDrift 28s ease-in-out infinite alternate;
    z-index: -1;
}

@keyframes nebulaDrift {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.55;
    }
    100% {
        transform: translate3d(-3%, 3%, 0) scale(1.07);
        opacity: 0.75;
    }
}

.wrapper {
    text-align: center;
    max-width: 480px;
    width: 100%;
    padding: 1.75rem 1.6rem 1.3rem;
    background: rgba(13, 4, 24, 0.7);
    border: 1.5px solid rgba(255, 118, 48, 0.3);
    border-radius: 22px;
    box-shadow: 0 28px 60px rgba(7, 0, 18, 0.8);
    backdrop-filter: blur(6px);
}

h1 {
    margin: 0 0 0.75rem;
    font-family: "Creepster", "Montserrat", cursive;
    font-size: 2.6rem;
    letter-spacing: 0.12em;
    color: #ff823c;
    text-shadow: 0 0 18px rgba(255, 125, 32, 0.55), 0 0 38px rgba(119, 0, 255, 0.45);
}

.hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    margin-bottom: 0.9rem;
    font-size: 1rem;
    flex-wrap: wrap;
}

.hud-actions {
  display: flex;
  gap: 0.9rem;
  width: 100%;
  justify-content: center;
}

.hud-card {
    flex: 1;
    min-width: 120px;
    padding: 0.45rem 0.65rem;
    background: linear-gradient(135deg, rgba(33, 14, 40, 0.92), rgba(71, 22, 92, 0.65));
    border: 1px solid rgba(255, 135, 61, 0.45);
    border-radius: 12px;
    box-shadow: inset 0 0 12px rgba(255, 152, 73, 0.25);
    text-shadow: 0 0 6px rgba(255, 115, 56, 0.4);
}

#score,
#lives {
    font-weight: 700;
    color: #ffd166;
}

.hud-actions button {
  flex: 1 1 0;
  min-width: 0;
}

#startButton,
#pauseButton {
  padding: 0.48rem 1.18rem;
  border: 1px solid rgba(255, 162, 73, 0.65);
  background: linear-gradient(135deg, #ff7a31 0%, #ffb347 100%);
  color: #2a0b14;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 12px 25px rgba(255, 102, 0, 0.35);
}

#startButton:hover,
#startButton:focus-visible,
#pauseButton:hover,
#pauseButton:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 35px rgba(255, 128, 0, 0.45);
  filter: brightness(1.05);
}

#pauseButton:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}

#game {
    position: relative;
    width: 420px;
    height: 580px;
    margin: 0 auto;
    border: 2px solid rgba(255, 138, 56, 0.55);
    border-radius: 22px;
    background: radial-gradient(circle at 50% 18%, rgba(81, 18, 120, 0.55) 0, transparent 42%),
    linear-gradient(180deg, rgba(22, 5, 39, 0.94) 0%, rgba(7, 2, 19, 0.92) 55%, rgba(4, 0, 10, 0.88) 100%);
    overflow: hidden;
    box-shadow: 0 25px 65px rgba(7, 0, 18, 0.85);
}

#game::before {
    content: "";
    position: absolute;
    inset: -25%;
    background: radial-gradient(circle at 75% 15%, rgba(255, 148, 46, 0.22) 0, transparent 48%),
    radial-gradient(circle at 15% 75%, rgba(111, 47, 255, 0.18) 0, transparent 45%);
    filter: blur(18px);
    opacity: 0.55;
    z-index: 0;
}

#game::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(1px 1px at 15% 25%, rgba(255, 226, 149, 0.5) 0, transparent 90%),
    radial-gradient(1px 1px at 75% 40%, rgba(255, 226, 149, 0.4) 0, transparent 90%),
    radial-gradient(1px 1px at 60% 75%, rgba(204, 168, 255, 0.35) 0, transparent 90%),
    radial-gradient(1px 1px at 35% 60%, rgba(255, 120, 189, 0.35) 0, transparent 90%);
    background-size: 120px 140px;
    background-repeat: repeat;
    animation: twinkle 5s linear infinite;
    opacity: 0.35;
    z-index: 0;
}

@keyframes twinkle {
    0% {
        opacity: 0.25;
    }
    50% {
        opacity: 0.45;
    }
    100% {
        opacity: 0.25;
    }
}

#game > * {
    z-index: 1;
}

.hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: rgba(255, 220, 190, 0.78);
    letter-spacing: 0.04em;
}

#player,
.invader,
.bullet,
.enemy-bullet {
    position: absolute;
    z-index: 2;
}

#player {
    width: 48px;
    height: 22px;
    background: linear-gradient(180deg, #ff9d32 0%, #ff4e00 100%);
    border: 1px solid rgba(255, 205, 140, 0.4);
    border-radius: 8px 8px 14px 14px;
    box-shadow: 0 0 24px rgba(255, 122, 0, 0.7);
}

#player::after {
    content: "";
    position: absolute;
    inset: 4px 6px auto 6px;
    height: 4px;
    border-radius: 999px;
    background: radial-gradient(circle at 50% 50%, rgba(255, 241, 214, 0.9), rgba(255, 145, 43, 0.4));
}

#player.hit {
    animation: flicker 0.5s ease-in-out 1;
}

@keyframes flicker {
    0%,
    100% {
        filter: brightness(1);
        opacity: 1;
    }
    40% {
        filter: brightness(1.6);
        opacity: 0.45;
    }
    70% {
        filter: brightness(0.6);
        opacity: 0.7;
    }
}

.invader {
    width: 36px;
    height: 24px;
    background: linear-gradient(145deg, #7f45ff 0%, #3d1495 100%);
    border: 1px solid rgba(255, 230, 255, 0.22);
    border-radius: 6px;
    box-shadow: 0 0 18px rgba(154, 95, 255, 0.5);
    animation: invaderGlow 1.8s ease-in-out infinite alternate;
}

.invader::before,
.invader::after {
    content: "";
    position: absolute;
    top: 5px;
    width: 7px;
    height: 7px;
    background: radial-gradient(circle at 50% 50%, rgba(255, 228, 255, 0.95), rgba(126, 182, 255, 0.35));
    border-radius: 50%;
}

.invader::before {
    left: 7px;
}

.invader::after {
    right: 7px;
}

@keyframes invaderGlow {
    0% {
        box-shadow: 0 0 14px rgba(154, 95, 255, 0.4);
        filter: brightness(1);
    }
    100% {
        box-shadow: 0 0 22px rgba(255, 128, 255, 0.6);
        filter: brightness(1.25);
    }
}

.bullet {
    width: 4px;
    height: 16px;
    background: linear-gradient(180deg, #ffeab6 0%, #ff8b1f 100%);
    border-radius: 999px;
    box-shadow: 0 0 14px rgba(255, 168, 72, 0.8);
}

.enemy-bullet {
    width: 5px;
    height: 18px;
    background: linear-gradient(180deg, #ff4d85 0%, #7f2dff 100%);
    border-radius: 999px;
    box-shadow: 0 0 14px rgba(144, 77, 255, 0.85);
}

#message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0.95rem 1.65rem;
    border: 1px solid rgba(255, 155, 70, 0.4);
    background: linear-gradient(135deg, rgba(24, 6, 35, 0.92), rgba(54, 18, 75, 0.88));
    border-radius: 14px;
    font-size: 1rem;
    letter-spacing: 0.06em;
    pointer-events: none;
    box-shadow: 0 20px 45px rgba(7, 0, 16, 0.7);
    white-space: pre-line;
    text-shadow: 0 0 16px rgba(255, 151, 72, 0.45);
    color: #ffe7c3;
    z-index: 2;
}

.hidden {
    display: none;
}

@media (max-width: 540px) {
    .wrapper {
        padding: 1.4rem 1.2rem 1.1rem;
    }

    #game {
        width: 92vw;
        height: 130vw;
        max-width: 420px;
        max-height: 580px;
    }
}
