* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #04061a;
  font-family: "Menlo", "Consolas", "Courier New", monospace;
  color: #cfe6ff;
  user-select: none;
}

canvas { display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
}

#hud-top {
  position: absolute; top: 14px; left: 50%;
  transform: translateX(-50%);
  width: min(560px, 80vw);
  display: flex; align-items: center; gap: 14px;
}

#level-name {
  font-size: 12px; letter-spacing: 2px;
  color: #9fd8ff; white-space: nowrap;
  text-shadow: 0 0 8px rgba(53, 224, 255, .6);
}

#progress {
  flex: 1; height: 6px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 3px; overflow: hidden;
}

#progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #35e0ff, #8fffe0);
  box-shadow: 0 0 10px rgba(53,224,255,.8);
}

#timer {
  font-size: 13px; color: #eaf6ff; min-width: 58px; text-align: right;
}

#hud-bars {
  position: absolute; left: 18px; bottom: 18px;
  display: flex; flex-direction: column; gap: 7px;
  width: 200px;
}

.bar { display: flex; align-items: center; gap: 8px; font-size: 10px; letter-spacing: 1px; }
.bar span { width: 34px; color: #9fb8d8; }

.bar .track {
  flex: 1; height: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px; overflow: hidden;
}

.bar .fill { height: 100%; width: 100%; transition: width .08s linear; }
#bar-speed { background: #35e0ff; }
#bar-speed.boost { background: #ff9d35; box-shadow: 0 0 8px #ff9d35; }
#bar-o2 { background: #6f8dff; }
#bar-fuel { background: #ffd35c; }
.fill.low { background: #ff4d5c !important; box-shadow: 0 0 8px #ff4d5c; }

/* ---------- Overlays ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(4,6,26,.55), rgba(2,3,14,.88));
}

.panel {
  text-align: center;
  padding: 36px 44px;
  border: 1px solid rgba(120,180,255,.25);
  border-radius: 10px;
  background: rgba(6,10,32,.82);
  box-shadow: 0 0 60px rgba(40,120,255,.15), inset 0 0 40px rgba(40,120,255,.05);
  max-width: min(560px, 92vw);
}

.panel.small { padding: 26px 40px; }

h1 {
  font-size: 42px; letter-spacing: 8px; font-weight: 700;
  color: #eaf6ff;
  text-shadow: 0 0 18px rgba(53,224,255,.9), 0 0 50px rgba(53,224,255,.4);
}

h1 span {
  display: block; font-size: 15px; letter-spacing: 14px;
  color: #35e0ff; margin-top: 2px;
}

.tagline { font-size: 11px; color: #7d93b8; margin: 10px 0 24px; }

.section-label {
  font-size: 10px; letter-spacing: 3px; color: #5f7ba8; margin-bottom: 10px;
}

#planet-list {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px; margin-bottom: 22px;
}

#road-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 22px; }

.level-btn {
  font-family: inherit; font-size: 13px; letter-spacing: 2px;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: rgba(53,224,255,.06);
  border: 1px solid rgba(53,224,255,.3);
  border-radius: 6px; color: #cfe6ff; cursor: pointer;
}

.level-btn:hover:not(:disabled) {
  background: rgba(53,224,255,.18);
  box-shadow: 0 0 14px rgba(53,224,255,.35);
}

.level-btn:disabled {
  opacity: .32; cursor: default;
  border-color: rgba(255,255,255,.12);
  background: transparent;
}

.level-btn .best { font-size: 10px; color: #8fffe0; }
.level-btn .lock { font-size: 10px; color: #6a7fa0; }

.planet-btn { flex-direction: column; align-items: flex-start; gap: 3px; }
.planet-btn .pname { font-size: 12px; letter-spacing: 2px; }
.planet-btn .pstat { font-size: 9px; color: #6a7fa0; letter-spacing: 1px; }
.planet-btn .pstat.done { color: #8fffe0; }

.back-btn {
  font-family: inherit; font-size: 11px; letter-spacing: 2px;
  background: transparent; border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px; color: #9fb8d8; padding: 8px 14px; cursor: pointer;
}
.back-btn:hover { background: rgba(255,255,255,.06); }

.help { font-size: 11px; color: #8ea6c8; line-height: 1.9; }
.help b { color: #dceeff; }
.help .hint { margin-top: 10px; color: #64789a; font-size: 10px; line-height: 1.6; }

#msg-title {
  font-size: 26px; letter-spacing: 5px; color: #ff5c6e;
  text-shadow: 0 0 16px rgba(255,77,92,.8);
  margin-bottom: 10px;
}

#msg-title.good {
  color: #8fffe0;
  text-shadow: 0 0 16px rgba(80,255,190,.8);
}

#msg-sub { font-size: 12px; color: #9fb8d8; line-height: 1.9; white-space: pre-line; }
#msg-keys { font-size: 11px; color: #7d93b8; margin-top: 10px; }

/* ---------- Touch controls ---------- */

#msg-actions { display: none; gap: 10px; justify-content: center; margin-top: 16px; }

#msg-actions button {
  font-family: inherit; font-size: 13px; letter-spacing: 2px;
  padding: 12px 22px; border-radius: 8px; cursor: pointer;
  background: rgba(53,224,255,.12); color: #dceeff;
  border: 1px solid rgba(53,224,255,.4);
}

#msg-actions #msg-menu { background: transparent; border-color: rgba(255,255,255,.2); color: #9fb8d8; }

body.touch #msg-actions { display: flex; }
body.touch #msg-keys { display: none; }

.touch-help { display: none; }
body.touch .touch-help { display: block; }
body.touch .kb-help { display: none; }
.rotate-hint { display: none; color: #64789a; font-size: 10px; margin-top: 4px; }

#touch-ui button, #btn-pause {
  position: fixed; z-index: 6;
  font-family: inherit; font-weight: 700; color: #dceeff;
  background: rgba(120,180,255,.10);
  border: 1px solid rgba(120,180,255,.35);
  border-radius: 50%;
  touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none;
  display: flex; align-items: center; justify-content: center;
}

#touch-ui button:active { background: rgba(53,224,255,.28); }

#t-steer-l, #t-steer-r {
  width: 68px; height: 68px; font-size: 20px;
  bottom: calc(26px + env(safe-area-inset-bottom));
}
#t-steer-l { left: calc(20px + env(safe-area-inset-left)); }
#t-steer-r { left: calc(104px + env(safe-area-inset-left)); }

