*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: #0f1024;
  color: #f5f7ff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  background: linear-gradient(140deg, #2b2170 0%, #1a1a48 45%, #0f1024 100%);
  background-attachment: fixed;
  padding: 72px 20px 80px;
}

/* Fundo com padrão repetido de objetos de jogo. Camada separada para
 * baixar a opacidade sem apagar o gradiente base. Usamos uma camada maior
 * que a viewport + transform (acelerado por GPU) em vez de animar
 * background-position (que roda na CPU e trepida). */
body::before {
  content: "";
  position: fixed;
  top: -200px;
  left: -200px;
  right: -200px;
  bottom: -200px;
  background-image: url("pattern.svg");
  background-repeat: repeat;
  background-size: 200px 200px;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
  animation: pattern-drift 40s linear infinite;
}

/* Vinheta suave sobre o padrão para dar profundidade e melhorar contraste. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(15, 16, 36, 0.55) 100%);
  pointer-events: none;
  z-index: 0;
}

.hub {
  position: relative;
  z-index: 1;
}

@keyframes pattern-drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(200px, 200px, 0);
  }
}

/* Respeita a preferência do sistema por menos animações — em mobile, também
 * um sinal indireto de bateria baixa (iOS ativa Reduce Motion no Low Power
 * Mode se o usuário configurou). Zera o único loop infinito da página. */
@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.hub {
  max-width: 1100px;
  margin: 0 auto;
}

.hub-header {
  text-align: center;
  margin-bottom: 56px;
  padding-top: 8px;
}

.hub-header h1 {
  font-family: "Fredoka", "Baloo 2", "Poppins", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(3rem, 9vw, 6rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(
    100deg,
    #ff6bd6 0%,
    #ffd93d 30%,
    #4ade80 55%,
    #3ec1ff 80%,
    #a06bff 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* text-shadow em vez de filter: drop-shadow — igualmente bonito e sem
   * recomputo por frame (evita reflow do glifo mascarado pelo gradiente). */
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  transform: rotate(-2deg);
  display: inline-block;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 20px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  outline: none;
}

.game-card__icon {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.game-card__name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.game-card__desc {
  font-size: 0.85rem;
  color: rgba(245, 247, 255, 0.65);
  line-height: 1.4;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: rgba(245, 247, 255, 0.5);
}

/* Language toggle — portado do jogo Blip Hue para manter identidade visual. */
.lang-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
}

.lang-toggle-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 30, 58, 0.75);
  color: #f5f7ff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  transition: filter 100ms ease, transform 100ms ease;
}

.lang-toggle-btn:hover {
  filter: brightness(1.15);
}

.lang-toggle-btn:active {
  transform: scale(0.94);
}

.lang-toggle-flag {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
    "Twemoji Mozilla", emoji, sans-serif;
  font-size: 22px;
  line-height: 1;
}

.lang-toggle-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  margin: 0;
  border-radius: 14px;
  background: rgba(26, 30, 58, 0.95);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: lang-pop 180ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

/* Necessário porque `display: flex` acima sobrescreve o `display: none`
 * padrão do atributo `hidden`, deixando o menu sempre visível. */
.lang-toggle-menu[hidden] {
  display: none;
}

@keyframes lang-pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.lang-toggle-option {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  cursor: pointer;
  transition: background-color 100ms ease, transform 100ms ease;
}

.lang-toggle-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.lang-toggle-option.active {
  background: rgba(255, 217, 61, 0.22);
  box-shadow: inset 0 0 0 1.5px rgba(255, 217, 61, 0.55);
}

.lang-toggle-option .lang-toggle-flag {
  font-size: 22px;
}
