* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0a1420; }
body { font-family: 'Segoe UI', system-ui, sans-serif; color: #eaf4ff; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(20,60,95,0.55), rgba(4,10,18,0.88));
  backdrop-filter: blur(3px); z-index: 20;
}
.panel {
  background: rgba(8, 22, 36, 0.88); border: 1px solid rgba(90, 200, 255, 0.25);
  border-radius: 14px; padding: 34px 44px; text-align: center;
  box-shadow: 0 12px 60px rgba(0,0,0,0.6); max-width: 640px;
}
.panel h2 { letter-spacing: 4px; font-weight: 600; margin-bottom: 22px; color: #9fdcff; }

.titleBlock { text-align: center; }
.gameTitle {
  font-size: 92px; font-weight: 800; letter-spacing: 10px; color: #fff;
  text-shadow: 0 0 40px rgba(60, 200, 255, 0.8), 0 4px 0 rgba(0,0,0,0.4);
}
.gameTitle span { color: #35e0ff; }
.gameSub { margin: 6px 0 34px; letter-spacing: 3px; color: #8fc3e8; font-size: 15px; }
.foot { margin-top: 30px; font-size: 11px; color: #5b7c96; letter-spacing: 1px; }

.menuBtns { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.btn {
  font: inherit; font-size: 16px; letter-spacing: 2px; cursor: pointer;
  color: #dff2ff; background: linear-gradient(180deg, rgba(40,90,130,0.85), rgba(20,50,80,0.85));
  border: 1px solid rgba(120, 210, 255, 0.4); border-radius: 8px;
  padding: 12px 34px; min-width: 240px; transition: all .15s;
}
.btn:hover { background: linear-gradient(180deg, rgba(60,140,190,0.95), rgba(30,80,120,0.95)); transform: translateY(-1px); box-shadow: 0 4px 18px rgba(50,190,255,0.35); }
.btn.big { font-size: 20px; padding: 16px 40px; border-color: rgba(140, 230, 255, 0.7); }

/* level cards */
#levelCards { display: flex; gap: 16px; justify-content: center; margin-bottom: 26px; flex-wrap: wrap; }
.card {
  width: 178px; padding: 18px 14px; border-radius: 10px; cursor: pointer;
  background: rgba(16, 40, 62, 0.9); border: 1px solid rgba(90, 200, 255, 0.25);
  transition: all .15s; text-align: center;
}
.card:hover { transform: translateY(-3px); border-color: #35e0ff; box-shadow: 0 6px 24px rgba(50,190,255,0.3); }
.card h3 { font-size: 15px; letter-spacing: 2px; color: #9fdcff; margin-bottom: 8px; }
.card p { font-size: 11px; color: #a8c6dd; line-height: 1.45; min-height: 46px; }
.card .meta { margin-top: 10px; font-size: 11px; color: #6fa8cc; }
.card .starsLine { color: #ffd23e; font-size: 15px; letter-spacing: 3px; }

/* help */
.controlsGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 26px; text-align: left; margin-bottom: 18px; }
.controlsGrid div { display: flex; gap: 12px; align-items: baseline; font-size: 14px; }
.controlsGrid b { color: #35e0ff; font-family: monospace; min-width: 66px; }
.controlsGrid span { color: #b9d4e8; }
.tip { font-size: 13px; color: #9fbdd4; line-height: 1.55; margin-bottom: 20px; }

/* finish */
.stars { font-size: 44px; letter-spacing: 10px; color: #ffd23e; text-shadow: 0 0 24px rgba(255,210,62,0.6); margin-bottom: 8px; }
.stars .off { color: rgba(255,255,255,0.18); text-shadow: none; }
.finTime { font-size: 34px; font-family: monospace; color: #fff; }
.finBest { font-size: 13px; color: #7fb2d4; margin: 8px 0 24px; }

/* loading */
.loadTitle { font-size: 34px; font-weight: 800; letter-spacing: 8px; color: #35e0ff; margin-bottom: 18px; }
#loadText { font-size: 13px; color: #8fc3e8; margin-bottom: 14px; letter-spacing: 1px; }
.loadBar { width: 320px; height: 6px; background: rgba(255,255,255,0.12); border-radius: 3px; overflow: hidden; margin: 0 auto; }
#loadFill { height: 100%; width: 0%; background: linear-gradient(90deg, #1899c9, #35e0ff); transition: width .2s; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hudTop { position: absolute; top: 18px; left: 22px; right: 22px; display: flex; justify-content: space-between; align-items: flex-start; }
#hudLeft { text-shadow: 0 2px 6px rgba(0,0,0,0.7); }
#lvlName { font-size: 15px; letter-spacing: 3px; color: #9fdcff; }
#cpCount { font-size: 26px; font-weight: 700; }
#timer { font-size: 20px; font-family: monospace; color: #ffd23e; }
#minimap {
  border-radius: 50%; border: 2px solid rgba(120, 210, 255, 0.35);
  background: rgba(6, 18, 30, 0.55); box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

#hudBottom { position: absolute; bottom: 20px; left: 22px; right: 22px; display: flex; justify-content: space-between; align-items: flex-end; }
#gaugesLeft { display: flex; gap: 26px; }
.gauge { text-shadow: 0 2px 6px rgba(0,0,0,0.7); }
.gauge .gLabel { font-size: 11px; letter-spacing: 2px; color: #7fb2d4; margin-right: 8px; }
.gauge #speedVal, .gauge #altVal { font-size: 30px; font-weight: 700; font-family: monospace; }
.gauge .gUnit { font-size: 12px; color: #9fc4de; margin-left: 4px; }
.gauge .bar { width: 150px; height: 5px; background: rgba(255,255,255,0.15); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.gauge .bar div { height: 100%; width: 0%; background: linear-gradient(90deg, #1899c9, #35e0ff); }
#thrWrap { position: relative; width: 26px; height: 130px; background: rgba(255,255,255,0.12); border-radius: 6px; overflow: hidden; border: 1px solid rgba(120,210,255,0.3); }
#thrBar { position: absolute; bottom: 0; left: 0; right: 0; height: 50%; background: linear-gradient(180deg, #ffd23e, #ff8c1a); }
#thrWrap .gLabel { position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-size: 9px; color: #06263c; font-weight: 700; }

#message {
  position: absolute; top: 26%; left: 0; right: 0; text-align: center;
  font-size: 44px; font-weight: 800; letter-spacing: 6px; color: #fff;
  text-shadow: 0 0 30px rgba(53, 224, 255, 0.9), 0 3px 0 rgba(0,0,0,0.5);
  animation: msgPop 0.35s ease-out;
}
#message.good { color: #7dffb0; text-shadow: 0 0 30px rgba(90,255,160,0.9); }
#message.bad { color: #ff7a5c; text-shadow: 0 0 30px rgba(255,110,80,0.9); }
@keyframes msgPop { 0% { transform: scale(1.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

#countdown {
  position: absolute; top: 38%; left: 0; right: 0; text-align: center;
  font-size: 130px; font-weight: 800; color: #ffd23e;
  text-shadow: 0 0 50px rgba(255, 210, 62, 0.8);
}
#countdown.pop { animation: cdPop 0.9s ease-out; }
@keyframes cdPop { 0% { transform: scale(2.2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.9); opacity: 0.9; } }

#ringArrow { position: absolute; width: 46px; height: 46px; text-align: center; }
.arrowHead {
  width: 0; height: 0; margin: 0 auto;
  border-left: 13px solid transparent; border-right: 13px solid transparent;
  border-bottom: 22px solid rgba(53, 224, 255, 0.95);
  filter: drop-shadow(0 0 8px rgba(53,224,255,0.8));
}
.arrowDist { font-size: 11px; font-family: monospace; color: #bff0ff; margin-top: 3px; text-shadow: 0 1px 4px #000; }
#ringArrow.edge .arrowHead { border-bottom-color: rgba(255, 210, 62, 0.95); }

#crashFlash { position: absolute; inset: 0; background: radial-gradient(ellipse, rgba(255,60,20,0.55), rgba(120,0,0,0.75)); opacity: 0; transition: opacity .25s; }
#crashFlash.on { opacity: 1; }

#muteTag { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); font-size: 11px; letter-spacing: 2px; color: #ff9d7a; }
/* ============ touch controls ============ */
#touchUI { position: fixed; inset: 0; pointer-events: none; z-index: 40; display: none; }
body.touch #touchUI { display: block; }
#stickZone { position: absolute; left: 0; top: 0; width: 55%; height: 100%; pointer-events: auto; touch-action: none; }
#stickBase {
  position: absolute; width: 118px; height: 118px; margin: -59px 0 0 -59px;
  border: 2px solid rgba(255,255,255,0.45); border-radius: 50%;
  background: rgba(20,30,45,0.28); backdrop-filter: blur(2px);
}
#stickKnob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(255,255,255,0.75); box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
#thrWrap { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: auto; text-align: center; }
#thrTrack {
  position: relative; width: 34px; height: 38vh; min-height: 160px;
  border: 2px solid rgba(255,255,255,0.45); border-radius: 18px;
  background: rgba(20,30,45,0.28); touch-action: none;
}
#thrKnob {
  position: absolute; left: 3px; bottom: 50%; width: 24px; height: 24px; margin-bottom: -12px;
  border-radius: 50%; background: rgba(255,190,80,0.9); box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.thrLabel { display: block; margin-top: 6px; font: 600 11px/1 monospace; color: rgba(255,255,255,0.7); letter-spacing: 1px; }
#tButtons { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; pointer-events: auto; }
.tbtn {
  min-width: 58px; padding: 12px 10px; border: 2px solid rgba(255,255,255,0.45); border-radius: 12px;
  background: rgba(20,30,45,0.35); color: #fff; font: 700 12px/1 monospace; letter-spacing: 1px;
  touch-action: none;
}
.tbtn.on { background: rgba(90,200,255,0.55); border-color: #fff; }
/* compact HUD on small screens */
@media (max-width: 760px) {
  #hud { transform: scale(0.8); transform-origin: top left; }
}
