/* Página de jogos — shell integrado; só a grade rola */

body.page-games-browse {
  --browse-cols: 3;
  --browse-grid-gap: 0.45rem;
  --browse-provider-w: 5.775rem;
  --browse-provider-h: 4.004rem;
  --browse-provider-gap: 0.77rem;
  --browse-sidebar-w: calc(var(--browse-provider-w) + 0.45rem);
  --browse-bg: var(--bg-deep);
  --browse-inset: var(--bg-void);
  --browse-header-bg: var(--bg-surface);
  --browse-chip-bg: var(--bg-elevated);
  --browse-gold: var(--accent-gold);
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-primary);
}

body.page-games-browse .app-shell {
  height: 100dvh;
  overflow: hidden;
  background: var(--browse-bg);
}

body.page-games-browse .app-main.games-browse {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 0 0 var(--safe-bottom);
  overflow: hidden;
  background: var(--browse-bg);
}

.games-browse__page-title,
.games-browse__page-subtitle,
.games-browse__provider-bar {
  display: none;
}

.games-browse__toolbar--mobile {
  display: grid;
}

/* —— Painel superior unificado —— */
.games-browse__controls {
  flex-shrink: 0;
  background: var(--browse-bg);
}

.games-browse__controls-inner {
  display: flex;
  flex-direction: column;
  padding-bottom: 0.55rem;
}

.games-browse__toolbar {
  display: grid;
  grid-template-columns: 2.25rem 1fr 2.25rem;
  align-items: center;
  min-height: 2.25rem;
  padding: calc(0.5rem + var(--safe-top)) var(--container-pad) 0.5rem;
  background: var(--browse-header-bg);
}

.games-browse__search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.55rem var(--container-pad) 0.45rem;
}

.games-browse__search input {
  width: 100%;
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(209, 165, 78, 0.42);
  background: var(--browse-chip-bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

.games-browse__search input::placeholder {
  color: var(--text-muted);
}

.games-browse__search input:focus {
  outline: none;
  border-color: var(--browse-gold);
}

.games-browse__search-btn {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(209, 165, 78, 0.42);
  background: var(--browse-chip-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

.games-browse__search-btn:hover {
  color: var(--text-primary);
}

/* —— Corpo centralizado —— */
.games-browse__frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.games-browse__stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--browse-sidebar-w) minmax(0, 1fr);
  overflow: hidden;
  background: var(--browse-bg);
}

.games-browse__sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--browse-provider-gap);
  padding: 0.55rem 0.22rem;
  background: var(--browse-bg);
  overflow-y: auto;
  scrollbar-width: thin;
}

.games-browse__provider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: var(--browse-provider-w);
  min-height: var(--browse-provider-h);
  padding: 0.35rem 0.3rem 0.3rem;
  border-radius: var(--radius-sm);
  background: var(--browse-chip-bg);
  text-decoration: none;
  color: var(--browse-gold);
  flex-shrink: 0;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.games-browse__provider:hover:not(.is-active) {
  background: color-mix(in srgb, var(--browse-chip-bg) 88%, var(--browse-gold));
}

.games-browse__provider.is-active {
  background: var(--accent-gold);
  color: var(--bg-void);
}

.games-browse__provider-box {
  display: grid;
  place-items: center;
  width: 100%;
  height: auto;
  min-height: 1.65rem;
  padding: 0;
  border: none;
  background: transparent;
}

.games-browse__provider.is-active .games-browse__provider-box {
  background: transparent;
}

.games-browse__provider-box img {
  display: block;
  width: auto;
  height: auto;
  max-width: 2.1rem;
  max-height: 1.35rem;
  object-fit: contain;
}

.games-browse__provider-fallback {
  font-size: 0.72rem;
  font-weight: 800;
  color: inherit;
  letter-spacing: 0.02em;
}

.games-browse__provider-name {
  max-width: 100%;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.games-browse__provider.is-active .games-browse__provider-name {
  color: inherit;
}

.games-browse__back {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast);
}

.games-browse__back--desktop {
  display: none;
}

.games-browse__back:hover {
  color: var(--text-primary);
}

.games-browse__provider-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.35rem;
  padding: 0.3rem 0.85rem 0.3rem 0.35rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(209, 165, 78, 0.28);
  background: var(--browse-chip-bg);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition:
    background var(--duration-fast),
    color var(--duration-fast),
    border-color var(--duration-fast);
}

.games-browse__provider-chip:hover {
  border-color: rgba(209, 165, 78, 0.45);
}

.games-browse__provider-chip.is-active {
  color: var(--bg-void);
  background: var(--accent-gold);
  border-color: var(--accent-gold);
}

.games-browse__provider-chip-logo {
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 0.4rem;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
  flex-shrink: 0;
}

.games-browse__provider-chip.is-active .games-browse__provider-chip-logo {
  background: rgba(0, 0, 0, 0.18);
}

.games-browse__provider-chip-logo img {
  display: block;
  width: auto;
  height: auto;
  max-width: 1.35rem;
  max-height: 1.1rem;
  object-fit: contain;
}

