/* ============================================================
   Retro Games — identidade visual retrô / arcade
   Fontes: Press Start 2P (títulos) + VT323 (corpo)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  --bg: #0b0a1a;
  --bg-soft: #14122b;
  --card: #191636;
  --card-hover: #221d4a;
  --text: #e9e6ff;
  --text-dim: #8f8bc4;
  --accent: #7c5cff;   /* roxo neon */
  --accent-2: #ff4d8d; /* magenta neon */
  --accent-3: #2ff5c0; /* verde/ciano neon */
  --amber: #ffcf4d;    /* âmbar arcade */
  --border: #34306a;
  --radius: 4px;       /* cantos duros/pixelados */
  --shadow: 6px 6px 0 rgba(0, 0, 0, 0.55);
  --font-display: 'Press Start 2P', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'VT323', 'Courier New', monospace;
  --font: var(--font-body); /* compat: jogos usam --font indiretamente */
}

* {
  box-sizing: border-box;
}

/* Site sem zoom: bloqueia pinça e duplo toque (a rolagem continua) e evita que o
   iOS aumente o texto sozinho. Tamanhos de texto e de toque são pensados para isso. */
html {
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  -webkit-tap-highlight-color: transparent;
}

}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.4;
  color: var(--text);
  min-height: 100vh;
  background-color: var(--bg);
  /* grade estilo horizonte de arcade */
  background-image:
    radial-gradient(circle at 50% -20%, rgba(124, 92, 255, 0.22), transparent 55%),
    linear-gradient(rgba(124, 92, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 92, 255, 0.06) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  background-attachment: fixed;
}

/* Scanlines de CRT sobre tudo */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}

/* Celular/toque: sem as scanlines e sem fundo fixo. Eles obrigam o aparelho a
   recompor a tela inteira a cada quadro dos jogos. */
@media (pointer: coarse) {
  body::after { display: none; }
  body { background-attachment: scroll; }
}

a {
  color: inherit;
  text-decoration: none;
}

/* -------------------- Header -------------------- */
header.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  flex-wrap: wrap;
  gap: 14px;
  border-bottom: 2px solid var(--border);
  background: rgba(11, 10, 26, 0.6);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 1px;
  cursor: pointer;
}

.brand .logo-mark {
  height: 36px;
  width: auto;
  display: block;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 8px rgba(124, 92, 255, 0.7));
}

.brand .wordmark {
  color: var(--accent-3);
  text-shadow:
    0 0 6px rgba(47, 245, 192, 0.8),
    2px 2px 0 rgba(0, 0, 0, 0.6);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
}

.back-link:hover {
  color: var(--text);
  border-color: var(--accent-3);
  box-shadow: 0 0 10px rgba(47, 245, 192, 0.4);
}

/* -------------------- Layout -------------------- */
main {
  padding: 0 40px 64px;
  max-width: 1200px;
  margin: 0 auto;
}

.hero {
  text-align: center;
  padding: 48px 20px 52px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  line-height: 1.3;
  margin: 0 0 20px;
  color: var(--accent-2);
  text-shadow:
    0 0 8px rgba(255, 77, 141, 0.8),
    0 0 20px rgba(255, 77, 141, 0.5),
    4px 4px 0 rgba(0, 0, 0, 0.5);
}

.hero p {
  color: var(--text-dim);
  font-size: 1.35rem;
  max-width: 620px;
  margin: 0 auto;
}

/* -------------------- Grid de jogos -------------------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 28px;
}

.game-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s steps(2), box-shadow 0.12s ease, border-color 0.12s ease;
}

.game-card:hover {
  transform: translate(-3px, -3px);
  border-color: var(--accent-3);
  box-shadow: 9px 9px 0 rgba(0, 0, 0, 0.55), 0 0 18px rgba(47, 245, 192, 0.35);
}

.game-card .icon {
  font-size: 2.6rem;
  line-height: 1;
}

.game-card h3 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  line-height: 1.4;
  margin: 6px 0 0;
  color: var(--text);
}

.game-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 1.15rem;
  flex-grow: 1;
}

.game-card .tag {
  align-self: flex-start;
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--amber);
  padding: 5px 9px;
  border-radius: var(--radius);
}

/* -------------------- Footer -------------------- */
footer.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 1.1rem;
}

/* -------------------- Auth widget (header) -------------------- */
.auth-widget {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-user {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: var(--accent-3);
}

.auth-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: var(--bg);
  background: var(--accent-3);
  box-shadow: 0 0 10px rgba(47, 245, 192, 0.5);
}

/* -------------------- Página de login -------------------- */
.auth-page {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 26px;
  background: var(--bg-soft);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 5px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.6rem;
  padding: 12px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 0 12px rgba(124, 92, 255, 0.5);
}

.auth-field {
  margin-bottom: 18px;
}

.auth-field label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.auth-field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.3rem;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--accent-3);
  box-shadow: 0 0 10px rgba(47, 245, 192, 0.35);
}

