
/* ============================================================
   RALLY X — PORTFÓLIO 3D
   CSS completo e responsivo
   ============================================================ */

:root {
  --orange: #ff5b25;
  --lime: #c9ff32;
  --cyan: #00d9ff;
  --dark: #101820;
  --panel: rgba(12, 19, 25, 0.88);
  --white: #f4f7fa;
}

/* ============================================================
   RESET E ESTRUTURA PRINCIPAL
   ============================================================ */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--dark);
  color: var(--white);
  font-family: Inter, Arial, sans-serif;
}

body {
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: var(--white);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: var(--dark);
}

/* Canvas ocupa a tela toda, sem deslocar a interface. */
#world {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  z-index: 0;
  touch-action: none;
}

/* ============================================================
   PAINÉIS DE VIDRO
   ============================================================ */

.glass {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ============================================================
   BARRA SUPERIOR
   ============================================================ */

.topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  min-height: 80px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(
    to bottom,
    rgba(8, 13, 22, 0.82),
    rgba(8, 13, 22, 0)
  );
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.logo {
  flex-shrink: 0;
  font-size: 29px;
  font-weight: 1000;
  font-style: italic;
  letter-spacing: -1.5px;
  line-height: 1;
  white-space: nowrap;
}

.logo span,
.loading-content strong span {
  color: var(--lime);
}

.logo small {
  display: block;
  margin-top: 6px;
  font-size: 9px;
  color: var(--lime);
  letter-spacing: 3px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.nav button {
  padding: 10px 12px;
  border-bottom: 1px solid transparent;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.nav button:hover,
.nav button.active {
  color: var(--lime);
  border-bottom-color: var(--lime);
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ui-btn {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.85);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.ui-btn:hover,
.ui-btn.selected {
  border-color: var(--lime);
  color: var(--lime);
}

/* ============================================================
   HERO / INTRODUÇÃO
   ============================================================ */

.hero {
  position: absolute;
  z-index: 3;
  left: 4%;
  top: 24%;
  width: min(390px, 42vw);
  pointer-events: none;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.85);
  transition: opacity 0.4s ease;
}

.eyebrow {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--lime);
}

.hero h1 {
  margin: 13px 0;
  font-size: clamp(38px, 5vw, 72px);
  font-weight: 1000;
  font-style: italic;
  line-height: 0.94;
  letter-spacing: -2px;
}

.hero h1 span {
  color: var(--lime);
}

.hero p {
  max-width: 340px;
  font-size: 14px;
  line-height: 1.7;
  color: #f1f1f1;
}

#explore {
  pointer-events: auto;
  padding: 13px 23px;
  margin-top: 12px;
  border: 1px solid var(--lime);
  border-radius: 30px;
  background: var(--lime);
  color: #101820;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 1px;
}

#explore:hover {
  transform: translateY(-2px);
  background: #dcff83;
}

/* ============================================================
   NAVEGAÇÃO LATERAL
   ============================================================ */

.section-rail {
  position: absolute;
  z-index: 4;
  right: 25px;
  top: 34%;
  display: grid;
  gap: 10px;
}

.rail-btn {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 2px 8px #000;
}

.rail-num {
  width: 29px;
  height: 29px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(17, 24, 32, 0.82);
}

.rail-btn:hover .rail-num,
.rail-btn.active .rail-num {
  border: 2px solid var(--lime);
  color: var(--lime);
}

/* ============================================================
   HUD E VELOCÍMETRO
   ============================================================ */

.hud {
  position: absolute;
  z-index: 4;
  bottom: 24px;
  left: 25px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.speedometer {
  width: 130px;
  height: 130px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.44);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8, 13, 22, 0.88);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.38);
}

.speedometer strong {
  font-size: 37px;
  line-height: 1;
  font-style: italic;
}

.speedometer span {
  margin-top: 7px;
  font-size: 10px;
  color: var(--lime);
  letter-spacing: 2px;
}

.gear {
  margin-top: 8px;
  font-size: 12px;
}

.gear b {
  color: var(--lime);
}

/* ============================================================
   MINIMAPA
   ============================================================ */

