* { margin:0; padding:0; box-sizing:border-box; }

body {
  background: #1a1008;
  background-image:
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(80,50,20,0.08) 3px, rgba(80,50,20,0.08) 6px),
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(80,50,20,0.06) 3px, rgba(80,50,20,0.06) 6px);
  font-family: 'Press Start 2P', monospace;
  color: #ddd;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  overflow-x: hidden;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 720px;
  padding: 10px;
}

#marquee {
  text-align: center;
  padding: 12px 0 8px;
}

#title-text {
  font-size: 20px;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #f44, #fa0, #ff0, #0f0, #0af, #a0f, #f44);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: rainbow-scroll 3s linear infinite;
}

@keyframes rainbow-scroll {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

#tagline {
  font-size: 8px;
  color: #a98;
  margin-top: 4px;
  letter-spacing: 1px;
}

#crt-frame {
  position: relative;
  border: 8px solid #2a1a0a;
  border-radius: 12px;
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.8),
    0 0 20px rgba(0,0,0,0.6),
    0 4px 15px rgba(0,0,0,0.4);
  background: #000;
  overflow: hidden;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 160 / 228;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0,0,0,0.15) 1px,
    rgba(0,0,0,0.15) 2px
  );
  z-index: 2;
}

#crt-vignette {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.5) 100%);
  z-index: 3;
}

#controls-panel {
  width: 100%;
  max-width: 640px;
  background: linear-gradient(180deg, #3a2810, #2a1a08);
  border: 3px solid #1a0f05;
  border-radius: 0 0 8px 8px;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  color: #c90;
}

.control-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.control-label {
  color: #fa0;
  font-weight: bold;
}

#buttons-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
}

.retro-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #555, #333);
  color: #fff;
  border: 2px solid #777;
  border-radius: 4px;
  cursor: pointer;
  text-shadow: 0 1px 2px #000;
  transition: all 0.1s;
}

.retro-btn:hover {
  background: linear-gradient(180deg, #777, #555);
  border-color: #fa0;
  color: #fa0;
}

.retro-btn:active {
  transform: scale(0.95);
}

.btn-reset {
  background: linear-gradient(180deg, #800, #500);
  border-color: #a33;
}
.btn-reset:hover {
  background: linear-gradient(180deg, #a33, #700);
  border-color: #f55;
  color: #fcc;
}

#volume-row {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 100%;
  justify-content: center;
  margin-top: 2px;
}

#volume-slider {
  width: 100px;
  accent-color: #fa0;
  height: 4px;
}

#touch-controls {
  display: none;
  width: 100%;
  max-width: 640px;
  padding: 10px;
  justify-content: space-between;
  align-items: center;
}

#dpad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  gap: 4px;
  width: 120px;
  height: 120px;
}

.dpad-btn {
  width: 36px;
  height: 36px;
  font-size: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.dpad-up { grid-area: up; justify-self: center; }
.dpad-left { grid-area: left; align-self: center; }
.dpad-right { grid-area: right; align-self: center; }
.dpad-down { grid-area: down; justify-self: center; }

.fire-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 28px;
  background: rgba(255,80,120,0.3);
  border: 3px solid rgba(255,80,120,0.6);
  color: #f8a;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#game-footer {
  width: 100%;
  max-width: 640px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 7px;
  color: #665;
  padding: 8px 4px;
}

#game-footer a {
  color: #a86;
  text-decoration: none;
}
#game-footer a:hover {
  color: #fa0;
}

@media (max-width: 600px) {
  #title-text { font-size: 13px; }
  #tagline { font-size: 6px; }
  .retro-btn { font-size: 7px; padding: 6px 10px; }
  #controls-panel { font-size: 6px; }
  #game-footer { font-size: 5px; }
}

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