:root {
  --paper: #f3e7d2;
  --ink: #221d17;
  --teal: #1e4b47;
  --orange: #d9541e;
  --ochre: #e4a62c;
  --sage: #6e8b5a;
  --needle: #d9541e;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: #ded2bb;
  color: var(--ink);
  font-family: "Archivo", Arial, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

#poster {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(100vw, calc(100dvh * 2 / 3));
  height: min(calc(100vw * 3 / 2), 100dvh);
  transform: translate(-50%, -50%);
  background: var(--paper);
  overflow: hidden;
  container-type: inline-size;
  box-shadow: 6px 7px 0 rgba(34, 29, 23, 0.12);
  isolation: isolate;
}

@media (max-aspect-ratio: 2/3) {
  #poster {
    width: 100vw;
    height: 100dvh;
    box-shadow: none;
  }
}

#paper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}

#topband {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 21%;
  z-index: 7;
  pointer-events: none;
}

#masthead {
  position: absolute;
  left: 3.7%;
  top: 3.2%;
  width: 52%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

#notice {
  position: absolute;
  left: 4.35%;
  top: calc(3.2% + 23.4cqw);
  margin: 0;
  font-family: "Archivo", Arial, sans-serif;
  font-size: clamp(7px, 1.2cqw, 11px);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(42, 38, 30, 0.62);
  white-space: nowrap;
}

#tagline {
  position: absolute;
  left: 4.35%;
  top: calc(3.2% + 20.7cqw);
  margin: 0;
  font-family: "Archivo", Arial, sans-serif;
  font-size: clamp(8px, 1.5cqw, 13px);
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #2a261e;
  white-space: nowrap;
}

#dial {
  position: absolute;
  right: 3.2%;
  top: 2.8%;
  width: 22.5%;
  aspect-ratio: 601 / 598;
}

#dialFace {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

#eraseNeedle {
  position: absolute;
  left: 50%;
  top: 15.4%;
  width: 6.2%;
  height: 34.6%;
  transform: translateX(-50%);
  background: #ededdf;
}

#eraseHub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10%;
  height: 10%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #ededdf;
}

#eraseNum {
  position: absolute;
  left: 35.5%;
  top: 70%;
  width: 29%;
  height: 15%;
  background: #ededdf;
}

#topTick {
  position: absolute;
  left: 50%;
  top: 9.4%;
  width: 3.2%;
  height: 7.2%;
  transform: translateX(-50%);
  border-radius: 40%;
  background: #2b2a24;
}

#needleWrap {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  will-change: transform;
}

#needle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3.5%;
  height: 35%;
  transform: translate(-50%, -100%);
  background: var(--needle);
  clip-path: polygon(50% 0%, 78% 7%, 60% 100%, 40% 100%, 22% 7%);
}

#needleBase {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8.2%;
  height: 8.2%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--needle);
  box-shadow: 1px 1px 0 rgba(34, 29, 23, 0.22);
}

#dialSpeed {
  position: absolute;
  left: 0;
  bottom: 12%;
  width: 100%;
  text-align: center;
  font-family: "Barlow Condensed", Impact, sans-serif;
  font-weight: 800;
  font-size: 3.35cqw;
  line-height: 0.9;
  letter-spacing: 0.02em;
  color: #29271f;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

#readout {
  position: absolute;
  right: 3.7%;
  top: calc(2.8% + 22.8cqw);
  text-align: right;
  font-family: "Barlow Condensed", Impact, sans-serif;
  font-size: clamp(9px, 1.75cqw, 15px);
  line-height: 1.12;
  letter-spacing: 0.12em;
  color: #2a261e;
  text-transform: uppercase;
}

#readout .row {
  white-space: nowrap;
}

#readout .lbl {
  margin-right: 0.5em;
  font-family: "Archivo", Arial, sans-serif;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #4b463b;
}

#readout .unit {
  margin-left: 0.35em;
  font-family: "Archivo", Arial, sans-serif;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #4b463b;
}

#readout .num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#world {
  position: absolute;
  left: 0;
  top: 21%;
  width: 100%;
  height: 65%;
  overflow: hidden;
  z-index: 2;
  background: var(--teal);
}

#fieldL,
#fieldR {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
  background: #e0b45b;
}

#fieldL { left: 0; }
#fieldR { right: 0; }

.fieldimg {
  position: absolute;
  left: -2%;
  top: -2%;
  width: 104%;
  height: 104%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 50%;
  user-select: none;
  -webkit-user-drag: none;
}

#roadEdge,
#road {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#roadEdge {
  z-index: 2;
  background: #efe3cc;
  clip-path: polygon(36.5% 0, 63.5% 0, 91.5% 100%, 8.5% 100%);
}

#road {
  z-index: 3;
  background-color: var(--teal);
  background-image: url(assets/road_surface.webp);
  background-size: cover;
  background-position: 50% 50%;
  clip-path: polygon(38% 0, 62% 0, 90% 100%, 10% 100%);
}

#game {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

#game canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#fallbackCar {
  position: absolute;
  left: 50%;
  top: 73%;
  height: 100px;
  width: 56px;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

#bottomband {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 14%;
  z-index: 7;
  pointer-events: none;
}

#legend {
  position: absolute;
  left: 50%;
  top: 9%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  gap: 6.4cqw;
}

.keygroup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1cqw;
  pointer-events: none;
}

.keycap {
  position: relative;
  width: 13.5cqw;
  aspect-ratio: 243 / 264;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.keycap img {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 60ms ease, filter 60ms ease;
  user-select: none;
  -webkit-user-drag: none;
}

.keycap.is-pressed img {
  transform: translateY(0.75cqw) scale(0.97);
  filter: brightness(0.84) contrast(1.08);
}

.keylabel {
  font-family: "Archivo", Arial, sans-serif;
  font-size: clamp(7px, 1.5cqw, 12px);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #2a261e;
}

