body {
  margin: 0;
  overflow: hidden;
  background-color: #000;
  width: 100%;
  height: 100%;
}

/* Opcional: Para WebKit browsers mais antigos */
@supports (-webkit-overflow-scrolling: touch) {
  body {
      -webkit-overflow-scrolling: auto;
  }
}

/* Adicione isso no início do seu CSS */
html, body {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -webkit-overflow-scrolling: auto !important;
  overscroll-behavior: none;
}

/* Aplicar para todos os elementos */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Exceção para inputs e textareas (se necessário) */
input, textarea {
  -webkit-user-select: auto;
  user-select: auto;
}

canvas {
  display: block;
  position: absolute; /* Garante que o canvas fique na camada base */
  transform: translate3d(0,0,0);
  backface-visibility: hidden;
  perspective: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1; /* Canvas fica abaixo da UI */
}

.menu-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('BG.jpg') no-repeat top center fixed;
  background-size: cover;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.menu-content {
  text-align: center;
  background: rgba(0, 0, 0, 0.9);
  padding: 30px;
  width: 500px;
  border-radius: 10px;
  color: #fff;
  font-family: Arial, sans-serif;
}

.menu-content h1 {
  font-size: 36px;
  margin-bottom: 20px;
  margin-top: 0;
}

.menu-content h2 {
  font-size: 16px;
  margin-bottom: 20px;
}

.menu-content h3 {
  font-size: 20px;
  margin-bottom: 20px;
  line-height:26px;
}

.menu-content h4 {
  font-size: 18px;
  margin-bottom: 20px;
  font-weight: 400;
  line-height: 32px;
  color: rgba(255, 255, 255, 0.7);
}

#pilot-name {
  padding: 15px;
  font-size: 20px;
  width: 92%;
  letter-spacing: 1px;
  margin-bottom: 20px;
  border: 1px solid rgba(105, 105, 105, 0.4);
  border-radius: 5px;
  background: rgba(105, 105, 105, 0.4);
  color: #fff;
}

#start-engine-btn {
  touch-action: manipulation; /* Melhora a resposta tátil */
  user-select: none; /* Previne seleção de texto */
  padding: 15px 30px;
  pointer-events: auto;
  width: 100%;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  background: #468F42;
  border: none;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 10;
}

#start-engine-btn:hover {
  transform: scale(1.02);
}

.mobile-controls {
  display: none;
}

/* Estilo para o aviso de trapaça */
#cheat-warning {
  animation: shake 0.5s ease-in-out;
  z-index: 10;
}

@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
  20% { transform: translate(-50%, -50%) rotate(5deg); }
  40% { transform: translate(-50%, -50%) rotate(-5deg); }
  60% { transform: translate(-50%, -50%) rotate(5deg); }
  80% { transform: translate(-50%, -50%) rotate(-5deg); }
}

#game-screen {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden; /* Evita que o conteúdo transborde */
}

#timer-container {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px;
  border-radius: 5px;
  color: white;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10; /* Acima do canvas */
}

#current-lap-time, #last-lap-time, #best-lap-time {
  font-weight: bold;
  min-width: 100px;
  display: inline-block;
  color: #fff;
}

#current-lap-time, #last-lap-time, #best-lap-time {
  font-weight: bold;
  min-width: 100px; /* Garante espaço para o texto */
  display: inline-block;
}

#world-record-container {
  position: absolute;
  top: 100px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px;
  border-radius: 5px;
  color: white;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10;
}

#world-record-pilot {
  font-weight: bold;
  color: gold;
}

#world-record-time {
  font-weight: bold;
  color: gold;
}

#leaderboard {
  position: absolute;
  top: 166px;
  left: 10px;
  font-size: 16px;
  background: rgba(0,0,0,0.7);
  padding: 10px;
  border-radius: 5px;
  font-family: 'Courier New', Courier, monospace;
  color: white;
  z-index: 10;
}

.leaderboard-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
  z-index: 10;
}

.leaderboard-list li {
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  z-index: 10;
}

.pilot-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
}

