/* ==========================================================================
   Égua Mano! Gamer - Controles Virtuais Touch (Mobile & Tablet)
   Clean Architecture: Interface Virtual Estilo NES Retrô (8-bit)
   ========================================================================== */

/* Container de Controles Touch */
#touch-controls {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
}

/* Ativação em telas com toque ou largura reduzida */
@media (hover: none) and (pointer: coarse), (max-width: 960px) {
  #touch-controls {
    display: block;
  }
  #controls-bar {
    display: none;
  }
  #trivia-bar {
    bottom: auto;
    top: 8px;
    padding: 4px 10px;
    max-width: calc(100vw - 110px);
    gap: 6px;
  }
  .trivia-badge {
    font-size: 10px;
    padding: 1px 6px;
  }
  #trivia-text {
    font-size: 11px;
    max-width: 200px;
  }
}

/* Calibragem precisa para modo Retrato (Portrait) no celular */
@media (orientation: portrait), (max-width: 600px) {
  #trivia-bar {
    top: 8px;
    left: 8px;
    transform: none;
    max-width: calc(100vw - 105px);
    padding: 3px 8px;
  }
  #trivia-text {
    font-size: 10px;
    max-width: 170px;
  }
  .touch-top-bar {
    top: 8px;
    right: 8px;
  }
  .touch-btn-top {
    padding: 5px 10px;
    font-size: 10px;
  }

  /* Redimensionamento e ancoragem dos controles no rodapé sem amontoamento */
  .nes-dpad-container {
    bottom: 12px;
    left: 8px;
    transform: scale(0.8);
    transform-origin: bottom left;
  }
  .nes-action-panel {
    bottom: 12px;
    right: 8px;
    transform: scale(0.8);
    transform-origin: bottom right;
    gap: 8px;
    padding: 6px 10px;
  }
  .nes-center-panel {
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%) scale(0.72);
    gap: 12px;
    padding: 4px 8px;
  }
}

/* ==========================================================================
   1. D-PAD NES (Cruz Direcional Clássica com Suporte a Deslize)
   ========================================================================== */
.nes-dpad-container {
  position: absolute;
  bottom: 20px;
  left: 18px;
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nes-dpad-cross {
  position: relative;
  width: 132px;
  height: 132px;
  background: rgba(18, 20, 26, 0.82);
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7), inset 0 0 12px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.nes-dpad-arm {
  position: absolute;
  background: linear-gradient(135deg, #2b2d35, #1a1b20);
  border: 1.5px solid #3f424e;
  color: #94a3b8;
  font-size: 18px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 0.06s, transform 0.06s, color 0.06s;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.nes-dpad-arm:active, .nes-dpad-arm.active {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #000;
  border-color: #fef08a;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 12px rgba(234, 179, 8, 0.6);
  transform: scale(0.95);
}

.nes-dpad-up {
  top: 4px;
  left: 45px;
  width: 42px;
  height: 44px;
  border-radius: 8px 8px 0 0;
  border-bottom: none;
}

.nes-dpad-down {
  bottom: 4px;
  left: 45px;
  width: 42px;
  height: 44px;
  border-radius: 0 0 8px 8px;
  border-top: none;
}

.nes-dpad-left {
  top: 45px;
  left: 4px;
  width: 44px;
  height: 42px;
  border-radius: 8px 0 0 8px;
  border-right: none;
}

.nes-dpad-right {
  top: 45px;
  right: 4px;
  width: 44px;
  height: 42px;
  border-radius: 0 8px 8px 0;
  border-left: none;
}

.nes-dpad-center {
  position: absolute;
  top: 45px;
  left: 45px;
  width: 42px;
  height: 42px;
  background: #1f2026;
  border: 1px solid #2d3039;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nes-dpad-center::after {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #15161a;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 1px 1px rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   2. BOTÕES CENTRAIS SELECT & START (Pílulas Inclinadas Clássicas)
   ========================================================================== */
.nes-center-panel {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 6px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.nes-pill-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.nes-pill-btn {
  width: 44px;
  height: 14px;
  background: #334155;
  border: 1.5px solid #475569;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  transition: transform 0.08s, background 0.08s;
  transform: rotate(-25deg);
}

.nes-pill-btn:active, .nes-pill-btn.active {
  background: #facc15;
  border-color: #fef08a;
  transform: rotate(-25deg) scale(0.92);
  box-shadow: 0 0 8px #facc15;
}

.nes-pill-text {
  font-size: 8px;
  font-weight: bold;
  color: #94a3b8;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ==========================================================================
   3. BOTÕES DE AÇÃO NES (B e A Inclinados em Vermelho Nintendo)
   ========================================================================== */
.nes-action-panel {
  position: absolute;
  bottom: 18px;
  right: 18px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  pointer-events: auto;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.72);
  border-radius: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
}

.nes-btn-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nes-round-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ef4444, #b91c1c 70%, #7f1d1d);
  border: 2px solid #f87171;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.7), inset 0 2px 4px rgba(255, 255, 255, 0.4), inset 0 -3px 6px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.06s ease, filter 0.06s ease;
}

.nes-btn-b {
  margin-bottom: 2px;
}

.nes-btn-a {
  margin-bottom: 18px; /* Elevação diagonal clássica do botão A no NES */
}

.nes-round-btn:active, .nes-round-btn.active {
  transform: scale(0.92);
  filter: brightness(1.25);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8), inset 0 3px 6px rgba(0, 0, 0, 0.8), 0 0 14px #ef4444;
  border-color: #ffffff;
}

.nes-btn-letter {
  font-size: 24px;
  font-weight: 900;
  font-style: italic;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.nes-btn-action-label {
  font-size: 9px;
  font-weight: 800;
  color: #facc15;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px #000;
}

/* ==========================================================================
   4. BARRA SUPERIOR DE PAUSA
   ========================================================================== */
.touch-top-bar {
  position: absolute;
  top: 14px;
  right: 16px;
  pointer-events: auto;
}

.touch-btn-top {
  background: rgba(15, 23, 42, 0.82);
  border: 1.5px solid rgba(250, 204, 21, 0.75);
  border-radius: 16px;
  color: #facc15;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  touch-action: none;
}

.touch-btn-top:active, .touch-btn-top.active {
  background: rgba(250, 204, 21, 0.35);
  transform: scale(0.94);
}

