/* Loading Screen Styles */
#loading-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#loading-bg {
  position: fixed;
  inset: 0;
  background: url("../assets/backgrounds/loading_screen.png") center/cover no-repeat;
  /* Add these two lines */
  background-attachment: fixed; 
  height: 100%;
  z-index: -1;
}

/* Consolidated Game Title (for both loading and login screens) */
#game-title {
  font-family: 'Cinzel', serif;
  color: #f5e6c8;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 0.2rem;
  text-shadow: 0 0 20px rgba(255, 215, 150, 0.8), 2px 2px 5px #000;
  font-size: clamp(1.5rem, 5vw, 3rem); /* Reduced from original */
  padding: 20px;
  text-align: center;
  width: 100%;
  display: block;
  animation: qi-glow 3s ease-in-out infinite alternate;
  margin-bottom: 20px; 
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(0);
}

@keyframes qi-glow {
  from {
    text-shadow: 0 0 10px rgba(255, 215, 150, 0.5);
    transform: scale(1);
  }
  to {
    text-shadow: 0 0 30px rgba(255, 215, 150, 1), 0 0 50px rgba(255, 165, 0, 0.4);
    transform: scale(1.05);
  }
}

#loading-panel {
  position: absolute;
  bottom: 15%; /* Moved up slightly to avoid overflow */
  width: 70%; /* Reduced from 80% */
  max-width: 500px; /* Reduced from 600px */
  display: flex;
  flex-direction: column;
  align-items: center;
}

#loading-bar-bg {
  background: url("../assets/loading_bar_bg.png") no-repeat center/contain;
  height: 30px;
  width: 100%;
  position: relative;
}

#loading-bar-fill {
  background: url("../assets/loading_bar_fill.png") no-repeat left/contain;
  height: 100%;
  width: 0%;
  transition: width 0.4s ease;
}

#loading-text {
  order: 2;
  color: #f5e6c8;
  font-size: clamp(12px, 1.5vw, 14px); /* Reduced from original */
  margin-top: 15px;
  text-shadow: 0 0 10px rgba(255, 215, 150, 0.6);
  font-style: italic;
}

#loading-percent {
  color: #e0d6b8;
  font-size: 10px; /* Reduced from 12px */
  margin-top: 5px;
}

/* Login Screen Styles */
#login-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  background: transparent;
}

#game-title {
  margin-top: 2rem;
  margin-bottom: auto;
}

.journey-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: auto;
  width: 90%;
  max-width: 400px;
}

.stylish-btn {
  font-family: 'Cinzel', serif;
  padding: 15px 30px;
  font-size: 1.2rem;
  text-transform: uppercase;
  cursor: pointer;
  border: 2px solid #f5e6c8;
  background: rgba(20, 20, 20, 0.8);
  color: #f5e6c8;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

.stylish-btn:hover {
  background: #f5e6c8;
  color: #1a1a1a;
  box-shadow: 0 0 25px rgba(245, 230, 200, 0.6);
  transform: translateY(-3px);
}

.primary-btn {
  border-color: #ffd700;
  box-shadow: inset 0 0 10px rgba(255, 215, 0, 0.2);
}

.secondary-btn {
  border-color: #c0c0c0;
}

/* Portal Box Styles */
.portal-box {
  position: relative;
  background: radial-gradient(circle at center, rgba(30, 25, 15, 0.95) 0%, rgba(10, 10, 10, 0.98) 100%);
  padding: 40px;
  border: 1px solid rgba(212, 175, 55, 0.5);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  animation: box-entry 1.5s ease-out forwards, floating 4s ease-in-out infinite;
  z-index: 10;
}

.portal-box::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  z-index: -1;
  background: linear-gradient(45deg, #d4af37, #f5e6c8, #b8860b, #d4af37);
  background-size: 400%;
  border-radius: 10px;
  filter: blur(15px);
  opacity: 0.4;
  animation: qi-pulse 8s linear infinite;
}

.portal-box::after {
  content: "◈";
  position: absolute;
  color: #d4af37;
  font-size: 1.5rem;
  bottom: 5px;
  right: 5px;
}

@keyframes qi-pulse {
  0% { background-position: 0% 50%; opacity: 0.3; }
  50% { background-position: 100% 50%; opacity: 0.6; }
  100% { background-position: 0% 50%; opacity: 0.3; }
}

.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ffd700;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 0 10px #fff;
  animation: sparkle-fly 0.8s ease-out forwards;
}

@keyframes sparkle-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* MMORPG Button Styles */
.mmorpg-btn {
  width: 100%;
  margin: 20px 0;
  padding: 14px;
  font-family: 'Cinzel', serif;
  font-weight: bold;
  font-size: 1.4rem;
  letter-spacing: 3px;
  color: #f5e6c8;
  background: linear-gradient(135deg, #1a1a1a 0%, #333 100%);
  border: 2px solid #444;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mmorpg-btn.primary {
  border-color: #d4af37;
  background: linear-gradient(135deg, #3d321b 0%, #1a1a1a 100%);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.mmorpg-btn:hover {
  transform: scale(1.05);
  border-color: #fff;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
}

.glow-effect {
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 87, 0.4), transparent);
  transform: skewX(-25deg);
  animation: shimmer 1s infinite;
}

@keyframes shimmer {
  from { left: -100%; }
  to { left: 150%; }
}

/* Animations */
@keyframes box-entry {
  from { opacity: 0; transform: translateY(50px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes floating {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.box-subtitle {
  color: #d4af37;
  text-align: center;
  font-family: 'Cinzel', serif;
  margin-bottom: 20px;
  font-size: 0.9rem;
  letter-spacing: 4px;
  opacity: 0.7;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
  .stylish-btn {
    font-size: 1rem;
    padding: 12px 20px;
  }
}
#login-screen.auth-active #game-title {
  position: absolute;
  top: 15px;
  font-size: clamp(1.2rem, 3vw, 2rem); /* Slightly smaller when top-centered */
}

/* Ensure the portal box remains centered while the title moves away */
#login-screen.auth-active {
  justify-content: center;
  padding-top: 15px; 
}
.password-container {
    position: relative;
    width: 81%;
    margin-bottom: 10px; /* Spacing between fields */
    margin-left: 29px;
}

.password-container input {
    width: 100%;
    padding-right: 3px; /* Space for the eye icon */
}

.toggle-password {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%); /* Perfectly centers vertically */
    cursor: pointer;
    color: #d4af37;
    filter: grayscale(1);
    opacity: 0.5;
    transition: 0.3s;
    user-select: none;
}

.toggle-password.active-glow {
    filter: grayscale(0);
    opacity: 1;
    text-shadow: 0 0 8px #d4af37;
}

.field-hint {
    font-size: 0.75rem;
    color: #888;
    margin-top: -10px;
    margin-bottom: 15px;
    text-align: left;
}

.auth-error {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid #ff4d4d;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}