:root {
  --yellow: #ffd300;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--yellow);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

.bridge {
  fill: #fff;
}

.machine {
  fill: #000;
  fill-rule: evenodd;
}

/* A thin outline in the background color sets a part off against the white part behind it. */
.part {
  stroke: var(--yellow);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.smoke {
  fill: #c4c4c4;
}

#scene[hidden] {
  display: none;
}

/* ---- Driving game ---- */

#fade {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
}

@font-face {
  font-family: 'Russo One';
  src: url('vendor/russo-one/russo-one-latin.woff2') format('woff2');
  font-display: block;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  font: 500 13px/1.4 system-ui, sans-serif;
  color: #fff;
  pointer-events: none;
}

/* White game text with a thin dark outline, readable on yellow hills and grey sky alike. */
#hud .tag,
#hud .autopilot,
#hud .help {
  font-family: 'Russo One', system-ui, sans-serif;
  font-weight: 400;
  text-shadow:
    1px 0 0 rgb(0 0 0 / 0.6), -1px 0 0 rgb(0 0 0 / 0.6), 0 1px 0 rgb(0 0 0 / 0.6), 0 -1px 0 rgb(0 0 0 / 0.6),
    1px 1px 0 rgb(0 0 0 / 0.45), -1px -1px 0 rgb(0 0 0 / 0.45), 1px -1px 0 rgb(0 0 0 / 0.45), -1px 1px 0 rgb(0 0 0 / 0.45),
    0 2px 8px rgb(0 0 0 / 0.3);
  white-space: nowrap;
}

/* Placed by hud.js, which sets a transform every frame. */
#hud .tag {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  font-variant-numeric: tabular-nums;
}

#hud .speed-tag {
  text-align: right;
}

#hud .value,
#hud .penalty {
  display: inline-block;
  font-size: 36px;
  line-height: 1.1;
}

#hud .unit {
  margin-left: 5px;
  font-size: 16px;
}

#hud .penalty {
  margin-left: 10px;
  font-size: 26px;
  color: #ff4d4d;
  transform-origin: left center;
}

#hud .penalty[hidden] {
  display: none;
}

#hud .caption {
  font-size: 14px;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

/* The points each meter earns at this speed. It dims while nothing is earned, off the road or on autopilot. */
#hud .multiplier {
  transition: opacity 0.4s;
}

#hud .multiplier.idle {
  opacity: 0.4;
}

#hud .combo {
  display: inline-block;
  margin-left: 0.5em;
  color: #ffd300;
}

#hud .combo[hidden] {
  display: none;
}

#hud .autopilot {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.55);
  color: var(--yellow);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#hud .autopilot[hidden] {
  display: none;
}

/* The rest of the HUD lets clicks through to the game, these buttons take them. */
#hud .detail,
#hud .audio-toggle,
#hud .help-button {
  padding: 4px 10px;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 4px;
  background: rgb(0 0 0 / 0.32);
  color: #fff;
  font-family: 'Russo One', system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  cursor: pointer;
  pointer-events: auto;
}

#hud .settings {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  gap: 8px;
}

#hud .audio-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 32px;
  padding: 5px;
}

#hud .audio-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#hud .audio-toggle[aria-pressed='true'] .mute-slash {
  display: none;
}

#hud .audio-toggle[aria-pressed='false'] {
  color: rgb(255 255 255 / 0.55);
}

#hud .help-button {
  position: absolute;
  bottom: 24px;
  left: 24px;
  min-width: 2.2em;
  transition: opacity 0.6s;
}

#hud .detail:hover,
#hud .audio-toggle:hover,
#hud .help-button:hover {
  background: rgb(0 0 0 / 0.5);
}

#hud .help-button.hidden {
  opacity: 0;
  pointer-events: none;
}

#hud .help {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 12px;
  align-items: center;
  font-size: 14px;
  transition: opacity 1.5s;
}

#hud .help.hidden {
  opacity: 0;
}

/* Groups of keys for the same control stack on top of each other, keeping the pane narrow. */
#hud .keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

#hud .key-group {
  display: flex;
  gap: 3px;
}

#hud .key-group.cluster {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

#hud .key-group.cluster kbd:first-child {
  grid-column: 2;
}

#hud .key-group.cluster kbd:nth-child(2) {
  grid-column: 1;
}

/* A dark ring around the light border keeps the key readable on any background. */
#hud kbd {
  min-width: 1.6em;
  padding: 0 5px;
  border: 1px solid rgb(255 255 255 / 0.8);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.45), inset 0 0 0 1px rgb(0 0 0 / 0.25);
  font: inherit;
  font-size: 12px;
  text-align: center;
}
