/* Not Social Media — identidade "rota de fuga"
 * Cyberpunk de beco, não de vitrine: neon ciano (saída) + rosa choque
 * (rebelião) sobre azul-violeta blecaute. Os jogos herdam a paleta
 * pelas variáveis; a assinatura é o risco neon piscando sobre "social". */
:root {
  --bg: #0a0c14;         /* blecaute */
  --surface: #11141f;    /* bunker */
  --surface-2: #1a1e2f;  /* conduíte */
  --text: #e6ecf5;
  --text-dim: #7e88a2;
  --accent: #45f0c7;     /* neon "saída" */
  --accent-2: #ff3d7f;   /* rosa "rebelião" */
  --display: 'Chakra Petch', 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --topbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* CRT: scanlines quase subliminares sobre tudo (só atmosfera) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0 1px, transparent 1px 4px);
  opacity: 0.06;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Top bar ---- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) 4px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 12, 20, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* Acima do drawer (z 40): com o menu fullscreen, o hambúrguer/X é o fechamento */
  z-index: 45;
}
/* Linha de sinal: ciano vira magenta — a transmissão pirata do site */
.topbar::before {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent-2) 72%, transparent);
  opacity: 0.55;
}

/* Marca: letreiro neon com a negação como assinatura */
.brand {
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  color: var(--text);
  text-shadow: 0 0 14px rgba(69, 240, 199, 0.28);
}
.brand span {
  position: relative;
  color: var(--text-dim);
  margin: 0 2px;
}
/* O risco sobre "social" pisca como neon com mau contato */
.brand span::after {
  content: '';
  position: absolute;
  left: -3%;
  right: -3%;
  top: 54%;
  height: 2.5px;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2), 0 0 20px rgba(255, 61, 127, 0.5);
  animation: neon-strike 7s infinite;
}
@keyframes neon-strike {
  0%, 41%, 45%, 74%, 77%, 100% { opacity: 1; }
  42%, 44% { opacity: 0.25; }
  75%, 76% { opacity: 0.4; }
}

/* Wrapper de centro: brand + game title com animação de fade */
.topbar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 56px;
  flex: 1;
  min-width: 0; /* deixa o centro encolher em vez de espremer os pills laterais */
  overflow: hidden;
}

/* Marca em destaque, maior no centro — com fade quando jogo aparece */
.topbar-center .brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  position: relative;
  z-index: 2;
  opacity: 1;
  animation: brand-fade-alternate 8s ease-in-out infinite;
}

/* Título dinâmico do jogo: emoji + nome, alternância com fade */
.game-title {
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.03em;
  min-height: 20px;
  text-align: center;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: absolute;
  opacity: 0;
  animation: title-alternate 8s ease-in-out infinite;
}

/* Animação: título do jogo aparece e desaparece (brand fica invisível enquanto jogo visível) */
@keyframes title-alternate {
  0% { opacity: 0; }
  20% { opacity: 1; }
  48% { opacity: 1; }
  52% { opacity: 0; }
  100% { opacity: 0; }
}

/* Animação: brand desaparece quando jogo aparece */
@keyframes brand-fade-alternate {
  0% { opacity: 1; }
  20% { opacity: 0; }
  48% { opacity: 0; }
  52% { opacity: 1; }
  100% { opacity: 1; }
}

/* Botão shuffle no topbar (direita) — estética igual ao drawer */
.topbar-shuffle-btn {
  width: auto;
  height: 40px;
  padding: 0 10px;
  gap: 5px;
  border: 1px dashed var(--accent-2);
  border-radius: 10px;
  background: transparent;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 0 8px rgba(255, 61, 127, 0.3);
  flex-shrink: 0;
}

.topbar-shuffle-btn:active {
  background: rgba(255, 61, 127, 0.18);
  box-shadow: 0 0 16px rgba(255, 61, 127, 0.6);
}

.shuffle-icon {
  font-size: 0.95rem;
}

.shuffle-label {
  white-space: nowrap;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-btn:active { background: var(--surface-2); }

/* Botão do menu: moldura neon — a porta de saída para os outros jogos */
.menu-pill {
  width: auto;
  height: 40px;
  padding: 0 12px 0 10px;
  gap: 6px;
  background: rgba(69, 240, 199, 0.07);
  border: 1px solid var(--accent);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(69, 240, 199, 0.22), inset 0 0 8px rgba(69, 240, 199, 0.06);
  flex-shrink: 0;
}
.menu-pill:active {
  background: rgba(69, 240, 199, 0.18);
}
.menu-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s, opacity 0.2s;
}
.icon-btn[aria-expanded="true"] .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.icon-btn[aria-expanded="true"] .hamburger span:nth-child(2) { opacity: 0; }
.icon-btn[aria-expanded="true"] .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Drawer ---- */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  background: var(--surface);
  z-index: 40;
  padding: calc(var(--topbar-h) + var(--safe-top) + 8px) 16px calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.drawer.open { transform: translateX(0); }

/* Tagline como prompt de terminal, com cursor vivo */
.drawer-tagline {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.78rem;
  margin-bottom: 16px;
}
.drawer-tagline::before { content: '> '; color: var(--accent-2); }
.drawer-tagline::after {
  content: '_';
  animation: cursor-blink 1.1s steps(1) infinite;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

.game-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 10px;
  align-content: start;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
}
/* Telas largas: mais colunas aproveitando o fullscreen */
@media (min-width: 560px) {
  .game-list { max-width: 900px; grid-template-columns: repeat(3, 1fr); }
}
.game-list li { position: relative; } /* âncora para a estrela de favorito e o selo de versão */

