html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #07100d;
  color: #f7fbff;
  font-family: Arial, sans-serif;
  touch-action: none;
}

button {
  border: 0;
  border-radius: 8px;
  background: #1967d2;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  min-height: 42px;
  padding: 10px 14px;
}

button:hover,
button:focus-visible {
  filter: brightness(1.12);
}

#gameShell {
  position: fixed;
  inset: 0;
  background: #07100d;
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: auto;
}

#mapModePanel {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 5;
  width: min(520px, calc(100vw - 28px));
  transform: translate(-50%, -50%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 8px;
  background: rgba(7, 16, 13, 0.93);
  border: 1px solid rgba(150, 210, 255, 0.28);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.46);
}

#mapModePanel.hidden {
  display: none;
}

#mapModePanel h1,
#mapModePanel p {
  margin: 0;
}

#mapModePanel h1 {
  color: #fff0a6;
  font-size: 28px;
}

#mapModePanel p {
  color: #d7e7ef;
  font-size: 14px;
}

#mapModePanel div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

#mapModePanel button[data-map-mode="game"] {
  background: #1b8a5d;
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
  z-index: 3;
}

.hud-row {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
}

.hud-row > div,
#dispatchPanel {
  background: rgba(7, 16, 13, 0.88);
  border: 1px solid rgba(150, 210, 255, 0.24);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.hud-row > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
}

.hud-row strong {
  font-size: 18px;
}

#statusLine {
  color: #b8c9d6;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#scoreBox {
  display: grid;
  place-items: center;
  min-width: 70px;
  padding: 8px;
  border-radius: 8px;
}

#scoreBox span {
  color: #a8bdca;
  font-size: 11px;
  text-transform: uppercase;
}

#scoreBox strong {
  color: #ffe071;
  font-size: 26px;
  line-height: 1;
}

#vehicleHealth {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(7, 16, 13, 0.88);
  border: 1px solid rgba(150, 210, 255, 0.24);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

#vehicleHealth span {
  color: #a8bdca;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

#vehicleHealth div {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

#vehicleHealth i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #41d17d;
}

#vehicleHealth strong {
  min-width: 42px;
  color: #fff;
  font-size: 12px;
  text-align: right;
}

#dispatchPanel {
  display: none;
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  pointer-events: auto;
}

#dispatchPanel.show {
  display: block;
}

.dispatch-top {
  display: flex;
  justify-content: space-between;
  color: #7ed0ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

#dispatchPanel h2 {
  margin: 8px 0 4px;
  color: #fff0a6;
  font-size: 21px;
}

#dispatchPanel p {
  margin: 0;
  color: #d9e7ef;
  font-size: 14px;
  line-height: 1.35;
}

.dispatch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

#declineCallBtn {
  background: #5b6570;
}

#controlsHint {
  position: fixed;
  right: 12px;
  top: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: min(520px, calc(100vw - 460px));
  z-index: 3;
}

#controlsHint span {
  background: rgba(7, 16, 13, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #d6e4ec;
  font-size: 12px;
  padding: 7px 10px;
}

#trainingPanel {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 7, 10, 0.62);
  pointer-events: auto;
}

#trainingPanel.hidden {
  display: none;
}

.training-card {
  width: min(760px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  overflow: auto;
  border-radius: 8px;
  background: rgba(8, 16, 20, 0.97);
  border: 1px solid rgba(150, 210, 255, 0.28);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
  padding: 18px;
}

.training-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#trainingTag {
  color: #7ed0ff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

#closeTrainingBtn {
  min-height: 34px;
  background: #5b6570;
  padding: 7px 11px;
}

#trainingTitle {
  margin: 12px 0 8px;
  color: #fff0a6;
  font-size: 24px;
}

#trainingNarrative {
  margin: 0;
  color: #d9e7ef;
  font-size: 15px;
  line-height: 1.45;
}

#trainingFacts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

#trainingFacts span {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #dbe9f0;
  font-size: 13px;
  line-height: 1.3;
  padding: 9px 10px;
}

#trainingOptions {
  display: grid;
  gap: 8px;
}

#trainingOptions button {
  min-height: 44px;
  background: #234d78;
  text-align: left;
}

#trainingOptions button.primary {
  background: #1b8a5d;
}

#trainingOptions button.caution {
  background: #9a5d1e;
}

#trainingOptions button.danger {
  background: #9b2635;
}

#mobileControls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  grid-template-columns: minmax(136px, 1fr) minmax(112px, auto);
  align-items: end;
  gap: 18px;
  padding: 0 max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  pointer-events: none;
  z-index: 3;
}

#mobileJoystick,
#mobileActionButtons {
  pointer-events: auto;
}

#mobileJoystick {
  width: 142px;
  height: 142px;
  display: grid;
  place-items: center;
  touch-action: none;
}

#joystickBase {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(126, 208, 255, 0.18), rgba(7, 16, 13, 0.78) 62%);
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.36), inset 0 0 0 1px rgba(126, 208, 255, 0.18);
}

#joystickStick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #f7fbff;
  border: 5px solid #1967d2;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);
}

#mobileActionButtons {
  display: grid;
  gap: 10px;
  width: 112px;
}

#mobileActionButtons button {
  min-height: 58px;
  padding: 8px 10px;
  background: rgba(25, 103, 210, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

#mobileLightsBtn.active {
  background: #d11f3b;
}

#mobileEngageBtn {
  background: #1b8a5d;
}

@media (max-width: 820px), (pointer: coarse) {
  #mobileControls {
    display: grid;
  }

  #controlsHint {
    display: none;
  }

  #hud {
    width: calc(100vw - 24px);
  }

  #mapModePanel div {
    grid-template-columns: 1fr 1fr;
  }
}
