:root {
  --neon-cyan: #00ffff;
  --neon-magenta: #ff00ff;
  --neon-purple: #9d00ff;
  --deep-black: #05070a;
  --grid-color: rgba(0, 255, 255, 0.05);
  --glass: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --font-main: 'Inter', sans-serif;
  --font-logo: 'Orbitron', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background-color: var(--deep-black);
  color: white;
  font-family: var(--font-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Background Grid Effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: -1;
  pointer-events: none;
}

.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.4s ease, transform 0.4s ease;
  overflow-y: auto;
}

.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* --- LOGO & MENU --- */
.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 3.5rem;
  text-align: center;
}

.logo-text {
  font-family: var(--font-logo);
  font-size: clamp(3.5rem, 10vw, 6rem);
  font-weight: 900;
  letter-spacing: 0.4rem;
  margin-bottom: 0.5rem;
}

.logo-subtext {
  font-family: var(--font-logo);
  font-size: 0.9rem;
  letter-spacing: 0.6rem;
  color: var(--neon-magenta);
  text-transform: uppercase;
}

.neon-glow-text {
  color: white;
  text-shadow: 
    0 0 7px var(--neon-cyan),
    0 0 10px var(--neon-cyan),
    0 0 21px var(--neon-cyan),
    0 0 42px var(--neon-cyan);
}

.menu-options {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  max-width: 400px;
}

.btn {
  font-family: var(--font-logo);
  padding: 1.2rem 2.5rem;
  border: none;
  border-radius: 8px;
  background: var(--glass);
  color: white;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.15rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 1px solid var(--glass-border);
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.btn:hover {
  transform: translateY(-4px) scale(1.03);
  background: white;
  color: var(--deep-black);
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.5);
}

.primary-btn {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  color: white;
  border: none;
}

/* --- HUD --- */
.game-hud {
  position: absolute;
  top: 1.5rem;
  left: 2rem;
  right: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  pointer-events: none;
}

.score-container, .high-score-container, .room-indicator {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border-left: 3px solid var(--neon-cyan);
}

.hud-label {
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.7;
  letter-spacing: 0.1rem;
}

.hud-value {
  font-family: var(--font-logo);
  font-size: 1.5rem;
  font-weight: 900;
}

.neon-cyan { color: var(--neon-cyan); text-shadow: 0 0 10px var(--neon-cyan); }
.neon-magenta { color: var(--neon-magenta); text-shadow: 0 0 10px var(--neon-magenta); }

.hud-controls {
  display: flex;
  gap: 1rem;
  pointer-events: all;
  position: relative;
  z-index: 1000;
}

.pause-icon, .fs-btn, .quit-icon {
  background: rgba(10, 15, 25, 0.9);
  border: 1px solid var(--neon-cyan);
  color: white;
  font-family: var(--font-logo);
  font-size: 0.9rem; /* Slightly bigger for mobile */
  padding: 0 1.5rem;
  height: 48px;
  border-radius: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  font-weight: 900;
  letter-spacing: 0.1rem;
  text-shadow: 0 0 5px rgba(255,255,255,0.5);
}

.fs-btn {
  width: 44px;
}

.quit-icon:hover {
  background: rgba(255, 0, 0, 0.5);
  border-color: #ff0000;
  box-shadow: 0 0 15px #ff0000;
}

.fs-btn {
  font-size: 1.5rem;
}

/* --- GAME CANVAS AREA --- */
#canvas-wrapper {
  position: relative;
  background: var(--deep-black); 
  border: none; /* Borders will be drawn in Canvas for glow control */
  padding: 15px; /* Visual padding around the arena */
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 95vw;
  max-height: 85vh;
  box-shadow: 0 0 100px rgba(0, 0, 0, 0.9);
  border-radius: 12px;
}

canvas {
  image-rendering: pixelated; /* Manter precisão visual */
}

/* --- TOUCH CONTROLS --- */
.touch-controls {
  position: absolute;
  bottom: 2rem;
  width: 100%;
  display: none; /* Hidden by default, shown via Media Query on mobile */
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 20;
}

.touch-row {
  display: flex;
  gap: 1.5rem;
}

