/* Phone Fretboard — neck-first, width-correct, embed-aware */

.fb-mbar,
.fb-mdock,
.fb-msheet,
.fb-msheet-backdrop,
.fb-rotate-hint,
.fb-neck-scrub,
.fb-find-bar {
  display: none !important;
}

body.fb-find-chord #btn-find-chord,
body.fb-find-chord #fb-m-find,
html.fb-embed body.fb-find-chord {
  /* find active styling via JS class on buttons */
}

@media (max-width: 760px), ((max-width: 980px) and (pointer: coarse)) {
  :root {
    --fb-safe-top: env(safe-area-inset-top, 0px);
    --fb-safe-bottom: env(safe-area-inset-bottom, 0px);
    --fb-safe-left: env(safe-area-inset-left, 0px);
    --fb-safe-right: env(safe-area-inset-right, 0px);
    --fb-dock-h: 3.7rem;
    --fb-bar-h: 2.85rem;
    --fb-chip-h: 6.1rem;
  }

  html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    background: #080706 !important;
  }
  body.fb-mobile-ui {
    padding: 0 !important;
    margin: 0 !important;
    padding-bottom: calc(var(--fb-dock-h) + var(--fb-chip-h) + var(--fb-safe-bottom) + 0.35rem) !important;
  }
  /* Inside Song Builder app: host owns top chrome */
  html.fb-embed body.fb-mobile-ui {
    padding-top: 0 !important;
  }
  html.fb-embed .fb-mbar {
    display: none !important;
  }
  html.fb-embed .fb-rotate-hint {
    display: none !important;
  }

  .fb-mbar {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 40;
    align-items: center;
    gap: 0.35rem;
    min-height: var(--fb-bar-h);
    padding: 0.3rem 0.5rem;
    margin: 0;
    background: rgba(12, 10, 8, 0.96);
    border-bottom: 1px solid rgba(196,165,116,0.25);
  }
  .fb-mbar .brand { font-weight: 700; font-size: 0.85rem; color: #e8c98a; }
  .fb-mbar button {
    min-height: 40px;
    padding: 0.35rem 0.65rem;
    border-radius: 11px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06);
    color: #ebe4d8;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 650;
  }
  .fb-mbar .grow { margin-left: auto; }
  body.fb-find-chord .fb-mbar #fb-m-find {
    background: rgba(251,191,36,0.22);
    border-color: #fbbf24;
    color: #fde68a;
  }

  body > nav,
  .app-header,
  .app-footer,
  .side-panel,
  #help-panel,
  .help-panel,
  #coach-bar,
  .coach-bar,
  #board-legend,
  .board-legend,
  #path-controls,
  .path-controls,
  .focus-transport,
  #fb-tour {
    display: none !important;
  }

  .app-shell {
    padding: 0.25rem 0.45rem 0.35rem !important;
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
  .main-grid,
  .app-shell > .grid,
  .grid.lg\:grid-cols-12 {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.35rem !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  .center-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .fb-rotate-hint {
    display: none !important; /* scrubber is enough */
  }

  .fretboard-container {
    order: -1;
    contain: paint;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    border-radius: 14px;
    border: 1px solid rgba(196,165,116,0.22);
    background: #0c0a08;
    padding: 0.2rem 0.1rem;
    margin: 0 !important;
  }
  #fretboard {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    touch-action: manipulation;
  }
  .card-panel:has(.fretboard-container),
  .card-panel:has(#fretboard) {
    order: -1;
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }
  .card-panel:has(.fretboard-container) > :not(.fretboard-container):not(.fb-neck-scrub):not(.fb-find-bar) {
    display: none !important;
  }

  .fb-neck-scrub {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.15rem 0.1rem;
    width: 100%;
    box-sizing: border-box;
  }
  .fb-neck-scrub label {
    font-size: 0.68rem;
    color: #95897a;
    white-space: nowrap;
    min-width: 4.4rem;
  }
  .fb-neck-scrub input[type=range] {
    flex: 1;
    min-height: 40px;
    max-width: 100%;
    accent-color: #c4a574;
  }

  .fb-find-bar {
    display: none;
    padding: 0.4rem 0.5rem;
    margin: 0.2rem 0;
    border-radius: 12px;
    background: rgba(251,191,36,0.08);
    border: 1px solid rgba(251,191,36,0.35);
  }
  body.fb-find-chord .fb-find-bar { display: block !important; }
  .fb-find-bar .guess { font-size: 1.05rem; font-weight: 700; color: #fde68a; margin-bottom: 0.2rem; }
  .fb-find-bar .alts { font-size: 0.72rem; color: #c4b5a0; margin-bottom: 0.35rem; min-height: 1em; }
  .fb-find-bar .row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
  .fb-find-bar button {
    min-height: 44px; padding: 0.4rem 0.7rem; border-radius: 11px;
    border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.07);
    color: #ebe4d8; font: inherit; font-size: 0.8rem; font-weight: 650;
  }
  .fb-find-bar button.primary {
    background: linear-gradient(180deg, #fbbf24, #d97706); color: #1a1208; border: 0; flex: 1;
  }

  /* Progression chip strip — sticky just above Play dock */
  .progression-panel {
    order: 5;
    position: fixed !important;
    left: var(--fb-safe-left);
    right: var(--fb-safe-right);
    bottom: calc(var(--fb-dock-h) + var(--fb-safe-bottom));
    z-index: 45;
    margin: 0 !important;
    background: rgba(12, 10, 8, 0.97) !important;
    border: 0 !important;
    border-top: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 0 !important;
    padding: 0.35rem 0.45rem 0.3rem !important;
    box-shadow: 0 -6px 18px rgba(0,0,0,0.35) !important;
    max-height: var(--fb-chip-h);
    overflow: hidden !important;
  }
  .progression-panel > .flex.flex-wrap.items-center.justify-between,
  .progression-panel .tele-bar,
  .progression-panel #tele-bar,
  .progression-panel .section-header,
  .progression-panel .flex.flex-wrap.gap-1 {
    display: none !important;
  }
  #progression-slots, .tp-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.4rem;
    padding: 0.1rem 0;
    margin: 0 !important;
  }
  #progression-slots > * {
    flex: 0 0 auto !important;
    min-width: 5.6rem !important;
    max-width: 7rem;
    min-height: 3.6rem !important;
    max-height: 4.4rem;
    overflow: hidden !important;
    border-radius: 12px !important;
    padding: 0.4rem 0.5rem !important;
  }
  #progression-slots > * * {
    font-size: 0.72rem !important;
    line-height: 1.15 !important;
  }
  #progression-slots select,
  #progression-slots input,
  #progression-slots button,
  #progression-slots .fa-eye,
  #progression-slots [onclick*="cycleSlotEye"],
  #progression-slots [onclick*="removeSlot"],
  #progression-slots label {
    display: none !important;
  }

  .fb-mdock {
    display: flex !important;
    position: fixed;
    left: var(--fb-safe-left);
    right: var(--fb-safe-right);
    bottom: var(--fb-safe-bottom);
    z-index: 50;
    align-items: center;
    gap: 0.35rem;
    min-height: var(--fb-dock-h);
    padding: 0.35rem 0.55rem;
    background: rgba(10, 8, 6, 0.98);
    border-top: 1px solid rgba(248, 113, 113, 0.35);
  }
  .fb-mdock button {
    min-height: 48px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.07);
    color: #ebe4d8; font: inherit; font-weight: 700; font-size: 0.88rem;
  }
  .fb-mdock .step-btn { flex: 0.7; }
  .fb-mdock .play-big {
    flex: 1.4; background: linear-gradient(180deg, #f87171, #dc2626); color: #fff; border: 0;
  }

  .fb-msheet-backdrop {
    display: none; position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.55);
  }
  body.fb-more-open .fb-msheet-backdrop { display: block !important; }
  .fb-msheet {
    display: none; position: fixed;
    left: var(--fb-safe-left); right: var(--fb-safe-right); bottom: 0; z-index: 70;
    max-height: min(78vh, 36rem); overflow: auto; -webkit-overflow-scrolling: touch;
    background: #1a1612; border-radius: 16px 16px 0 0;
    border: 1px solid rgba(255,255,255,0.1); border-bottom: 0;
    padding: 0.85rem 0.9rem calc(1.1rem + var(--fb-safe-bottom));
  }
  body.fb-more-open .fb-msheet { display: block !important; }
  .fb-msheet h3 { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 700; color: #e8c98a; }
  .fb-msheet .hint { font-size: 0.78rem; opacity: 0.75; margin: 0 0 0.55rem; }
  .fb-msheet .row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.65rem; }
  .fb-msheet button {
    min-height: 44px; padding: 0.5rem 0.75rem; border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.06);
    color: inherit; font: inherit; font-size: 0.8rem; font-weight: 600;
  }
  .fb-msheet .share-out {
    width: 100%; min-height: 4rem; font-size: 0.7rem; border-radius: 8px; padding: 0.45rem;
    background: #0c0a08; color: inherit; border: 1px solid rgba(255,255,255,0.12);
  }
}

@media ((max-width: 980px) and (pointer: coarse) and (orientation: landscape)) {
  :root { --fb-dock-h: 3.2rem; --fb-chip-h: 3.8rem; }
}
