/* JRPG.WORLD Emerald Live v0.1.6.2
   Desktop data-first UX pass. Mobile below 960px intentionally untouched. */

@media (min-width: 960px) {
  html,
  body {
    min-height: 100%;
  }

  body.pf-mobile-first {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    touch-action: auto !important;
    overscroll-behavior-y: auto !important;
    padding: 0 0 .8rem !important;
  }

  body.pf-mobile-first #root {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 0 !important;
  }

  body.pf-mobile-first .app-container {
    width: 100% !important;
    max-width: 1100px !important;
    min-height: 0 !important;
    margin: 0 auto !important;
  }

  body.pf-mobile-first .main-content {
    flex: 0 0 auto !important;
    justify-content: flex-start !important;
    align-items: center !important;
    width: 100% !important;
    padding: .45rem 1rem 0 !important;
  }

  body.pf-mobile-first .emulator-container.game-playing {
    width: 100% !important;
    max-width: 1000px !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }

  body.pf-mobile-first .emulator-layout.only-keyboard.game-playing {
    width: min(900px, 100%) !important;
    max-width: min(900px, calc((100dvh - 155px) * 1.5)) !important;
    min-width: 0 !important;
    margin: .1rem auto 0 !important;
  }

  body.pf-mobile-first .emulator-layout.only-keyboard .console-center,
  body.pf-mobile-first .emulator-layout.only-keyboard .screen-bezel,
  body.pf-mobile-first .emulator-layout.only-keyboard .bezel-inner,
  body.pf-mobile-first .emulator-layout.only-keyboard .canvas-wrapper {
    width: 100% !important;
    min-width: 0 !important;
  }

  body.pf-mobile-first .emulator-layout.only-keyboard .screen-bezel {
    margin-bottom: 0 !important;
    padding: .58rem .72rem !important;
    border-radius: 12px 12px 15px 15px !important;
  }

  body.pf-mobile-first .emulator-layout.only-keyboard canvas {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 3 / 2 !important;
    object-fit: contain !important;
  }

  /* Hide the upstream legend. Actual mappings are unchanged. */
  body.pf-mobile-first .keyboard-instructions {
    display: none !important;
  }

  /* Second screen in normal flow. */
  body.pf-mobile-first #pokefield-live-panel {
    position: relative !important;
    inset: auto !important;
    z-index: 1 !important;
    flex: 0 0 auto !important;
    width: min(900px, calc(100% - 2rem)) !important;
    max-width: 900px !important;
    max-height: none !important;
    overflow: visible !important;
    margin: .62rem auto 0 !important;
    padding: 9px 12px 10px !important;
    border: 1px solid rgba(255,255,255,.13) !important;
    border-radius: 14px !important;
    background: rgba(6,10,18,.985) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.3), inset 0 1px rgba(255,255,255,.025) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    touch-action: auto !important;
  }

  body.pf-mobile-first #pokefield-live-panel::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 50%;
    width: 108px;
    height: 4px;
    transform: translateX(-50%);
    border: 1px solid rgba(255,255,255,.11);
    border-bottom: 0;
    border-radius: 4px 4px 0 0;
    background: #151923;
  }

  /* Remove internal build copy and ornamental prose from the primary view. */
  body.pf-mobile-first #pokefield-live-panel .pf-head {
    margin-bottom: 4px !important;
    min-height: 20px;
    gap: 8px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-brand strong {
    font-size: 0 !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-brand strong::after {
    content: "JRPG.WORLD / EMERALD";
    font-size: 12px;
    letter-spacing: .085em;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-head span {
    margin-left: 7px !important;
    font-size: 7px !important;
    padding: 2px 5px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-head small {
    display: none !important;
  }

  /* A healthy connection needs no sentence-length status bar. Errors still show. */
  body.pf-mobile-first #pokefield-live-panel .pf-status.ok {
    display: none !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-status:not(.ok) {
    margin: 4px 0 5px !important;
    padding: 5px 7px !important;
    font-size: 9.5px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-kicker {
    display: none !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-explainer,
  body.pf-mobile-first #pf-desktop-about {
    display: none !important;
  }

  body.pf-mobile-first #pokefield-live-panel #pf-owned-drawer.pf-desktop-empty {
    display: none !important;
  }

  /* Signature moment: identity + all six IVs are visible on the same first row. */
  body.pf-mobile-first #pokefield-live-panel .pf-primary:not(:empty) {
    display: block !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-card {
    display: grid !important;
    grid-template-columns: minmax(235px, .9fr) minmax(0, 1.65fr) !important;
    grid-template-areas:
      "identity ivs"
      "hidden evs"
      "detail detail" !important;
    align-items: center !important;
    column-gap: 10px !important;
    row-gap: 5px !important;
    margin: 3px 0 0 !important;
    padding: 7px 9px !important;
    border-radius: 12px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-title {
    grid-area: identity !important;
    min-width: 0;
    gap: 7px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-sprite {
    width: 42px !important;
    height: 42px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-name {
    font-size: 16px !important;
    line-height: 1.05 !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-sub {
    margin-top: 2px !important;
    font-size: 9.5px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-breed-note {
    margin-top: 3px !important;
    padding: 2px 5px !important;
    font-size: 7px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-signal {
    padding: 3px 6px !important;
    font-size: 8px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-grid {
    grid-area: ivs !important;
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 3px !important;
    margin: 0 !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-stat {
    min-width: 0;
    padding: 5px 2px !important;
    text-align: center !important;
    border-radius: 7px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-stat em {
    display: block;
    font-size: 7px !important;
    letter-spacing: 0 !important;
    white-space: nowrap;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-stat b {
    margin-top: 1px;
    font-size: 15px !important;
    line-height: 1 !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-hp {
    grid-area: hidden !important;
    display: flex !important;
    justify-content: space-between !important;
    gap: 7px !important;
    margin: 0 !important;
    padding: 5px 7px !important;
    font-size: 9.5px !important;
    border-radius: 7px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-ev-quick {
    grid-area: evs !important;
    margin: 0 !important;
    padding: 5px 7px !important;
    min-width: 0;
    border-radius: 7px;
    background: rgba(255,255,255,.035);
    font-size: 9px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-detail {
    grid-area: detail !important;
    margin-top: 0 !important;
    padding-top: 3px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-detail summary {
    padding: 2px 0 !important;
    font-size: 8px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-drawer {
    margin-top: 5px !important;
  }

  body.pf-mobile-first #pokefield-live-panel .pf-drawer > summary {
    padding: 5px 2px 3px !important;
    font-size: 9px !important;
  }

  /* Idle: one neutral line, no product-explainer blocks. */
  .pf-desktop-only {
    display: block;
  }

  .pf-desktop-idle {
    margin: 4px 1px 1px;
    padding: 7px 8px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 8px;
    background: rgba(255,255,255,.025);
    color: #8f99aa;
    font-size: 9.5px;
  }

  .pf-desktop-idle[hidden] {
    display: none !important;
  }

  .pf-desktop-idle strong {
    color: #c9d2df;
    font-size: 9px;
    letter-spacing: .08em;
  }

  /* Third priority. Keep mappings visible but quiet. */
  .pf-desktop-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    flex: 0 0 auto;
    width: min(900px, calc(100% - 2rem));
    margin: .4rem auto 0;
    padding: 6px 8px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 9px;
    background: rgba(8,10,14,.88);
    font-family: Outfit, Inter, system-ui, sans-serif;
  }

  .pf-desktop-controls-title {
    margin-right: 1px;
    color: #626c7b;
    font-size: 7px;
    font-weight: 800;
    letter-spacing: .14em;
  }

  .pf-desktop-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .pf-desktop-control kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 20px;
    padding: 2px 5px;
    border: 1px solid #424858;
    border-bottom-width: 2px;
    border-radius: 4px;
    background: linear-gradient(#2b2f3c,#222631);
    color: #dfffe9;
    font: 800 9px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  }

  .pf-desktop-control span {
    color: #768091;
    font-size: 7px;
    font-weight: 700;
    letter-spacing: .045em;
    white-space: nowrap;
  }

  /* Short laptop screens: reserve enough room for the live answer itself. */
  @media (max-height: 820px) {
    body.pf-mobile-first .main-content {
      padding-top: .25rem !important;
    }

    body.pf-mobile-first .emulator-layout.only-keyboard.game-playing {
      width: min(820px, 100%) !important;
      max-width: min(820px, calc((100dvh - 205px) * 1.5)) !important;
    }

    body.pf-mobile-first .emulator-layout.only-keyboard .screen-bezel {
      padding: .48rem .58rem !important;
    }

    body.pf-mobile-first #pokefield-live-panel {
      width: min(820px, calc(100% - 2rem)) !important;
      max-width: 820px !important;
      margin-top: .48rem !important;
      padding-top: 7px !important;
      padding-bottom: 8px !important;
    }

    .pf-desktop-controls {
      width: min(820px, calc(100% - 2rem));
      margin-top: .3rem;
      padding-top: 5px;
      padding-bottom: 5px;
    }
  }
}

@media (max-width: 959px) {
  .pf-desktop-only,
  .pf-desktop-controls {
    display: none !important;
  }
}
