#controls-panel, #speedometer, #camera-mode {
  position: fixed;
  z-index: 5;
  box-sizing: border-box;
  color: #edf3f6;
  background: linear-gradient(135deg, rgba(26, 38, 47, 0.92), rgba(16, 25, 32, 0.84));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px);
  font: 13px/1.5 "Segoe UI", sans-serif;
  pointer-events: none;
}
#controls-panel::before, #speedometer::before, #camera-mode::before {
  display: block;
  margin-bottom: 7px;
  color: #9fd4dc;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.6px;
}
#controls-panel::before, #speedometer::before {
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
}
#controls-panel {
  top: 20px; left: 20px;
  width: max-content;
  max-width: min(680px, calc(100vw - 184px));
  padding: 10px 14px;
}
#controls-panel::before { content: "CONTROLES"; }
#gamepad-status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #5b6871;
  opacity: 0.6;
  vertical-align: middle;
}
#gamepad-status.connected::before {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.7);
  opacity: 1;
}
.controls-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 0;
}
.legend-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}
.legend-group:first-child { padding-left: 0; border-left: 0; }
.legend-group:last-child { padding-right: 0; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  font-size: 12px;
  white-space: nowrap;
}
.legend-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 26px;
}
.legend-icon svg { width: 100%; height: 100%; }
.round-icon {
  width: 26px;
  margin: 0 9px;
  box-sizing: border-box;
  padding: 5px;
  border: 1.5px solid rgba(237, 243, 246, 0.75);
  border-radius: 50%;
}
.keycap {
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  border: 1.5px solid rgba(237, 243, 246, 0.75);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
}
.keycap.wide { width: auto; padding: 0 8px; font-size: 11px; }
.keys { display: flex; gap: 4px; }
.keys-wide .keys { min-width: 52px; }
#legend-keyboard { display: flex; }
#legend-gamepad { display: none; }
body[data-input-mode="gamepad"] #legend-keyboard { display: none; }
body[data-input-mode="gamepad"] #legend-gamepad { display: flex; }
.keycap.key-a { color: #6cc24a; }
.keycap.key-b { color: #e5484d; }
#gamepad-status {
  width: 0;
  min-width: 100%;
  margin-top: 6px;
  color: #afbec7;
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-line;
  padding-left: 14px;
  text-indent: -14px;
}
#speedometer {
  top: 20px; right: 20px;
  width: 124px; padding: 14px 18px;
  text-align: right;
  color: #afbec7;
  font-size: 12px;
}
#speedometer::before { content: "VELOCIDADE"; }
#speed-value {
  display: block;
  color: #ffffff;
  font-size: 42px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
#speed-unit-row {
  position: relative;
}
#reverse-indicator {
  display: none;
  position: absolute;
  left: 0;
  color: #ff6b6b;
  font-weight: 700;
  letter-spacing: 1px;
}
#reverse-indicator.visible { display: inline; }
#camera-mode {
  bottom: 20px; left: 20px;
  max-width: calc(100vw - 120px);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
#camera-mode::before { content: none; }
#camera-mode-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}
#camera-mode-hint svg { width: 20px; height: 20px; flex: none; }
#camera-mode-hint .hint-key { width: 22px; height: 22px; border-radius: 6px; font-size: 12px; line-height: 19px; }
#camera-mode-hint .hint-pad { display: none; }
body[data-input-mode="gamepad"] #camera-mode-hint .hint-key { display: none; }
body[data-input-mode="gamepad"] #camera-mode-hint .hint-pad { display: block; }
@media (max-width: 480px) {
  #controls-panel { top: 12px; left: 12px; max-width: calc(100vw - 140px); padding: 12px; }
  .controls-legend { gap: 10px 20px; }
  .legend-group, .legend-group:last-child { padding: 0; border-left: 0; }
  #speedometer { top: 12px; right: 12px; width: 104px; padding: 12px; }
  #speed-value { font-size: 36px; }
  #camera-mode { bottom: 12px; left: 12px; padding: 12px; }
}
#reset-fade {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  background: #000;
}
#collision-flash {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse, transparent 40%, rgba(220, 30, 30, 0.65));
  border: 6px solid rgba(220, 30, 30, 0.8);
}
#fullscreen-button {
  position: fixed;
  z-index: 5;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(135deg, rgba(26, 38, 47, 0.92), rgba(16, 25, 32, 0.84));
  color: #edf3f6;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
@media (max-width: 480px) {
  #fullscreen-button { right: 12px; bottom: 12px; width: 40px; height: 40px; font-size: 18px; }
}
body.is-fullscreen #controls-panel,
body.is-fullscreen #speedometer,
body.is-fullscreen #camera-mode {
  display: none;
}