.pilot-position {
  color: gold;
  margin-right: 10px;
  min-width: 30px;
}

.pilot-name {
  flex-grow: 1;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  z-index: 10;
}

.pilot-time {
  color: #00ccff;
  margin-left: 10px;
  z-index: 10;
}

/* Estilizar os rótulos */
#timer-container div {
  display: flex;
  justify-content: space-between;
  min-width: 200px;
}

/* Garantir visibilidade */
#timer-container span {
  color: #fff;
}

/* Estilos do Dashboard de Corrida */
.racing-dashboard {
  display: block;
  position: absolute;
  bottom: 30px;
  right: 30px;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #2a2a2a;
  border-radius: 50%;
  padding: 20px;
  font-family: 'Segment7', sans-serif;
  color: #FFFFFF;
  text-shadow: 0 0 10px #FFFFFF;
  min-width: 200px;
  min-height: 200px;
  opacity:1;
  z-index: 20;
}

.rpm-gauge {
  position: relative;
  margin-top: 16%;
  margin-left: 5%;
  height: 24px;
  width: 90%;
  background: rgba(50, 50, 50, 0.8);
  border-radius: 5px;
  margin-bottom: 15px;
  overflow: hidden;
}

.rpm-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ff00 0%, #ff0000 100%);
  transition: width 0.1s linear;
  font-family: arial;
}

.rpm-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-size: 14px;
  font-family: Arial, sans-serif;
}

.gear-display {
  font-size: 40px;
  text-align: center;
  color: #00ffff;
  text-shadow: 0 0 15px #00ffff;
  margin: 10px 0;
}

.speed-display {
  text-align: center;
  position: relative;
  margin-right: 12%;
}

.speed-number {
  font-size: 62px;
  letter-spacing: -2px;
  margin-right: 5px;
}

.speed-unit {
  font-size: 18px;
  color: #ffffff;
  position: absolute;
  bottom: 12px;
  font-family: Arial, sans-serif;
}

/* Animação de troca de marcha */
@keyframes gearShift {
  0% { transform: scale(1); }
  50% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

/* Fonte digital */
@font-face {
  font-family: 'Segment7';
  src: url('/assets/fonts/G7_Segment_7a.woff') format('woff');
  font-weight: 500;
  font-style: normal;
}

/* Mini Mapa */
.map-container {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 200px;
  height: 200px;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #ffffff;
  border-radius: 8px;
  overflow: hidden;
  z-index: 100;
}

.map-viewport {
  width: 100%;
  height: 100%;
}

.game-screen {
  position: relative;
  width: 100%;
  height: 100%;
}

.start-animation {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5); /* Começa pequeno */
  color: #ffffff; /* Vermelho vibrante */
  font-family: 'Courier New', Courier, monospace;
  font-size: 72px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.6); /* Sombra para destacar */
  opacity: 0; /* Começa invisível */
  filter: blur(5px); /* Começa desfocado */
  z-index: 1000; /* Aumentado para garantir que fique acima de tudo */
  pointer-events: none; /* Não interfere com cliques */
  display: block; /* Garante que não seja afetado por display: none inicial */
}

/* Animação (mantém como está) */
@keyframes letsGo {
  0% {
      transform: translate(-50%, -50%) scale(0.5);
      opacity: 0;
      filter: blur(5px);
  }
  20% {
      transform: translate(-50%, -50%) scale(1.2); /* Overshoot para "pop" */
      opacity: 1;
      filter: blur(0);
  }
  40% {
      transform: translate(-50%, -50%) scale(1); /* Volta ao tamanho normal */
      opacity: 1;
      filter: blur(0);
  }
  80% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
      filter: blur(0);
  }
  100% {
      transform: translate(-50%, -50%) scale(0.8);
      opacity: 0;
      filter: blur(3px);
  }
}

/* Aplicar a animação quando ativada (mantém como está) */
.start-animation.active {
  animation: letsGo 2s ease-in-out forwards;
}




