@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --bg-color: #2c3e50;
  --panel-bg: rgba(0, 0, 0, 0.85);
  --text-color: #ecf0f1;
  --accent-color: #e74c3c;
  --grid-border: #4a5c60;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Press Start 2P', monospace; /* Pixel font */
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
  touch-action: none; /* Prevent scroll on mobile */
}

#game-container {
  position: relative;
  width: 100%;
  max-width: 600px; /* Keep aspect ratio roughly */
  aspect-ratio: 3/4;
  background: #000;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated; /* Crucial for pixel art */
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through to controls if needed */
  display: flex;
  flex-direction: column;
}

#top-bar {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: rgba(0,0,0,0.6);
  font-size: 10px;
}

.stat-box {
  flex: 1;
  text-align: center;
}

#phase-disp {
  color: #f1c40f;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  pointer-events: auto;
  z-index: 10;
}

.hidden {
  display: none !important;
}

h1 {
  font-size: 24px;
  color: #e74c3c;
  margin-bottom: 20px;
  line-height: 1.5;
}

p {
  font-size: 12px;
  color: #bdc3c7;
  line-height: 1.6;
  margin-bottom: 20px;
}

.instructions {
  background: rgba(255,255,255,0.1);
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 5px;
}

button {
  background: #e74c3c;
  border: 4px solid #c0392b;
  color: white;
  padding: 15px 30px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  text-transform: uppercase;
}

button:active {
  background: #c0392b;
  border-color: #e74c3c;
}

#info-panel {
  position: absolute;
  top: 50px;
  width: 100%;
  text-align: center;
}

#info-text {
  background: rgba(0,0,0,0.7);
  display: inline-block;
  padding: 5px 10px;
  color: #f39c12;
  font-size: 10px;
}

/* Mobile Controls */
#mobile-controls {
  position: absolute;
  bottom: 20px;
  left: 0;
  width: 100%;
  height: 120px;
  display: none; /* Hidden on desktop by default, or shown via JS detection */
  pointer-events: auto;
  justify-content: space-between;
  padding: 0 20px;
  box-sizing: border-box;
}

@media (hover: none) and (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
}

.d-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.d-row {
  display: flex;
}

.d-btn {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  color: white;
  font-size: 16px;
  padding: 0;
  margin: 2px;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}

.d-btn:active {
  background: rgba(255,255,255,0.5);
}

.action-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(231, 76, 60, 0.6);
  border: 4px solid rgba(192, 57, 43, 0.8);
  align-self: center;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  margin-left: auto;
  user-select: none;
}

.action-btn:active {
  background: rgba(231, 76, 60, 0.9);
}
