/* Pixel Hood Tetris — layout.
   The arcade image is the fixed visual foundation. Every dynamic layer is
   positioned as a percentage of the #stage, whose aspect ratio is locked to
   the 1024x1536 source image, so overlays always track the artwork at any size. */

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

html, body {
  width: 100%;
  height: 100%;
  background: #05030a;
  overflow: hidden;
  font-family: "Courier New", monospace;
  -webkit-user-select: none;
  user-select: none;
  /* Phones: the game owns every finger gesture (no scroll, zoom, double-tap
     zoom, long-press menu or grey tap flash). No effect on mouse/keyboard. */
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  aspect-ratio: 1024 / 1536;
}

#arcade-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  pointer-events: none;
}

/* Widened screen frame, extended up to the side panels.
   Image rect: x 260..770 (w 510), y 292..1296 (h 1004) of 1024x1536. */
#screen-frame {
  position: absolute;
  left: 25.3906%;
  top: 19.0104%;
  width: 49.8047%;
  height: 65.3646%;
  display: block;
  pointer-events: none;
}

/* Playfield inside the widened screen.
   Image rect: x 268..762 (w 494), y 300..1288 (h 988) -> exactly 1:2,
   so the 10x20 grid has square cells. */
#playfield {
  position: absolute;
  left: 26.1719%;
  top: 19.5313%;
  width: 48.2422%;
  height: 64.3229%;
  overflow: hidden;
}

/* NEXT preview, covering the baked minis inside the existing NEXT panel.
   Preview content box approx x 782..982 (w 200), y 428..650 (h 222).
   left   = 782/1024 = 76.3672%
   top    = 428/1536 = 27.8646%
   width  = 200/1024 = 19.5313%
   height = 222/1536 = 14.4531% */
#next {
  position: absolute;
  left: 76.3672%;
  top: 27.8646%;
  width: 19.5313%;
  height: 14.4531%;
  image-rendering: pixelated;
  pointer-events: none;
  /* Opaque backing matching the panel so the baked preview minis are hidden. */
  background: #060310;
}

/* Live HUD values overlaid on the baked SCORE / LEVEL / LINES number rows.
   Each box is opaque (panel colour) to fully replace the static digits without
   touching any surrounding artwork. Text is left-aligned like the originals. */
.hud-val {
  position: absolute;
  left: 4.88%;            /* ~50/1024 */
  width: 20.70%;          /* ~212/1024 */
  color: #c3f93a;
  background: #060310;    /* opaque panel bg to hide baked digits */
  font-weight: bold;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  padding-left: 0.35em;
  text-shadow: 0 0 6px rgba(150, 240, 40, 0.55);
  line-height: 1;
}

/* number row bands (of 1024x1536):
   SCORE  y 413..460 -> top 26.89%  height 3.06%
   LEVEL  y 522..570 -> top 33.98%  height 3.13%
   LINES  y 633..680 -> top 41.21%  height 3.06% */
#hud-score { top: 26.89%; height: 3.06%; }
#hud-level { top: 33.98%; height: 3.13%; }
#hud-lines { top: 41.21%; height: 3.06%; }

/* Overlay (pause / game over) confined to the playfield rectangle. */
#overlay {
  position: absolute;
  left: 26.1719%;
  top: 19.5313%;
  width: 48.2422%;
  height: 64.3229%;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(5, 3, 12, 0.72);
}
#overlay.show { display: flex; }

#overlay-inner { padding: 4%; }

/* Gesture hint, touch devices only (main.js adds .show), near the bottom of
   the playfield. Never blocks input. */
#touch-hint {
  position: absolute;
  left: 26.1719%;
  width: 48.2422%;
  top: 70%;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
#touch-hint.show { opacity: 1; }
#touch-hint span {
  padding: 0.5em 0.8em;
  background: rgba(5, 3, 12, 0.82);
  border: 1px solid rgba(195, 249, 58, 0.6);
  color: #d8ffb0;
  text-align: center;
  line-height: 1.5;
  text-shadow: 0 0 6px rgba(150, 240, 40, 0.55);
}

#overlay-title {
  color: #c3f93a;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(150, 240, 40, 0.8);
  margin-bottom: 0.6em;
  line-height: 1.1;
}
#overlay-sub {
  color: #d8ffb0;
  line-height: 1.4;
  opacity: 0.9;
}

/* D-pad y botones del arcade, dibujados con codigo en assets/controls.svg
   (la animacion vive dentro del SVG). Cubre x 380..725, y 1300..1400. */
#controls {
  position: absolute;
  left: 37.1094%;
  top: 84.6354%;
  width: 33.6914%;
  height: 6.5104%;
  display: block;
  pointer-events: none;
}

/* Mini sobre el recuadro "PIXEL HOOD CHAIN".
   Cubre el interior exacto del marco magenta: x 781..983 (w 203),
   y 685..890 (h 206) de 1024x1536, con las esquinas recortadas 8 px igual
   que el marco. Oculta hasta que carga un Mini, asi si fallan las imagenes
   se sigue viendo el arte original. */
#mini-panel {
  position: absolute;
  left: 76.2695%;
  top: 44.5964%;
  width: 19.8242%;
  height: 13.4115%;
  display: none;
  background: #020224;
  clip-path: polygon(3.9% 0, 96.1% 0, 100% 3.9%, 100% 96.1%, 96.1% 100%, 3.9% 100%, 0 96.1%, 0 3.9%);
  overflow: hidden;
  pointer-events: none;
}
#mini-panel.ready { display: flex; }

#mini-panel .mp-card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}
#mini-panel .mp-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
}

/* Destello lima detras del Mini al cambiar. */
#mini-panel .mp-flash {
  position: absolute;
  left: 5%;
  top: 5%;
  width: 90%;
  height: 90%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 255, 60, 0.95) 0%, rgba(129, 229, 0, 0.55) 38%, rgba(129, 229, 0, 0) 70%);
  opacity: 0;
}

/* Chispas pixeladas que salen disparadas al cambiar. */
#mini-panel .mp-spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4.5%;
  aspect-ratio: 1 / 1;
  background: #dafe00;
  box-shadow: 0 0 6px rgba(218, 254, 0, 0.9);
  opacity: 0;
  transform: translate(-50%, -50%);
}


/* Portrait/OpenSea shell: extend the 2:3 cabinet without moving its overlays. */
@media (orientation: portrait) {
  html, body {
    background:
      repeating-linear-gradient(0deg, transparent 0 14px, rgba(190, 255, 52, 0.09) 14px 16px),
      linear-gradient(90deg, #110418, #351047 18%, #170620 50%, #351047 82%, #110418);
  }

  #stage { isolation: isolate; }

  #stage::before,
  #stage::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50vw;
    z-index: -1;
    pointer-events: none;
    background:
      repeating-linear-gradient(0deg, transparent 0 12px, rgba(199, 255, 62, 0.12) 12px 14px),
      linear-gradient(90deg, #16051e 0 72%, #542068 72% 92%, #baff38 92% 96%, #291035 96%);
  }

  #stage::before {
    right: calc(100% - 1px);
  }

  #stage::after {
    left: calc(100% - 1px);
    transform: scaleX(-1);
  }
}
