/* Defines universal CSS reset and base body styling */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #050508;
  color: #fff;
}

/* ===== (B) ====/
/* Styles the full-screen loading overlay and its animated progress bar */
#buddyLoadingOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: #050508;
}

#buddyLoadingContent {
  width: min(90%, 320px);
  padding: 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

#buddyLoadingText {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 500;
  color: #d0d0d0;
}

#buddyLoadingBar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

#buddyLoadingBarFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4facfe, #00f2fe);
  border-radius: 999px;
  transition: width 0.2s ease;
}

/* ===== (C) ====/
/* Styles the landscape-orientation lock prompt shown on mobile */
.orientation-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(5, 5, 8, 0.92);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  pointer-events: auto;
  touch-action: none;
}

.orientation-message { max-width: 260px; padding: 20px; }
.orientation-icon { font-size: 2.8rem; display: block; margin-bottom: 10px; }
.orientation-text { font-size: 1.2rem; font-weight: 600; margin: 0 0 6px; }

/* Show only on portrait mobile/tablet */
@media (orientation: portrait) and (max-width: 1024px) {
  .orientation-overlay { display: flex; }
}

/* ===== (E) ====/
/* Positions and styles the on-screen touch D-pad controls */
.touch-dpad {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 999;
  display: grid;
  grid-template-columns: 52px 52px 52px;
  grid-template-rows: 52px 52px 52px;
  gap: 6px;
  touch-action: none;
  user-select: none;
}

.dpad-btn {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.dpad-btn:active, .dpad-btn.active {
  background: rgba(255, 255, 255, 0.35);
}

/* Cross layout positioning */
.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }
.dpad-right { grid-column: 3; grid-row: 2; }

/* Hide on desktop (mouse/keyboard users) */
@media (hover: hover) and (pointer: fine) {
  .touch-dpad { display: none; }
}

/* ===== (G) ====/
/* Sets up the full-size 3D rendering canvas */
#buddyCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ===== (K) Enhanced Roblox Glassmorphism ==== */
.buddy-message-box {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 998;
  display: none;
  max-width: 280px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.15), 
    0 2px 6px rgba(0, 0, 0, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  font-family: "Gotham SSm", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transform: translateY(-50%);
  pointer-events: auto;
  animation: float 3s ease-in-out infinite;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes float {
  0%, 100% { transform: translateY(-52%); }
  50% { transform: translateY(-48%); }
}

.buddy-message-box::after {
  content: "";
  position: absolute;
  left: 24px;
  bottom: -13px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 12px solid rgba(255, 255, 255, 0.85);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

.buddy-message-text {
  margin: 0 0 16px;
  line-height: 1.5;
  font-size: 16px;
  font-weight: 500;
  color: #1a1a1a;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

.buddy-message-link {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, #00A2FF 0%, #0088D6 100%);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 162, 255, 0.25);
  border: none;
  cursor: pointer;
  text-align: center;
}

.buddy-message-link:hover {
  background: linear-gradient(135deg, #0088D6 0%, #0070B8 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0, 162, 255, 0.3);
}

.buddy-message-link:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 162, 255, 0.25);
}