/* ============================================================
   style.css — Estilos do jogo
   Canvas centralizado, overlays, controles mobile
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  /* Fallback para browsers sem suporte a dvh */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #0F172A;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  /* Previne qualquer scroll ou zoom no mobile */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

/* --- Layout Container --- */
#gameContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  /* Fallback + unidade moderna */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}

/* --- Rotação Automática para Modo Paisagem no Mobile Retrato --- */
@media (max-width: 900px) and (orientation: portrait) {
  #gameContainer {
    width: 100vh;
    width: 100dvh;
    height: 100vw;
    height: 100dvw;
    top: 0;
    left: 100vw;
    left: 100dvw;
    transform: rotate(90deg);
    transform-origin: 0 0;
  }
}

/* --- Canvas --- */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #87CEEB;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 1;
  touch-action: none;
}

/* --- Gaveta Retrátil de Fullscreen (sinalizada por seta) --- */
.fs-drawer {
  position: fixed;
  top: 14px;
  right: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  transform: translateX(calc(100% - 24px));
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  -webkit-user-select: none;
}

.fs-drawer:hover,
.fs-drawer.open,
.fs-drawer:focus-within {
  transform: translateX(0);
}

.fs-drawer-arrow {
  width: 24px;
  height: 38px;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(245, 158, 11, 0.7);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: #F59E0B;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.4);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  padding: 0;
  outline: none;
}

.fs-drawer-arrow:hover {
  background: rgba(245, 158, 11, 0.2);
  color: #FDE047;
  border-color: #FDE047;
}

.fs-arrow-icon {
  display: inline-block;
  transition: transform 0.25s ease;
  animation: pulse-arrow 1.8s ease-in-out infinite;
}

.fs-drawer:hover .fs-arrow-icon,
.fs-drawer.open .fs-arrow-icon {
  transform: rotate(180deg);
  animation: none;
}

@keyframes pulse-arrow {
  0%, 100% {
    transform: translateX(0);
    opacity: 0.8;
  }
  50% {
    transform: translateX(-3px);
    opacity: 1;
    text-shadow: 0 0 6px #F59E0B;
  }
}

.fs-drawer-content {
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(245, 158, 11, 0.7);
  border-left: none;
  border-radius: 0 0 0 10px;
  padding: 4px 8px 4px 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
}

#btnFullscreen {
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.9);
  color: #E2E8F0;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 1;
}

#btnFullscreen:hover {
  background: rgba(59, 130, 246, 0.5);
  border-color: rgba(59, 130, 246, 0.8);
  color: #FFFFFF;
}

#btnFullscreen:active {
  transform: scale(0.92);
  background: rgba(59, 130, 246, 0.7);
}

/* Ícone muda quando está em fullscreen */
#btnFullscreen .fs-icon-expand { display: inline; }
#btnFullscreen .fs-icon-compress { display: none; }

:fullscreen #btnFullscreen .fs-icon-expand,
:-webkit-full-screen #btnFullscreen .fs-icon-expand {
  display: none;
}
:fullscreen #btnFullscreen .fs-icon-compress,
:-webkit-full-screen #btnFullscreen .fs-icon-compress {
  display: inline;
}

/* --- Mobile Controls --- */
#mobileControls {
  display: none;
  position: fixed;
  bottom: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  padding: 0 20px;
  z-index: 100;
  justify-content: space-between;
  align-items: flex-end;
  touch-action: none;
}

@media (max-width: 768px), (pointer: coarse) {
  #mobileControls {
    display: flex;
  }
}

.ctrl-group {
  display: flex;
  gap: 10px;
}

.ctrl-btn {
  width: 60px;
  height: 60px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.85);
  color: #E2E8F0;
  font-family: 'Press Start 2P', monospace;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* Crítico: impede gestos nativos do browser nos botões */
  touch-action: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.1s, transform 0.1s;
}

.ctrl-btn:active {
  background: rgba(59, 130, 246, 0.7);
  transform: scale(0.92);
}

.ctrl-btn-jump {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  font-size: 14px;
  background: rgba(34, 197, 94, 0.6);
  border-color: rgba(34, 197, 94, 0.5);
}

.ctrl-btn-jump:active {
  background: rgba(34, 197, 94, 0.9);
}

/* --- Botão Mobile de Pular Mensagem --- */
#btnSkipDialog {
  display: none;
  position: fixed;
  bottom: 150px;
  bottom: calc(158px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  z-index: 120;
  padding: 10px 16px;
  min-height: 44px;
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #F59E0B;
  border-radius: 12px;
  color: #FDE047;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.45), 0 4px 12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s, border-color 0.15s;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#btnSkipDialog .skip-arrow {
  font-size: 26px;
  display: inline-block;
  transition: transform 0.2s ease;
}

@media (max-width: 768px), (pointer: coarse) {
  #btnSkipDialog.visible {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    animation: pulse-skip-btn 1.4s ease-in-out infinite;
  }
}

#btnSkipDialog:active {
  transform: scale(0.92) !important;
  background: rgba(245, 158, 11, 0.35);
  border-color: #FDE047;
  color: #FFFFFF;
}

#btnSkipDialog:active .skip-arrow {
  transform: translateX(2px);
}

@keyframes pulse-skip-btn {
  0%, 100% {
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.4), 0 4px 10px rgba(0, 0, 0, 0.5);
    border-color: #F59E0B;
  }
  50% {
    box-shadow: 0 0 22px rgba(245, 158, 11, 0.8), 0 4px 14px rgba(0, 0, 0, 0.6);
    border-color: #FDE047;
  }
}

/* --- Loading / Title styling --- */
#loadingOverlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0F172A;
  color: #E2E8F0;
  font-size: 14px;
  z-index: 200;
  transition: opacity 0.5s;
}

#loadingOverlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #334155;
  border-top-color: #3B82F6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Footer info --- */
#gameInfo {
  color: #64748B;
  font-size: 8px;
  position: absolute;
  top: 50px;
  left: 12px;
  text-align: center;
  z-index: 10;
  pointer-events: none;
}
