/* ============================================================
   main.css — Nibbles Neon V2
   Fase 1: Glassmorphism, Temas, Transições, Trail, Shake, A11y
   ============================================================ */

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

/* ── Tipografia ────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=VT323&family=Press+Start+2P&display=swap');

/* ── Design Tokens (Tema padrão: Retrowave Neon) ───────────── */
:root {
  /* Cores canvas/jogo */
  --bg:          #000818;
  --grid:        #0A1A2A;
  --wall:        #CC2244;
  --wall-glow:   #FF3366;
  --p1-body:     #FFE84D;
  --p1-glow:     #FFFF00;
  --p1-head:     #FFFFFF;
  --p2-body:     #44FF88;
  --p2-glow:     #00FF66;
  --p2-head:     #CCFFDD;
  --number:      #FFFFFF;
  --number-glow: #00CCFF;

  /* HUD */
  --hud:         #00CCFF;
  --hud-dim:     rgba(0, 204, 255, 0.5);
  --hud-bg:      rgba(0, 20, 40, 0.7);
  --hud-border:  rgba(0, 204, 255, 0.2);

  /* Overlay glassmorphism */
  --overlay-bg:   rgba(0, 8, 24, 0.72);
  --glass-inner:  linear-gradient(135deg, rgba(0, 204, 255, 0.08) 0%, rgba(0, 8, 24, 0.6) 100%);
  --glass-border: rgba(0, 204, 255, 0.25);

  /* Textos overlay */
  --accent:      #00CCFF;
  --title:       #FFE84D;
  --title-glow:  rgba(255, 232, 77, 0.75);

  /* Tipografia */
  --font-hud:    'VT323', monospace;
  --font-title:  'Press Start 2P', monospace;

  /* Transição de tema */
  --theme-transition: 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* ── Transição global ao trocar tema ───────────────────────── */
.theme-transitioning,
.theme-transitioning * {
  transition:
    background-color var(--theme-transition),
    color            var(--theme-transition),
    border-color     var(--theme-transition),
    box-shadow       var(--theme-transition),
    text-shadow      var(--theme-transition) !important;
}

/* ── Base ──────────────────────────────────────────────────── */
html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  transition: background-color var(--theme-transition);
}

#game-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: center center;
}

/* ── HUD ───────────────────────────────────────────────────── */
#hud {
  width: 800px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-family: var(--font-hud);
  font-size: 22px;
  color: var(--hud);
  text-shadow: 0 0 8px var(--hud), 0 0 20px var(--hud);
  background: var(--hud-bg);
  border-bottom: 1px solid var(--hud-border);
  transition:
    color var(--theme-transition),
    background-color var(--theme-transition),
    border-color var(--theme-transition),
    text-shadow var(--theme-transition);
}

#hud .hud-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}

#hud .hud-label {
  color: var(--hud-dim);
  font-size: 16px;
}

#hud-powerup {
  min-width: 66px;
  text-align: left;
}

#hud-powerup.is-active {
  color: #FFE84D;
  text-shadow: 0 0 8px #FFE84D, 0 0 18px #FFE84D;
}

/* ── Theme switcher no HUD ─────────────────────────────────── */
#hud-theme-btn {
  background: none;
  border: 1px solid var(--hud-border);
  color: var(--hud-dim);
  font-family: var(--font-hud);
  font-size: 16px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: color 0.2s, border-color 0.2s;
}
#hud-theme-btn:hover {
  color: var(--hud);
  border-color: var(--hud);
}

.is-hidden { display: none !important; }

/* ── Canvas container ──────────────────────────────────────── */
#canvas-container {
  position: relative;
  width: 800px;
  height: 600px;
  overflow: hidden;

  /* B055 — Double-bezel glassmorphism */
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  box-shadow:
    0 0 0 3px rgba(0, 0, 0, 0.6),
    0 0 0 4px var(--glass-border),
    0 0 40px rgba(0, 204, 255, 0.12),
    0 0 80px rgba(0, 204, 255, 0.05),
    inset 0 0 60px rgba(0, 0, 20, 0.5);
  transition: box-shadow var(--theme-transition), border-color var(--theme-transition);
}

#game-canvas {
  display: block;
  width: 800px;
  height: 600px;
  image-rendering: pixelated;
}

