@media (max-width: 900px) {
  
  
  
  /* Filter sheet behaves like a full-width bottom drawer on mobile */
  #tb-overlay {
    z-index: 9998;
  }

  #tb-sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: 32px 32px 0 0;
    transform: translateY(110%);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: transform 220ms ease, opacity 180ms ease;
  }

  #tb-sheet.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* Keep the page locked to the viewport width */
  html,
  body,
  .tournament-page {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Each step owns the full viewport height */
  .tb-step {
    min-height: 100vh;
    width: 100%;
    padding: 50px 14px;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    
  }
  #step-1.tb-step{
    align-items: start;
    padding-top: 12px;
  }
  .tb-step-inner {
    width: 100%;
    max-width: 960px;
    min-height: 100%;
    padding-top: 100px;
    justify-content: start;
    box-sizing: border-box;
  }

  .tb-step-inner:first-child{
    padding-top: 32px;
  }

  /* Step 1: base options stay side-by-side (2 columns) */
  .tb-base-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
  }

  /* Step 2: size grid = 3 columns x 2 rows */
  .tb-size-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 90px;
    gap: 12px;
    width: 100%;
    margin-top: 32px;
  }

  /* Step 3 layout */
  .tb-builder {
    display: grid;
    grid-template-columns: 1fr;
    gap: 88px;
    width: 100%;
  }

  .tb-top-controls {
    grid-template-columns: 1fr;
    gap: 10px;
    box-sizing: border-box;
    margin-bottom: 32px;
  }

  /* Preview panel smaller to fit the screen */
  .tb-right,
  .tb-preview-panel {
    width: 100%;
  }

  .tb-preview-frame {
    aspect-ratio: 3 / 4;
    max-width: 320px;
    width: 85%;
    margin: 0 auto;
    margin-top: 32px;
  }


  /* Sticker grid scroll container: fixed to viewport width, horizontal scroll only */
  .tb-grid-scroll {
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 12px;
    border-radius: 6px;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Sticker grid: 3 columns x 2 rows per “page”, grows horizontally */
  .tb-grid {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(3, auto);
    grid-auto-columns: 94px;
    gap: 8px;
    min-height: 200px;
    width: max-content;
    min-width: 100%;
    align-items: start;
  }

  /* Keep cards a consistent, smaller size */
  .tb-sticker-card {
    width: 94px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .tb-sticker-card img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
  }

  .tb-sticker-meta {
    display: none;
  }

  .tb-sticker-team {
    font-family: Inter, system-ui, sans-serif;
    text-align: left;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 500;
  }

  .tb-sticker-event {
    display: none;
  }

  /* Scrollbar styling for horizontal progress */
  .tb-grid-scroll::-webkit-scrollbar {
    height: 8px;
  }

  .tb-grid-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
  }

  .tb-grid-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 4px;
  }



}


@media (max-width: 900px) {
  /* Step 3: stop grid children from forcing the container wider */
  #step-3 .tb-builder {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* IMPORTANT: allow grid items to shrink (prevents width inflation) */
  #step-3 .tb-left,
  #step-3 .tb-right {
    min-width: 0;
  }

  /* Make the top controls respect the container width (fixes "cut off" search bar) */
  #step-3 .tb-top-controls {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #step-3 .tb-search {
    width: 100%;
    min-width: 0;
  }

  #step-3 .tb-search input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Keep the horizontal scrolling ONLY on the sticker panel */
  #step-3 .tb-grid-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  /* Keep your horizontal "pages" behaviour */
  #step-3 .tb-grid {
    width: max-content;
  }

  /* Sheet header drag affordance */
  .tb-sheet-header{
    cursor: grab;
    touch-action: none;
    height: 50px;
  }
  .tb-sheet-header:active{
    cursor: grabbing;
  }

  /* Match cart drawer visual language */
  #tb-sheet{
   box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  background: #2d2b24;
    border-radius: 10px 10px 0 0;
  }

  #tb-sheet .tb-sheet-header{
    padding: 0 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    border-bottom: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.18);
  }

  #tb-sheet .tb-sheet-body{
    max-height: calc(80vh - 56px);
    overflow-y: auto;
  }

  #tb-sheet .tb-sheet-option{
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  /* Floating reorder bar (overlay) */
  .tb-reorder-floating-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 12px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    padding: 10px 14px;
    box-sizing: border-box;
    z-index: 1200;
    background: rgba(45, 43, 36, 0.95);
    backdrop-filter: blur(4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 200ms ease, opacity 200ms ease;
  }

  .tb-step-3{
    margin-bottom: 0px;
  }

  .tb-reorder-floating-container.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* Prevent overlap with floating bar */
  .tb-reorder-floating-pad {
    padding-bottom: 120px;
  }

  .tb-reorder-sentinel {
    width: 100%;
    height: 1px;
  }
}
