/* Black, one pink, thin lines. The game is the picture; the page stays out of its way. */
:root {
  --pink: #ff2d95;
  --hot: #ffd9ec;
  --deep: #7a0a45;
  --line: rgba(255, 45, 149, 0.45);
  --glass: rgba(6, 2, 8, 0.72);
  --type: "Avenir Next Condensed", "DIN Condensed", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --left: env(safe-area-inset-left, 0px);
  --right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--hot);
  font-family: var(--type);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

[hidden] { display: none !important; }

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

button {
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* The menu: the track runs behind it. */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.2vh;
  padding: calc(var(--top) + 16px) 20px calc(var(--bottom) + 16px);
  background: radial-gradient(ellipse at 50% 40%, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.82));
}

#logo { width: min(86vw, 132vh, 760px); }
#logo svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 0 14px rgba(255, 45, 149, 0.75)); }

.tag {
  margin: 0;
  font-size: clamp(11px, 2.4vmin, 16px);
  letter-spacing: 0.42em;
  color: var(--pink);
  display: flex;
  align-items: center;
  gap: 1em;
}
.tag i { width: 2.6em; height: 1px; background: var(--line); }

.note { margin: 0; font-size: 13px; letter-spacing: 0.2em; color: rgba(255, 217, 236, 0.75); min-height: 1em; text-align: center; }

nav { display: flex; flex-direction: column; gap: 10px; width: min(78vw, 320px); margin-top: 1vh; }

.btn {
  padding: 13px 18px;
  font-size: 17px;
  letter-spacing: 0.3em;
  border: 1px solid var(--line);
  background: var(--glass);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.btn.big {
  padding: 17px 18px;
  font-size: 24px;
  font-weight: 700;
  color: #1a0010;
  background: linear-gradient(180deg, #ff86c2, var(--pink) 55%, #c4106a);
  border-color: transparent;
}
.btn:active { filter: brightness(1.4); }

footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--bottom) + 10px);
  display: flex;
  justify-content: space-between;
  padding: 0 calc(var(--right) + 16px) 0 calc(var(--left) + 16px);
  font-size: 11px;
  color: rgba(255, 217, 236, 0.5);
}
.link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

@media (orientation: landscape) and (max-height: 520px) {
  .screen { gap: 1.4vh; }
  #logo { width: min(58vw, 150vh); }
  nav { flex-direction: row; width: min(92vw, 720px); }
  nav .btn { flex: 1; padding: 12px 8px; font-size: 14px; }
  nav .btn.big { flex: 1.5; font-size: 20px; }
}

