* { box-sizing: border-box; user-select: none; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #060913;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #eef6ff;
}

#game-canvas, #speed-lines {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
}
#speed-lines { pointer-events: none; z-index: 2; }

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

.hud-panel {
  position: absolute;
  background: rgba(7, 11, 24, 0.72);
  border: 1px solid rgba(0, 240, 255, 0.35);
  backdrop-filter: blur(6px);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.hud-tl { top: 16px; left: 16px; min-width: 215px; }
.course-tag { font-size: 11px; font-weight: 800; letter-spacing: 1.8px; color: #00f0ff; }
.course-name { font-size: 17px; font-weight: 800; letter-spacing: 0.6px; margin: 2px 0; }
.cp-row { font-size: 12px; color: #84f5b5; font-weight: 600; }

.hud-tc {
  top: 16px; left: 50%; transform: translateX(-50%);
  text-align: center; min-width: 240px; padding: 8px 20px;
}
.timer-val {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 28px; font-weight: 800; letter-spacing: 1px; color: #ffffff;
  text-shadow: 0 0 14px rgba(0, 240, 255, 0.45);
}
.pb-row { font-size: 11px; font-weight: 700; color: #a7bad9; letter-spacing: 0.8px; margin-top: 2px; }
.pb-row .sep { margin: 0 8px; opacity: 0.4; }
.pb-row .gold { color: #ffd447; }

.hud-tr { top: 16px; right: 16px; width: 328px; }
.tut-head {
  display: flex; justify-content: space-between; font-size: 11px;
  font-weight: 800; letter-spacing: 1.5px; color: #00f0ff; margin-bottom: 6px;
}
.tut-head .muted { color: #88a0c2; }
.tut-step {
  font-size: 13px; font-weight: 700; color: #ffd447;
  background: rgba(255, 212, 71, 0.12);
  border-left: 3px solid #ffd447;
  padding: 5px 8px; border-radius: 4px; margin-bottom: 8px; line-height: 1.3;
}
.tut-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px;
  font-size: 11px; color: #cde0ff;
}
.tut-grid b { color: #00f0ff; }

.hud-bc {
  bottom: 18px; left: 50%; transform: translateX(-50%);
  width: min(360px, 90vw); text-align: center; padding: 10px 16px;
}
.state-pill {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 1.8px;
  padding: 2px 10px; border-radius: 999px; margin-bottom: 4px;
  background: rgba(0, 240, 255, 0.16); color: #00f0ff;
}
.state-pill.hot { background: rgba(255, 62, 165, 0.28); color: #ff69c4; }
.state-pill.wall { background: rgba(56, 255, 168, 0.24); color: #5effb6; }
.speed-row { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.speed-num {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 30px; font-weight: 800; color: #ffffff;
}
.speed-unit { font-size: 12px; font-weight: 700; color: #8ea9cf; }
.bar-track {
  width: 100%; height: 7px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.10); overflow: hidden; margin: 5px 0 8px;
}
.bar-fill { height: 100%; width: 0%; transition: width 0.06s linear; border-radius: 999px; }
.speed-fill { background: linear-gradient(90deg, #00f0ff, #5effb6, #ff3ea5); }
.dash-row { display: flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: #9db4d8; }
.dash-track { flex: 1; height: 5px; margin: 0; }
.dash-fill { width: 100%; background: #00f0ff; }
.music-lbl { color: #a7bad9; }

#crosshair {
  position: fixed; top: 50%; left: 50%; width: 6px; height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 50%; background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.9);
}

#grapple-reticle {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: none; flex-direction: column; align-items: center; pointer-events: none;
}
#grapple-reticle.locked { display: flex; }
#grapple-reticle .diamond {
  width: 24px; height: 24px; border: 2px solid #ff3ea5;
  transform: rotate(45deg);
  box-shadow: 0 0 14px #ff3ea5, inset 0 0 8px rgba(255, 62, 165, 0.45);
}
#grapple-reticle .grapple-label {
  margin-top: 10px; font-size: 10px; font-weight: 800; letter-spacing: 1.3px;
  color: #ff79c6; background: rgba(7, 11, 24, 0.8); padding: 2px 7px; border-radius: 4px;
}

#toast-banner {
  position: fixed; top: 96px; left: 50%; transform: translateX(-50%);
  font-size: 14px; font-weight: 800; letter-spacing: 1.4px;
  padding: 6px 16px; border-radius: 999px;
  background: rgba(8, 14, 28, 0.85); border: 1px solid #5effb6; color: #5effb6;
  opacity: 0; transition: opacity 0.2s ease;
}
#toast-banner.show { opacity: 1; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at center, rgba(12, 18, 38, 0.72), rgba(4, 6, 14, 0.92));
  backdrop-filter: blur(8px);
}
.modal-backdrop.hidden { display: none; }

.modal-card {
  width: min(720px, 92vw);
  background: rgba(10, 15, 32, 0.94);
  border: 1px solid rgba(0, 240, 255, 0.45);
  border-radius: 14px; padding: 26px 28px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 240, 255, 0.14);
}
.kicker { font-size: 11px; font-weight: 800; letter-spacing: 2.5px; color: #ff5ebc; }
.game-title {
  margin: 6px 0 8px; font-size: 46px; font-weight: 900; letter-spacing: 5px;
  background: linear-gradient(90deg, #00f0ff, #ffffff, #ff47ad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.subtitle { font-size: 14px; color: #b7cae8; max-width: 540px; margin: 0 auto 18px; line-height: 1.45; }

.course-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.course-btn {
  background: rgba(18, 28, 56, 0.85); border: 1px solid rgba(110, 150, 220, 0.3);
  border-radius: 10px; padding: 10px 8px; cursor: pointer; color: #eaf3ff;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.course-btn:hover { transform: translateY(-2px); border-color: #00f0ff; }
.course-btn.active {
  border-color: #00f0ff; background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.25);
}
.course-btn .c-num { font-size: 10px; font-weight: 800; color: #00f0ff; letter-spacing: 1.2px; }
.course-btn .c-name { font-size: 12px; font-weight: 700; margin: 4px 0; }
.course-btn .c-pb { font-size: 11px; font-family: 'Consolas', monospace; color: #ffd447; }

.modal-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.btn-primary, .btn-secondary {
  border: none; border-radius: 9px; padding: 12px 26px; font-size: 14px;
  font-weight: 800; letter-spacing: 1.2px; cursor: pointer;
}
.btn-primary {
  background: linear-gradient(90deg, #00f0ff, #42ffb8); color: #041018;
  box-shadow: 0 6px 24px rgba(0, 240, 255, 0.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  background: rgba(255, 255, 255, 0.10); color: #e8f2ff;
  border: 1px solid rgba(255, 255, 255, 0.22);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.18); }

.key-strip { margin-top: 16px; font-size: 11px; color: #8da6cc; font-weight: 600; }

.finish-title { margin: 8px 0 4px; font-size: 26px; font-weight: 900; letter-spacing: 2px; }
.finish-time {
  font-family: 'Consolas', monospace; font-size: 52px; font-weight: 900;
  color: #00f0ff; text-shadow: 0 0 24px rgba(0, 240, 255, 0.5); margin: 8px 0 4px;
}
.finish-sub { font-size: 14px; font-weight: 700; color: #ffd447; margin-bottom: 22px; }

@media (max-width: 780px) {
  .hud-tr { display: none; }
}