.drawer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-2);
}

.control-btn {
  flex: 1 1 80px; /* cresce para preencher, mas quebra a linha se não couber */
  min-width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1px solid var(--surface-2);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.control-btn:active {
  background: var(--surface-2);
  border-color: var(--accent);
}

.control-btn:hover {
  border-color: var(--accent);
  background: rgba(69, 240, 199, 0.08);
}

#btn-pwa-install:not([hidden]) {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(69, 240, 199, 0.2);
}

.control-icon {
  font-size: 1.1rem;
}

.control-label {
  white-space: nowrap;
}

/* Categorias com prefixo de comentário: o menu é código do submundo */
.game-list .drawer-cat {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 14px 10px 6px;
  border-bottom: 1px solid var(--surface-2);
  margin-bottom: 4px;
}
.game-list .drawer-cat::before { content: '// '; color: var(--accent-2); }
.game-list .drawer-cat:first-child { padding-top: 4px; }
.game-list button {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  /* padding-right reserva a faixa direita para a estrela (topo) e a versão (base):
   * é a sangria que separa o texto do número da versão, sem crescer o botão. */
  padding: 12px 40px 12px 12px;
  border: 1px solid var(--surface-2);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.game-list button:active { background: var(--surface-2); }
.game-list button.active {
  background: var(--surface-2);
  outline: 1px solid var(--accent);
  box-shadow: 0 0 10px rgba(69, 240, 199, 0.15);
}
.game-list .g-emoji { font-size: 1.4rem; }
.game-list .g-name { font-family: var(--display); font-weight: 600; letter-spacing: 0.02em; }
.game-list .g-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 2px;
}

/* Selo de versão YYMMDD: canto inferior direito, discreto, inerte ao toque.
 * A faixa direita (padding-right: 40px do botão) o separa do texto — sangria. */
.g-ver {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  opacity: 0.7;
  pointer-events: none;
  letter-spacing: 0.02em;
}

/* Estrela de favorito: hit area 44px no canto do card, glifo pequeno.
 * Seletor com button para vencer .game-list button (0-1-1), que senão
 * impõe width/height 100% e centraliza a estrela no meio do card. */
.game-list button.g-fav {
  position: absolute;
  top: 2px;
  right: 2px;
  /* width/height: auto anula o `100%` herdado de `.game-list button` (senão a
   * estrela ocupa o card inteiro e o glifo, centralizado, cai sobre a descrição).
   * min-* preserva o alvo de toque >=44px com o glifo pequeno. */
  width: auto;
  height: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  font-size: 1.05rem;
  color: var(--text-dim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.game-list button.g-fav.faved {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(69, 240, 199, 0.6);
}

.random-btn {
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--accent-2);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}
.random-btn:active {
  background: rgba(255, 61, 127, 0.18);
  box-shadow: 0 0 20px rgba(255, 61, 127, 0.6);
}

.random-btn.neon-pulse {
  animation: neon-pulse-btn 3s ease-in-out infinite;
}

@keyframes neon-pulse-btn {
  0%, 100% {
    border-color: var(--accent-2);
    box-shadow: 0 0 8px rgba(255, 61, 127, 0.4);
  }
  50% {
    border-color: var(--accent-2);
    box-shadow: 0 0 16px rgba(255, 61, 127, 0.8), 0 0 24px rgba(255, 61, 127, 0.3);
  }
}

.drawer-note {
  margin-top: 10px;
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.pix-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--surface-2);
}

.pix-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pix-btn {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(69, 240, 199, 0.08);
  color: var(--accent);
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pix-btn:active {
  background: rgba(69, 240, 199, 0.18);
  box-shadow: 0 0 12px rgba(69, 240, 199, 0.3);
}

.pix-code {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--surface-2);
}

.pix-code-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

#pix-code-text {
  display: block;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.3;
  margin-bottom: 8px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  overflow-x: auto;
}

.copy-btn {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  background: transparent;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-btn:active {
  background: rgba(255, 61, 127, 0.15);
}
/* Segundo botão de cópia (Pix de qualquer valor): respiro entre os dois. */
.copy-btn + .copy-btn { margin-top: 6px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 11, 0.55);
  z-index: 35;
  opacity: 0;
  transition: opacity 0.25s;
}
.overlay.show { opacity: 1; }

/* ---- Stage (game area) ---- */
.stage {
  position: fixed;
  top: calc(var(--topbar-h) + var(--safe-top));
  left: 0;
  right: 0;
  bottom: 0;
}
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Toast used by shell when switching games */
.game-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--surface-2);
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 14px;
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  max-width: 88vw;
  z-index: 20;
  pointer-events: none;
  animation: toast-fade 3.1s ease forwards;
}
.game-toast small {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--accent);
  line-height: 1.4;
}
@keyframes toast-fade {
  0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- Toques de identidade nos popups dos jogos (common.js) ----
 * Só propriedades que o CSS injetado não define: nada é sobrescrito. */
.ns-end-card { border: 1px solid rgba(69, 240, 199, 0.18); }
.ns-intro-name { font-family: var(--display); letter-spacing: 0.04em; }
.ns-end-score { font-family: var(--display); }
.ns-end-title { font-family: var(--mono); font-size: 0.8rem; }

/* ---- Acessibilidade: sem flicker para quem prefere calma ---- */
@media (prefers-reduced-motion: reduce) {
  .brand span::after,
  .drawer-tagline::after {
    animation: none;
  }
}