.auth-card .btn {
  width: 100%;
  margin-top: 6px;
}

.auth-error {
  color: var(--accent-2);
  font-size: 1.15rem;
  min-height: 1.3em;
  margin-bottom: 12px;
  text-align: center;
  text-shadow: 0 0 6px rgba(255, 77, 141, 0.5);
}

.auth-note {
  margin-top: 22px;
  font-size: 1.05rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

/* Aviso de que a pontuação não será salva sem conta */
.aviso-conta {
  text-align: center;
  color: var(--text-dim);
  font-size: 1.05rem;
  min-height: 1em;
}

.aviso-conta:empty {
  display: none;
}

.aviso-conta a {
  color: var(--accent-3);
  text-decoration: underline;
}

/* Etapa de confirmação por código */
.code-intro {
  text-align: center;
  color: var(--text-dim);
  font-size: 1.15rem;
  margin: 0 0 20px;
  line-height: 1.6;
}

.code-intro strong {
  color: var(--accent-3);
  font-size: 1.05rem;
  word-break: break-all;
}

.code-input {
  text-align: center;
  font-family: var(--font-display) !important;
  font-size: 1.1rem !important;
  letter-spacing: 6px;
  padding: 16px 12px !important;
}

#code-form .btn {
  width: 100%;
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

/* -------------------- Botões -------------------- */
.btn {
  border: 2px solid rgba(0, 0, 0, 0.4);
  border-radius: var(--radius);
  padding: 13px 24px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  cursor: pointer;
  background: var(--accent);
  color: white;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55);
  transition: transform 0.08s steps(2), box-shadow 0.08s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.12);
}

.btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.55);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.secondary {
  background: var(--bg-soft);
  border: 2px solid var(--border);
  color: var(--text);
}

/* -------------------- Game shell / stats -------------------- */
.game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding-top: 12px;
}

.panel {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.stat-row {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  text-align: center;
}

.stat .value {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--accent-3);
  text-shadow: 0 0 8px rgba(47, 245, 192, 0.6);
}

.stat .label {
  font-family: var(--font-display);
  font-size: 0.5rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
}

/* Celular, sem zoom: texto em fonte "pixel" nunca abaixo de ~11 px, todo botão ou
   link com pelo menos 44 px de altura (tamanho de toque confortável) e o cabeçalho
   nunca passa da largura da tela. ("body" na frente = vence regras de outros arquivos.) */
@media (max-width: 640px) {
  body .back-link,
  body .game-tab,
  body .game-card .tag,
  body .semana-badge,
  body .premium-badge,
  body .stat .label,
  body .message,
  body #question-counter,
  body #running-score { font-size: 0.7rem; }

  body .back-link {
    min-height: 44px;
    min-width: 44px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  body .brand { min-height: 44px; min-width: 44px; }
  body .fav-btn { width: 44px; height: 44px; }
  body .game-tab { min-height: 44px; }
  body input, body select, body textarea { font-size: 16px; }

  /* Cabeçalho: os botões quebram de linha em vez de vazar, e o nome do usuário
     fica só na letra (avatar). */
  body .site-header { padding: 8px 12px; gap: 8px; }
  body .site-header .auth-widget {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }
  /* Páginas fora dos jogos: marca em cima, botões numa linha própria embaixo.
     (o #auth-widget interno também é .auth-widget: não pode encolher nem quebrar) */
  body:not(.pagina-jogo) .site-header .auth-widget { flex: 1 1 100%; justify-content: flex-start; }
  body:not(.pagina-jogo) .site-header .auth-widget .auth-widget { flex: 0 0 auto; flex-wrap: nowrap; }
  body:not(.pagina-jogo) .site-header .back-link { padding: 0 10px; }
  body .auth-user { font-size: 0; gap: 0; }
  body .auth-avatar { width: 32px; height: 32px; font-size: 0.7rem; }
  body .brand .logo-mark { height: 30px; }
}

/* Menu da conta (ícone no canto direito do cabeçalho) */
.menu-conta { position: relative; margin-left: auto; }
.menu-conta-btn { border: 0; cursor: pointer; font-family: var(--font-display); padding: 0; }
.menu-conta-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.menu-conta-lista {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 200; min-width: 190px;
  background: var(--card, #1a1740); border: 2px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.menu-conta-lista[hidden] { display: none; }
.menu-conta-nome {
  padding: 8px 12px; color: var(--accent-3); font-family: var(--font-display); font-size: 0.6rem;
  border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-conta-item {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: var(--radius); cursor: pointer;
  color: var(--text); font-family: var(--font-display); font-size: 0.7rem; text-decoration: none;
}
.menu-conta-item:hover, .menu-conta-item:focus-visible { background: var(--card-hover, #252158); outline: none; }
body .auth-avatar.menu-conta-btn { width: 40px; height: 40px; font-size: 0.8rem; }
/* O ícone da conta sempre no canto direito do cabeçalho */
.site-header #auth-widget { margin-left: auto; }
