* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: #0b0b12;
  color: #eee;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  overflow: hidden;
  user-select: none;
}
#app {
  position: relative;
  width: 960px; height: 540px;
  margin: 20px auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 2px #333, 0 10px 40px rgba(0,0,0,0.6);
}
canvas { display: block; background: #87ceeb; }
.hidden { display: none !important; }

#hud { position: absolute; top: 0; left: 0; right: 0; }
#hudTop {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.4);
  font-weight: bold; font-size: 15px;
}
#hudSpeed span { font-size: 11px; opacity: 0.7; font-weight: normal; }
#hudProgressWrap {
  flex: 1; height: 8px; background: rgba(255,255,255,0.2); border-radius: 4px; overflow: hidden;
}
#hudProgressBar { height: 100%; width: 0%; background: #4ad0ff; }
#hudTop button { margin: 0; padding: 4px 10px; font-size: 14px; }
#flipPopup {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  font-size: 22px; font-weight: bold; color: #ffd54a;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
  opacity: 0; pointer-events: none;
}

#touchControls { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; padding: 14px; pointer-events: none; }
.touchSide { display: flex; gap: 10px; pointer-events: auto; }
.touchBtn {
  width: 58px; height: 58px; border-radius: 50%;
  background: rgba(255,255,255,0.18); border: 2px solid rgba(255,255,255,0.4);
  color: #fff; font-size: 20px; margin: 0;
}
.touchBtn:active { background: rgba(255,255,255,0.4); }

.screen {
  position: absolute; inset: 0;
  background: rgba(5,5,10,0.88);
  display: flex; align-items: center; justify-content: center;
}
.panel {
  background: #1a1a28; border: 1px solid #333; border-radius: 10px;
  padding: 22px 30px; max-width: 540px; text-align: center;
}
.panel.wide { max-width: 860px; width: 820px; }
.panel h1 { margin: 0 0 6px; letter-spacing: 1px; }
.panel .tag { opacity: 0.7; font-size: 13px; margin-top: 0; }
.wheelie { margin-left: 8px; display: inline-block; animation: wob 1.6s ease-in-out infinite; }
@keyframes wob { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

button {
  background: #4a6cf7; color: #fff; border: none;
  padding: 9px 20px; border-radius: 6px; font-size: 14px; cursor: pointer; margin: 5px 4px;
}
button:hover { filter: brightness(1.15); }
button:disabled { background: #444; color: #888; cursor: not-allowed; }

.controls { margin-top: 12px; font-size: 13px; line-height: 1.7; text-align: left; display: inline-block; }
.controls.small { font-size: 12px; opacity: 0.75; }
.small { opacity: 0.7; font-size: 12px; }

#worldTabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
#worldTabs button { background: #2a2a40; font-size: 12px; }
#worldTabs button.active { background: #4a6cf7; outline: 2px solid #fff; }

#levelGrid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
  padding: 6px 4px; max-height: 300px; overflow-y: auto;
}
#levelGrid button { margin: 0; padding: 10px 0; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
#levelGrid button.current { outline: 2px solid #fff; }
#levelGrid .stars { font-size: 10px; color: #ffd54a; }

#bikeList { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; margin: 10px 0; }
.bikeRow { background: #12121c; border-radius: 8px; padding: 10px 14px; text-align: left; display: flex; align-items: center; gap: 14px; }
.bikeRow.selected { outline: 2px solid #4ad0ff; }
.bikeRow .bikeName { font-weight: bold; min-width: 110px; }
.bikeRow .bars { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; font-size: 10px; }
.statBar { background: #333; border-radius: 3px; height: 6px; overflow: hidden; margin-top: 2px; }
.statBar i { display: block; height: 100%; background: #4ad0ff; }
.bikeRow button { margin: 0; font-size: 12px; padding: 6px 12px; }

#colorPicks { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid #0000; }
.swatch.active { border-color: #fff; }

#coinCount { font-weight: bold; color: #ffd54a; margin-bottom: 6px; }
#winStars { font-size: 34px; letter-spacing: 6px; margin: 6px 0; }
#winStats { white-space: pre-line; }

#modePick { margin-bottom: 6px; }
.modeBtn { background: #2a2a40; }
.modeBtn.selected { background: #4a6cf7; outline: 2px solid #fff; }
.p1c { color: #4ad0ff; }
.p2c { color: #ff5b7a; }
