/* =========================
   RESET
========================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  overflow-x: hidden;
  background:
    radial-gradient(
      circle at top,
      #101b3c 0%,
      #030611 45%,
      #000000 100%
    );
  color: #ffffff;
  font-family:
    Arial,
    Helvetica,
    sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  font: inherit;
}


/* =========================
   GENERAL PAGE
========================= */

.game-page {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.hidden {
  display: none !important;
}


/* =========================
   START SCREEN
========================= */

.screen-panel {
  width: min(100%, 650px);
  padding: 34px 24px;
  border: 3px solid #43ff7b;
  border-radius: 20px;
  background:
    linear-gradient(
      180deg,
      rgba(8, 18, 48, 0.96),
      rgba(0, 0, 0, 0.97)
    );
  box-shadow:
    0 0 18px rgba(67, 255, 123, 0.55),
    inset 0 0 22px rgba(28, 95, 255, 0.18);
  text-align: center;
}

.start-screen h1 {
  margin-bottom: 18px;
  color: #fff700;
  font-size: clamp(2.2rem, 9vw, 4.5rem);
  line-height: 1;
  letter-spacing: 4px;
  text-shadow:
    0 0 8px #fff700,
    0 0 18px rgba(255, 247, 0, 0.8);
}

.intro-text {
  margin-bottom: 24px;
  color: #ffffff;
  font-size: clamp(1rem, 4vw, 1.3rem);
  line-height: 1.5;
}

.instructions {
  margin-bottom: 28px;
  padding: 18px;
  border: 2px solid #2796ff;
  border-radius: 14px;
  background: rgba(0, 20, 58, 0.75);
  text-align: left;
}

.instructions p {
  margin-bottom: 14px;
  color: #e9f6ff;
  font-size: 1rem;
  line-height: 1.5;
}

.instructions p:last-child {
  margin-bottom: 0;
}

.instructions strong {
  color: #43ff7b;
}


/* =========================
   BUTTONS
========================= */

.main-button,
.secondary-button,
.home-button,
.pause-button,
.control-button {
  border: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.main-button {
  min-width: 190px;
  min-height: 54px;
  padding: 14px 24px;
  border: 2px solid #fff700;
  border-radius: 12px;
  background:
    linear-gradient(
      180deg,
      #fff700,
      #ffbd00
    );
  color: #000000;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow:
    0 0 15px rgba(255, 247, 0, 0.6),
    inset 0 -4px 0 rgba(0, 0, 0, 0.22);
}

.main-button:active {
  transform: translateY(2px);
  box-shadow:
    0 0 8px rgba(255, 247, 0, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22);
}

.secondary-button {
  min-width: 150px;
  min-height: 48px;
  padding: 12px 22px;
  border: 2px solid #ffffff;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 1px;
}

.secondary-button:active {
  transform: translateY(2px);
}


/* =========================
   GAME SCREEN
========================= */

.game-screen {
  width: min(100%, 760px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.score-box,
.lives-box {
  flex: 1;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px 14px;
  border: 2px solid #2d8cff;
  border-radius: 12px;
  background:
    linear-gradient(
      180deg,
      rgba(10, 32, 76, 0.96),
      rgba(0, 5, 18, 0.96)
    );
  box-shadow:
    0 0 12px rgba(45, 140, 255, 0.4);
}

.header-label {
  margin-bottom: 2px;
  color: #43ff7b;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 2px;
}

#scoreDisplay,
#livesDisplay {
  color: #ffffff;
  font-size: 1.45rem;
  font-weight: 900;
}


/* =========================
   GAME CONTAINER
========================= */

.game-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 3px solid #43ff7b;
  border-radius: 14px;
  background: #000000;
  box-shadow:
    0 0 18px rgba(67, 255, 123, 0.5),
    inset 0 0 22px rgba(0, 0, 0, 0.9);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 11;
  background: #02030a;
  touch-action: none;
}


/* =========================
   PAUSE BUTTON
========================= */

.pause-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 44px;
  height: 44px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 900;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.pause-button:active {
  transform: scale(0.94);
}


/* =========================
   OVERLAY PANELS
========================= */

.overlay-panel {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.9);
  text-align: center;
}

.overlay-panel h2 {
  color: #fff700;
  font-size: clamp(2rem, 9vw, 4rem);
  line-height: 1;
  letter-spacing: 3px;
  text-shadow:
    0 0 10px #fff700,
    0 0 22px rgba(255, 247, 0, 0.75);
}

.overlay-panel p {
  max-width: 420px;
  color: #ffffff;
  font-size: clamp(1rem, 4vw, 1.3rem);
  line-height: 1.5;
}

#finalScoreDisplay {
  color: #43ff7b;
}


