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

body {
  background-color: #1a1a1a;
  background-image:
    radial-gradient(circle at 20px 20px, #222 1px, transparent 1px),
    radial-gradient(circle at 40px 40px, #1e1e1e 1px, transparent 1px);
  background-size: 60px 60px;
  font-family: 'Press Start 2P', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
  color: #9bbc0f;
  user-select: none;
}

#console-shell {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#console-top {
  background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
  border-radius: 16px 16px 0 0;
  padding: 8px 24px 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid #444;
  border-bottom: none;
  width: calc(100% + 40px);
  max-width: 100vw;
  justify-content: center;
}

#power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a4;
  box-shadow: 0 0 6px #4a4, 0 0 12px #2a2;
  animation: pulse-led 2s ease-in-out infinite;
}

@keyframes pulse-led {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; box-shadow: 0 0 8px #6c6, 0 0 16px #4a4; }
}

#console-label {
  font-size: 6px;
  color: #888;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#screen-bezel {
  background: #2a2a2a;
  border: 3px solid #444;
  border-top: 3px solid #555;
  padding: 12px;
  position: relative;
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.5),
    0 4px 20px rgba(0,0,0,0.5);
  border-radius: 4px;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0f380f;
  border-radius: 2px;
}

#scanline-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  bottom: 12px;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.12) 1px,
    rgba(0,0,0,0.12) 2px
  );
  border-radius: 2px;
  mix-blend-mode: multiply;
}

#scanline-overlay::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.25) 100%);
  border-radius: 2px;
}

#console-bottom {
  background: linear-gradient(180deg, #2a2a2a 0%, #333 100%);
  border-radius: 0 0 20px 20px;
  padding: 6px 24px 12px;
  border: 2px solid #444;
  border-top: none;
  width: calc(100% + 40px);
  max-width: 100vw;
  height: 20px;
}

#virtual-controls {
  display: none;
  width: 100%;
  max-width: 480px;
  padding: 16px 12px;
  justify-content: space-between;
  align-items: center;
}

#dpad-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dpad-mid-row {
  display: flex;
  gap: 2px;
  align-items: center;
}

.dpad-center {
  width: 36px;
  height: 36px;
  background: #333;
  border-radius: 4px;
}

.dpad-btn {
  width: 36px;
  height: 36px;
  background: #2a2a2a;
  border: 2px solid #555;
  border-radius: 6px;
  color: #888;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
  background: #444;
  border-color: #9bbc0f;
  color: #9bbc0f;
}

#start-btn-container {
  display: flex;
  align-items: center;
}

.action-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 8px 14px;
  background: #2a2a2a;
  border: 2px solid #555;
  border-radius: 12px;
  color: #888;
  cursor: pointer;
}

.action-btn:active {
  background: #444;
  border-color: #9bbc0f;
  color: #9bbc0f;
}

.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 10px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ab-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#ab-container .round-btn {
  display: inline-flex;
}

#ab-container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

#controls-ref {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 16px;
  margin-top: 8px;
  font-size: 7px;
  color: #666;
  justify-content: center;
}

#options-bar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.opt-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 6px 10px;
  background: #222;
  border: 1px solid #444;
  border-radius: 4px;
  color: #777;
  cursor: pointer;
  transition: all 0.15s;
}

.opt-btn:hover {
  background: #333;
  color: #9bbc0f;
  border-color: #9bbc0f;
}

.opt-btn.active {
  background: #2a3a0f;
  color: #9bbc0f;
  border-color: #8bac0f;
  box-shadow: 0 0 6px rgba(155, 188, 15, 0.3);
}

#game-footer {
  margin-top: 16px;
  padding: 12px 20px;
  font-size: 7px;
  color: #555;
  display: flex;
  gap: 24px;
  justify-content: center;
  width: 100%;
  flex-wrap: wrap;
}

#game-footer a {
  color: #8bac0f;
  text-decoration: none;
}

#game-footer a:hover {
  color: #9bbc0f;
  text-decoration: underline;
}

@media (max-width: 600px) {
  #virtual-controls {
    display: flex;
  }
  #controls-ref {
    display: none;
  }
  #console-top, #console-bottom {
    width: 100%;
  }
  body {
    padding: 4px;
  }
}

@media (pointer: coarse) {
  #virtual-controls {
    display: flex;
  }
}