/* ==========================================================================
   DECLARAÇÃO DE FONTES CUSTOMIZADAS (LOCAL / OFFLINE)
   ========================================================================== */
@font-face {
  font-family: 'Faster One';
  src: url('../fonts/FasterOne-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Russo One';
  src: url('../fonts/RussoOne-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-racing: 'Faster One', cursive, sans-serif;
  --font-main: 'Russo One', sans-serif;
  --font-body: 'Russo One', 'Segoe UI', Roboto, sans-serif;

  --bg-dark: rgba(10, 14, 23, 0.86);
  --bg-panel: rgba(16, 22, 36, 0.78);
  --accent: #00f0ff;
  --accent-hot: #ff2a5f;
  --accent-gold: #ffcc00;
  --accent-green: #00e676;
  --text-main: #f4f7fb;
  --text-dim: #94a3b8;
  --border-glow: rgba(0, 240, 255, 0.35);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #070a10;
  font-family: var(--font-main);
  color: var(--text-main);
}

#game-canvas-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

canvas {
  display: block;
}

/* Canvas de Confeitos Rápidos (Modo Contra o Relógio) */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 22;
  pointer-events: none;
}

/* Anúncio Didático de Volta no Centro da Tela */
#lap-feedback-overlay {
  position: fixed;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 21;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
  min-width: 320px;
  max-width: 90vw;
}

#lap-feedback-overlay.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.lap-feedback-card {
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(10px);
  border: 2px solid var(--accent-green);
  border-radius: 14px;
  padding: 14px 26px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.lap-feedback-card.faster {
  border-color: var(--accent-green);
  box-shadow: 0 0 28px rgba(0, 230, 118, 0.45), 0 14px 36px rgba(0, 0, 0, 0.75);
}

.lap-feedback-card.tied {
  border-color: var(--accent-gold);
  box-shadow: 0 0 28px rgba(255, 204, 0, 0.45), 0 14px 36px rgba(0, 0, 0, 0.75);
}

.lap-feedback-card.slower {
  border-color: var(--accent-hot);
  box-shadow: 0 0 28px rgba(255, 42, 95, 0.45), 0 14px 36px rgba(0, 0, 0, 0.75);
}

.lap-feedback-title {
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.lap-feedback-time {
  font-family: var(--font-racing);
  font-size: 42px;
  font-weight: 400;
  letter-spacing: 2px;
  line-height: 1.1;
  text-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
}

.lap-feedback-status {
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
}

/* Divisor de Tela para o Modo X1 */
#split-divider {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--accent) 0%, rgba(255, 255, 255, 0.35) 50%, var(--accent-hot) 100%);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
  z-index: 4;
  pointer-events: none;
  display: none;
}

#split-divider.visible {
  display: block;
}

/* Speed Lines Overlay */
#speed-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background: radial-gradient(circle at center, transparent 52%, rgba(0, 240, 255, 0.18) 88%, rgba(0, 140, 255, 0.38) 100%);
  transition: opacity 0.15s ease-out;
}

/* Notificação Flutuante (usada apenas fora da corrida ativa) */
#capture-toast {
  position: fixed;
  top: 86px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 25;
  background: rgba(10, 14, 23, 0.92);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#capture-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Indicador Discreto de Gravação Ativa */
#rec-indicator {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(255, 42, 95, 0.22);
  border: 1px solid var(--accent-hot);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.4px;
  color: #ffffff;
  box-shadow: 0 0 16px rgba(255, 42, 95, 0.5);
  pointer-events: none;
}

#rec-indicator.active {
  display: flex;
}

.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-hot);
  animation: recBlink 0.8s infinite alternate;
}

@keyframes recBlink {
  from { opacity: 0.25; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

/* Countdown Banner */
#countdown-overlay {
  position: fixed;
  top: 36%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  pointer-events: none;
  text-align: center;
}

#countdown-text {
  font-family: var(--font-racing);
  font-size: 84px;
  font-weight: 400;
  letter-spacing: 4px;
  text-shadow: 0 0 35px rgba(0, 240, 255, 0.8), 0 6px 22px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#countdown-text.show {
  opacity: 1;
  transform: scale(1);
}

/* ==========================================================================
   TELA DE CARREGAMENTO IMERSIVA DKT RACING (LOADING SCREEN AAA)
   ========================================================================== */
.loading-screen-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background-color: #050811;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.65s ease;
}

.loading-bg-layer {
  position: absolute;
  inset: 0;
  background-image: url('../img/loading-bg.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transform: scale(1.03);
  animation: loadingBgZoom 12s ease-out forwards;
  z-index: 0;
}

@keyframes loadingBgZoom {
  from { transform: scale(1.04); }
  to { transform: scale(1.0); }
}

.loading-vignette-layer {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 48%, rgba(5, 10, 20, 0.28) 0%, rgba(4, 8, 16, 0.72) 70%, rgba(2, 5, 12, 0.92) 100%),
    linear-gradient(180deg, rgba(4, 7, 15, 0.45) 0%, rgba(4, 8, 18, 0.18) 45%, rgba(3, 6, 14, 0.82) 100%);
  z-index: 1;
  pointer-events: none;
}

