* {
  margin: 0;
  padding: 0;
}

/* a pixelated, monospaced font, similar to ones used in early video games */
@font-face {
  font-family: monogram;
  src: url(monogram.ttf);
}

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  background: url("../images/glow.webp");
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  overflow: hidden;
  line-height: 0.8; /* Adjusted for solving a line spacing problem with the monogram font in Firefox */
}

#starfield {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hide the planet image */
#planet-image {
  display: none;
}

/* Show and style the video */
#planet-video {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  position: absolute;
  bottom: 0;
  left: 0;
  pointer-events: none;
}

#planet {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.star {
  position: absolute;
  background-color: lightskyblue;
  border-radius: 50%;
}

/* near 1:1 aspect ratio view */
.main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.info {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  height: 9vw;
  width: 85vmax;
  background-color: #00000000;
  z-index: 2;
}
.square {
  display: flex;
  width: 50vmax;
  height: 50vmax;
  margin: 0 auto;
  position: relative; /* This is necessary for the absolute positioning of the cannon to work */
  -webkit-mask-image: repeating-linear-gradient(#00000077 2px, #000000ff 4px);
  mask-image: repeating-linear-gradient(#00000077 2px, #000000ff 4px);
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  filter: drop-shadow(0 0 3px #ddd);
}

/* landscape view */
@media (min-aspect-ratio: 1.45) {
  .main {
    display: flex;
    flex-direction: row;
    justify-content: center;
  }
  .info {
    display: flex;
    flex-direction: column;
    justify-content:flex-start;
    width: 16vw;
    height: 96vh;
  }
  .square {
    display: flex;
    width: 96vmin;
    height: 96vmin;
  }
}

/* portrait view */
@media (max-aspect-ratio: 0.98) {
  .main {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .info {
    display: flex;
    height: 12vw;
    width: 90vw;
  }
  .square {
    display: flex;
    width: 78vmin;
    height: 78vmin;
  }
}

p {
  font-size: 4.2vmin;
  font-family: monogram, Courier, monospace;
  color: white;
  padding: 0.6vh;
  text-align: center;
  /* add a glow to the text */
  text-shadow: 0 0 12px #fff;
}

.mask-text {
  /* creates a scanline effect, appropriate to an early video game display */
  -webkit-mask-image: repeating-linear-gradient(#00000077 2px, black 4px);
  mask-image: repeating-linear-gradient(#00000077 2px, black 4px);
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
}

.scoreboard-container {
  font-size: 4.2vmin;
  font-family: monogram, Courier, monospace;
  color: white;
  padding: 1vh;
  text-align: left;
  -webkit-mask-image: repeating-linear-gradient(#ffffff77 2px, black 4px);
  mask-image: repeating-linear-gradient(#ffffff77 2px, black 4px);
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  text-shadow: 0 0 12px #fff;
}

form {
  font-family: monogram, Courier, monospace;
  color: white;
  width: 100%;
  padding-left: 27vmin;
}

input[type="text"] {
  font-family: monogram, Courier, monospace;
  color: white;
  background-color: #000000aa;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding-left: 4vmin;
  width: 40%;
  font-size: 6vmin;
}

input[type="text"]::placeholder {
  color: #888;
  font-size: 6vmin; 
}

.square .cannon {
  position: absolute;
  height: 3%;
  transform: translateX(-50%);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.square .cannonShot {
  position: absolute;
  height: 2%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  transform: translateX(-50%);
}
.square .alienShot {
  position: absolute;
  height: 2%;
  transform: translateX(-50%);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}
.square .lowAlien {
  position: absolute;
  height: 3%;
  transform: translateX(-50%);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.square .saucer {
  position: absolute;   
  height: 3%;   
  transform: translateX(-50%);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.square .pop {
  position: absolute;
  height: 12%;
  transform: translate(-50%, 50%);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

#base-area {
  position: absolute;
  width: 87.5%;
  height: 25%;
  bottom: 10%;
  left: 6.25%;
}

.tile {
  background-image: url('../images/tilemap.png');
  background-size: 800% 600%; /* 8 tiles wide, 6 tiles high */
  position: absolute;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.start-message {
  position: absolute;
  top: 13%;
  left: 20%;
  z-index: 1000;
  font-size: 4.2vmin;
  font-family: monogram, Courier, monospace;
  color: white;
  padding: 1vh;
  text-align: left;
}

.message-line {
  height: 1.2em;
  margin-bottom: 0.5em;  /* Space between lines */
}

.modal-overlay {
  position: fixed; /* Use fixed positioning to ensure the modal stays in view */
  top: 50%; /* Position the modal vertically at the center of the viewport */
  left: 50%; /* Position the modal horizontally at the center of the viewport */
  width: 97vmin;
  height: 52vmin;
  transform: translate(
    -50%,
    -80%
  );
  z-index: 9999; /* Ensure the modal appears above other content */
  padding: 10px; /* Add padding to the modal */
}

.modal-overlay-intro {
  background-color: #000000;
  position: fixed; /* Use fixed positioning to ensure the modal stays in view */
  top: 50%; /* Position the modal vertically at the center of the viewport */
  left: 50%; /* Position the modal horizontally at the center of the viewport */
  width: 98vmin;
  height: 52vmin;
  transform: translate(
    -50%,
    -80%
  );
  z-index: 9999; /* Ensure the modal appears above other content */
  padding: 20px; /* Add padding to the modal */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  box-shadow: 0px 0px 8px 8px black;
}

.modal-overlay-story {
  background-color: #00005555;
  position: fixed; /* Use fixed positioning to ensure the modal stays in view */
  top: 50%; /* Position the modal vertically at the center of the viewport */
  left: 50%; /* Position the modal horizontally at the center of the viewport */
  width: 98vmin;
  height: 52vmin;
  transform: translate(
    -50%,
    -80%
  );
  z-index: 9999; /* Ensure the modal appears above other content */
  padding: 20px; /* Add padding to the modal */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  border-radius: 50%;
  box-shadow: 0px 0px 8px 8px #00005555;
}

.game-over-message {
  font-family: monogram, Courier, monospace;
  font-size: 27vmin;
  color: white;
  text-align: left;
  padding-left: 3vmin;
  background-color: #33333300;
  /* adds a scanline effect to the GAME OVER message */
  -webkit-mask-image: repeating-linear-gradient(#ffffff77 2px, black 6px);
  mask-image: repeating-linear-gradient(#ffffff77 2px, black 6px);
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  text-shadow: 0 0 12px #fff;
}

button {
  display: flex;
  justify-content: center;
  margin: 50px auto;
  padding: 5px;
  font-family: monogram;
  font-size: 50px;
  width: 280px;
  height: 60px;
  cursor: pointer;
  border-radius: 15px;
  border-color: #fff;
  color: #fff;
  background-color: transparent;
}

#restart-btn {
  position: absolute;
  top: calc(100% + 10px); /* Position the button below the message */
  left: 50%; /* Align the button horizontally */
  transform: translateX(-50%); /* Center the button horizontally */
  max-width: 40%; /* Reduce the size of the image */
}
