html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

body {
  background-image: url("../images/stars.jpeg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  color: white;
  text-align: center;
  font-family: "Courier New", Courier, monospace;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.initial-load {
  display: none !important;
}

.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, #000428, #004e92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
  font-family: 'Press Start 2P', cursive;
  font-size: 24px;
}

.loading-text {
  text-align: center;
  animation: pulse 1.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

.game-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
}

.headers {
  font-size: 18px;
  margin-bottom: 20px;
  position: relative;
}

.cell {
  width: calc(40px + 1vw);
  height: calc(30px + 0.5vw);
  font-size: 20px;
  text-align: center;
  vertical-align: middle;
}

.score {
  font-size: 20px;
  font-weight: bold;
  color: white;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 5px;
  position: fixed;
  top: 20px;
  left: 20px;
  border: 2px solid #4CAF50;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
  z-index: 1000;
}

.board-container {
  margin: 20px auto;
  border: 2px solid #fff;
  border-collapse: separate;
  border-spacing: 5px;
  background-color: rgba(0, 0, 0, 0.1);
  max-height: 70vh;
  max-width: 90vw;
  overflow: hidden;
}

.modal {
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.7);
}

.modal-content {
  background-color: #222;
  margin: 15% auto;
  padding: 40px;
  border: 3px solid #fff;
  width: 80%;
  max-width: 500px;
  text-align: center;
  color: #fff;
  font-family: 'Press Start 2P', cursive;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.controls-modal {
  position: fixed;
  z-index: 2;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.9);
}

.controls-content {
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 5% auto;
}

.controls-content h2 {
  color: #4CAF50;
  margin-bottom: 30px;
  font-size: calc(20px + 0.5vw);
  text-align: center;
}

.controls-section h3, .mobile-controls-section h3 {
  color: #FFD700;
  margin-bottom: 20px;
  font-size: calc(16px + 0.3vw);
  border-bottom: 2px solid #4CAF50;
  padding-bottom: 10px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 15px;
  margin: 20px 0;
  text-align: left;
}

.control-item {
  display: flex;
  align-items: center;
  padding: 15px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.control-item:hover {
  background-color: rgba(255, 255, 255, 0.15);
  transform: translateX(5px);
}

.control-key {
  background-color: #4CAF50;
  color: white;
  padding: 10px 15px;
  border-radius: 6px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  min-width: 120px;
  text-align: center;
  margin-right: 20px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
  font-size: calc(12px + 0.2vw);
}

.control-desc {
  font-size: calc(13px + 0.3vw);
  color: #ddd;
  line-height: 1.4;
}

.game-objectives, .game-tips {
  margin: 30px 0;
  text-align: left;
}

.game-objectives h3, .game-tips h3 {
  color: #FFD700;
  margin-bottom: 15px;
  font-size: calc(16px + 0.3vw);
  border-bottom: 2px solid #FFD700;
  padding-bottom: 8px;
}

.game-objectives ul, .game-tips ul {
  list-style: none;
  padding: 0;
}

.game-objectives li, .game-tips li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: calc(12px + 0.2vw);
  color: #ccc;
  line-height: 1.5;
}

.game-objectives li:before {
  content: "• ";
  color: #4CAF50;
  font-weight: bold;
  margin-right: 10px;
}

.game-tips li:before {
  content: "→ ";
  color: #FFD700;
  font-weight: bold;
  margin-right: 10px;
}

.msg {
  font-size: calc(18px + 0.5vw);
  margin-bottom: 30px;
}

.restart-btn {
  background-color: #4CAF50;
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: calc(14px + 0.3vw);
  margin: 4px 2px;
  cursor: pointer;
  font-family: 'Press Start 2P', cursive;
  text-transform: uppercase;
  border: 3px solid #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  transition: all 0.3s ease;
}

.menu-btn {
  background-color: #2196F3;
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: calc(14px + 0.3vw);
  margin: 4px 2px;
  cursor: pointer;
  font-family: 'Press Start 2P', cursive;
  text-transform: uppercase;
  border: 3px solid #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  transition: all 0.3s ease;
}

