html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #0b1020; }
#view { display: block; width: 100vw; height: 100vh; }

#help {
  position: fixed; left: 14px; top: 14px; max-width: 330px;
  font: 12px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #cfd8e3; background: rgba(10, 16, 30, 0.72);
  border: 1px solid rgba(140, 180, 220, 0.22); border-radius: 8px;
  padding: 10px 12px; user-select: none;
}
#help h1 { margin: 0 0 8px; font-size: 15px; letter-spacing: 0.5px; color: #eaf2fb; }
#help h1 span { color: #6fb3d8; font-weight: normal; font-size: 12px; }
#help table { border-collapse: collapse; width: 100%; }
#help td { padding: 2px 4px 2px 0; vertical-align: top; white-space: nowrap; }
#help td:first-child { color: #9fe0b0; width: 78px; }
#help .why { margin: 9px 0 0; color: #93a4b8; font-size: 11px; line-height: 1.5; }
#help .why b { color: #d7e6f5; }

.home-btn {
  position: fixed; left: 14px; bottom: 12px; z-index: 5;
  font: 12px ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #9fe0b0;
  text-decoration: none; background: rgba(10, 16, 30, 0.72);
  border: 1px solid rgba(140, 180, 220, 0.22); border-radius: 8px;
  padding: 6px 10px; user-select: none;
}
.home-btn:hover { color: #eaf2fb; background: rgba(20, 30, 50, 0.85); }

/* Touch controls. main.js adds body.touch when the device reports a coarse pointer (a finger),
   or when ?pad=1 is in the URL. The container ignores pointer events so tapping anywhere that is
   NOT a button still reaches the canvas; only the buttons capture input. touch-action: none stops
   the browser from turning a held thumb into a scroll or a long-press menu. */
#touchpad {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: none; justify-content: space-between; align-items: flex-end;
  padding: 0 10px 10px; pointer-events: none;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
body.touch #touchpad { display: flex; }
.pad-left, .pad-right { display: flex; gap: 8px; pointer-events: auto; }
.tbtn {
  min-width: 64px; height: 64px; padding: 4px 6px; border-radius: 12px;
  font: 700 20px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #eaf2fb; background: rgba(14, 22, 40, 0.8);
  border: 1px solid rgba(140, 180, 220, 0.3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  touch-action: none; -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.tbtn span { font-size: 9px; font-weight: 400; color: #93a4b8; margin-top: 4px; line-height: 1.15; }
.tbtn.on { background: rgba(60, 110, 160, 0.92); border-color: #9fe0b0; }
.t-rocket.on { background: rgba(226, 118, 42, 0.92); }
.t-respawn.on { background: rgba(150, 60, 60, 0.92); }

/* The pad lives where the thumbs go, so the home button moves out of the way. */
body.touch .home-btn {
  left: 50%; right: auto; bottom: auto; top: 8px; transform: translateX(-50%);
}

/* Phone-sized screens: the help panel is 330px wide, which on a 390px screen covers
   most of the view. Shrink it and drop the explanatory paragraph (the key table is the
   part you actually need while driving). */
@media (max-width: 620px) {
  #help { max-width: 56vw; font-size: 10px; padding: 7px 8px; }
  #help h1 { font-size: 12px; }
  #help .why { display: none; }
  #readout { font-size: 10px; padding: 5px 8px; }
  .home-btn { font-size: 10px; padding: 5px 8px; }
  .tbtn { min-width: 54px; height: 56px; font-size: 17px; }
  .tbtn span { font-size: 8px; }
  body.touch .home-btn { top: 6px; }
}

#readout {
  position: fixed; right: 14px; top: 14px; text-align: right;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #cfd8e3; background: rgba(10, 16, 30, 0.72);
  border: 1px solid rgba(140, 180, 220, 0.22); border-radius: 8px;
  padding: 8px 12px; user-select: none; white-space: pre;
}