#t-jump {
  width: 92px; height: 92px; font-size: 14px; letter-spacing: 1px;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom));
  border-color: rgba(53,224,255,.55);
  background: rgba(53,224,255,.14);
}

#t-brake {
  width: 60px; height: 60px; font-size: 9px; letter-spacing: 1px;
  right: calc(128px + env(safe-area-inset-right));
  bottom: calc(30px + env(safe-area-inset-bottom));
  color: #ffd35c; border-color: rgba(255,211,92,.4);
}

#btn-pause {
  top: calc(12px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  width: 40px; height: 40px; font-size: 12px; border-radius: 10px;
  color: #9fb8d8;
}

@media (orientation: portrait) {
  body.touch .rotate-hint { display: block; }
}

/* ---------- Small screens ---------- */

@media (max-width: 720px), (max-height: 480px) {
  h1 { font-size: 28px; letter-spacing: 5px; }
  h1 span { font-size: 12px; letter-spacing: 9px; }
  .panel { padding: 20px 22px; max-height: 92vh; overflow-y: auto; }
  .panel.small { padding: 20px 26px; }
  .level-btn { padding: 12px 14px; font-size: 12px; }
  .help { font-size: 10px; }
  #hud-bars { width: 148px; left: 12px; bottom: calc(110px + env(safe-area-inset-bottom)); }
  body:not(.touch) #hud-bars { bottom: 14px; }
  #hud-top { width: 86vw; }
  #level-name { font-size: 10px; letter-spacing: 1px; }
  #msg-title { font-size: 20px; letter-spacing: 3px; }
}
