/* PALETA FINAL: LIMPO E FORTE (CLEAN & BOLD) */
:root {
  --icegurt-dark-blue: #003D7A; /* Azul Marinho FORTE (Estrutura/Header) */
  --icegurt-light-blue: #E0F6FF; /* Azul Bebê Claro (Fundo suave) */
  --icegurt-red: #FF0000; /* VERMELHO VIVO (Ação/Destaque) */
  --icegurt-white: #FFFFFF;
  --icegurt-gray: #CCCCCC;
  --icegurt-text-dark: #1A1A1A; /* Texto escuro */
}

/* Base e Estilos Globais */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Courier New', monospace;
  background: linear-gradient(135deg, var(--icegurt-light-blue) 0%, #FFD1D1 100%);
  color: var(--icegurt-text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ESTRUTURA DE TELAS */
.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

/* A tela principal não deve ser flex centralizada */
#mainScreen.active {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
}

/* GameScreen só é flex no modo tela cheia */
#gameScreen.active {
  display: flex;
}

/* PAINÉIS E BOTÕES */
.main-panel {
  background: var(--icegurt-white);
  border: 4px solid var(--icegurt-dark-blue);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
  text-align: center;
  width: 100%;
}

.main-title {
  color: var(--icegurt-red);
  font-size: 2.5em;
  margin-bottom: 20px;
}

.section-title {
  color: var(--icegurt-dark-blue);
  font-size: 1.8em;
  margin-bottom: 25px;
  text-align: center;
}

.form-input {
  width: 100%;
  padding: 12px;
  margin: 10px 0;
  background: var(--icegurt-light-blue);
  border: 2px solid var(--icegurt-dark-blue);
  color: var(--icegurt-text-dark);
  font-family: 'Courier New', monospace;
  border-radius: 5px;
}

/* BOTÕES PRIMÁRIOS */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--icegurt-red);
  color: var(--icegurt-white);
  border: none;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  margin: 10px 0;
  box-shadow: 0 4px 0 var(--icegurt-dark-blue);
  transition: all 0.1s ease-in-out;
  font-size: 1em;
}

.btn-primary:hover {
  background: #CC0000;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--icegurt-dark-blue);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--icegurt-dark-blue);
}

.btn-primary:disabled {
  background: var(--icegurt-gray);
  cursor: not-allowed;
  box-shadow: 0 4px 0 #888;
}

/* BOTÕES SECUNDÁRIOS */
.btn-small {
  background: var(--icegurt-light-blue);
  color: var(--icegurt-dark-blue);
  border: 2px solid var(--icegurt-dark-blue);
  padding: 5px 12px;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-small:hover {
  background: var(--icegurt-white);
}

.btn-secondary {
  padding: 12px 20px;
  background: var(--icegurt-dark-blue);
  color: var(--icegurt-white);
  border: none;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 0 4px 0 var(--icegurt-red);
  transition: all 0.1s ease-in-out;
}

.btn-secondary:hover {
  background: #005A99;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--icegurt-red);
}

.btn-secondary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--icegurt-red);
}

/* ============================ */
/* ===== TELA AUTH (FLIP) ===== */
/* ============================ */

#authScreen.active {
  padding: 20px;
}

.auth-container {
  perspective: 1000px;
  width: 100%;
  max-width: 500px;
}

.auth-card {
  width: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
  min-height: 450px;
}

.auth-card.is-flipped {
  transform: rotateY(180deg);
}

.auth-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.auth-back {
  transform: rotateY(180deg);
}