/* ── B059 — Screen Shake ───────────────────────────────────── */
#canvas-container.is-shaking {
  animation: screen-shake 200ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes screen-shake {
  0%   { transform: translate(0, 0); }
  15%  { transform: translate(-5px, -3px) rotate(-0.5deg); }
  30%  { transform: translate(5px, 3px)  rotate(0.5deg); }
  45%  { transform: translate(-4px, 2px) rotate(-0.3deg); }
  60%  { transform: translate(4px, -2px) rotate(0.3deg); }
  75%  { transform: translate(-2px, 1px); }
  90%  { transform: translate(2px, -1px); }
  100% { transform: translate(0, 0); }
}

/* ── B055 — Screen Overlay Glassmorphism ───────────────────── */
#screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 36px;
  text-align: center;
  color: #fff;

  /* Glassmorphism */
  background: var(--overlay-bg);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);

  /* Dupla borda de vidro */
  border: 1px solid var(--glass-border);
  outline: 3px solid rgba(0, 0, 0, 0.4);
  outline-offset: -5px;

  /* Gradiente interno de vidro */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 80px rgba(0, 0, 0, 0.3);

  /* B056 — estado inicial para animação de entrada */
  opacity: 0;
  transform: translateY(12px);

  text-shadow: 0 0 12px rgba(0, 204, 255, 0.9);
}

/* ── B056 — Visibilidade com animação ──────────────────────── */
#screen-overlay.is-visible {
  display: flex;
  animation: overlay-enter 280ms cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

#screen-overlay.is-leaving {
  animation: overlay-leave 200ms cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

@keyframes overlay-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes overlay-leave {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ── Título do overlay ─────────────────────────────────────── */
.overlay-title {
  font-family: var(--font-title);
  font-size: 36px;
  line-height: 1.35;
  color: var(--title);
  text-shadow:
    0 0 10px var(--title),
    0 0 28px var(--title-glow);
  transition: color var(--theme-transition), text-shadow var(--theme-transition);
}

/* ── Corpo do overlay ──────────────────────────────────────── */
.overlay-body {
  max-width: 720px;
  font-family: var(--font-hud);
  font-size: 30px;
  line-height: 1.22;
  color: var(--accent);
  transition: color var(--theme-transition);
}

/* ── Grade de atalhos na tela de título (2 colunas) ─────────── */
.title-shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, auto);
  grid-template-rows: repeat(4, auto);
  grid-auto-flow: column;
  column-gap: 48px;
  row-gap: 2px;
  justify-content: center;
  justify-items: start;
  text-align: left;
  white-space: nowrap;
  margin: 6px 0;
}

/* ── Seletor de tema no overlay ────────────────────────────── */
.overlay-theme-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.theme-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.theme-dot:hover    { transform: scale(1.3); }
.theme-dot.is-active { box-shadow: 0 0 0 2px #fff, 0 0 8px currentColor; transform: scale(1.2); }
.theme-dot[data-theme="retrowave"] { background: #00CCFF; }
.theme-dot[data-theme="dosgreen"]  { background: #00CC00; }
.theme-dot[data-theme="cyberpunk"] { background: #FFAA00; }
.theme-dot[data-theme="doslight"]  { background: #1A1A8C; }

/* ── Seletor de idioma no overlay (pt-BR/en/es) ────────────── */
.overlay-lang-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.lang-flag {
  font-size: 20px;
  line-height: 1;
  padding: 2px;
  border-radius: 4px;
  cursor: pointer;
  filter: grayscale(0.7) brightness(0.75);
  transition: transform 0.15s, filter 0.15s;
}
.lang-flag:hover     { transform: scale(1.15); filter: grayscale(0.2) brightness(0.95); }
.lang-flag.is-active { filter: none; box-shadow: 0 0 0 2px var(--accent); transform: scale(1.1); }

/* ── B(refino) — Entrada de nome no hall da fama ───────────── */
#name-entry-input {
  display: block;
  margin: 10px auto;
  width: 150px;
  padding: 8px 12px;
  font-family: var(--font-title);
  font-size: 26px;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
  color: var(--title);
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--glass-border);
  border-radius: 6px;
  outline: none;
  text-shadow: 0 0 10px var(--title);
}
#name-entry-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent);
}

#name-entry-submit {
  display: block;
  margin: 14px auto 0;
  padding: 8px 28px;
  font-family: var(--font-hud);
  font-size: 20px;
  color: var(--hud);
  background: rgba(0, 204, 255, 0.08);
  border: 1px solid var(--hud-border);
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: color 0.15s, border-color 0.15s;
}
#name-entry-submit:hover,
#name-entry-submit:active {
  color: var(--title);
  border-color: var(--title);
}

