/*
 * The D-pad and A/B pad for the classic-mode games.
 *
 * ⚠️ `touch-action: none` ON THE PAD IS LOAD-BEARING. Without it a thumb resting on the cross
 * scrolls the page, and the pad reads as broken on a phone — the exact hardware this zone is for.
 * It is set on the pad only, so the rest of the page still scrolls.
 */
/*
 * ⚠️ THE PAD TAKES SPACE IN THE LAYOUT, IT DOES NOT FLOAT OVER THE GAME.
 *
 * The first version was `position: fixed` with the board unchanged, so it covered the bottom two
 * rows of every board — in Travessia that is the player's starting bank, and in Destruidor the
 * lives. A control that hides the thing it controls is worse than no control.
 *
 * `--jl-pad-h` is published on :root by pad.js once the pad is measured, and the classic-mode games
 * read it for their own bottom padding. A viewport-relative constant would be wrong on the two
 * device shapes the zone actually targets (a tall phone and a short one).
 */
:root { --jl-pad-h: 96px; }

.jl-pad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /*
   * ⭐ FURTHER FROM THE EDGE (owner request, 2026-11-21). 18px put the cross and the A button close
   * enough that a thumb resting on the phone's bezel pressed them, or missed them — the phone's own
   * edge gestures compete for that strip, and a back-swipe from the left margin is a lost game.
   * 28px clears both, and the side buttons keep their size because the cross is unchanged.
   */
  padding: 12px 28px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(12, 17, 24, 0) 0%, rgba(12, 17, 24, 0.82) 34%, #0c1118 100%);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

/* ---- the cross ---- */
.jl-pad-cross {
  position: relative;
  display: grid;
  /*
   * ⭐ A THUMB, NOT A FINGERNAIL (owner request, 2026-11-26: "make a larger D pad and buttons for
   * the three Retro games").
   *
   * The cross was 40px a cell — 120px across — and A was 64px. On a phone held in two hands that is
   * a target you have to look at. 52px a cell is 156px across, which the thumb finds blind.
   *
   * ⚠️ AND IT COSTS THE BOARD NOTHING. The classic-mode boards are WIDTH-limited on a phone
   * (9 columns across 412px), so the extra 36px of pad height comes out of empty space, not the
   * playfield. Measured on a 412x892 screen: the Destruidor cell stays 39px.
   */
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  place-items: stretch;
}
.jl-pad-up    { grid-area: 1 / 2 / 2 / 3; }
.jl-pad-left  { grid-area: 2 / 1 / 3 / 2; }
.jl-pad-right { grid-area: 2 / 3 / 3 / 4; }
.jl-pad-down  { grid-area: 3 / 2 / 4 / 3; }
.jl-pad-hub   { grid-area: 2 / 2 / 3 / 3; background: #1c2530; border-radius: 4px; }

.jl-pad-btn {
  display: grid;
  place-items: center;
    min-width: 52px;
    min-height: 52px;
  border: 1px solid #2f4356;
  background: #1c2530;
  color: #cfdae6;
  font: 600 13px/1 system-ui, sans-serif;
  border-radius: 8px;
  touch-action: none;
  transition: background .08s ease, transform .08s ease;
}
.jl-pad-up,
.jl-pad-left,
.jl-pad-right,
.jl-pad-down { border-radius: 6px; }
.jl-pad-btn:active,
.jl-pad-btn[aria-pressed="true"] { background: #2f4356; color: #fff; transform: scale(.96); }
.jl-pad-btn.jl-pad-hit { background: #4a7fb5; color: #fff; }

/* ---- the two buttons ---- */
.jl-pad-buttons { display: flex; align-items: center; gap: 14px; }
.jl-pad-a,
.jl-pad-b {
    width: 74px;
    height: 74px;
    min-width: 74px;
    min-height: 74px;
  border-radius: 50%;
    font: 700 21px/1 system-ui, sans-serif;
  /* OUR palette: the project's blue for A, a neutral for B. Not hardware colours. */
  border-color: #3d6b96;
  background: #1b2f44;
  color: #dbe8f4;
}
  .jl-pad-a { width: 80px; height: 80px; min-width: 80px; min-height: 80px; }
.jl-pad-a:active,
.jl-pad-a[aria-pressed="true"] { background: #3d6b96; }
.jl-pad-b:active,
.jl-pad-b[aria-pressed="true"] { background: #2f4356; }

/* ---- a thumb-sized target on a narrow phone, and never covering the board ---- */
@media (max-width: 359px) {
  .jl-pad { padding: 10px 20px calc(10px + env(safe-area-inset-bottom, 0px)); }
  /*
   * ⚠️ THE NARROW-PHONE FALLBACK WAS SMALLER THAN THE OLD DEFAULT — 34px cells on a 320-359px
   * screen. Left alone it would have quietly undone this change on the phones that need big targets
   * most. It now shrinks RELATIVE to the new sizes: 46px cells, 64/70px buttons.
   */
  .jl-pad-cross { grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); }
  .jl-pad-btn { min-width: 46px; min-height: 46px; }
  .jl-pad-a, .jl-pad-b { width: 64px; height: 64px; min-width: 64px; min-height: 64px; font: 700 18px/1 system-ui, sans-serif; }
  .jl-pad-a { width: 70px; height: 70px; min-width: 70px; min-height: 70px; }
}

/*
 * ---- the retro HUD (owner request, 2026-11-21) -----------------------------------------------
 *
 * A fixed-width, monospaced, upper-case bar so the score line reads like the machines this zone is
 * modelled on. `Courier New` first with `ui-monospace` behind it: Courier is present on every
 * Android build and every Mac, and the fallback keeps the character on a device that has dropped it.
 *
 * ⚠️ NO hardware name, palette or logo (IP-64-5). A monospaced score line is typography, not trade
 * dress — the same reasoning that let a D-pad cross exist without copying a panel.
 */
.jl-tv-hud, .jl-ar-hud, .jl-as-hud, .jl-de-hud {
  font-family: "Courier New", Courier, "Nimbus Mono PS", ui-monospace, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.jl-tv-lab, .jl-ar-lab, .jl-as-lab, .jl-de-lab {
  font-family: "Courier New", Courier, "Nimbus Mono PS", ui-monospace, monospace;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.jl-tv-val, .jl-ar-val, .jl-as-val, .jl-de-val {
  font-family: "Courier New", Courier, "Nimbus Mono PS", ui-monospace, monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* ---- the hit flash and the death pause (owner request, 2026-11-21) --------------------------
 *
 * ⚠️ A LOST LIFE MUST BE SEEN. The board used to cut to the result panel on the same frame the
 * killing blow landed, so on a phone the player saw a box appear and never saw WHY. The game now
 * flashes what hit it, holds for three seconds, and only then shows the panel.
 */
.jl-hitflash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 90, 60, 0.55), rgba(255, 40, 20, 0) 70%);
  opacity: 0;
  animation: jl-hitflash 0.55s ease-out;
  z-index: 5;
}
@keyframes jl-hitflash {
  0% { opacity: 0.95; }
  60% { opacity: 0.45; }
  100% { opacity: 0; }
}

/* The pause itself: dim, and say why, so three seconds of nothing is not three seconds of doubt. */
.jl-death-hold {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 11, 16, 0.55);
  z-index: 6;
  pointer-events: none;
}
.jl-death-hold span {
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 13px;
  color: #ffd54f;
  padding: 8px 14px;
  border: 1px solid rgba(255, 213, 79, 0.5);
  border-radius: 8px;
  background: rgba(12, 16, 22, 0.85);
}
