:root {
  --fly-yellow: #facc15;
  --fly-amber: #f59e0b;
  --fly-blue: #38bdf8;
  --fly-red: #ef4444;
  --fly-dark: #0f172a;
  --fly-card: rgba(15, 23, 42, 0.88);
  --fly-card-border: rgba(250, 204, 21, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0284c7;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: #fff;
}

.game-viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Header overlay */
.top-header {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}

.nav-home-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--fly-card);
  border: 1.5px solid var(--fly-card-border);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav-home-btn:hover {
  transform: translateY(-2px);
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--fly-yellow);
}

.title-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--fly-card);
  border: 1.5px solid var(--fly-card-border);
  padding: 6px 16px;
  border-radius: 999px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.badge-icon {
  font-size: 20px;
}

.badge-text {
  font-weight: 900;
  letter-spacing: 0.06em;
  font-size: 13px;
  color: #fff;
}

.badge-tag {
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #0f172a;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 6px;
}

.top-controls {
  pointer-events: auto;
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--fly-card);
  border: 1.5px solid var(--fly-card-border);
  color: #fff;
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  transform: scale(1.08);
  border-color: var(--fly-yellow);
}

/* Floating Distance & Speed HUD */
.hud-cluster {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--fly-card);
  border: 2px solid var(--fly-card-border);
  border-radius: 20px;
  padding: 10px 22px;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 15;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #94a3b8;
  text-transform: uppercase;
}

.hud-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
}

.hud-value.highlight {
  color: var(--fly-yellow);
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.6);
}

.hud-divider {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.15);
}

/* Distance gauge bar */
.distance-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.distance-track {
  position: relative;
  width: 140px;
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.distance-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #10b981);
  border-radius: 999px;
  transition: width 0.1s ease;
}

/* Floating Buzz Boy Proximity / Taunt Bubble */
.proximity-tracker {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #38bdf8;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.35);
  pointer-events: none;
  z-index: 15;
  transition: all 0.2s ease;
}

.proximity-tracker .taunt-text {
  color: #facc15;
}

/* Turbo / Boost Meter at Bottom */
.boost-panel {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--fly-card);
  border: 2px solid rgba(245, 158, 11, 0.4);
  padding: 10px 24px;
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 15;
}

.boost-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 20px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #facc15;
}

.boost-bar {
  width: 200px;
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(250, 204, 21, 0.4);
  position: relative;
}

.boost-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444, #facc15);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
  transition: width 0.08s ease;
}

.boost-hint {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 700;
}

/* Touch On-Screen Controls for mobile / touch */
.touch-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 25;
}

.touch-dpad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
  pointer-events: auto;
}

.touch-btn {
  background: rgba(15, 23, 42, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  touch-action: manipulation;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
}

.touch-btn:active {
  background: var(--fly-yellow);
  color: #0f172a;
  transform: scale(0.92);
}

.touch-boost-btn {
  pointer-events: auto;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border: 3px solid #facc15;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.5);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s;
}

.touch-boost-btn:active {
  transform: scale(0.92);
}

/* Modals & Overlays */
.overlay-modal {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.modal-card {
  max-width: 520px;
  width: 100%;
  background: linear-gradient(145deg, #0f172a, #1e293b);
  border: 3px solid var(--fly-yellow);
  border-radius: 28px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(250, 204, 21, 0.25);
  position: relative;
  overflow: hidden;
}

.modal-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.modal-badge {
  display: inline-block;
  background: var(--fly-yellow);
  color: #0f172a;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 32px;
  font-weight: 900;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 12px;
}

.modal-title span {
  color: var(--fly-yellow);
}

.modal-desc {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-keys-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 26px;
  text-align: left;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
  border-radius: 12px;
}

.key-badge {
  background: #334155;
  border: 1px solid #64748b;
  color: #facc15;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 0 #1e293b;
}

.key-text {
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
}

.modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 28px;
  background: linear-gradient(135deg, #facc15, #f59e0b);
  border: none;
  border-radius: 999px;
  color: #0f172a;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(245, 158, 11, 0.7);
}

.modal-btn:active {
  transform: translateY(1px);
}

/* Victory / Level Complete card */
.victory-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(250, 204, 21, 0.3);
  padding: 12px 8px;
  border-radius: 16px;
}

.stat-box .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 900;
  color: var(--fly-yellow);
}

.stat-box .lbl {
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  margin-top: 4px;
  letter-spacing: 0.08em;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 768px) {
  .hud-cluster {
    top: 64px;
    padding: 6px 14px;
    gap: 10px;
  }
  .hud-value {
    font-size: 16px;
  }
  .distance-track {
    width: 90px;
  }
  .boost-panel {
    bottom: 96px;
    padding: 6px 16px;
  }
  .boost-bar {
    width: 140px;
  }
  .proximity-tracker {
    bottom: 160px;
    font-size: 11px;
    padding: 6px 14px;
  }
}