.games-browse__provider-chip-fallback {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.games-browse__provider-chip-name {
  max-width: 8.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.games-browse__title {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.games-browse__toolbar-spacer {
  width: 2.25rem;
}

/* —— Área rolável de jogos —— */
.games-browse__viewport {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem var(--container-pad) 0.65rem;
  background: var(--browse-bg);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.games-browse__empty {
  display: grid;
  place-items: center;
  min-height: 8rem;
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.games-browse__grid {
  display: grid;
  grid-template-columns: repeat(var(--browse-cols), minmax(0, 1fr));
  gap: var(--browse-grid-gap);
}

.games-browse__grid .game-tile--browse .game-tile__hit {
  display: flex;
  flex-direction: column;
  border: none;
  background: transparent;
  padding: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.games-browse__grid .game-tile--browse .game-tile__thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  overflow: hidden;
  background: var(--bg-elevated);
}

.games-browse__grid .game-tile--browse .game-tile__thumb img {
  object-fit: cover;
}

.games-browse__grid .game-tile--browse .game-tile__fav {
  position: absolute;
  top: 0.22rem;
  right: 0.22rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}

.games-browse__grid .game-tile--browse .game-tile__info--browse {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  width: 100%;
  padding: 0.42rem 0.35rem 0.48rem;
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-align: center;
}

.games-browse__grid .game-tile--browse .game-tile__name {
  margin: 0;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.games-browse__grid .game-tile--browse .game-tile__provider {
  margin: 0;
  color: var(--accent-primary);
  font-size: 0.52rem;
  font-weight: 600;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.games-browse__grid .game-tile--browse .game-tile__play {
  background: var(--accent-primary);
  color: var(--bg-void);
}

/* —— Rodapé fixo (paginação) —— */
.games-browse__footer {
  flex-shrink: 0;
  background: var(--browse-bg);
  border-top: none;
}

.games-browse__footer-layout {
  display: grid;
  grid-template-columns: var(--browse-sidebar-w) minmax(0, 1fr);
}

.games-browse__footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 1.85rem;
  padding: 0.5rem var(--container-pad) 0.55rem;
}

.games-browse__pager {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.games-browse__pager::-webkit-scrollbar {
  display: none;
}

.games-browse__pager-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 1.65rem;
  height: 1.65rem;
  padding: 0 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--browse-chip-bg);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
}

.games-browse__pager-btn--nav {
  min-width: 1.75rem;
  font-size: 0.85rem;
  line-height: 1;
}

.games-browse__pager-btn:hover:not(.is-disabled):not(.is-active) {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.14);
}

.games-browse__pager-btn.is-active {
  color: var(--bg-void);
  background: var(--accent-gold);
  border-color: var(--accent-gold);
}

.games-browse__pager-btn.is-disabled {
  opacity: 0.28;
  pointer-events: none;
}

@media (min-width: 768px) {
  body.page-games-browse {
    --browse-cols: 6;
    --browse-grid-gap: 0.65rem;
    --browse-provider-w: 5.25rem;
    --browse-provider-h: 3.5rem;
    --browse-provider-gap: 0.55rem;
    --browse-sidebar-w: 5.5rem;
    --browse-bg: var(--bg-deep);
    --browse-header-bg: transparent;
    --browse-chip-bg: var(--bg-surface);
  }

  .games-browse__controls-inner,
  .games-browse__frame {
    max-width: none;
    margin-inline: 0;
    width: 100%;
    padding-inline: 0;
  }

  .games-browse__frame {
    flex: 1;
    min-height: 0;
  }

  .games-browse__page-title {
    display: block;
    margin: 0 0 0.25rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
  }

  .games-browse__provider-bar {
    display: flex;
  }

  .games-browse__toolbar--mobile {
    display: none;
  }

  .games-browse__search {
    max-width: 28rem;
    margin-inline: 0;
    width: 100%;
    padding-inline: 0;
    padding-top: 0;
    padding-bottom: 0.75rem;
  }

  .games-browse__search input,
  .games-browse__search-btn {
    height: 2.65rem;
  }

  .games-browse__search-btn {
    width: 2.65rem;
  }

  .games-browse__stage {
    grid-template-columns: var(--browse-sidebar-w) minmax(0, 1fr);
    gap: 1.5rem;
    padding-top: 0.25rem;
  }

  .games-browse__sidebar {
    padding: 0;
    align-items: stretch;
    background: transparent;
  }

  .games-browse__provider {
    width: 100%;
    min-height: var(--browse-provider-h);
    padding: 0.45rem 0.4rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
  }

  .games-browse__provider.is-active {
    border-color: var(--accent-gold);
  }

  .games-browse__provider-box img {
    max-width: 2rem;
    max-height: 1.25rem;
  }

  .games-browse__provider-name {
    font-size: 0.62rem;
  }

  .games-browse__viewport {
    padding: 0 0 1rem;
  }

  .games-browse__grid {
    grid-template-columns: repeat(auto-fill, minmax(6.25rem, 1fr));
    gap: var(--browse-grid-gap);
    justify-content: start;
  }

  .games-browse__grid .game-tile--browse {
    width: 100%;
  }

  .games-browse__grid .game-tile--browse .game-tile__thumb {
    aspect-ratio: 3 / 4;
    width: 100%;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .games-browse__grid .game-tile--browse .game-tile__info--browse {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    padding: 0.48rem 0.4rem 0.52rem;
  }

  .games-browse__grid .game-tile--browse .game-tile__name {
    font-size: 0.64rem;
  }

  .games-browse__grid .game-tile--browse .game-tile__provider {
    font-size: 0.58rem;
  }

  .games-browse__footer-layout {
    grid-template-columns: var(--browse-sidebar-w) minmax(0, 1fr);
    gap: 1.5rem;
  }

  .games-browse__footer-inner {
    padding-inline: 0;
    padding-bottom: 0.75rem;
    min-height: 2rem;
  }

  .games-browse__pager-btn {
    min-width: 1.75rem;
    height: 1.75rem;
    font-size: 0.74rem;
  }
}
