/* FoxHunt3D v4.5.2 — Ralliareena, ajoneuvot ja katsomo */

#rallyArenaHud {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  width: min(660px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, minmax(74px, auto));
  gap: 7px;
  align-items: stretch;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(5,17,27,.84), rgba(8,28,42,.62));
  box-shadow: 0 16px 48px rgba(0,0,0,.28);
  backdrop-filter: blur(10px);
  color: #f7fbff;
  pointer-events: none;
  text-shadow: 0 2px 7px rgba(0,0,0,.76);
}
#rallyArenaHud.hidden { display: none !important; }
.rally-hud-main,
.rally-hud-metric {
  min-width: 0;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255,255,255,.065);
}
.rally-hud-main { display: grid; gap: 2px; }
.rally-hud-main strong { color: #68e2ff; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; }
.rally-hud-main span { overflow: hidden; color: #b7c8d8; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.rally-hud-metric { text-align: center; }
.rally-hud-metric span { display: block; color: #a9bdcc; font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.rally-hud-metric strong { display: block; margin-top: 3px; color: #ffd166; font-size: 13px; }

#rallyArenaPrompt {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(680px, calc(100vw - 30px));
  padding: 8px 13px;
  border: 1px solid rgba(104,226,255,.34);
  border-radius: 999px;
  background: rgba(4,16,26,.76);
  color: #e9f9ff;
  font-size: 11px;
  font-weight: 780;
  text-align: center;
  text-shadow: 0 2px 6px #000;
  pointer-events: none;
  backdrop-filter: blur(8px);
}
#rallyArenaPrompt.hidden { display: none !important; }

#rallyTiltHud {
  position: absolute;
  z-index: 7;
  right: 18px;
  top: 300px;
  width: 150px;
  padding: 9px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  background: rgba(5,17,27,.72);
  backdrop-filter: blur(9px);
  color: #f7fbff;
  pointer-events: none;
}
#rallyTiltHud.hidden { display: none !important; }
.rally-tilt-title { margin-bottom: 7px; color: #68e2ff; font-size: 9px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.rally-tilt-row { display: grid; grid-template-columns: 42px 1fr; gap: 7px; align-items: center; margin: 4px 0; color: #b7c8d8; font-size: 8px; text-transform: uppercase; }
.rally-tilt-track { position: relative; height: 7px; border-radius: 999px; background: rgba(255,255,255,.11); }
.rally-tilt-track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255,255,255,.42); }
.rally-tilt-marker { position: absolute; left: 50%; top: 50%; width: 11px; height: 11px; border-radius: 50%; background: #ffd166; box-shadow: 0 0 12px rgba(255,209,102,.48); transform: translate(-50%,-50%); }

#vehicleControls,
#spectatorControls {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: none;
  pointer-events: none;
}
#vehicleControls.active,
#spectatorControls.active { display: block; }