.loading-screen-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-screen-content {
  position: relative;
  z-index: 2;
  width: 92%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.loading-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.loading-logo-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.loading-logo-img {
  width: 100%;
  max-width: 350px;
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 28px rgba(0, 240, 255, 0.4));
  animation: logoFloat 3s ease-in-out infinite alternate;
}

@keyframes logoFloat {
  0% { transform: translateY(0) scale(1); filter: drop-shadow(0 8px 24px rgba(0, 240, 255, 0.35)); }
  100% { transform: translateY(-4px) scale(1.02); filter: drop-shadow(0 12px 32px rgba(0, 240, 255, 0.58)); }
}

@media (max-width: 680px) {
  .loading-logo-img {
    max-width: 250px;
  }
}

.loading-badge {
  display: inline-block;
  padding: 5px 18px;
  background: rgba(6, 22, 36, 0.78);
  border: 1.5px solid rgba(0, 240, 255, 0.45);
  border-radius: 999px;
  font-family: var(--font-main);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1.8px;
  color: var(--accent);
  text-transform: uppercase;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.25), inset 0 0 10px rgba(0, 240, 255, 0.12);
}

/* Barra de Progresso Estilo Tacômetro Segmentado Esportivo */
.loading-bar-wrapper {
  width: 100%;
  max-width: 650px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.loading-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.loading-status-text {
  font-family: 'Segoe UI', Roboto, sans-serif;
  color: #e2e8f0;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 82%;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

.loading-percentage {
  font-family: var(--font-main);
  color: var(--accent);
  font-weight: 900;
  min-width: 46px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.55);
}

.loading-bar-track {
  width: 100%;
  height: 28px;
  padding: 3px;
  background: rgba(8, 15, 28, 0.88);
  border: 1.5px solid rgba(148, 163, 184, 0.42);
  border-top-color: rgba(255, 42, 95, 0.55);
  border-bottom-color: rgba(0, 240, 255, 0.55);
  border-radius: 5px;
  transform: skewX(-18deg);
  overflow: hidden;
  position: relative;
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.75),
    0 0 18px rgba(0, 240, 255, 0.18),
    inset 0 2px 6px rgba(0, 0, 0, 0.85);
}

/* Grade de gomos apagados no fundo do trilho */
.loading-bar-track::before {
  content: '';
  position: absolute;
  inset: 3px;
  background: repeating-linear-gradient(
    90deg,
    rgba(30, 58, 95, 0.35) 0px,
    rgba(30, 58, 95, 0.35) 16px,
    rgba(5, 10, 20, 0.85) 16px,
    rgba(5, 10, 20, 0.85) 21px
  );
  border-radius: 2px;
  pointer-events: none;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  transition: width 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
  /* Gomos iluminados em degradê azul -> ciano neon */
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 16px,
      rgba(6, 12, 24, 0.92) 16px,
      rgba(6, 12, 24, 0.92) 21px
    ),
    linear-gradient(90deg, #0264c8 0%, #00a8ff 52%, #00f0ff 88%, #9efeff 100%);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.65);
}

.loading-bar-glow {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9));
  box-shadow: 0 0 14px #00f0ff, 0 0 24px #ffffff;
}

.loading-bar-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.28) 50%,
    transparent 100%
  );
  animation: loadingShimmer 1.6s infinite;
}

@keyframes loadingShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* Botão de Entrada Interativo (Paralelogramo Arredondado com Texto 100% Nítido) */
.loading-action-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 6px;
  animation: loadingActionFade 0.4s ease;
}

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

.btn-loading-start {
  position: relative;
  min-width: 280px;
  max-width: 340px;
  padding: 15px 42px;
  background: transparent;
  border: none;
  color: #030a14;
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, filter 0.18s ease;
}

/* Camada de fundo inclinada com cantos arredondados e borda neon clara */
.btn-loading-start::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #00f7ff 0%, #00b8ff 52%, #0084ff 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  transform: skewX(-14deg);
  box-shadow: 0 0 28px rgba(0, 240, 255, 0.55), 0 8px 20px rgba(0, 0, 0, 0.55);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  animation: pulseGlow 1.5s infinite alternate;
  z-index: 0;
}

.btn-loading-start .btn-skew-content {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transform: none;
}

.btn-loading-start:hover {
  transform: translateY(-2px) scale(1.03);
}

.btn-loading-start:hover::before {
  filter: brightness(1.12);
  box-shadow: 0 0 38px rgba(0, 240, 255, 0.85), 0 10px 24px rgba(0, 0, 0, 0.65);
}

.btn-loading-start:active {
  transform: scale(0.98);
}

.pulse-icon {
  font-size: 14px;
  font-style: normal;
}

@keyframes pulseGlow {
  from {
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.42), 0 6px 16px rgba(0, 0, 0, 0.5);
  }
  to {
    box-shadow: 0 0 34px rgba(0, 240, 255, 0.82), 0 0 50px rgba(0, 132, 255, 0.45);
  }
}

.loading-footer-tip {
  font-family: 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color: #e2e8f0;
  background: rgba(6, 18, 30, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 240, 255, 0.35);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.65), 0 0 18px rgba(0, 240, 255, 0.14);
  padding: 12px 22px;
  border-radius: 8px;
  max-width: 560px;
  line-height: 1.48;
  margin-top: 8px;
}

.loading-footer-tip .tip-highlight,
.loading-footer-tip strong {
  font-family: var(--font-main);
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
