:root {
  --fg: #fff;
  --bg: #0b1020;
  --chip: rgba(0, 0, 0, 0.45);
}
html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  overflow: hidden;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--fg);
  touch-action: none;
}
canvas {
  display: block;
}
#hud {
  position: fixed;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: var(--chip);
  padding: 8px 14px;
  border-radius: 12px;
}
#spd {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}
#hud small {
  opacity: 0.8;
}
#help {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: var(--chip);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}
#load {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-size: 18px;
  z-index: 5;
}
.btn {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--chip);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}
.btn.on {
  background: rgba(255, 255, 255, 0.35);
}
@media (pointer: coarse) {
  .btn {
    display: flex;
  }
  #help {
    display: none;
  }
}
#msg {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: var(--chip);
  padding: 18px 28px;
  border-radius: 14px;
  font-size: 24px;
  text-align: center;
  display: none;
  z-index: 4;
}
#pbtn {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  transform: translateX(-50%);
  background: var(--chip);
  padding: 6px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 18px;
  user-select: none;
  z-index: 3;
}
#menu {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 6;
}
.mbox {
  background: #161b2e;
  border-radius: 16px;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 240px;
  max-width: 86vw;
  text-align: center;
}
.mbox h2 {
  margin: 0 0 4px;
}
.mbox button.mb {
  font: inherit;
  font-size: 16px;
  padding: 10px;
  border-radius: 10px;
  border: 0;
  background: #2b3556;
  color: #fff;
  cursor: pointer;
}
.mbox button.mb:hover {
  background: #3a4772;
}
.sw {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 4px 0;
}
.swb {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0;
}
.mbox small {
  opacity: 0.7;
  font-size: 11px;
  line-height: 1.4;
}
#start {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.55));
  z-index: 5;
}
.big {
  max-width: min(92vw, 480px);
}
.big h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 2px;
}
.sub {
  margin: 0;
  opacity: 0.85;
  font-size: 14px;
  line-height: 1.5;
}
.row {
  display: flex;
  gap: 8px;
}
.row .mb {
  flex: 1;
}
.go {
  background: #d8261e !important;
  font-weight: 700;
  font-size: 18px !important;
}
.go:hover {
  background: #f03a2e !important;
}
#mini {
  display: none;
  position: fixed;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 150px);
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  z-index: 2;
}
#garrow {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 54px);
  display: none;
  flex-direction: column;
  align-items: center;
  font-size: 13px;
  text-shadow: 0 1px 3px #000;
  z-index: 2;
}
#gar {
  font-size: 26px;
  color: #ffd23f;
  line-height: 1;
}
#drops {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.grid .mb {
  font-size: 14px !important;
  padding: 9px 6px !important;
}
#dmg {
  width: 120px;
  height: 6px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
#dmgBar {
  display: block;
  height: 100%;
  width: 100%;
  background: #4ade80;
}
#toast {
  position: fixed;
  left: 50%;
  top: 24%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 2px 6px #000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 4;
  text-align: center;
  max-width: 90vw;
}
#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
#bustV {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0) 45%, rgba(255, 0, 0, 0.75) 100%);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
#garage {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 8;
}
.urow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.pips {
  letter-spacing: 3px;
  color: #ffd23f;
}
.urow .mb {
  min-width: 130px;
}
.mb:disabled {
  opacity: 0.45;
  cursor: default;
}
/* ---- Hill Drive: Horizon additions ---- */
[hidden] {
  display: none !important;
}

html,
body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Title: "HILL DRIVE" with a sunset-coloured "HORIZON" line under it */
.big h1 span {
  display: block;
  margin: 4px -0.62em 0 0;
  font-size: 0.42em;
  font-weight: 600;
  letter-spacing: 0.62em;
  color: #ffb347;
  text-shadow: 0 0 18px rgba(255, 140, 60, 0.45);
}

/* PWA: "update ready" bar */
#upd {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 16px;
  background: #161b2e;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
#upd button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 9px;
  padding: 7px 14px;
  background: #d8261e;
  color: #fff;
  cursor: pointer;
}
#upd button.x {
  background: transparent;
  font-weight: 400;
  opacity: 0.7;
  padding: 7px 8px;
}

/* end-of-run message: tappable, with a "new best" flourish */
#msg {
  cursor: pointer;
}
#msg small {
  opacity: 0.75;
}
.nb {
  color: #ffd23f;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 6px;
  animation: nbPulse 0.9s ease-in-out infinite alternate;
}
@keyframes nbPulse {
  from {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(255, 210, 63, 0);
  }
  to {
    transform: scale(1.12);
    text-shadow: 0 0 16px rgba(255, 210, 63, 0.8);
  }
}
@media (prefers-reduced-motion: reduce) {
  .nb {
    animation: none;
  }
}

/* rotate-your-phone overlay: touch devices held in portrait */
#rot {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background: var(--bg);
  text-align: center;
  font-size: 20px;
}
#rot i {
  display: block;
  font-style: normal;
  font-size: 64px;
  animation: rotHint 1.8s ease-in-out infinite;
}
@keyframes rotHint {
  0%, 30% { transform: rotate(0); }
  70%, 100% { transform: rotate(-90deg); }
}
@media (pointer: coarse) and (orientation: portrait) {
  #rot { display: flex; }
}
@media (prefers-reduced-motion: reduce) {
  #rot i { animation: none; }
}