.vehicle-steer-pad,
.spectator-move-pad {
  position: absolute;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 138px;
  height: 138px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  background: rgba(4,15,24,.32);
  box-shadow: inset 0 0 0 12px rgba(255,255,255,.025), 0 12px 30px rgba(0,0,0,.16);
  pointer-events: auto;
  touch-action: none;
}
.vehicle-steer-pad::before,
.spectator-move-pad::before {
  content: "";
  position: absolute;
  inset: 29px;
  border: 4px solid rgba(255,255,255,.24);
  border-radius: 50%;
}
.vehicle-steer-knob,
.spectator-move-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 50%;
  background: rgba(104,226,255,.28);
  transform: translate(-50%,-50%);
}
.vehicle-steer-caption,
.spectator-move-caption {
  position: absolute;
  left: 50%;
  bottom: -18px;
  transform: translateX(-50%);
  color: rgba(255,255,255,.72);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.vehicle-action-grid,
.spectator-action-grid {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, minmax(82px, 98px));
  gap: 8px;
  pointer-events: auto;
}
.vehicle-control-button,
.spectator-control-button {
  min-height: 55px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 14px;
  background: rgba(4,15,24,.56);
  color: #f7fbff;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.1;
  text-shadow: 0 2px 5px #000;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.vehicle-control-button.is-held,
.spectator-control-button.is-held { filter: brightness(1.35); transform: scale(.97); }
.vehicle-control-button.brake { border-color: rgba(255,93,93,.58); background: rgba(130,24,35,.53); }
.vehicle-control-button.handbrake { border-color: rgba(255,209,102,.55); background: rgba(105,76,18,.53); }
.vehicle-control-button.exit,
.spectator-control-button.exit { border-color: rgba(104,226,255,.55); }
.vehicle-control-button.camera,
.spectator-control-button.camera { border-color: rgba(198,166,255,.55); }

.rally-setting-group .rally-control-status {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(104,226,255,.065);
  color: #b7c8d8;
  font-size: 10px;
  line-height: 1.45;
}
.rally-setting-group .rally-setting-actions { margin-top: 9px; }
.rally-track-table {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}
.rally-track-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 9px;
  background: rgba(255,255,255,.04);
  color: #b7c8d8;
  font-size: 10px;
}
.rally-track-row strong { color: #f7fbff; }
.rally-track-row b { color: #ffd166; font-variant-numeric: tabular-nums; }
.rally-profile-card {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(104,226,255,.22);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(104,226,255,.055), rgba(255,255,255,.025));
}
.rally-profile-card h3 { margin: 0 0 8px; color: #68e2ff; }
.rally-profile-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.rally-profile-stat { padding: 9px; border-radius: 9px; background: rgba(255,255,255,.055); }
.rally-profile-stat span { display:block; color:#a9bdcc; font-size:8px; letter-spacing:.08em; text-transform:uppercase; }
.rally-profile-stat strong { display:block; margin-top:4px; color:#ffd166; font-size:15px; }

@media (pointer: coarse), (max-width: 900px) {
  #rallyArenaHud { top: 58px; grid-template-columns: minmax(0,1fr) repeat(3,minmax(58px,auto)); width: min(600px, calc(100vw - 18px)); padding: 6px; gap: 5px; }
  #rallyArenaHud .rally-hud-metric:last-child { display: none; }
  #rallyTiltHud { right: 10px; top: 165px; width: 130px; }
  #rallyArenaPrompt { bottom: 6px; font-size: 9px; padding: 6px 10px; }
  body.rally-vehicle-active #mobileControls,
  body.rally-spectator-active #mobileControls { display: none !important; }
}

@media (max-width: 620px) {
  #rallyArenaHud { top: 8px; left: 8px; right: 8px; width: auto; transform: none; grid-template-columns: 1fr repeat(2,66px); }
  #rallyArenaHud .rally-hud-metric:nth-of-type(4),
  #rallyArenaHud .rally-hud-metric:nth-of-type(5) { display:none; }
  #rallyTiltHud { top: 84px; width: 115px; }
  .vehicle-steer-pad,
  .spectator-move-pad { width: 112px; height: 112px; left: 12px; bottom: 18px; }
  .vehicle-steer-knob,
  .spectator-move-knob { width: 48px; height: 48px; }
  .vehicle-action-grid,
  .spectator-action-grid { right: 10px; bottom: 14px; grid-template-columns: repeat(2,72px); gap: 6px; }
  .vehicle-control-button,
  .spectator-control-button { min-height: 48px; font-size: 8px; border-radius: 12px; }
  .rally-profile-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (orientation: landscape) and (max-height: 460px) {
  #rallyArenaHud { top: 5px; grid-template-columns: minmax(0,1fr) repeat(4,70px); }
  #rallyArenaHud .rally-hud-metric:last-child { display:block; }
  #rallyTiltHud { top: 60px; right: 8px; width: 118px; padding: 6px; }
  .vehicle-steer-pad,
  .spectator-move-pad { width: 106px; height: 106px; bottom: 14px; }
  .vehicle-action-grid,
  .spectator-action-grid { bottom: 12px; grid-template-columns: repeat(2,72px); }
  .vehicle-control-button,
  .spectator-control-button { min-height: 45px; }
}

/* Rally and spectator modes use their own concise HUD. Hide the flight/ground
   instrumentation that would otherwise overlap the vehicle controls. */
body.rally-vehicle-active #missionPanel,
body.rally-vehicle-active #networkPanel,
body.rally-vehicle-active #statusPanel,
body.rally-vehicle-active #groundModePanel,
body.rally-vehicle-active #quickInventory,
body.rally-vehicle-active #radarPanel,
body.rally-vehicle-active #voiceDock,
body.rally-spectator-active #missionPanel,
body.rally-spectator-active #networkPanel,
body.rally-spectator-active #statusPanel,
body.rally-spectator-active #groundModePanel,
body.rally-spectator-active #quickInventory,
body.rally-spectator-active #radarPanel,
body.rally-spectator-active #voiceDock {
  display: none !important;
}
body.rally-vehicle-active #notifications,
body.rally-spectator-active #notifications { top: 92px; }
body.rally-vehicle-active #chatToggleButton,
body.rally-spectator-active #chatToggleButton { top: 166px; right: 10px; }
body.rally-vehicle-active #settingsButton,
body.rally-spectator-active #settingsButton { top: 202px; right: 10px; }

@media (pointer: coarse), (max-width: 900px) {
  body.rally-vehicle-active #rallyArenaPrompt,
  body.rally-spectator-active #rallyArenaPrompt { display: none !important; }
  body.rally-vehicle-active #notifications,
  body.rally-spectator-active #notifications { top: 68px; width: min(520px, 72vw); }
}

@media (orientation: landscape) and (max-height: 460px) {
  body.rally-vehicle-active #chatToggleButton,
  body.rally-spectator-active #chatToggleButton { top: 162px; right: 8px; }
  body.rally-vehicle-active #settingsButton,
  body.rally-spectator-active #settingsButton { top: 196px; right: 8px; }
}