.map-box {
  width: 120px;
  height: 115px;
  padding: 8px;
  overflow: hidden;
}

.map-box canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================
   PAINEL DE CONTROLES DESKTOP
   ============================================================ */

.controls {
  position: absolute;
  z-index: 4;
  right: 25px;
  bottom: 25px;
  width: 260px;
  padding: 14px;
}

.controls h3 {
  margin: 0 0 12px;
  font-size: 11px;
  color: var(--lime);
  letter-spacing: 2px;
}

.control-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0;
  font-size: 10px;
  color: #e4e7ea;
}

kbd {
  min-width: 23px;
  padding: 5px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  font: inherit;
  color: white;
}

/* ============================================================
   CHECKPOINTS / SEÇÕES
   ============================================================ */

#checkpoint {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 17%;
  transform: translateX(-50%);
  width: min(420px, 80vw);
  max-height: 65vh;
  overflow-y: auto;
  padding: 18px;
  text-align: center;
  display: none;
}

#checkpoint.visible {
  display: block;
}

#checkpoint h2 {
  margin: 8px 0;
  color: var(--lime);
  font-size: 21px;
}

#checkpoint p {
  font-size: 13px;
  line-height: 1.6;
  color: #e3e8ec;
}

#checkpoint button {
  padding: 10px 17px;
  border-radius: 6px;
  background: var(--orange);
  font-weight: 900;
  font-size: 11px;
}

#checkpoint button:hover {
  background: #ff784c;
}

/* ============================================================
   ASSINATURA INFERIOR
   ============================================================ */

.bottom-brand {
  position: absolute;
  z-index: 3;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.61);
  white-space: nowrap;
  pointer-events: none;
}

/* ============================================================
   CONTROLES MOBILE
   ============================================================ */

#mobile-controls {
  display: none;
  position: absolute;
  z-index: 6;
  bottom: 20px;
  left: 14px;
  right: 14px;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  touch-action: none;
}

.touch-group {
  display: grid;
  grid-template-columns: repeat(2, 55px);
  gap: 8px;
  pointer-events: auto;
}

.touch-btn {
  min-width: 0;
  height: 53px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  background: rgba(16, 24, 32, 0.9);
  font-size: 19px;
  font-weight: 900;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-btn:active,
.touch-btn.pressed {
  background: var(--lime);
  color: var(--dark);
}

.touch-btn.accelerate {
  border-color: var(--lime);
}

.touch-btn.brake {
  border-color: var(--orange);
}

/* ============================================================
   TELA DE CARREGAMENTO
   ============================================================ */

#loading {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  background: #101820;
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

#loading.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  padding: 20px;
  text-align: center;
}

.loading-content strong {
  font-size: 35px;
  font-style: italic;
}

.loading-content p {
  font-size: 11px;
  letter-spacing: 3px;
  color: #a9b4bd;
}

.loading-bar {
  width: 190px;
  height: 3px;
  margin: 22px auto;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.13);
}

.loading-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--lime);
  animation: load 1.3s ease forwards;
}

/* Corrigido: nome da animação sem asteriscos. */
@keyframes load {
  to {
    width: 100%;
  }
}

/* ============================================================
   TABLETS E TELAS ATÉ 900 PX
   ============================================================ */

@media (max-width: 900px) {
  .topbar {
    min-height: 66px;
    padding: 14px;
    gap: 12px;
  }

  .nav {
    display: none;
  }

  .hero {
    top: 18%;
    left: 5%;
    width: 65%;
  }

  .hero h1 {
    font-size: clamp(36px, 8vw, 60px);
  }

  .hero p {
    font-size: 12px;
  }

  .section-rail {
    right: 12px;
    top: 34%;
    gap: 12px;
  }

  .rail-btn {
    font-size: 0;
  }

  .controls {
    display: none;
  }

  #mobile-controls {
    display: flex;
  }

  .hud {
    left: 14px;
    bottom: 115px;
  }

  .speedometer {
    width: 90px;
    height: 90px;
  }

  .speedometer strong {
    font-size: 27px;
  }

  .map-box,
  .bottom-brand {
    display: none;
  }
}

