@charset "UTF-8";

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a0f1a;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0a0f1a;
}

/* ── Loading ── */
#loading {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #0a0f1a;
  color: #c8d6e5;
  transition: opacity 0.5s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.loading-bar {
  width: min(320px, 70vw); height: 6px;
  background: #1a2540; border-radius: 3px; overflow: hidden;
}
#loading-progress {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #5b8def, #7eb8da);
  border-radius: 3px;
  transition: width 0.2s ease;
}
#loading-text {
  margin-top: 14px;
  font-size: 14px; color: #8395a7; letter-spacing: 0.08em;
}

/* ── Score UI ── */
#score {
  position: fixed; top: 18px; left: 24px; z-index: 50;
  font-size: clamp(18px, 3vw, 32px); font-weight: 700;
  color: #1a2744; letter-spacing: 0.04em;
  text-shadow: 0 0 6px rgba(255,255,255,0.5);
  pointer-events: none;
}

/* ── Top-right controls ── */
#top-controls {
  position: fixed; top: 12px; right: 16px; z-index: 55;
  display: flex; gap: 8px;
}
.top-btn,
#top-controls #sound-toggle {
  width: 44px; height: 44px;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 50%;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(6px);
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.8);
  transition: background 0.2s;
}
.top-btn:hover,
#top-controls #sound-toggle:hover {
  background: rgba(255,255,255,0.25);
}

/* ── Overlays ── */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(10,15,26,0.82);
  backdrop-filter: blur(8px);
  color: #e8edf2;
  text-align: center;
}
.overlay[hidden] { display: none; }

.overlay h1 {
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 700; letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.overlay .sub {
  font-size: clamp(16px, 3vw, 24px);
  color: #8395a7; margin-bottom: 36px;
}
.overlay .btn {
  padding: 14px 48px;
  border: none; border-radius: 12px;
  background: linear-gradient(135deg, #5b8def, #4a7fd4);
  color: #fff; font-size: clamp(18px, 3vw, 24px); font-weight: 600;
  letter-spacing: 0.06em; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 20px rgba(91,141,239,0.35);
}
.overlay .btn:hover { transform: scale(1.05); }
.overlay .btn:active { transform: scale(0.97); }

.overlay .hint {
  margin-top: 24px;
  font-size: 14px; color: #5a6a80;
  max-width: 320px; line-height: 1.7;
}

/* ── Controls card ── */
.controls-card {
  margin-top: 32px;
  padding: 20px 28px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(4px);
  max-width: 420px;
}
.controls-title {
  font-size: 15px; font-weight: 600;
  color: #c8d6e5; margin: 0 0 14px;
  text-align: center; letter-spacing: 0.06em;
}
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.controls-grid .ctrl {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #8395a7;
}
.controls-grid kbd {
  display: inline-block;
  min-width: 24px; padding: 2px 7px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 5px;
  background: rgba(255,255,255,0.08);
  color: #d0d8e4; font-size: 12px; font-weight: 600;
  font-family: inherit; text-align: center;
  line-height: 1.5;
}
.controls-grid .touch-icon {
  font-size: 16px; width: 28px; text-align: center;
}
.controls-mobile {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 13px; color: #7e8fa0;
  text-align: center;
}

/* ── Mobile virtual controls ── */
.mobile-ctrl {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 55;
  justify-content: space-between; align-items: flex-end;
  padding: 0 24px 28px;
  pointer-events: none;
}
@media (pointer: coarse) {
  .mobile-ctrl { display: flex; }
}
.ctrl-group {
  pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.ctrl-btn {
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, transform 0.08s;
}
.ctrl-btn:active, .ctrl-btn.pressed {
  background: rgba(255,255,255,0.32);
  transform: scale(0.9);
}
.ctrl-btn--jump {
  width: 60px; height: 60px;
}
.ctrl-btn--jump span {
  font-size: 24px; line-height: 1;
}
.ctrl-btn--dir {
  width: 68px; height: 68px;
}
.ctrl-btn--dir span {
  font-size: 28px; line-height: 1;
}

#final-score {
  font-size: clamp(24px, 5vw, 40px);
  margin-bottom: 28px;
  color: #ffd166;
  font-weight: 700;
}
