@font-face {
  font-family: 'Press Start 2P';
  src: url('/fonts/PressStart2P-Regular.ttf') format('truetype');
  font-display: block;
}

:root {
  --yellow: #ffe14d;
  --orange: #ff7a1a;
  --pink: #ff3d7f;
  --celeste: #7fd3ff;
  --bg: #1a0b2e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-items: center;
}

#game {
  width: min(100vw, calc(100dvh * 16 / 9));
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--bg);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.2vh;
  padding: 3vh 4vw;
  text-align: center;
  z-index: 2;
}
.screen.dim { background: rgba(10, 4, 24, 0.82); }
.hidden { display: none !important; }

h2 {
  margin: 0;
  color: var(--yellow);
  font-size: clamp(14px, 3.4vh, 28px);
  text-shadow: 3px 3px 0 #000, 0 0 12px var(--orange);
}

.logo canvas {
  width: min(80vw, 60vh * 3);
  max-width: 720px;
  image-rendering: pixelated;
  filter: drop-shadow(4px 4px 0 #000);
}

.menu { display: flex; flex-direction: column; gap: 1.2vh; }
.menu.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }

button {
  font: inherit;
  font-size: clamp(10px, 2.2vh, 16px);
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 3px solid var(--celeste);
  padding: 1.1vh 2.2vh;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
  text-shadow: 2px 2px 0 #000;
}
button:hover, button:focus-visible, button.selected {
  outline: none;
  color: var(--yellow);
  border-color: var(--yellow);
  background: rgba(255, 122, 26, 0.35);
}
button:disabled { opacity: 0.4; cursor: default; }
button.primary { border-color: var(--yellow); color: var(--yellow); }

.hint { font-size: clamp(8px, 1.6vh, 12px); color: var(--celeste); text-shadow: 2px 2px 0 #000; margin: 0; }
.tiny { font-size: clamp(6px, 1.1vh, 9px); color: #bbb; margin: 0; line-height: 1.7; max-width: 900px; }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.stations { display: flex; gap: 2vw; flex-wrap: wrap; justify-content: center; }
.station {
  width: min(28vw, 240px);
  padding: 2vh 1vw;
  border: 3px solid #555;
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
}
.station .dial { color: var(--orange); font-size: clamp(14px, 3vh, 24px); }
.station .name { margin-top: 1.4vh; font-size: clamp(8px, 1.6vh, 12px); line-height: 1.6; }
.station.selected { border-color: var(--yellow); background: rgba(255, 122, 26, 0.3); }
.station.selected .name { color: var(--yellow); }

.course { display: flex; flex-direction: column; gap: 1.1vh; align-items: center; }
.course .tier { display: flex; gap: 1vw; justify-content: center; align-items: center; }
.course .tier > span { width: 8em; text-align: right; white-space: nowrap; font-size: clamp(6px, 1.2vh, 9px); color: #bbb; }
.course button { font-size: clamp(7px, 1.5vh, 12px); padding: 0.9vh 1.2vh; min-width: 11em; }
.course button small { display: block; margin-top: 0.6vh; font-size: 0.7em; color: var(--orange); }
.course button.selected { box-shadow: 4px 4px 0 #000, 0 0 10px var(--orange); }
@media (max-height: 480px) {
  #course { gap: 1.2vh; padding-top: 1vh; padding-bottom: 1vh; }
  .course { gap: 0.8vh; }
  .course .tier > span { display: none; }
  .course button { min-width: 8.5em; padding: 0.7vh 0.8vh; }
}

.big { font-size: clamp(18px, 5vh, 40px); color: var(--yellow); margin: 0; text-shadow: 3px 3px 0 #000; }
.path { font-size: clamp(7px, 1.4vh, 11px); color: var(--celeste); line-height: 1.8; margin: 0; max-width: 90vw; }
.msg { font-size: clamp(8px, 1.5vh, 12px); min-height: 1.5em; margin: 0; color: var(--yellow); }

.initials { display: flex; gap: 1vw; align-items: center; flex-wrap: wrap; justify-content: center; }
.initials label { font-size: clamp(8px, 1.5vh, 12px); color: var(--celeste); }
.initials input {
  font: inherit;
  font-size: clamp(16px, 3.4vh, 28px);
  width: 4.2em;
  text-align: center;
  text-transform: uppercase;
  background: #000;
  color: var(--yellow);
  border: 3px solid var(--yellow);
  padding: 0.6vh;
  letter-spacing: 0.3em;
}

.tabs { display: flex; gap: 1vw; }
.tabs button.active { color: var(--yellow); border-color: var(--yellow); }
.ranklist {
  list-style: none;
  margin: 0;
  padding: 0;
  width: min(92vw, 760px);
  max-height: 52vh;
  overflow-y: auto;
  font-size: clamp(8px, 1.6vh, 12px);
}
.ranklist li {
  display: grid;
  grid-template-columns: 3em 4em 1fr 9em;
  gap: 1vw;
  padding: 0.7vh 0;
  border-bottom: 1px dashed #333;
  text-align: left;
}
.ranklist li.me { color: var(--yellow); }
.ranklist .score { text-align: right; }
.ranklist .goal { color: var(--celeste); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.helptext { max-width: 860px; font-size: clamp(8px, 1.5vh, 12px); line-height: 2; text-align: left; }
.helptext b { color: var(--yellow); font-weight: normal; }
.toggle { display: block; margin: 0.6vh 0; cursor: pointer; }
.toggle input { transform: scale(1.4); margin-right: 1em; }

.corner {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 5;
  padding: 6px 10px;
}
.corner.off { opacity: 0.45; text-decoration: line-through; }

#touch { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
#touch .pad {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 14px;
  pointer-events: auto;
}
#touch .pad.left { left: max(14px, env(safe-area-inset-left)); }
#touch .pad.right { right: max(14px, env(safe-area-inset-right)); }
#touch .pad button {
  width: 19vmin;
  height: 19vmin;
  font-size: 4vmin;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.5);
  touch-action: none;
}
#touch .pad button.gas { border-color: var(--yellow); color: var(--yellow); }
#touch .pad button.brake { border-color: var(--pink); color: var(--pink); width: 15vmin; height: 15vmin; align-self: flex-end; font-size: 2.6vmin; }
#touch .pad button.down { background: rgba(255, 255, 255, 0.35); }
#touch-pause {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  pointer-events: auto;
  padding: 6px 12px;
}