/* =========================
   MOBILE CONTROLS
========================= */

.mobile-controls {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.control-button {
  min-height: 62px;
  border-radius: 14px;
  font-weight: 900;
  letter-spacing: 1px;
  touch-action: none;
}

.direction-button {
  border: 2px solid #2d8cff;
  background:
    linear-gradient(
      180deg,
      #164b9f,
      #082457
    );
  color: #ffffff;
  font-size: 1.6rem;
  box-shadow:
    0 0 10px rgba(45, 140, 255, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.3);
}

.fire-button {
  border: 2px solid #ff3838;
  background:
    linear-gradient(
      180deg,
      #ff3b3b,
      #a90000
    );
  color: #ffffff;
  font-size: 1.15rem;
  box-shadow:
    0 0 12px rgba(255, 56, 56, 0.55),
    inset 0 -4px 0 rgba(0, 0, 0, 0.3);
}

.control-button:active {
  transform: translateY(2px);
  filter: brightness(1.18);
}


/* =========================
   HOME BUTTON
========================= */

.home-button {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 2px solid #ffffff;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 1px;
}

.home-button:active {
  transform: translateY(2px);
}


/* =========================
   HIDDEN GAME ASSETS
========================= */

.game-assets {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.game-assets img {
  width: 1px;
  height: 1px;
}


/* =========================
   SMALL PHONES
========================= */

@media (max-width: 480px) {

  .game-page {
    align-items: flex-start;
    padding: 8px;
  }

  .screen-panel {
    margin-top: 12px;
    padding: 26px 16px;
    border-radius: 16px;
  }

  .instructions {
    padding: 14px;
  }

  .instructions p {
    font-size: 0.92rem;
  }

  .game-header {
    gap: 8px;
    margin-bottom: 7px;
  }

  .score-box,
  .lives-box {
    min-height: 50px;
    padding: 6px 10px;
    border-radius: 9px;
  }

  .header-label {
    font-size: 0.66rem;
  }

  #scoreDisplay,
  #livesDisplay {
    font-size: 1.2rem;
  }

  .game-container {
    border-width: 2px;
    border-radius: 10px;
  }

  .pause-button {
    top: 8px;
    right: 8px;
    width: 38px;
    height: 38px;
  }

  .mobile-controls {
    gap: 7px;
    margin-top: 8px;
  }

  .control-button {
    min-height: 54px;
    border-radius: 10px;
  }

  .direction-button {
    font-size: 1.3rem;
  }

  .fire-button {
    font-size: 1rem;
  }

  .home-button {
    min-height: 43px;
    margin-top: 8px;
  }

}


/* =========================
   SHORT LANDSCAPE SCREENS
========================= */

@media (orientation: landscape) and (max-height: 600px) {

  .game-page {
    align-items: flex-start;
    padding: 6px;
  }

  .game-screen {
    width: min(100%, 480px);
  }

  .game-header {
    margin-bottom: 5px;
  }

  .score-box,
  .lives-box {
    min-height: 42px;
  }

  #gameCanvas {
    max-height: 72vh;
  }

  .mobile-controls {
    margin-top: 6px;
  }

  .control-button {
    min-height: 42px;
  }

  .home-button {
    min-height: 38px;
    margin-top: 6px;
  }

}


/* =========================
   DESKTOP
========================= */

@media (min-width: 900px) {

  .game-page {
    padding: 24px;
  }

  .game-screen {
    width: min(72vh, 720px);
  }

  .mobile-controls {
    max-width: 560px;
  }

  .control-button:hover,
  .main-button:hover,
  .secondary-button:hover,
  .home-button:hover,
  .pause-button:hover {
    filter: brightness(1.15);
  }

}