/* Dispositivos móveis */
@media (max-width: 768px) {

.gear-display {
    margin: 0px 0;
}

.speed-display {
  margin-right: 20%;
}

.mobile-controls button {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    transition: transform 0.2s, opacity 0.2s;
    color: rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Previne o highlight ao segurar */
.mobile-controls button:active {
    -webkit-tap-highlight-color: transparent;
    transform: scale(0.9);
    opacity: 0.6;
}

.mobile-controls button * {
    pointer-events: none;
}

.menu-content {
  width: 80%;
}

.menu-content h1 {
  font-size: 32px;
  margin-bottom: 20px;
}

.menu-content h2 {
  font-size: 14px;
  margin-bottom: 20px;
  text-wrap: balance;
}

.menu-content h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

.menu-content h4 {
  display: none;
}

.racing-dashboard {
    top: -20px;
    right: -20px;
    bottom: auto;
    min-width: 186px;
    min-height: 186px;
    padding: 10px;
    transform: scale(0.7);
}

#pilot-name {
  padding: 15px;
  font-size: 20px;
  width: 90%;
  letter-spacing: 1px;
  margin-bottom: 20px;
  border: 1px solid rgba(105, 105, 105, 0.4);
  border-radius: 5px;
  background: rgba(105, 105, 105, 0.4);
  color: #fff;
}

#start-engine-btn {
  padding: 15px 30px;
  width: 100%;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  background: #468F42;
  border: none;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s;
}

/* Garante que os botões não apareçam em hover */
@media (hover: hover) {
  .mobile-controls button:hover {
      background: rgba(0,0,0,0.7) !important;
  }
}

#timer-container {
  padding: 4px;
  font-size: 12px;
}

#world-record-container {
  top: 80px;
  font-size: 12px;
}

#leaderboard {
  top: 142px;
  font-size: 12px;
  display: none;
}

/* Mapa reduzido */
.map-container {
    top: -20px;
    left: -20px;
    right: auto;
    transform: scale(0.7);
    display: none;
}

.start-animation {
  transform: translate(-50%, -50%) scale(0.5); /* Começa pequeno */
  font-size: 34px;
}

/* controles */
.mobile-controls {
  position: fixed;
  bottom: 10px;
  width: 95%;
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
  z-index: 100;
}

.btn-accelerate, .btn-brake {
  width: 40%;
  height: 110px;
  border-radius: 12px;
  font-size: 14px;
  touch-action: manipulation;
  transition: all 0.1s ease; /* Reduced from 0.2s for snappier response */
}

.btn-accelerate {
  border: none;
  background: linear-gradient(135deg, rgba(91, 255, 25, 0.8), rgba(0, 180, 50, 0.5));
  box-shadow: 0 0 10px rgba(91, 255, 25, 0.5);
}

.btn-brake {
  border: none;
  background: linear-gradient(135deg, rgba(255, 25, 25, 0.8), rgba(180, 0, 0, 0.5));
  box-shadow: 0 0 10px rgba(255, 25, 25, 0.5);
}

.btn-left, .btn-right {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(150, 150, 150, 0.1));
  color: #fff;
  font-size: 30px;
  touch-action: manipulation;
  transition: all 0.1s ease; /* Faster transition */
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.btn-accelerate:active {
  transform: scale(0.95);
  background: linear-gradient(135deg, rgba(91, 255, 25, 1), rgba(0, 180, 50, 0.7));
  box-shadow: 0 0 15px rgba(91, 255, 25, 0.8);
  transition: all 0s; /* Instant change on press */
}

.btn-brake:active {
  transform: scale(0.95);
  background: linear-gradient(135deg, rgba(255, 25, 25, 1), rgba(180, 0, 0, 0.7));
  box-shadow: 0 0 15px rgba(255, 25, 25, 0.8);
  transition: all 0s; /* Instant change on press */
}

.btn-left:active, .btn-right:active {
  transform: scale(0.95);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.5), rgba(150, 150, 150, 0.2));
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
  transition: all 0s; /* Instant change on press */
}

.left-controls {
  display: flex;
  gap: 15px;
  width: 50%;
}

.right-controls {
  display: flex;
  gap: 15px;
  align-items: baseline;
}
}
