:root {
  --bg: #04101e;
  --fg: #cfeaff;
  --accent: #ff9a3c;
  --panel: rgba(4, 16, 30, 0.72);
  --line: rgba(120, 200, 255, 0.35);
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace;
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  pointer-events: none;
}

.panel {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 6px);
  left: calc(env(safe-area-inset-left) + 6px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  white-space: pre;
}

#toolbar {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 6px);
  right: calc(env(safe-area-inset-right) + 6px);
  display: flex;
  gap: 4px;
  pointer-events: auto;
}

button {
  font: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  touch-action: manipulation;
}

button:active { background: rgba(60, 120, 180, 0.6); }

#steer-hint {
  position: absolute;
  left: calc(env(safe-area-inset-left) + 5vmin);
  bottom: calc(env(safe-area-inset-bottom) + 6vmin);
  opacity: 0.45;
  text-align: center;
  font-size: 14px;
}

#steer-hint small { font-size: 10px; }

#steer-ring {
  position: absolute;
  width: 18vmin;
  height: 18vmin;
  margin: -9vmin 0 0 -9vmin;
  border: 2px solid var(--line);
  border-radius: 50%;
  display: none;
}

#steer-knob {
  position: absolute;
  width: 7vmin;
  height: 7vmin;
  left: 50%;
  top: 50%;
  margin: -3.5vmin 0 0 -3.5vmin;
  border-radius: 50%;
  background: rgba(120, 200, 255, 0.65);
}

#pads {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 3vmin);
  bottom: calc(env(safe-area-inset-bottom) + 3vmin);
  display: flex;
  align-items: flex-end;
  gap: 2vmin;
}

.pad {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: rgba(20, 60, 100, 0.35);
  font-size: 13px;
  letter-spacing: 1px;
}

#pad-throttle { width: 26vmin; height: 36vmin; border-color: var(--accent); }
#pad-brake { width: 22vmin; height: 22vmin; }
.pad.on { background: rgba(255, 154, 60, 0.45); }
#pad-brake.on { background: rgba(255, 80, 80, 0.45); }

#status {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 4px);
  transform: translateX(-50%);
  opacity: 0.85;
  text-align: center;
}

#info {
  position: absolute;
  inset: 8px;
  box-sizing: border-box;
  padding: 8px;
  overflow: auto;
  touch-action: pan-y;
  background: rgba(4, 16, 30, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  -webkit-user-select: text;
  user-select: text;
}

#info[hidden] { display: none; }
.info-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
label { display: block; margin: 4px 0; }
select, input[type=text] {
  font: inherit;
  color: var(--fg);
  background: #0a2236;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px;
}
input[type=text] { width: 60%; }
pre { white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: var(--fg);
  background: #0a2236;
  border: 1px solid var(--line);
  -webkit-user-select: text;
  user-select: text;
}

#rotate {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--bg);
  align-items: center;
  justify-content: center;
  font-size: 20px;
  z-index: 10;
}

@media (orientation: portrait) {
  #rotate { display: flex; }
}
