/* R&H6900 POCKET - the handheld. Mounted <=740px: the page becomes a Y2K pocket
   console: molded shell, LCD bezel around the screens, fixed control deck
   (d-pad / SELECT+START / B+A). Static gradients only; transform/opacity motion;
   the deck respects the iOS home indicator via safe-area padding. */

.deck { display: none; }

@media (max-width: 740px) {

  /* ---------- shell ---------- */
  body.pocket {
    background:
      radial-gradient(140% 60% at 50% -10%, #16240f 0%, #0b130a 45%, #060a06 100%);
    /* clear the fixed deck */
    padding-bottom: calc(178px + env(safe-area-inset-bottom, 0px));
  }
  body.pocket .cab {
    /* fill the viewport above the fixed deck so the device never ends mid-screen */
    min-height: calc(100svh - 196px - env(safe-area-inset-bottom, 0px));
    margin: 8px 8px 0;
    border: 2px solid #1c2b18;
    border-radius: 18px 18px 10px 10px;
    background: linear-gradient(180deg, #101a0e 0%, #0a100a 60%, #080d08 100%);
    box-shadow: inset 0 1px 0 rgba(160, 220, 140, 0.08), 0 6px 24px rgba(0, 0, 0, 0.6);
    overflow: hidden;
  }

  /* speaker grille strip above the HUD */
  body.pocket .cab::before {
    content: "";
    display: block;
    height: 14px;
    margin: 6px auto 0;
    width: 120px;
    background: radial-gradient(circle 2px at 6px 7px, #1f301c 98%, transparent) 0 0 / 12px 14px repeat-x;
  }

  /* ---------- LCD ---------- */
  body.pocket .screen-root {
    margin: 4px 8px 8px;
    border: 3px solid #060a06;
    border-radius: 8px;
    background: #0a0f0a;
    box-shadow: inset 0 0 0 1px #223a1e, inset 0 0 26px rgba(0, 0, 0, 0.55);
  }
  .screen { padding: 14px 12px 22px; }
  .screen-title { font-size: clamp(28px, 8vw, 40px); margin-bottom: 14px; }

  /* ---------- HUD compress ---------- */
  .hud { font-size: 12px; gap: 8px; padding: 8px 10px; }
  .hud-num { font-size: 12px; }

  /* ---------- nav: horizontal scroll row, real tap targets ---------- */
  .cabnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cabnav::-webkit-scrollbar { display: none; }
  .navb { min-height: 44px; white-space: nowrap; flex: 0 0 auto; display: flex; align-items: center; }

  /* ---------- attract ---------- */
  .attract { min-height: 62svh; gap: 16px; }
  .attract-stage { height: 44svh; }
  .attract-title .chrome-title { font-size: clamp(56px, 19vw, 92px); }
  .vs-pair { gap: 10px; }
  .vs-fighter { width: clamp(96px, 30vw, 130px); }
  .vs-big { font-size: clamp(28px, 9vw, 44px); }

  /* ---------- menu ---------- */
  .menu-list { padding-bottom: 4vh; }
  .menu-item { min-height: 52px; font-size: clamp(22px, 6.4vw, 30px); }
  .menu-item em { display: none; }

  /* ---------- pick a side: two full-width panels, VS chip between ---------- */
  .siderow { grid-template-columns: 1fr; gap: 8px; }
  .sidebtn { min-height: 84px; padding: 10px; grid-auto-flow: row; }
  .side-name { font-size: clamp(26px, 8vw, 36px); }
  .vs-chip { justify-self: center; font-size: 26px; padding: 0; }
  .devil-line { font-size: 12px; line-height: 1.5; }
  .qty { min-height: 44px; min-width: 56px; }
  .bigbtn { width: 100%; min-height: 48px; text-align: center; }
  .qtyrow { gap: 10px; }

  /* ---------- roster: sticky compact preview, boss between the two columns ---------- */
  .roster-wrap { display: flex; flex-direction: column; gap: 12px; }
  .preview {
    order: -1;
    position: sticky;
    top: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 8px 12px;
    padding: 8px;
    background: #0a0f0a;
    border-bottom: 2px solid var(--line);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.55);
  }
  .preview-art-wrap { aspect-ratio: 1 / 1; }
  .namebar {
    margin-top: 0;
    font-size: 19px;
    min-height: 0;
    padding: 6px 8px;
    align-self: start;
  }
  .preview-meta {
    grid-column: 2;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    margin: 0;
  }
  .preview-meta dd { font-size: 15px; }
  /* the boss slot rides at the top of the preview, above the fold, where the
     hidden devil belongs; traits drop below the grid to keep the strip short */
  .boss-slot { grid-column: 1 / -1; grid-row: 1; min-height: 56px; margin: 0 0 4px; }
  .boss-slot img { width: 44px; height: 44px; }
  .boss-q { font-size: 30px; }
  .preview-meta.traits { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  /* the preview is a 92px + 1fr strip on the handheld; without a span the button is trapped
     in the narrow column and wraps to three lines */
  #previewOpen { grid-column: 1 / -1; margin-top: 8px; }
  .preview-meta.traits dd { font-size: 14px; }
  .select-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .tile { min-width: 44px; }
  .roster-head { font-size: 12px; }
  .roster-head.p2 { text-align: left; }

  /* ---------- roster filters: real tap targets, selects go full width ---------- */
  .rfilter { padding: 10px; gap: 10px; }
  .rf-label { min-width: 100%; }
  .rf-b, .rf-clear { min-height: 44px; padding: 10px 12px; }
  .rf-traits { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .rf-sel select { min-height: 44px; max-width: none; width: 100%; }
  .rf-foot { gap: 10px; }

  /* ---------- the fighter card is full screen on the handheld ---------- */
  .fighter { padding: 0; align-items: stretch; }
  .fighter-frame {
    width: 100%;
    max-height: none;
    height: 100%;
    border-width: 0 0 3px;
  }
  .fighter-body {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .fighter-art-wrap { width: min(320px, 78%); margin: 0 auto; }
  .fighter-stats, .fighter-traits { grid-template-columns: 1fr 1fr; }
  .fighter-links { position: sticky; bottom: 0; background: #070c07; padding-top: 8px; }

  /* ---------- team tally ---------- */
  .tally-head { flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
  .tally-title { flex-basis: 100%; order: -1; }
  .tally-bar { height: 22px; }

  /* ---------- the draw reveal, handheld-sized ---------- */
  .reveal { padding: 10px; align-items: flex-start; }
  .reveal-frame {
    margin-top: 6vh;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .reveal-art-wrap { width: min(240px, 68%); }
  .reveal-name { font-size: 20px; }
  .reveal-actions .bigbtn { width: 100%; }

  /* ---------- shelf ---------- */
  .shelf-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  .shelf-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .shelf-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .shelf-actions .bigbtn { width: 100%; }

  /* ---------- scores: rows become cards ---------- */
  .scoretable thead { display: none; }
  .scoretable, .scoretable tbody { display: block; }
  .scoretable tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 2px 10px;
    border: 1px solid var(--line);
    background: var(--panel2);
    padding: 8px 10px;
    margin-bottom: 8px;
  }
  .scoretable td { display: block; border: 0; padding: 0; }
  .scoretable td[data-l]::before {
    content: attr(data-l) " ";
    font-family: "Silkscreen", monospace;
    font-size: 12px;
    color: var(--red);
    letter-spacing: 0.08em;
  }
  .scoretable td:nth-child(1) { grid-row: 1 / 3; align-self: center; font-size: 26px; font-family: "Jersey10", monospace; }
  .scoretable td:nth-child(2) { grid-column: 2 / 4; }
  .scoretable td:nth-child(5) { grid-column: 3; grid-row: 2; text-align: right; }
  .scoretable td.center { grid-column: 1 / 4; text-align: center; }

  /* ---------- deck ---------- */
  .deck {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, #131f10 0%, #0a110a 100%);
    border-top: 2px solid #1c2b18;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.55);
  }
  .dpad {
    position: relative;
    width: 118px; height: 118px;
  }
  .dp {
    position: absolute;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, #263a20, #15220f);
    border: 1px solid #0a120a;
    color: #9fbf8f;
    font-size: 13px;
  }
  .dp:active { background: #33502a; transform: translateY(1px); }
  .dp.up { left: 37px; top: 0; border-radius: 6px 6px 0 0; }
  .dp.down { left: 37px; bottom: 0; border-radius: 0 0 6px 6px; }
  .dp.left { left: 0; top: 37px; border-radius: 6px 0 0 6px; }
  .dp.right { right: 0; top: 37px; border-radius: 0 6px 6px 0; }
  .dp-center {
    position: absolute; left: 37px; top: 37px; width: 44px; height: 44px;
    background: #15220f; border: 1px solid #0a120a;
  }
  .deck-mid { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
  /* Moulded device branding, not content: it sits between the d-pad and the A/B buttons and
     has a hard width budget. At 12px/0.18em the wordmark ran under the B button, so it keeps
     a smaller size and tighter tracking. Everything a visitor actually READS is >= 12px. */
  .pocket-brand {
    font-family: "Silkscreen", monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: #5e7a52;
    white-space: nowrap;
  }
  .pills { display: flex; gap: 12px; }
  .pill {
    min-width: 62px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
    font-family: "Silkscreen", monospace;
    font-size: 12px;
    letter-spacing: 0.1em;
    color: #8aa87a;
    background: linear-gradient(180deg, #22351c, #131f10);
    border: 1px solid #0a120a;
    border-radius: 99px;
    transform: rotate(-14deg);
  }
  .pill:active { transform: rotate(-14deg) translateY(1px); background: #2d4522; }
  .ab { display: flex; gap: 12px; align-items: flex-end; }
  .btn-ab {
    width: 54px; height: 54px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: "Silkscreen", monospace;
    font-weight: 700;
    font-size: 16px;
    color: #dff5d0;
    border: 1px solid #071007;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
  .btn-ab:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5); }
  #btnB { background: radial-gradient(circle at 35% 30%, #3d6b34, #1d3a16); margin-bottom: 16px; }
  #btnA { background: radial-gradient(circle at 35% 30%, #79b41e, #3d6b0e); }

  /* the bezel footer sits in flow above the deck; the blink note would wrap and
     clip against the shell's rounded overflow, so the pocket goes without it */
  .bezel { flex-wrap: wrap; gap: 8px; border-radius: 0 0 8px 8px; }
  .bezel-note { display: none; }

  /* ---------- the film on the handheld ---------- */
  /* the cabinet housing is desktop dressing; on a 390px screen it steals width from the
     picture, so the LCD itself becomes the frame */
  .film-cab { padding: 8px; border-width: 2px; margin-bottom: 18px; }
  .film-marquee { font-size: 12px; letter-spacing: 0.18em; margin-bottom: 8px; }
  .film-strip { display: none; }
  .film-sub { font-size: 12px; margin: -8px 0 14px; }
  .film-h3 { font-size: 12px; }
  .film-notes p { font-size: 17px; }
  /* native controls need a real tap target and must not be scaled down */
  .film-video { min-height: 0; }
  .film-links { gap: 10px; }
  .film-dl { padding: 12px 14px; min-height: 44px; display: inline-flex; align-items: center; }
  .linkish { min-height: 44px; display: inline-flex; align-items: center; }
}

/* tiny phones */
@media (max-width: 380px) {
  .dpad { width: 106px; height: 106px; }
  .dp.up, .dp.down { left: 31px; }
  .dp.left, .dp.right { top: 31px; }
  .dp-center { left: 31px; top: 31px; }
  .btn-ab { width: 48px; height: 48px; }
}

@media (max-width: 740px) {
  /* two covers a row keeps the boxart readable on the handheld screen */
  .lib-grid { grid-template-columns: 1fr 1fr; gap: 10px; min-height: 240px; }
  .lib-note { font-size: 15px; padding-left: 10px; }
}