/* ============================================================
   CELULARES
   ============================================================ */

@media (max-width: 480px) {
  .topbar {
    padding: 12px;
    gap: 8px;
  }

  .logo {
    font-size: 23px;
  }

  .logo small {
    font-size: 8px;
    letter-spacing: 2px;
  }

  .actions {
    gap: 5px;
  }

  .actions .ui-btn {
    padding: 9px 7px;
    font-size: 9px;
  }

  .hero {
    top: 18%;
    left: 5%;
    width: 78%;
  }

  .hero h1 {
    font-size: 39px;
  }

  .hero p {
    max-width: 255px;
    font-size: 11px;
    line-height: 1.6;
  }

  #explore {
    padding: 11px 17px;
  }

  .section-rail {
    top: 40%;
    right: 10px;
    gap: 10px;
  }

  .rail-num {
    width: 25px;
    height: 25px;
  }

  #checkpoint {
    top: 12%;
    width: calc(100% - 32px);
    max-height: 58vh;
    padding: 12px;
  }

  #checkpoint h2 {
    font-size: 18px;
  }

  #checkpoint p {
    font-size: 12px;
  }

  .hud {
    left: 12px;
    bottom: 100px;
  }

  .speedometer {
    width: 78px;
    height: 78px;
  }

  .speedometer strong {
    font-size: 24px;
  }

  .speedometer span {
    margin-top: 4px;
    font-size: 9px;
  }

  .gear {
    margin-top: 5px;
    font-size: 10px;
  }

  #mobile-controls {
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
  }

  .touch-group {
    grid-template-columns: repeat(2, 48px);
    gap: 7px;
  }

  .touch-btn {
    height: 47px;
    border-radius: 10px;
  }
}

/* ============================================================
   CELULARES EM PAISAGEM
   ============================================================ */

@media (max-width: 900px) and (orientation: landscape) {
  .topbar {
    min-height: 54px;
    padding: 8px 12px;
  }

  .logo {
    font-size: 20px;
  }

  .logo small {
    margin-top: 4px;
    font-size: 7px;
  }

  .hero {
    top: 22%;
    width: min(42%, 340px);
  }

  .hero h1 {
    margin: 8px 0;
    font-size: clamp(28px, 5vw, 43px);
  }

  .hero p {
    margin: 8px 0;
    font-size: 10px;
    line-height: 1.4;
  }

  #explore {
    margin-top: 5px;
    padding: 9px 13px;
    font-size: 9px;
  }

  .section-rail {
    top: 28%;
    gap: 5px;
  }

  .rail-num {
    width: 23px;
    height: 23px;
  }

  .hud {
    bottom: 12px;
  }

  .speedometer {
    width: 70px;
    height: 70px;
  }

  .speedometer strong {
    font-size: 22px;
  }

  .speedometer span {
    margin-top: 3px;
    font-size: 8px;
  }

  .gear {
    margin-top: 3px;
    font-size: 9px;
  }

  #mobile-controls {
    bottom: 10px;
  }

  .touch-group {
    grid-template-columns: repeat(2, 43px);
    gap: 5px;
  }

  .touch-btn {
    height: 42px;
  }

  #checkpoint {
    top: 12%;
    max-height: 75vh;
    padding: 10px;
  }

  #checkpoint h2 {
    font-size: 16px;
  }

  #checkpoint p {
    margin: 7px 0;
    font-size: 11px;
  }
}

/* ============================================================
   TELAS BAIXAS
   ============================================================ */

@media (max-height: 500px) {
  .hero {
    top: 20%;
  }

  .hero h1 {
    margin: 8px 0;
  }

  .hero p {
    line-height: 1.4;
  }

  .section-rail {
    top: 30%;
  }

  #checkpoint {
    top: 10%;
    max-height: 75vh;
  }
}

/* ============================================================
   REDUÇÃO DE MOVIMENTO
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }

  .hero,
  #loading {
    transition: none;
  }

  .loading-bar i {
    animation-duration: 0.1s;
  }
}
