@import url("https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700&display=swap");

/* =========================================
   1. VARIÁVEIS E BASE
   ========================================= */
:root {
  --bg-color: #2d3436;
  --card-bg: #ffffff;
  --primary: #6c5ce7; /* Roxo */
  --accent: #fdcb6e; /* Amarelo */
  --danger: #ff7675; /* Vermelho */
  --success: #00b894; /* Verde */
  --text-dark: #2d3436;
  --border: 3px solid #000;
  --shadow: 5px 5px 0px #000;
}

body {
  background-color: var(--bg-color);
  font-family: "Nunito", sans-serif;
  margin: 0;
  padding: 0;
  color: var(--text-dark);
}

/* =========================================
   2. COMPONENTES (Cards, Botões, Inputs)
   ========================================= */

/* Cards */
.game-card {
  background: var(--card-bg);
  border: var(--border);
  box-shadow: var(--shadow);
  border-radius: 15px;
  overflow: hidden;
  transition: transform 0.2s;
  position: relative;
  width: 100%;
  max-width: 350px;
}

.game-card:hover {
  transform: translateY(-5px);
}

.card-header {
  background-color: var(--primary);
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: var(--border);
  position: relative;
  color: white;
}

.card-body {
  padding: 20px;
  text-align: center;
}

.game-title {
  font-family: "Fredoka One", cursive;
  font-size: 1.5rem;
  margin-bottom: 5px;
  color: var(--text-dark);
}

.game-desc {
  font-size: 0.9rem;
  color: #636e72;
  margin-bottom: 20px;
}

/* Badges */
.live-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: var(--danger);
  color: #fff;
  padding: 5px 10px;
  border: 2px solid #000;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.8rem;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.points-badge {
  background-color: var(--accent);
  color: #000;
  padding: 5px 15px;
  border-radius: 20px;
  border: 2px solid #000;
  font-size: 0.9rem;
}

/* Botões */
.btn-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  border: 2px solid #000;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  font-family: "Fredoka One", cursive;
  text-decoration: none;
  display: block;
  color: #000;
  transition: all 0.1s;
  text-align: center;
  font-size: 1rem;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: none !important;
}
.btn-solo {
  background-color: var(--accent);
  box-shadow: 3px 3px 0 #000;
}
.btn-multi {
  background-color: var(--success);
  box-shadow: 3px 3px 0 #000;
}
.btn-google {
  background-color: #fff;
  box-shadow: 3px 3px 0 #000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Botão Rank */
.btn-rank {
  background-color: #f1c40f;
  color: #000;
  border: 2px solid #000;
  padding: 10px 20px;
  border-radius: 50px;
  font-family: "Fredoka One", cursive;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 3px 3px 0 #000;
  transition: transform 0.1s;
}
.btn-rank:hover {
  transform: scale(1.05);
  background-color: #f39c12;
}
.btn-rank:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* Inputs */
input,
select {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 2px solid #000;
  border-radius: 8px;
  font-family: "Nunito", sans-serif;
  font-size: 1rem;
  box-sizing: border-box;
  background-color: #f1f2f6;
}
input:focus {
  background-color: #fff;
  outline: none;
  border-color: var(--primary);
}

/* Avatar */
.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 2px 2px 0 #000;
  object-fit: cover;
  display: block;
}

/* Games Grid */
.games-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  justify-content: center;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}
.games-grid .game-card {
  width: 300px;
}

/* Notificações */
.notification-box {
  position: relative;
  cursor: pointer;
  margin-right: 15px;
}
.bell-icon {
  font-size: 1.5rem;
  transition: transform 0.2s;
}
.bell-icon:hover {
  transform: rotate(15deg);
}
.badge-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid #fff;
  font-weight: bold;
}
.notif-dropdown {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  width: 300px;
  background: #fff;
  border: var(--border);
  box-shadow: var(--shadow);
  border-radius: 10px;
  z-index: 1000;
  padding: 10px;
  color: var(--text-dark);
}
.notif-item {
  font-size: 0.9rem;
  padding: 10px;
  border-bottom: 1px dashed #ccc;
  text-align: left;
}
.notif-item:last-child {
  border-bottom: none;
}