.menu-btn:hover {
  background-color: #1976D2;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
  transform: scale(1.05);
}

.neighbor-shots {
  font-size: 18px;
  font-weight: bold;
  color: #FF6B6B;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 5px;
  position: fixed;
  bottom: 80px;
  right: 20px;
  border: 2px solid #FF6B6B;
  box-shadow: 0 0 10px rgba(255, 107, 107, 0.3);
  z-index: 1000;
}

.super-attacks {
  font-size: 18px;
  font-weight: bold;
  color: yellow;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 5px;
  position: fixed;
  bottom: 20px;
  right: 20px;
  border: 2px solid #FFD700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
  z-index: 1000;
}

.controls-btn {
  margin-top: 20px;
  background-color: #2196F3;
}

.controls-btn:hover {
  background-color: #1976D2;
}

.controls-btn-small {
  background-color: #2196F3;
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  position: fixed;
  top: 20px;
  right: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  border: 2px solid #2196F3;
  z-index: 1000;
}

.controls-btn-small:hover {
  background-color: #1976D2;
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(33, 150, 243, 0.5);
}

.restart-btn:hover {
  background-color: #45a049;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
  transform: scale(1.05);
}

.menu {
  width: 90vw;
  max-width: 800px;
  height: 80vh;
  max-height: 400px;
  background-color: rgb(124, 0, 128);
  font-size: calc(24px + 0.5vw);
  border: 1px solid white;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.btn {
  font-family: 'Press Start 2P', cursive;
  font-size: calc(20px + 0.5vw);
  letter-spacing: 4px;
  text-decoration: none;
  text-transform: uppercase;
  color: #000;
  cursor: pointer;
  border: 3px solid;
  padding: 0.25em 0.5em;
  box-shadow: 1px 1px 0px 0px, 2px 2px 0px 0px, 3px 3px 0px 0px, 4px 4px 0px 0px,
    5px 5px 0px 0px;
  position: relative;
  margin: 10px;
}

.btn:hover {
  background-color: #2e2e2e;
  color: aliceblue;
}

.menu:hover {
  background-color: rgb(10, 42, 100);
  cursor: context-menu;
  color: #3A6D8C;
}

.aliens-count {
  color: green;
}

.floor {
  background-color: rgb(180, 19, 19);
}

.count-score {
  color: red;
}

.help-text {
  font-size: 12px;
  color: #888;
  position: fixed;
  top: 60px;
  right: 20px;
  font-style: italic;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 5px 10px;
  border-radius: 3px;
  z-index: 1000;
}

.mobile-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  padding: 20px 10px 10px 10px;
  z-index: 999;
}