.touch-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 70px;
  height: 70px;
  border-radius: 12px;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  cursor: pointer;
  transition: all 0.1s ease;
}

.touch-btn:active {
  background: var(--neon-cyan);
  color: var(--deep-black);
  transform: scale(0.9);
  box-shadow: 0 0 20px var(--neon-cyan);
}

/* --- CHAT --- */
.chat-container {
  position: absolute;
  bottom: 1.5rem;
  left: 2rem;
  width: 250px;
  height: 200px;
  background: var(--glass);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  z-index: 100;
  pointer-events: all;
  backdrop-filter: blur(10px);
}

.chat-messages {
  flex: 1;
  padding: 0.5rem;
  overflow-y: auto;
  font-size: 0.8rem;
}

#chatInput {
  background: rgba(0,0,0,0.5);
  border: none;
  padding: 0.5rem;
  color: white;
  border-top: 1px solid var(--glass-border);
}

/* Premium Countdown Overlay */
.countdown-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  pointer-events: none;
}

.countdown-box {
  background: rgba(5, 7, 10, 0.85);
  border: 3px solid var(--neon-cyan);
  box-shadow: 0 0 40px rgba(0, 255, 255, 0.4);
  padding: 2.5rem 4rem;
  border-radius: 20px;
  backdrop-filter: blur(15px);
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 180px;
  min-height: 180px;
  transition: all 0.3s ease;
}

#countdownText {
  font-size: 7rem;
  margin: 0;
  line-height: 1;
}

@keyframes shadowPulse {
  0% { transform: scale(1.1); text-shadow: 0 0 10px var(--neon-cyan); }
  50% { transform: scale(1.3); text-shadow: 0 0 30px var(--neon-cyan), 0 0 50px var(--neon-cyan); }
  100% { transform: scale(1.1); text-shadow: 0 0 10px var(--neon-cyan); }
}

.shadow-pulse {
  animation: shadowPulse 0.5s infinite ease-in-out;
}

/* Replaces old countdown-num */
.countdown-num { display: none; }

/* Game Overlays (Level Up, etc.) */
.game-overlay-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-logo);
  font-size: 2.5rem;
  font-weight: 900;
  text-align: center;
  z-index: 30;
  pointer-events: none;
  width: 100%;
  opacity: 0;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.game-overlay-text.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

/* --- OVERLAYS & MODALS --- */
.backdrop-blur {
  backdrop-filter: blur(15px);
  background: rgba(0, 0, 0, 0.7);
}

.game-over-panel {
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.final-stats {
  display: flex;
  gap: 2rem;
  margin: 2rem 0;
  justify-content: center;
}

.stat-item span {
  font-size: 0.8rem;
  opacity: 0.7;
  display: block;
}

.modal {
  z-index: 1000;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--deep-black);
  padding: 3rem;
  max-width: 600px;
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 50px rgba(0, 255, 255, 0.2);
  position: relative;
  border-radius: 12px;
}

.close-modal {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  cursor: pointer;
  color: var(--neon-magenta);
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}

.help-item h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--neon-cyan);
}

.help-item p {
  font-size: 0.8rem;
  opacity: 0.8;
  line-height: 1.4;
}

/* --- ANIMATIONS --- */
@keyframes pulsate {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

.pulsate { animation: pulsate 2s infinite ease-in-out; }

@keyframes shake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake { animation: shake 0.5s infinite; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .logo-text { font-size: 3.5rem; letter-spacing: 0.2rem; }
  .menu-options { max-width: 300px; }
  .help-grid { grid-template-columns: 1fr; }
  .game-hud { top: 0.5rem; left: 0.5rem; right: 0.5rem; }
  .hud-value { font-size: 1rem; }
  .score-container, .high-score-container { padding: 0.4rem 0.8rem; }
  .hud-controls { gap: 0.5rem; }
  .quit-icon { padding: 0 1rem; height: 40px; }

  #gameScreen {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding-top: 0 !important;
  }

  /* Garantir que os controles de toque apareçam apenas durante o jogo */
  .touch-controls {
    display: flex !important;
    bottom: 0.5rem !important;
  }
}
