/* ===== Snake de Letras — pixel punk (paleta Nokia, cero carcasa) ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background:
    radial-gradient(120% 90% at 50% 10%, #202a19 0%, #161d13 55%, #0e130c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", monospace;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: rotate(-0.6deg);   /* pelín torcido, como sticker mal pegado */
}

/* marco: cinta de cuadritos + doble borde crudo */
#bezel {
  position: relative;
  padding: 10px;
  background:
    repeating-conic-gradient(#43523d 0% 25%, #202a19 0% 50%) 0 0 / 12px 12px;
  border: 3px solid #43523d;
  outline: 3px solid #0e130c;
  box-shadow:
    8px 8px 0 #0e130c,
    0 0 46px rgba(199, 240, 216, 0.14);
}

#screen {
  display: block;
  width: min(92vw, 132vh * 0.58);
  max-width: 720px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #c7f0d8;
}

/* scanlines CRT sutiles */
#scan {
  position: absolute;
  inset: 10px;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(14, 19, 12, 0.09) 2px 3px
  );
}

#tagline {
  color: #43523d;
  text-shadow: 0 0 8px rgba(199, 240, 216, 0.25);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ===== cruceta táctil (solo pantallas touch) ===== */
#dpad {
  display: none;
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 46px);
  gap: 6px;
  z-index: 5;
}
@media (pointer: coarse) {
  #dpad { display: grid; }
  #stage { margin-bottom: 150px; }
  #tagline { display: none; }
}

.key {
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  color: #c7f0d8;
  background: rgba(22, 29, 19, 0.85);
  border: 3px solid #43523d;
  box-shadow: 3px 3px 0 #0e130c;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.key:active {
  background: #c7f0d8;
  color: #161d13;
  transform: translate(2px, 2px);
  box-shadow: none;
}
.key.d.up    { grid-column: 2; grid-row: 1; }
.key.d.left  { grid-column: 1; grid-row: 2; }
.key.d.ok    { grid-column: 2; grid-row: 2; }
.key.d.right { grid-column: 3; grid-row: 2; }
.key.d.down  { grid-column: 2; grid-row: 3; }
.key.d.back  { grid-column: 3; grid-row: 3; font-size: 13px; }

/* ===== selector de letra del comodín ===== */
#letterpicker {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(9, 13, 7, 0.92);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}
#letterpicker.show { display: flex; }

.lp-title {
  color: #c7f0d8;
  font-weight: bold;
  letter-spacing: 2px;
  font-size: 13px;
  text-align: center;
  text-shadow: 0 0 10px rgba(199, 240, 216, 0.4);
}

.lp-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lp-row { display: flex; gap: 6px; justify-content: center; }

.lp-key {
  width: 32px; height: 32px;
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 14px;
  color: #c7f0d8;
  background: #161d13;
  border: 2px solid #43523d;
  box-shadow: 2px 2px 0 #0e130c;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lp-key:active {
  background: #c7f0d8;
  color: #161d13;
  transform: translate(1px, 1px);
  box-shadow: none;
}

.lp-cancel {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 1px;
  color: #43523d;
  background: transparent;
  border: 2px solid #43523d;
  padding: 6px 14px;
  cursor: pointer;
}
.lp-cancel:active { background: #43523d; color: #161d13; }
