/**
 * HSA Store Product Eligibility Game
 * Correções de responsividade para smartphones
 */

/* Verificação de viewport - inclua isso no HTML se ainda não tiver */
/* <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> */

/* Estilos gerais para dispositivos móveis */
@media only screen and (max-width: 768px) {
  /* Ajustes para o container principal */
  .game-modal {
    max-width: 100%;
    width: 100%;
    height: auto;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  /* Redução de padding para economizar espaço */
  .screen {
    padding: 16px;
    min-height: 100vh;
    height: auto;
    box-sizing: border-box;
  }

  /* Header mais compacto */
  .header {
    margin-bottom: 15px;
  }

  /* Botões em tela cheia para mobile */
  .primary-btn,
  .secondary-btn,
  .positive-btn,
  .negative-btn {
    width: 100%;
  }

  /* Garantir que a tela de boas-vindas adapte corretamente */
  .welcome-screen {
    padding: 16px;
  }

  .start-game-btn {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Ajustes na tabela de leaderboard */
  .ranking-section {
    width: 100%;
    margin-left: 0 !important;
  }

  .ranking-table {
    min-width: 0;
    width: 100%;
    font-size: 12px;
  }

  .ranking-table th,
  .ranking-table td {
    padding: 8px 4px;
  }
  .ranking-table {
    min-width: 370px !important;
  }
}

/* Smartphones (portrait) */
@media only screen and (max-width: 480px) {
  /* Ajustes para telas muito pequenas */
  h1 {
    font-size: 22px;
    margin-bottom: 15px;
  }

  h2 {
    font-size: 20px;
  }

  h3 {
    font-size: 16px;
  }

  p {
    font-size: 14px;
  }

  /* Layout da página de jogo */
  .game-stats-section {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
  }

  .stat-container {
    width: 100%;
    margin-bottom: 8px;
  }

  .stat-item {
    width: 100%;
    max-width: 280px;
  }

  /* Conteúdo do produto */
  .product-container {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }

  .product-image {
    width: 100%;
    height: auto;
    max-width: 200px;
    margin: 0 auto;
  }

  .product-info h3 {
    font-size: 18px;
  }

  .product-info p {
    font-size: 14px;
  }

  /* Botões de elegibilidade em coluna */
  .eligibility-buttons {
    flex-direction: column;
    gap: 10px;
  }

  /* Layout do leaderboard */
  .leaderboard-content {
    flex-direction: column;
    gap: 20px;
  }

  .celebration-section {
    width: 100%;
  }

  .ranking-section {
    width: 100%;
  }

  /* Formulário do usuário */
  .form-modal {
    width: 100%;
    padding: 50px 20px;
    left: 0;
    transform: none;
    border-radius: 0;
    height: 100vh;
    top: 0;
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  /* Resultados */
  .results-list {
    padding: 5px 0;
  }

  .result-item {
    flex-direction: column;
    padding: 12px;
  }

  .result-item .product-image {
    margin: 0 auto 10px;
  }
  .ranking-table {
    min-width: 370px !important;
  }
}

/* Corrigir especificamente telas muito pequenas */
@media only screen and (max-width: 350px) {
  /* .header .logo img {
    height: 24px;
  }*/
  .ranking-table {
    min-width: 370px !important;
  }

  .stat-title {
    font-size: 14px;
  }

  .stat-value {
    font-size: 14px;
  }

  .product-info h3 {
    font-size: 16px;
  }

  /* Ajustes para botões muito pequenos */
  .primary-btn,
  .secondary-btn,
  .positive-btn,
  .negative-btn {
    padding: 10px;
    font-size: 14px;
  }
}

/* Correção para orientação paisagem em smartphones */
@media only screen and (max-width: 850px) and (orientation: landscape) {
  .game-modal {
    height: auto;
    min-height: 100vh;
  }

  .screen {
    min-height: auto;
    padding: 12px;
  }

  .game-stats-section {
    flex-direction: row;
  }

  .stat-item {
    width: 110px;
  }

  .product-container {
    flex-direction: row;
    gap: 15px;
  }

  .product-image {
    flex: 0 0 150px;
  }

  /* Scroll para telas com muito conteúdo em paisagem */
  .results-list {
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* Corrigir overflow de textos longos */
@media only screen and (max-width: 768px) {
  /* Evitar que textos longos quebrem o layout */
  .product-info h3,
  .product-details h3,
  .congrats-message h2,
  .congrats-message h3 {
    word-break: break-word;
    overflow-wrap: break-word;
    margin-top: 17px;
  }

  /* Garantir que tabelas sejam responsivas */
  .ranking-table {
    width: 100%;
    min-width: 370px;
  }

  .ranking-table th,
  .ranking-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/**
 * CSS específico para dispositivos móveis
 * Adicione este CSS ao seu arquivo existente ou crie um novo arquivo
 */

/* Estilos para a classe mobile-device, que é adicionada via JavaScript */
.mobile-device .game-screen {
  padding: 16px;
}

.mobile-device .header {
  margin-bottom: 16px;
}

/* Estilos para a seção de estatísticas */
.mobile-device .game-stats-section {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.mobile-device .stat-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  text-align: center;
}

.mobile-device .stat-item {
  width: auto;
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-device .stat-value-container {
  background-color: white;
  border-radius: 6px;
  padding: 5px 12px;
  min-width: 50px;
  text-align: center;
}

.mobile-device .stat-value {
  font-size: 14px;
  font-weight: 600;
}

/* Estilos para o container do produto */
.mobile-device .product-container {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: 12px;
  background-color: white;
}

.mobile-device .product-image {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  margin-bottom: 16px;
}

.mobile-device .product-info {
  width: 100%;
}

.mobile-device .product-info h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.mobile-device .product-info p {
  font-size: 14px;
  margin-bottom: 16px;
}

.mobile-device .product-question {
  margin-bottom: 16px;
}

.mobile-device .eligibility-buttons {
  display: flex;
  gap: 10px;
}

.mobile-device .eligibility-buttons button {
  flex: 1;
  font-size: 16px;
  padding: 12px 8px;
  border-radius: 8px;
}

/* Ajustes para dispositivos muito pequenos */
@media only screen and (max-width: 350px) {
  .mobile-device .stat-title {
    font-size: 14px;
  }

  .mobile-device .stat-item {
    padding: 6px 10px;
  }

  .mobile-device .stat-value-container {
    padding: 4px 8px;
    min-width: 45px;
  }

  .mobile-device .stat-value {
    font-size: 13px;
  }

  .mobile-device .product-info h3 {
    font-size: 16px;
  }

  .mobile-device .product-info p {
    font-size: 13px;
  }

  .mobile-device .eligibility-buttons button {
    font-size: 14px;
  }
}

/* Otimizações para dispositivos com altura limitada */
@media only screen and (max-height: 600px) {
  .mobile-device .product-image img {
    max-height: 180px;
  }

  .mobile-device .product-info h3 {
    margin-bottom: 4px;
    margin-top: 15px;
  }

  .mobile-device .product-info p {
    margin-bottom: 8px;
  }

  .mobile-device .product-question {
    margin-bottom: 10px;
  }
}

/* Ajustes para orientação paisagem */
@media only screen and (orientation: landscape) and (max-height: 500px) {
  .mobile-device .product-container {
    flex-direction: row;
    gap: 16px;
  }

  .mobile-device .product-image {
    flex: 0 0 40%;
    margin-bottom: 0;
  }

  .mobile-device .product-info {
    flex: 1;
  }
}

@media only screen and (max-width: 768px) {
  /* Existing styles for game stats */
  .game-stats-section {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
  }
  .stat-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    flex: 1 !important;
    max-width: 33.33% !important;
    margin: 0 4px !important;
  }

  /* Center the product image */
  .product-image {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 0 auto 20px !important;
  }

  .product-image img {
    margin: 0 auto !important;
  }

  /* Container principal das estatísticas */
  .mobile-stats-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    margin-bottom: 20px;
    padding: 0 16px;
  }

  /* Bloco individual de estatística */
  .mobile-stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  /* Título da estatística */
  .mobile-stat-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
  }

  /* Item de estatística (caixa roxa) */
  .mobile-stat-item {
    background-color: #5d43b5;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 60px;
  }

  /* Ícone branco */
  .mobile-stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
  }

  .mobile-stat-icon svg {
    width: 22px;
    height: 22px;
    fill: white;
  }

  /* Valor da estatística (caixa branca) */
  .mobile-stat-value {
    background-color: white;
    border-radius: 6px;
    padding: 10px 16px;
    min-width: 80px;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    color: #333;
  }

  /* Linha separadora */
  .separator-line {
    height: 1px;
    background-color: #e8e8e8;
    margin: 10px 0 20px;
    width: 100%;
  }

  /* Container do produto ajustado para layout vertical */
  .product-container {
    flex-direction: column;
    padding: 16px;
    margin-top: 0;
  }

  /* Imagem do produto centralizada */
  .product-image {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
  }

  .product-image img {
    max-width: 90%;
    max-height: 240px;
    object-fit: contain;
  }
  /* Leaderboard screen optimizations */
  .leaderboard-screen {
    padding: 16px !important;
  }

  /* Center celebration graphic */
  .celebration-graphic {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
    margin: 20px auto !important;
  }

  .celebration-graphic img {
    max-width: 220px !important;
    height: auto !important;
  }

  /* Center and style congratulations text */
  .congrats-message {
    text-align: center !important;
    width: 100% !important;
  }

  .congrats-message h2,
  .congrats-message h3 {
    color: #5d43b5 !important;
    text-align: center !important;
    margin-bottom: 8px !important;
  }

  .congrats-message p {
    color: #666 !important;
    text-align: center !important;
    font-size: 16px !important;
  }

  /* Full width leaderboard box with rounded corners */
  .ranking-box {
    width: 100% !important;
    margin: 0 auto !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    background-color: white !important;
  }

  /* Purple header with "Leaderboard" text */
  .ranking-header {
    background-color: #5d43b5 !important;
    color: white !important;
    padding: 15px !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    text-align: center !important;
  }

  /* Table styling */
  .ranking-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .ranking-table th {
    color: #5d43b5 !important;
    text-align: left !important;
    padding: 12px 10px !important;
    border-bottom: 1px solid #eee !important;
    font-weight: 600 !important;
  }

  .ranking-table td {
    padding: 12px 10px !important;
    border-bottom: 1px solid #eee !important;
    color: #333 !important;
  }

  /* Email notice at the bottom */
  .email-notice {
    text-align: center !important;
    padding: 15px !important;
    color: #666 !important;
    font-size: 14px !important;
  }

  /* Highlight current user row */
  .ranking-table tr.highlight-row {
    background-color: #f0f0ff !important;
  }

  /* Medal icons */
  .medal-gold,
  .medal-silver,
  .medal-bronze {
    font-size: 20px !important;
    display: inline-block !important;
  }

  /* Email notice at bottom */
  .email-notice {
    text-align: center !important;
    color: #666 !important;
    font-size: 14px !important;
    margin-top: 16px !important;
    margin-bottom: 16px !important;
  }

  /* Show only the leaderboard section in full width */
  .leaderboard-content {
    flex-direction: column !important;
  }

  .ranking-section {
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* Ajustes para dispositivos muito pequenos */
  @media only screen and (max-width: 359px) {
    .mobile-stat-title {
      font-size: 16px;
    }

    .mobile-stat-item {
      padding: 10px 12px;
      height: 50px;
    }

    .mobile-stat-value {
      padding: 8px 12px;
      min-width: 70px;
      font-size: 14px;
    }
  }
}