.mobile-controls-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.mobile-left-controls, .mobile-center-controls, .mobile-right-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.mobile-btn {
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: white;
  padding: 15px 20px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 60px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-btn:active {
  background-color: rgba(255, 255, 255, 0.4);
  transform: scale(0.95);
}

.left-btn, .right-btn {
  background-color: rgba(76, 175, 80, 0.3);
  border-color: #4CAF50;
}

.fire-btn {
  background-color: rgba(244, 67, 54, 0.3);
  border-color: #F44336;
  font-size: 16px;
  min-width: 80px;
}

.n-btn {
  background-color: rgba(255, 107, 107, 0.3);
  border-color: #FF6B6B;
}

.x-btn {
  background-color: rgba(255, 215, 0, 0.3);
  border-color: #FFD700;
}

footer {
  color: yellowgreen;
  position: absolute;
  bottom: 10px;
  width: 100%;
  text-align: center;
  z-index: 1001;
}

@media (max-width: 768px) {
  .headers {
    font-size: 14px;
    margin-bottom: 10px;
  }
  
  .headers h1 {
    font-size: 18px;
    margin: 5px 0;
  }
  
  .headers h2 {
    font-size: 14px;
    margin: 5px 0;
  }
  
  .cell {
    width: calc(25px + 2vw);
    height: calc(20px + 1vw);
    font-size: 16px;
  }
  
  .board-container {
    max-height: 60vh;
    max-width: 95vw;
    margin: 10px auto;
  }
  
  .controls-grid {
    grid-template-columns: 1fr;
  }
  
  .control-item {
    flex-direction: column;
    text-align: center;
  }
  
  .control-key {
    margin-right: 0;
    margin-bottom: 10px;
    min-width: 100px;
  }
  
  .controls-btn-small {
    right: 10px;
    top: 10px;
    padding: 6px 10px;
    font-size: 14px;
  }
  
  .neighbor-shots {
    right: 10px;
    top: 60px;
    font-size: 14px;
    padding: 8px;
  }
  
  .super-attacks {
    right: 10px;
    top: 120px;
    font-size: 14px;
    padding: 8px;
  }
  
  .score {
    left: 10px;
    top: 10px;
    font-size: 16px;
    padding: 8px;
  }
  
  .help-text {
    right: 10px;
    top: 180px;
    font-size: 10px;
  }
  
  .controls-content {
    max-width: 95vw;
    margin: 2% auto;
    padding: 20px;
  }
  
  .modal-content {
    margin: 10% auto;
    padding: 20px;
    width: 90%;
  }
  
  .menu {
    width: 95vw;
    height: 70vh;
    font-size: 18px;
  }
  
  .btn {
    font-size: 16px;
    padding: 0.2em 0.4em;
  }
  
  .mobile-controls {
    display: block !important;
  }
  
  .mobile-btn {
    padding: 12px 16px;
    font-size: 16px;
    min-width: 50px;
    min-height: 50px;
  }
  
  .fire-btn {
    min-width: 70px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .cell {
    width: calc(20px + 1.5vw);
    height: calc(15px + 0.8vw);
    font-size: 14px;
  }
  
  .board-container {
    max-height: 50vh;
    margin: 5px auto;
  }
  
  .headers h1 {
    font-size: 16px;
  }
  
  .headers h2 {
    font-size: 12px;
  }
  
  .neighbor-shots {
    right: 5px;
    top: 50px;
    font-size: 12px;
    padding: 6px;
  }
  
  .super-attacks {
    right: 5px;
    top: 100px;
    font-size: 12px;
    padding: 6px;
  }
  
  .score {
    left: 5px;
    top: 5px;
    font-size: 14px;
    padding: 6px;
  }
  
  .help-text {
    right: 5px;
    top: 150px;
    font-size: 9px;
  }
  
  .mobile-btn {
    padding: 10px 14px;
    font-size: 14px;
    min-width: 45px;
    min-height: 45px;
  }
  
  .fire-btn {
    min-width: 60px;
    font-size: 12px;
  }
  
  .mobile-controls-container {
    gap: 5px;
  }
  
  .mobile-left-controls, .mobile-center-controls, .mobile-right-controls {
    gap: 5px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .board-container {
    max-height: 40vh;
  }
  
  .mobile-controls {
    padding: 10px 5px 5px 5px;
  }
  
  .mobile-btn {
    padding: 8px 12px;
    min-width: 40px;
    min-height: 40px;
    font-size: 12px;
  }
  
  .fire-btn {
    min-width: 50px;
    font-size: 10px;
  }
  
  .headers {
    margin-bottom: 5px;
  }
  
  .headers h1 {
    font-size: 14px;
    margin: 2px 0;
  }
  
  .headers h2 {
    font-size: 12px;
    margin: 2px 0;
  }
  
  .neighbor-shots {
    top: 40px;
    font-size: 10px;
    padding: 4px;
  }
  
  .super-attacks {
    top: 80px;
    font-size: 10px;
    padding: 4px;
  }
  
  .score {
    top: 5px;
    font-size: 12px;
    padding: 4px;
  }
  
  .help-text {
    top: 120px;
    font-size: 8px;
  }
}

@media (min-width: 769px) {
  .mobile-controls {
    display: none !important;
  }
}

