/* Tesla Roadster Sim: keys panel, touch pad, loading screen and responsive rules (load last). */
/* help */
.help {
  position: absolute;
  left: max(16px, env(safe-area-inset-left, 0px));
  top: 64px;
  padding: 12px 16px 12px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.help h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
}
.help h2 + ul {
  margin-bottom: 7px;
}
.help li {
  margin: 1px 0;
}
.help ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.help kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ano);
  border: 1px solid rgba(238, 240, 242, 0.25);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 4px;
}
/* one action per line: the keys in a column of their own, the words beside them, never wrapped */
.help li {
  display: grid;
  grid-template-columns: 72px auto;
  align-items: center;
  color: var(--dim);
  white-space: nowrap;
}
.help .k {
  display: flex;
  gap: 3px;
}
.help .k kbd {
  margin-right: 0;
}
.help .note {
  margin: 6px 0 0;
  color: var(--dim);
  font-size: 10px;
  white-space: nowrap;
}
.help .blip {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--gold);
  vertical-align: 0;
}

.context-hint {
  position: absolute;
  left: 50%;
  bottom: 112px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  text-shadow: 0 1px 6px #000;
}

/* touch pad */
.touch {
  position: absolute;
  inset: auto 0 112px 0;
  display: none;
  justify-content: space-between;
  padding: 0 16px;
}
.touch .cluster {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(2, 54px);
  gap: 8px;
}
.touch .tb {
  pointer-events: auto;
  border-radius: 50%;
  border: 1px solid rgba(238, 240, 242, 0.25);
  background: rgba(10, 12, 18, 0.5);
  color: var(--ano);
  font-family: var(--display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  display: grid;
  place-items: center;
  touch-action: none;
}
.touch .tb.active {
  background: rgba(255, 59, 59, 0.35);
  border-color: var(--led);
}
@media (pointer: coarse) {
  .touch {
    display: flex;
  }
  .help {
    display: none;
  }
  .context-hint {
    display: none;
  }
  .score {
    bottom: auto;
    top: 72px;
  }
}

/* city radar, bottom left like the games it borrows from */
.radar {
  position: absolute;
  left: max(16px, env(safe-area-inset-left, 0px));
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  width: 172px;
  height: 172px;
  border-radius: 50%;
  border: 2px solid rgba(238, 240, 242, 0.28);
  background: rgba(10, 12, 18, 0.55);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  display: none;
}
.in-city .radar {
  display: block;
}
.in-city .score {
  left: auto;
  right: max(16px, env(safe-area-inset-right, 0px));
  top: 104px;
  bottom: auto;
  text-align: right;
}
.city-only,
.in-city .site-only {
  display: none;
}
.help .city-only,
.in-city .help .site-only {
  display: none;
}
.in-city .help li.city-only {
  display: grid;
}
.in-city .help p.city-only {
  display: block;
}
@media (pointer: coarse) {
  /* the drive pad owns the bottom corners on touch screens */
  .radar {
    left: auto;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: auto;
    top: 64px;
    width: 118px;
    height: 118px;
  }
  .in-city .credit {
    display: none;
  }
  .in-city .score {
    top: 194px;
  }
}
.fade {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 5;
}

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--night);
  z-index: 10;
  transition: opacity 0.6s;
}
.loading div {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--dim);
  text-transform: uppercase;
  text-align: center;
  padding-inline: 16px;
}
.credit {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  position: absolute;
  right: max(16px, env(safe-area-inset-right, 0px));
  top: 56px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: rgba(138, 147, 160, 0.7);
  text-align: right;
  max-width: 260px;
}
/* grape.cool, in the bottom right corner */
.promo {
  position: absolute;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ano);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
}
.promo:hover {
  border-color: var(--grape);
}
.promo:focus-visible {
  outline: 2px solid var(--jet);
  outline-offset: 2px;
}
.promo svg {
  width: 14px;
  height: 14px;
  fill: var(--grape);
}
.promo .leaf {
  fill: var(--ok);
  stroke: var(--ok);
  stroke-width: 0.8;
  stroke-linecap: round;
}
/* the telemetry strip reaches the corner on narrower screens: sit just above it */
@media (max-width: 1020px) {
  .promo {
    bottom: calc(max(14px, env(safe-area-inset-bottom, 0px)) + 73px);
    padding: 4px 8px 4px 6px;
  }
  .schematic {
    bottom: 118px;
  }
}

@media (max-width: 760px) {
  .schematic {
    display: none;
  }
  /* the thruster schematic is gone at this size: the radar takes its corner */
  .radar {
    left: auto;
    right: max(16px, env(safe-area-inset-right, 0px));
    top: auto;
    bottom: 106px;
    width: 104px;
    height: 104px;
  }
  .in-city .score {
    left: max(16px, env(safe-area-inset-left, 0px));
    right: auto;
    top: auto;
    bottom: 92px;
    text-align: left;
  }
  .in-city .context-hint {
    display: none;
  }
  .score {
    bottom: 92px;
  }
  .cell {
    padding: 7px 8px 6px;
    min-width: 0;
  }
  .cell .v {
    font-size: 14px;
  }
  .cell.speed .v {
    font-size: 22px;
  }
  .cell.hide-sm {
    display: none;
  }
  .brand h1 {
    font-size: 14px;
  }
  .brand p {
    display: none;
  }
  .credit {
    display: none;
  }
  .promo {
    bottom: calc(max(14px, env(safe-area-inset-bottom, 0px)) + 62px);
  }
  .help {
    display: none;
  }
  .caption {
    top: 18%;
  }
}
@media (max-width: 760px) and (pointer: coarse) {
  /* phones: clear of the drive pad */
  .radar {
    bottom: 244px;
  }
  .in-city .score {
    top: 72px;
    bottom: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  .popup {
    animation-duration: 0.01s;
    animation-fill-mode: forwards;
  }
}