/* The pad: the whole screen steers, and two keys sit under the right thumb. */
#pad { position: fixed; inset: 0; }
.key {
  position: absolute;
  right: calc(var(--right) + 18px);
  width: 104px;
  height: 104px;
  font-size: 15px;
  letter-spacing: 0.22em;
  border: 1px solid var(--line);
  background: rgba(6, 2, 8, 0.38);
  clip-path: polygon(22px 0, 100% 0, 100% calc(100% - 22px), calc(100% - 22px) 100%, 0 100%, 0 22px);
}
#boost { bottom: calc(var(--bottom) + 26px); color: #1a0010; background: rgba(255, 45, 149, 0.6); font-weight: 700; }
#brake { bottom: calc(var(--bottom) + 26px); right: calc(var(--right) + 136px); width: 88px; height: 88px; }
/* Held tall, the brake sits above the boost, and the speed has the bottom left to itself. */
@media (orientation: portrait) {
  #brake { right: calc(var(--right) + 26px); bottom: calc(var(--bottom) + 144px); }
}
.key.down { filter: brightness(1.6); background: rgba(255, 45, 149, 0.9); color: #1a0010; }
#boost.spent { opacity: 0.4; }

/* Where the steering thumb went down, and how far it has gone. */
#puck { position: absolute; width: 0; height: 0; opacity: 0; transition: opacity 0.12s; pointer-events: none; }
#puck.on { opacity: 1; }
#puck::before { content: ""; position: absolute; left: calc(var(--range, 85px) * -1); width: calc(var(--range, 85px) * 2); top: -1px; height: 2px; background: var(--line); }
#puck i { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border: 2px solid var(--hot); transform: translateX(var(--x, 0px)) rotate(45deg); }

/* The HUD. Nothing in it takes a touch but the two chips. */
#hud { position: fixed; inset: 0; pointer-events: none; font-variant-numeric: tabular-nums; text-shadow: 0 0 10px rgba(255, 45, 149, 0.8), 0 1px 2px #000; }
#hud .chip { pointer-events: auto; }
.laps { position: absolute; top: calc(var(--top) + 12px); left: calc(var(--left) + 14px); display: flex; flex-direction: column; gap: 2px; }
#lap-time { font-size: 30px; letter-spacing: 0.06em; }
#lap-best, #lap-delta { font-size: 13px; letter-spacing: 0.16em; color: rgba(255, 217, 236, 0.8); }
#lap-delta.ahead { color: #7dffb6; }
#lap-delta.behind { color: #ff7a7a; }
.top-right { position: absolute; top: calc(var(--top) + 12px); right: calc(var(--right) + 14px); display: flex; align-items: center; gap: 8px; font-size: 13px; }
.chip { padding: 7px 11px; font-size: 11px; letter-spacing: 0.2em; border: 1px solid var(--line); background: var(--glass); }
.speed { position: absolute; left: calc(var(--left) + 16px); bottom: calc(var(--bottom) + 30px); display: flex; align-items: baseline; gap: 8px; }
#speed { font-size: 64px; font-style: italic; line-height: 0.9; letter-spacing: 0; }
.speed span { font-size: 12px; letter-spacing: 0.3em; color: var(--pink); }
.bars { position: absolute; left: calc(var(--left) + 16px); bottom: calc(var(--bottom) + 10px); width: min(46vw, 260px); display: flex; flex-direction: column; gap: 4px; }
.bar { position: relative; height: 5px; background: rgba(255, 255, 255, 0.12); }
.bar i { position: absolute; inset: 0; transform-origin: left; background: var(--pink); }
.bar span { position: absolute; right: -4px; top: -4px; transform: translateX(100%); font-size: 9px; letter-spacing: 0.2em; color: rgba(255, 217, 236, 0.6); }
#bar-heat i { background: #ffb347; }
#bar-heat.cooked i { background: #ff4a4a; }
#flash { position: absolute; left: 0; right: 0; top: 24%; text-align: center; font-size: 34px; font-weight: 700; letter-spacing: 0.2em; }
#flash small { display: block; font-size: 14px; letter-spacing: 0.4em; color: var(--pink); }

/* Sheets: the garage and the tuning panel. Up from the bottom when tall, in from the right when wide. */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48%;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding-bottom: var(--bottom);
  touch-action: pan-y;
}
@media (orientation: landscape) {
  .sheet { left: auto; top: 0; height: auto; width: min(46%, 430px); border-top: 0; border-left: 1px solid var(--line); padding-right: var(--right); }
}
.sheet header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sheet h2 { flex: 1; margin: 0; font-size: 15px; letter-spacing: 0.4em; color: var(--pink); }
#knobs, #sockets { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 14px 18px; touch-action: pan-y; }

.group { margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.4em; color: var(--pink); }
.knob { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 7px 0; font-size: 12px; letter-spacing: 0.12em; }
.knob output { font-variant-numeric: tabular-nums; color: rgba(255, 217, 236, 0.75); }
.knob.changed label, .knob.changed output { color: var(--pink); }
.knob input[type="range"] { grid-column: 1 / -1; width: 100%; height: 26px; margin: 0; accent-color: var(--pink); touch-action: pan-x; }
.knob input[type="color"] { width: 44px; height: 26px; padding: 0; border: 1px solid var(--line); background: none; }

.socket { padding: 12px 0; border-bottom: 1px solid rgba(255, 45, 149, 0.2); }
.socket h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: 0.4em; color: var(--pink); }
.pick { display: flex; align-items: center; gap: 8px; }
.pick b { flex: 1; text-align: center; font-size: 17px; letter-spacing: 0.16em; }
.pick button { width: 42px; height: 36px; border: 1px solid var(--line); font-size: 16px; }
.socket p { margin: 6px 0 2px; font-size: 12px; letter-spacing: 0.06em; text-transform: none; color: rgba(255, 217, 236, 0.8); }
.socket .mods { font-size: 11px; letter-spacing: 0.1em; color: rgba(255, 217, 236, 0.6); }
.mods .up { color: #7dffb6; }
.mods .down { color: #ff9b7a; }

#toast {
  position: fixed;
  left: 50%;
  top: calc(var(--top) + 14px);
  transform: translateX(-50%);
  padding: 9px 16px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: #1a0010;
  background: var(--pink);
  white-space: nowrap;
}
#fail {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: #000;
  color: var(--hot);
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}