.auth-face .main-panel {
  min-height: 450px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-face .main-panel p {
  margin-top: 15px;
}

.auth-face .main-panel a {
  color: var(--icegurt-red);
  font-weight: bold;
  cursor: pointer;
}

/* ====================== */
/* ===== HEADER ======== */
/* ====================== */

header {
  background: var(--icegurt-dark-blue);
  border-bottom: 5px solid var(--icegurt-red);
  padding: 15px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

header h1 {
  color: var(--icegurt-white);
  font-size: 1.5em;
  white-space: nowrap;
}

.user-info {
  color: var(--icegurt-light-blue);
  display: flex;
  gap: 20px;
  align-items: center;
  font-weight: bold;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ================================ */
/* ===== MAIN CONTENT & GRID ===== */
/* ================================ */

main {
  display: grid;
  grid-template-columns: 2.5fr 1.5fr;
  gap: 40px;
  max-width: 1200px;
  width: 100%;
  margin: 40px auto;
  padding: 0 20px;
  flex-grow: 1;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* ============= */
/* GAME CARD */
/* ============= */

.game-card {
  background: var(--icegurt-white);
  border: 4px solid var(--icegurt-dark-blue);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
  border-color: var(--icegurt-light-blue);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  border-color: var(--icegurt-red);
}

.game-card h3 {
  color: var(--icegurt-dark-blue);
  margin-top: 10px;
}

.game-card p {
  color: var(--icegurt-text-dark);
  margin: 10px 0 15px 0;
  flex-grow: 1;
}

.game-icon {
  font-size: 2.5em;
  margin-bottom: 10px;
}

.game-card .btn-primary {
  width: auto;
  padding: 10px 30px;
  margin: 0 auto;
}

/* ========================== */
/* LEADERBOARD */
/* ========================== */

.leaderboard-container {
  background: var(--icegurt-white);
  border: 3px solid var(--icegurt-red);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
  text-align: center;
  color: var(--icegurt-text-dark);
  align-self: start;
}

.leaderboard-container h2 {
  color: var(--icegurt-dark-blue);
  margin-bottom: 20px;
  border-bottom: 2px solid var(--icegurt-light-blue);
  padding-bottom: 10px;
}

.info-display {
  background: var(--icegurt-light-blue);
  border: 1px solid var(--icegurt-dark-blue);
  margin-bottom: 8px;
  padding: 10px;
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}

.leaderboard-item {
  border-color: var(--icegurt-dark-blue) !important;
}

.leaderboard-item:nth-child(1) {
  border-width: 3px !important;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
}

/* ======================================= */
/* ===== TELA DE JOGO & RESULTADOS ===== */
/* ======================================= */

.game-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    width: 100%;
    height: 100%;
    padding: 20px;
}

/* Container do canvas */
#gameContainer {
    flex: 1;
    max-width: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* CORREÇÃO: aplicar estilo ao canvas certo */
#gameContainer canvas {
    border: 6px solid #278bff;
    border-radius: 12px;
    background: #000;
    box-shadow:
        0 0 15px rgba(39, 139, 255, 0.9),
        0 0 35px rgba(39, 139, 255, 0.4);

    /* IMPORTANTÍSSIMO → pro Asteroids não ficar minúsculo */
    max-width: 100%;
    height: auto !important;
    image-rendering: pixelated;
}

/* SCOREBOARD */
#game-scoreboard {
    width: 270px;
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    border: 4px solid #ff4d4d;
    box-shadow:
        0 0 15px rgba(255, 80, 80, 0.5),
        0 0 25px rgba(255, 80, 80, 0.15);
    font-family: monospace;
    font-size: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* TELA CHEIA: correções */
body.game-is-active #gameScreen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

body.game-is-active .game-wrapper {
    flex: 1;
    height: 100%;
    padding-top: 70px; /* espaço pro botão voltar */
}

/* Footer */
footer {
  background-color: var(--icegurt-dark-blue);
  color: var(--icegurt-white);
  text-align: center;
  padding: 15px 0;
  margin-top: auto;
  border-top: 3px solid var(--icegurt-red);
  width: 100%;
}

/* ============================ */
/* ===== MODAL ===== */
/* ============================ */

.modal {
  position: fixed;
  z-index: 3000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--icegurt-white);
  border: 4px solid var(--icegurt-dark-blue);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
  text-align: center;
  width: 90%;
  max-width: 450px;
}

.modal-content #modalTitle {
  font-size: 1.8em;
  margin-bottom: 15px;
}

.modal-content p {
  font-size: 1.1em;
  color: var(--icegurt-text-dark);
  margin-bottom: 25px;
}

.modal-content .btn-primary {
  width: 100%;
}

/* ============================ */
/* ===== RESPONSIVIDADE ===== */
/* ============================ */

@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 0 15px;
    margin: 20px auto;
  }

  .games-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .leaderboard-container {
    align-self: center;
    width: 100%;
  }

  body.game-is-active .game-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 70px 20px 20px 20px;
  }

  .game-scoreboard {
    width: 90%;
    max-width: 500px;
    margin: 10px auto;
    position: relative;
    z-index: 0;
    align-self: auto;
  }

  #gameContainer {
    align-self: auto;
    width: 100%;
  }
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }

  .user-info {
    gap: 10px;
    justify-content: center;
  }

  header h1 {
    font-size: 1.3em;
  }

  .main-panel {
    padding: 20px;
  }

  #authScreen.active {
    padding: 10px;
  }

  .games-grid {
    grid-template-columns: 1fr;
  }

  .main-title {
    font-size: 2em;
  }

  .section-title {
    font-size: 1.5em;
  }

  .game-result-panel {
    padding: 20px;
  }

  .result-score {
    font-size: 2.5em;
  }
}

/* MODO TELA CHEIA */

body.game-is-active {
  overflow: hidden;
}

body.game-is-active #mainScreen {
  display: none;
}

body.game-is-active #gameScreen.active {
  background: #111;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.game-is-active .game-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

body.game-is-active .game-wrapper {
  width: 100%;
  height: 100%;
  border: none;
}

body.game-is-active #gameScreen .btn-secondary {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid var(--icegurt-white);
  margin: 0;
}
