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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Press Start 2P', monospace;
}

#app-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 70%);
}

#tv-frame {
  position: relative;
  flex-shrink: 0;
}

#tv-bezel {
  background: linear-gradient(145deg, #3a3a4a, #252535, #1e1e2e);
  border-radius: 16px;
  padding: 20px 24px 40px 24px;
  box-shadow: 
    0 0 0 3px #111,
    0 8px 32px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
}

#screen-container {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.9);
}

#canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

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

#crt-overlay {
  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.4) 100%);
  z-index: 3;
}

#bezel-label {
  color: #666;
  font-size: 7px;
  text-align: center;
  margin-top: 10px;
  letter-spacing: 3px;
}

#bezel-led {
  position: absolute;
  bottom: 14px;
  right: 30px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff2222;
  box-shadow: 0 0 6px #ff2222, 0 0 12px #ff000066;
  animation: led-pulse 2s ease-in-out infinite;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#mobile-controls {
  width: 100%;
  max-width: 520px;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

#dpad-container {
  display: grid;
  grid-template-columns: 40px 40px 40px;
  grid-template-rows: 40px 40px 40px;
  gap: 0;
}

.dpad-btn {
  background: #2a2a3a;
  border: 1px solid #3a3a4a;
  color: #888;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.dpad-btn:active {
  background: #4a4a5a;
  color: #fff;
}

#dpad-up { grid-column: 2; grid-row: 1; border-radius: 6px 6px 0 0; }
#dpad-left { grid-column: 1; grid-row: 2; border-radius: 6px 0 0 6px; }
.dpad-center { grid-column: 2; grid-row: 2; background: #333344; cursor: default; }
#dpad-right { grid-column: 3; grid-row: 2; border-radius: 0 6px 6px 0; }
#dpad-down { grid-column: 2; grid-row: 3; border-radius: 0 0 6px 6px; }

#action-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#meta-buttons {
  display: flex;
  gap: 12px;
}

.meta-btn {
  background: #444;
  border: none;
  color: #aaa;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.meta-btn:active { background: #666; color: #fff; }

#ab-buttons {
  display: flex;
  gap: 16px;
}

.action-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #8b1a1a;
  border: 2px solid #6b0e0e;
  color: #ddd;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: 0 3px 0 #500a0a;
}

.action-btn:active {
  background: #aa2a2a;
  transform: translateY(2px);
  box-shadow: 0 1px 0 #500a0a;
}

#footer {
  color: #444;
  font-size: 7px;
  padding: 8px;
  text-align: center;
  letter-spacing: 1px;
  flex-shrink: 0;
}

#footer a {
  color: #666;
  text-decoration: none;
  margin-left: 12px;
}

#footer a:hover { color: #999; }

@media (max-width: 600px) {
  #tv-bezel {
    border-radius: 8px;
    padding: 8px 8px 24px 8px;
  }
  #bezel-label { font-size: 5px; margin-top: 6px; }
  #bezel-led { bottom: 8px; right: 14px; width: 6px; height: 6px; }
  #mobile-controls { display: flex !important; }
}