/* Histórico */
.history-feed {
  max-width: 800px;
  margin: 40px auto;
  background: #dfe6e9;
  border: var(--border);
  border-radius: 15px;
  padding: 20px;
}
.history-title {
  font-family: "Fredoka One";
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-dark);
}
.history-item {
  background: #fff;
  padding: 10px 15px;
  margin-bottom: 10px;
  border-radius: 8px;
  border-left: 5px solid var(--primary);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

/* =========================================
   3. CABEÇALHO (ESTILO PADRÃO / DESKTOP)
   ========================================= */

/* --- CABEÇALHO (Layout Desktop Padrão) --- */
.dashboard-header {
  background-color: var(--primary);
  padding: 10px 30px;
  border-bottom: var(--border);
  display: flex;
  align-items: center; /* Centraliza verticalmente */
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  box-sizing: border-box;
}
/* Logo empurra o resto para a direita */
.logo {
  margin-right: auto;
}
.logo h2 {
  margin: 0;
  text-shadow: 2px 2px 0 #000;
  text-align: left;
}

/* Container do Avatar e Nome (Lado Direito) */
.user-basic-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Logo */
.logo h2 {
  margin: 0;
  text-align: left;
}

/* O Hambúrguer começa invisível no Desktop */
.hamburger {
  display: none;
}

/* O Menu de Links (Ranking, Sino, Sair) no Desktop */
.header-items {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-right: 20px;
}

/* =========================================
   4. RESPONSIVIDADE (TABLET E CELULAR)
   ========================================= */

@media (max-width: 1024px) {
  /* Ajustes Gerais de Layout */
  .game-arena,
  .rank-container,
  .profile-container,
  .inbox-container {
    width: 95% !important;
    max-width: 100% !important;
    margin: 10px auto;
    padding: 15px;
  }
  .profile-container {
    flex-direction: column;
  }
  .games-grid {
    gap: 20px;
  }
  .game-card {
    width: 100%;
  }

  /* Ajuste Header Mobile */
  .dashboard-header {
    padding: 10px 15px;
    flex-wrap: wrap; /* Permite que o menu desça (vire gaveta) */
  }

  .logo h2 {
    font-size: 1.2rem;
  }

  /* Área do Avatar no Mobile */
  .user-basic-info {
    gap: 10px;
    margin-left: auto; /* Garante que fique na direita */
  }
  .user-basic-info .avatar {
    width: 40px;
    height: 40px;
  }

  /* Mostra o ícone Hambúrguer */
  .hamburger {
    display: block;
    font-size: 1.8rem;
    cursor: pointer;
    color: #fff;
    margin-left: 10px;
  }

  /* Menu Gaveta (Escondido inicialmente) */
  .header-items {
    display: none; /* Some da linha horizontal */
    flex-basis: 100%; /* Ocupa uma linha nova inteira */
    flex-direction: column; /* Itens verticais */
    align-items: center;
    gap: 15px;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 20px;
    margin-top: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* Quando ativado pelo JS */
  .header-items.active {
    display: flex;
  }

  /* Botões largos no mobile */
  .header-items .btn,
  .header-items .btn-rank {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    box-sizing: border-box;
    margin-bottom: 5px;
  }

  .points-badge {
    display: block;
    margin: 10px 0;
  }
  .notification-box {
    margin: 10px 0;
  }

  .notif-dropdown {
    position: static;
    width: 100%;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  /* Chat Tela Cheia */
  .chat-box {
    height: 100vh !important;
    width: 100% !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }
  .chat-content {
    padding-bottom: 20px;
  }

  /* Ajuste Tabuleiros */
  .board {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1/1;
    border-width: 4px;
  }
  .square {
    width: 12.5%;
    height: 12.5%;
  }
  .piece {
    width: 80%;
    height: 80%;
  }
  canvas {
    width: 100% !important;
    height: auto !important;
  }
}

/* --- QUADRO DE RECORDES --- */
.record-box {
  background: #fff;
  border: 3px solid #f1c40f; /* Borda Dourada */
  border-radius: 15px;
  padding: 15px;
  margin-top: 20px;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.2);
  text-align: left;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.record-title {
  font-family: "Fredoka One";
  color: #f39c12;
  text-align: center;
  border-bottom: 2px dashed #eee;
  padding-bottom: 5px;
  margin-bottom: 10px;
}

.record-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.medal {
  margin-right: 10px;
  font-size: 1.2rem;
}
.rec-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 10px;
  border: 1px solid #ccc;
}
.rec-val {
  margin-left: auto;
  font-weight: bold;
  color: var(--text-dark);
}

/* Estilo para o contêiner do cabeçalho */
/* --- ESTILO DO LOGO PIXEL ART --- */
.pixel-logo {
  height: 75px; /* Define a altura fixa (o PC ajusta a largura sozinho) */
  width: auto; /* Mantém a proporção correta (não estica) */
  display: block; /* Remove espaços fantasmas embaixo da imagem */

  /* MÁGICA DO PIXEL ART: Isso deixa os quadrados bem nítidos */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Ajuste Fino para a caixa do logo */
.logo {
  display: flex;
  align-items: center;
  margin-right: auto; /* Empurra o menu para a direita */
  padding: 5px 0;
}

/* --- VERSÃO MOBILE --- */
@media (max-width: 1024px) {
  .pixel-logo {
    height: 40px; /* Menor no celular para caber na barra */
  }

  .logo {
    margin-right: 0; /* No mobile o layout muda, removemos o empurrão */
  }
}

.card-header {
  height: 150px; /* Altura fixa para o cabeçalho */
  width: 100%; /* Largura total */

  /* MÁGICA PARA A IMAGEM DE FUNDO */
  background-size: cover; /* Faz a imagem cobrir todo o espaço, cortando o excesso se necessário */
  background-position: center; /* Centraliza a imagem */
  background-repeat: no-repeat; /* Não repete a imagem */

  background-color: #2d3436; /* Cor de fundo de fallback (caso a imagem não carregue) */
  position: relative;
  border-bottom: 3px solid #000; /* Borda preta estilo pixel art */
}

/* --- CORREÇÕES GERAIS PARA MOBILE --- */

/* Garante que a arena nunca seja maior que a tela */
.game-arena {
    width: 95%; /* Ocupa 95% da tela, deixando uma margem */
    max-width: 600px; /* Trava no tamanho máximo para PC */
    margin: 10px auto;
    padding: 15px 10px; /* Reduz padding lateral */
    box-sizing: border-box; /* Garante que padding não aumente a largura */
    overflow: hidden; /* Corta qualquer coisa que tente sair */
}

/* Força TODOS os Canvas a se adaptarem */
canvas {
    width: 100% !important; /* Estica ou encolhe para caber na arena */
    height: auto !important; /* Mantém a proporção (aspect ratio) correta */
    max-width: 100%;
}

/* --- CORREÇÃO ESPECÍFICA: DAMAS --- */
/* O tabuleiro estava com width fixo de 400px */
.board {
    width: 100% !important;
    max-width: 400px; /* Limite original */
    height: auto !important;
    aspect-ratio: 1 / 1; /* Garante que fique quadrado */
    margin: 0 auto;
}

/* Ajusta as peças para serem relativas ao tamanho do quadrado */
.square {
    width: auto !important; /* O grid já define o tamanho */
    height: auto !important;
    aspect-ratio: 1 / 1;
}

.piece {
    width: 80% !important; /* A peça ocupa 80% do quadrado */
    height: 80% !important;
}

/* --- CORREÇÃO ESPECÍFICA: MEMÓRIA --- */
/* Garante que as cartas não estourem no mobile */
@media (max-width: 480px) {
    .memory-grid {
        gap: 5px; /* Menor espaço entre cartas */
    }
    .card-face {
        font-size: 1.5rem; /* Emojis menores */
        border-width: 1px;
    }
}

/* Esconde controles no PC */
/* =========================================
   5. CONTROLES MOBILE (BREAKOUT / SNAKE)
   ========================================= */

/* 1. Por padrão, esconde os botões no PC */
.controls-mobile {
    display: none;
}

/* 2. Mostra e estiliza apenas em Celulares e Tablets (até 1024px) */
@media (max-width: 1024px) {
    .controls-mobile {
        display: flex !important; /* Força a exibição */
        justify-content: center; /* Centraliza na tela */
        gap: 15px; /* Espaço entre os botões */
        width: 100%;
        margin-top: 20px;
        padding: 0 10px; /* Margem lateral de segurança */
        box-sizing: border-box;
        position: relative;
        z-index: 100; /* Garante que fique por cima de tudo */
    }

    .btn-move, .d-btn {
        flex: 1; /* Faz os botões ocuparem todo o espaço disponível */
        background: #2d3436; /* Fundo escuro */
        border: 2px solid #55efc4; /* Borda Neon */
        color: #55efc4;
        font-size: 3rem; /* Seta GIGANTE */
        padding: 20px 0; /* Altura generosa para o dedo não errar */
        border-radius: 15px;
        cursor: pointer;
        text-align: center;
        line-height: 1;
        
        /* Otimizações vitais para toque no celular */
        touch-action: manipulation; /* Evita zoom duplo */
        user-select: none; /* Não deixa selecionar o texto */
        -webkit-tap-highlight-color: transparent; /* Remove o flash azul do Android */
        transition: transform 0.1s, background 0.1s;
    }

    /* Efeito ao tocar */
    .btn-move:active, .d-btn:active {
        background: #55efc4;
        color: #000;
        transform: scale(0.95);
    }
}
