/* Page layout and the black-and-green arcade theme. */
* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #000000;
  color: #00FF00;
  font-family: "Courier New", Courier, monospace;
}

.page-shell {
  width: min(100%, 900px);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid #00FF00;
  padding-bottom: 8px;
}

.tab-button {
  background: #000000;
  border: 2px solid #00FF00;
  color: #00FF00;
  padding: 10px 18px;
  font: inherit;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.tab-button.active {
  background: #00FF00;
  color: #000000;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.game-container {
  width: min(100%, 800px);
  margin-block: auto;
  text-align: center;
}

.page-heading {
  margin: 0 0 16px;
  font-size: clamp(1.25rem, 5vw, 2rem);
  letter-spacing: 0.12em;
}

.info-panel {
  border: 2px solid #00FF00;
  background: rgba(0, 255, 0, 0.03);
  padding: 24px;
  text-align: left;
}

.info-panel h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.5rem;
}

.info-panel ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

/* The fixed canvas dimensions set the game's 4:3 aspect ratio. */
#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 2px solid #00FF00;
  background: #000000;
  image-rendering: pixelated;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 4vw, 28px);
  width: min(100%, 800px);
  margin: 14px auto 0;
}

.touch-movement-controls {
  display: contents;
}

.touch-control {
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border: 2px solid #00FF00;
  border-radius: 4px;
  appearance: none;
  -webkit-appearance: none;
  background-color: #000000;
  color: #00FF00;
  -webkit-text-fill-color: #00FF00;
  font: inherit;
  font-size: 0.9rem;
  font-weight: bold;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.touch-control:active {
  background-color: #00FF00;
  color: #000000;
  -webkit-text-fill-color: #000000;
}

.touch-control:focus-visible {
  outline: 2px solid #00FF00;
  outline-offset: 4px;
}

.touch-fire-control {
  min-width: 0;
}

/* Reduce the canvas width on short screens while preserving its 4:3 shape. */
@media (max-height: 850px) {
  #game-canvas {
    width: min(100%, 720px);
  }
}

@media (max-height: 700px) {
  #game-canvas {
    width: min(100%, 480px);
  }
}

@media (max-height: 500px) {
  #game-canvas {
    width: min(100%, 320px);
  }
}

@media (max-height: 380px) {
  #game-canvas {
    width: min(100%, 220px);
  }
}

/* Keep the start control outside the canvas so it works like a normal button. */
#start-button {
  margin-top: 20px;
  padding: 12px 28px;
  border: 2px solid #00FF00;
  background: #000000;
  color: #00FF00;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

#start-button:hover,
#start-button:focus-visible {
  outline: 2px solid #00FF00;
  outline-offset: 4px;
}

.game-status {
  min-height: 1.5em;
  margin: 18px 0 0;
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  .touch-controls {
    gap: 12px;
    margin-top: 10px;
  }

  .touch-control {
    min-height: 52px;
    padding: 8px 4px;
    font-size: 0.8rem;
  }
}
