* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0d1117;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #e8edf2;
  -webkit-user-select: none;
  user-select: none;
}

#backLink {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 10;
  font-size: 12px;
  font-weight: 600;
  color: rgba(232,237,242,0.5);
  text-decoration: none;
  transition: color 0.2s;
}

#backLink:hover { color: #ffd23f; }

#stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1100px;
  height: 650px;
  transform-origin: center center;
  transform: translate(-50%, -50%);
}

canvas#track {
  display: block;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  background: #6b8e4e;
}

#hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  gap: 14px;
  pointer-events: none;
}

#hud > div {
  background: rgba(10, 14, 20, 0.72);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

#hudPos { color: #ffd23f; }
#hudSpeed { color: #6fd3ff; }
#hudHeat { color: #8effa1; }

.hidden { display: none; }

#resetBtn {
  pointer-events: auto;
  margin-left: auto;
  background: rgba(10, 14, 20, 0.72);
  border: 1px solid rgba(255,255,255,0.18);
  color: #cfd8e3;
  padding: 8px 16px;
  font-size: 13px;
}

#resetBtn:hover { background: rgba(255, 93, 59, 0.85); color: #1a1005; }

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.panel {
  pointer-events: auto;
  background: rgba(12, 16, 24, 0.92);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 22px 34px;
  text-align: center;
  max-width: 460px;
  max-height: 560px;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.panel.hidden { display: none; }

.panel h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 0.08em;
  color: #ffd23f;
}

.panel .sub {
  margin: 0 0 12px;
  color: #9fb0c3;
  font-size: 13px;
}

.rules {
  text-align: left;
  margin: 0 0 14px;
  padding-left: 20px;
  color: #cfd8e3;
  font-size: 13px;
  line-height: 1.4;
}

.difficulty {
  margin: 0 0 14px;
}

.difficultyLabel {
  display: block;
  color: #9fb0c3;
  font-size: 12px;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.difficultyOptions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diffBtn {
  flex: 1 1 auto;
  min-width: 68px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16);
  color: #cfd8e3;
  padding: 9px 4px;
  font-size: 11.5px;
  letter-spacing: 0.01em;
}

.diffBtn:hover { background: rgba(255,255,255,0.12); }

.diffBtn.active {
  background: #ffd23f;
  border-color: #ffd23f;
  color: #1a1005;
}

.gameMode {
  margin: 0 0 14px;
  text-align: left;
}

.modeToggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cfd8e3;
  font-size: 13px;
  cursor: pointer;
}

.modeToggle input { accent-color: #ffd23f; width: 15px; height: 15px; }
.modeToggle + .modeToggle { margin-top: 8px; }

button {
  background: #ff5d3b;
  color: #1a1005;
  border: none;
  border-radius: 8px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

button:hover { background: #ff7c5c; }
button:active { transform: scale(0.96); }

#countdownNum {
  font-size: 110px;
  font-weight: 900;
  color: #ffd23f;
  text-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

#resultsList {
  text-align: left;
  margin: 0 0 16px;
  padding-left: 26px;
  font-size: 15px;
  line-height: 1.9;
}

#resultsList .you { color: #ffd23f; font-weight: 800; }

#standingsBlock {
  margin: 0 0 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.standingsLabel {
  display: block;
  color: #9fb0c3;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

#standingsList {
  text-align: left;
  margin: 0;
  padding-left: 26px;
  font-size: 14px;
  line-height: 1.7;
  color: #cfd8e3;
}

#standingsList .you { color: #ffd23f; font-weight: 800; }
#standingsList .leader { color: #8effa1; }

#recordLine {
  font-size: 12.5px;
  color: #8fa0b3;
  margin-bottom: 20px;
}

#steerControls {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  pointer-events: none;
}

.steerBtn {
  pointer-events: auto;
  padding: 16px 34px;
  font-size: 14px;
  border-radius: 30px;
  color: #1a1005;
  touch-action: none;
}

#steerLeftBtn { background: rgba(255, 93, 59, 0.85); }
#steerRightBtn { background: rgba(111, 211, 255, 0.75); }

.steerBtn.pressed {
  background: #fff;
  transform: scale(0.95);
}
