* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: #0b1220;
  color: #e7eaf2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

#game-root { position: fixed; inset: 0; }
#three-canvas { display: block; width: 100%; height: 100%; }

#gif-stage {
  position: fixed;
  top: -10000px; left: -10000px;
  width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

/* HUD */
#hud {
  position: fixed; top: 12px; left: 12px; right: 12px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
}
.hud-row { display: flex; gap: 10px; align-items: center; }
.hud-cell {
  background: rgba(8, 14, 28, 0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  min-width: 38px;
  text-align: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#hud-progress { flex: 1; min-width: 80px; padding: 0; overflow: hidden; }
#hud-progress-bar {
  height: 100%;
  display: flex; align-items: center;
  padding: 4px 6px;
}
#hud-progress-fill {
  height: 8px; width: 0%;
  background: linear-gradient(90deg, #8be9fd, #50fa7b);
  border-radius: 4px;
  transition: width 120ms linear;
}

.hidden { display: none !important; }

/* overlays */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(10,18,40,.55), rgba(0,0,0,.85));
  z-index: 10;
  padding: 16px;
}
.overlay-card {
  background: rgba(15,22,40,0.92);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 26px 28px;
  width: min(420px, 100%);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.overlay-card h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.overlay-card h1 .dot { color: #50fa7b; }
.overlay-card h2 { margin: 0 0 14px; font-size: 22px; }
.overlay-card .tag { color: #aab3c6; margin: 0 0 18px; font-size: 14px; }
.controls-hint {
  font-size: 12px;
  color: #93a0bd;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 10px;
  line-height: 1.7;
  margin-bottom: 18px;
}
.controls-hint b { color: #d6dcec; }

.btn-primary, .btn-secondary {
  display: inline-block;
  border: none; border-radius: 8px;
  padding: 12px 18px;
  font-size: 15px;
  cursor: pointer;
  margin: 4px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: transform .08s ease, background .15s ease;
}
.btn-primary { background: linear-gradient(135deg, #50fa7b, #8be9fd); color: #0b1220; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-secondary { background: rgba(255,255,255,0.08); color: #e7eaf2; }
.btn-secondary:hover { background: rgba(255,255,255,0.14); }

.stats {
  display: flex; justify-content: center; gap: 16px;
  margin: 8px 0 14px;
  font-size: 14px; color: #aab3c6;
}
.stats b { color: #fff; font-size: 18px; display: block; }

.overlay-card input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: #fff; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  margin: 6px 0 12px;
  outline: none;
}
.overlay-card input:focus { border-color: #50fa7b; }

.links { margin-top: 14px; font-size: 12px; color: #6b7896; }
.links a { color: #93a0bd; text-decoration: none; margin: 0 6px; }
.links a:hover { color: #50fa7b; }

#scores-list { text-align: left; max-height: 50vh; overflow: auto; padding-left: 22px; }
#scores-list li { padding: 4px 0; color: #c8cee0; }
#scores-list li b { color: #fff; }
#scores-list li.win::before { content: '★ '; color: #f1fa8c; }

/* touchpad */
#touchpad {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
}
#touchpad .tp {
  position: absolute;
  pointer-events: auto;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(8,14,28,0.45);
  color: #fff;
  font-size: 22px;
  backdrop-filter: blur(6px);
}
.tp:active { background: rgba(80,250,123,0.3); }
.tp-left { left: 18px; bottom: 80px; }
.tp-right { left: 102px; bottom: 80px; }
.tp-up { right: 18px; bottom: 144px; }
.tp-down { right: 18px; bottom: 60px; }

@media (max-width: 700px) {
  .overlay-card h1 { font-size: 22px; }
  .hud-cell { font-size: 12px; padding: 5px 8px; }
}
