:root {
  --shell: #2b2f3a;
  --shell-dark: #1a1c2c;
  --bezel: #3d4252;
  --accent: #e8c547;
  --accent-dim: #a8923a;
  --screen-glow: rgba(150, 220, 120, 0.08);
  --led-on: #5ad85a;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background:
    linear-gradient(180deg, rgba(6, 8, 18, 0.55) 0%, rgba(6, 8, 18, 0.78) 100%),
    url("../img/fondo.png") center / cover no-repeat fixed,
    var(--shell-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", monospace;
  color: #d7dbe8;
  touch-action: none;
}

/* Tinte CRT sutil sobre toda la página */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.10) 0px,
    rgba(0, 0, 0, 0.10) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.55;
}

#console {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}

/* ============ LOGO ============ */
#brand {
  text-align: center;
  line-height: 1.05;
  position: relative;
  padding: 4px 26px;
}

/* Marco pixel a los lados del logo */
#brand::before,
#brand::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translateY(-50%) rotate(45deg);
  background: var(--accent);
  box-shadow:
    0 0 10px rgba(232, 197, 71, 0.7),
    14px -14px 0 -3px var(--accent),
    -14px 14px 0 -3px var(--accent);
  animation: emblem-pulse 2.2s ease-in-out infinite;
}
#brand::before { left: -2px; }
#brand::after  { right: -2px; }
@keyframes emblem-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

#brand .sat {
  display: block;
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: 4px;
  color: #f5e27a;
  /* contorno pixel + profundidad + brillo */
  text-shadow:
    -2px -2px 0 #1a1c2c,
     2px -2px 0 #1a1c2c,
    -2px  2px 0 #1a1c2c,
     2px  2px 0 #1a1c2c,
     0    4px 0 #7a5a10,
     0    6px 0 #4a3408,
     0    0  22px rgba(232, 197, 71, 0.55);
  animation: logo-glow 3s ease-in-out infinite;
}
@keyframes logo-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}

#brand .sub {
  display: block;
  font-size: clamp(11px, 2vw, 15px);
  font-weight: 900;
  letter-spacing: 7px;
  margin-top: 6px;
  color: #ff4b5c;
  text-shadow:
    -1px -1px 0 #1a1c2c,
     1px -1px 0 #1a1c2c,
    -1px  1px 0 #1a1c2c,
     1px  1px 0 #1a1c2c,
     0 0 14px rgba(255, 75, 92, 0.6);
  animation: glitch-sub 3.2s steps(1) infinite;
}
@keyframes glitch-sub {
  0%, 90%, 100% {
    transform: translateX(0);
    text-shadow:
      -1px -1px 0 #1a1c2c, 1px -1px 0 #1a1c2c,
      -1px 1px 0 #1a1c2c, 1px 1px 0 #1a1c2c,
      0 0 14px rgba(255, 75, 92, 0.6);
  }
  92% {
    transform: translateX(-2px) skewX(-4deg);
    text-shadow: 3px 0 #00e5ff, -3px 0 #ff2d95;
  }
  94% {
    transform: translateX(2px) skewX(4deg);
    text-shadow: -3px 0 #00e5ff, 3px 0 #ff2d95;
  }
  96% {
    transform: translateX(-1px);
    text-shadow: 2px 0 #00e5ff, -2px 0 #ff2d95;
  }
}

/* ============ PANTALLA ============ */
#bezel {
  position: relative;
  background: linear-gradient(160deg, var(--bezel), #2a2e3c);
  border-radius: 14px;
  padding: 18px 22px 22px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -2px 6px rgba(0, 0, 0, 0.4);
}

#power-led {
  position: absolute;
  top: 7px;
  left: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--led-on);
  box-shadow: 0 0 8px var(--led-on), 0 0 2px #fff inset;
  animation: led-pulse 2.4s ease-in-out infinite;
}
@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

#screen {
  display: block;
  background: #0f0f1a;
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow:
    0 0 0 3px #14161f,
    0 0 30px var(--screen-glow);
  /* escala por JS */
}

/* ============ CONTROLES ============ */
#controls {
  display: none;
  width: 100%;
  max-width: 520px;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
}
#controls.visible {
  display: flex;
}

/* D-pad en cruz */
#dpad {
  position: relative;
  width: 132px;
  height: 132px;
}
#dpad .btn-dir {
  position: absolute;
  width: 46px;
  height: 46px;
  background: linear-gradient(160deg, #3a3f52, #232633);
  border: none;
  color: #aeb4c8;
  font-size: 14px;
  border-radius: 8px;
  box-shadow: 0 3px 0 #14161f, inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
}
#dpad .btn-dir:active, #dpad .btn-dir.held {
  background: linear-gradient(160deg, #2a2e3c, #1a1c2c);
  transform: translateY(2px);
  box-shadow: 0 1px 0 #14161f;
  color: var(--accent);
}
#dpad [data-key="up"]    { top: 0;    left: 43px; }
#dpad [data-key="left"]  { top: 43px; left: 0;  }
#dpad [data-key="right"] { top: 43px; right: 0; }
#dpad [data-key="down"]  { bottom: 0; left: 43px; }

/* Botones A/B */
#ab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
#ab-main {
  display: flex;
  gap: 18px;
  align-items: flex-end;
}
.btn-act {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  font-size: 18px;
  font-weight: bold;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #14161f, inset 0 2px 0 rgba(255, 255, 255, 0.18);
}
.btn-act:active, .btn-act.held {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #14161f;
}
.btn-a { background: linear-gradient(160deg, #e85d5d, #b03030); margin-bottom: 10px; }
.btn-b { background: linear-gradient(160deg, #5d8de8, #3055b0); }
.btn-sys {
  width: 42px;
  height: 18px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(160deg, #4a4f62, #2a2e3c);
  color: #aeb4c8;
  font-size: 10px;
  font-family: inherit;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 2px 0 #14161f;
}
.btn-sys:active, .btn-sys.held {
  transform: translateY(2px);
  box-shadow: none;
  color: var(--accent);
}

/* Escritorio: mostrar controles con teclado como ayuda? No — solo táctil */
@media (pointer: coarse), (max-width: 700px) {
  #controls { display: flex; }
  #console { gap: 10px; padding: 10px; }
  #bezel { padding: 14px 16px 16px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  #console { flex-direction: row; gap: 18px; }
  #brand { display: none; }
}