/* ── CRT scanlines ─────────────────────────────────────────── */
#crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.08) 3px,
    rgba(0, 0, 0, 0.08) 4px
  );
  z-index: 10;
}

/* ── Vinheta ───────────────────────────────────────────────── */
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 10, 0.7) 100%);
  z-index: 11;
}

/* ── B072 — D-pad touch translúcido ────────────────────────── */
#touch-dpad {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 4px;
  touch-action: none;
}

.dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--hud-dim);
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: none;
  user-select: none;
}

.dpad-btn:active {
  color: var(--hud);
  border-color: var(--hud);
  background: rgba(0, 204, 255, 0.18);
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

/* ── B074 — Popup de conquista desbloqueada ────────────────── */
/* Ancorado ao canvas-container (não à janela) para acompanhar o jogo
   em qualquer tamanho/posição de viewport, sem cobrir a área de jogo. */
#achievement-toast {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  max-width: 240px;
  padding: 12px 16px;
  font-family: var(--font-hud);
  font-size: 20px;
  line-height: 1.3;
  color: var(--hud);
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(0, 204, 255, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
  transition: opacity 220ms cubic-bezier(0.32, 0.72, 0, 1), transform 220ms cubic-bezier(0.32, 0.72, 0, 1);
}

#achievement-toast strong {
  color: var(--title);
}

#achievement-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  #achievement-toast { transition: opacity 220ms linear; transform: none; }
}

/* ── Responsivo ────────────────────────────────────────────── */
@media (max-width: 860px)  { #game-wrapper { transform: scale(0.86); } }
@media (max-width: 700px)  { #game-wrapper { transform: scale(0.72); } }
@media (max-height: 680px) { #game-wrapper { transform: scale(0.82); } }
@media (max-height: 560px) { #game-wrapper { transform: scale(0.68); } }
/* B072 — telas de smartphone (portrait), abaixo dos breakpoints acima */
@media (max-width: 480px)  { #game-wrapper { transform: scale(0.46); } }

/* ── B059a — Acessibilidade: prefers-reduced-motion ───────── */
@media (prefers-reduced-motion: reduce) {
  /* Desativa animação de entrada/saída do overlay */
  #screen-overlay.is-visible  { animation: none; opacity: 1; transform: none; }
  #screen-overlay.is-leaving  { animation: none; }

  /* Desativa screen shake */
  #canvas-container.is-shaking { animation: none; }

  /* Desativa todas as transições de troca de tema */
  .theme-transitioning,
  .theme-transitioning * {
    transition: none !important;
  }

  /* Substitui o shake por um flash de borda */
  #canvas-container.is-shaking {
    box-shadow: 0 0 0 3px rgba(255, 50, 80, 0.8), 0 0 40px rgba(255, 50, 80, 0.4);
  }
}

/* ── Modal de Conversão Missangas Jane ────────────────────── */
.bead-modal {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 249, 246, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeInModal 0.25s ease-out forwards;
}

.bead-modal.is-hidden {
  display: none !important;
}

.bead-modal-card {
  background: #FFFFFF;
  border: 2px solid rgba(236, 72, 153, 0.25);
  border-radius: 24px;
  padding: 2rem 2.2rem;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(236, 72, 153, 0.15), 0 4px 12px rgba(0,0,0,0.05);
}

.bead-modal-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.bead-modal-title {
  font-family: 'Fredoka One', 'Nunito', sans-serif;
  font-size: 1.5rem;
  color: #BE185D;
  margin-bottom: 0.5rem;
}

.bead-modal-subtitle {
  font-family: 'Nunito', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #4B5563;
  margin-bottom: 0.5rem;
}

.bead-modal-subtitle strong {
  color: #EC4899;
  font-size: 1.25rem;
}

.bead-modal-text {
  font-family: 'Nunito', sans-serif;
  font-size: 0.92rem;
  color: #6B7280;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.bead-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bead-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: 14px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.bead-btn-primary {
  background: linear-gradient(135deg, #EC4899 0%, #D946EF 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.35);
}

.bead-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.5);
}

.bead-btn-secondary {
  background: #F3F4F6;
  color: #4B5563;
  border: 1px solid rgba(0,0,0,0.06);
}

.bead-btn-secondary:hover {
  background: #E5E7EB;
  color: #1F2937;
}

@keyframes fadeInModal {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}


