@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:ital,wght@0,500;0,700;1,700&family=Rajdhani:wght@600;700&family=Plus+Jakarta+Sans:wght@500;600&display=swap');

:root {
  --bg-primary: #06090e;
  --neon-cyan: #00f0ff;
  --neon-cyan-glow: rgba(0, 240, 255, 0.45);
  --neon-orange: #ff8500;
  --neon-orange-glow: rgba(255, 133, 0, 0.45);
  --hud-bg: rgba(7, 14, 24, 0.82);
  --hud-border: rgba(0, 240, 255, 0.38);
  --hud-border-bright: #00f0ff;
  --text-main: #ffffff;
  --text-sub: #cbd5e1;
}

* {
  box-sizing: border-box;
}

html, body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  font-family: 'Chakra Petch', 'Rajdhani', sans-serif;
  color: var(--text-main);
  user-select: none;
  -webkit-user-select: none;
}

#unity-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

#unity-canvas {
  width: 100%;
  height: 100%;
  background: #06090e;
  display: block;
}

/* ==========================================================================
   Loading Screen Main Container
   ========================================================================== */
#unity-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  overflow: hidden;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.8s;
  opacity: 1;
  visibility: visible;
}

#unity-loading-screen.loading-fade-out {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
  visibility: hidden;
}

/* Background Image Layer */
.loading-bg {
  position: absolute;
  inset: 0;
  background: url('mansion_loading_bg.jpg') center center / cover no-repeat;
  filter: brightness(0.62) contrast(1.05);
  animation: bgBreathing 26s ease-in-out infinite alternate;
  z-index: 1;
}

@keyframes bgBreathing {
  0% { transform: scale(1); }
  100% { transform: scale(1.04); }
}

/* Vignette & Ambient Light Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: 
    radial-gradient(circle at 50% 55%, rgba(0, 240, 255, 0.05) 0%, rgba(6, 9, 14, 0.45) 50%, rgba(6, 9, 14, 0.92) 100%),
    linear-gradient(to bottom, rgba(6, 9, 14, 0.65) 0%, transparent 30%, rgba(6, 9, 14, 0.8) 100%);
  pointer-events: none;
}

/* Ambient Particles Canvas */
#loading-particles {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

/* Foreground Center Container */
.loading-content {
  position: relative;
  z-index: 10;
  width: 92%;
  max-width: 660px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px;
}

/* ==========================================================================
   In-Game Exact Title Graphic
   ========================================================================== */
.game-logo-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 520px;
  margin-bottom: 20px;
  animation: logoFloat 4s ease-in-out infinite alternate;
}

@keyframes logoFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

.game-logo-image {
  width: 100%;
  max-width: 480px;
  height: auto;
  object-fit: contain;
  display: block;
  filter: 
    drop-shadow(0 8px 18px rgba(0, 0, 0, 0.8)) 
    drop-shadow(0 0 26px rgba(255, 140, 0, 0.3));
  transition: transform 0.3s ease;
}

/* ==========================================================================
   Tactical Sci-Fi HUD Progress Card (Matches In-Game Difficulty Buttons)
   ========================================================================== */
.hud-card {
  position: relative;
  width: 100%;
  background: var(--hud-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 2px solid var(--hud-border);
  box-shadow: 
    0 0 24px var(--neon-cyan-glow),
    inset 0 0 24px rgba(0, 240, 255, 0.08),
    0 20px 50px rgba(0, 0, 0, 0.85);
  border-radius: 8px;
  /* Chamfered sci-fi corners matching in-game event cards */
  clip-path: polygon(
    14px 0, calc(100% - 14px) 0, 
    100% 14px, 100% calc(100% - 14px), 
    calc(100% - 14px) 100%, 14px 100%, 
    0 calc(100% - 14px), 0 14px
  );
  padding: 24px 28px 20px;
  margin-top: 6px;
}

/* Glowing Tactical Corner Notches */
.hud-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--neon-cyan);
  clip-path: polygon(
    14px 0, calc(100% - 14px) 0, 
    100% 14px, 100% calc(100% - 14px), 
    calc(100% - 14px) 100%, 14px 100%, 
    0 calc(100% - 14px), 0 14px
  );
  opacity: 0.85;
  pointer-events: none;
}

/* Top Center HUD Header Badge */
.hud-header-pill {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6, 12, 22, 0.95);
  border: 1px solid var(--neon-cyan);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 2px 18px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan-glow);
  text-transform: uppercase;
}

/* Progress Status Line */
.hud-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  margin-bottom: 14px;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.hud-pulse-beacon {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
  animation: beaconPulse 1.3s ease-in-out infinite;
  transform: rotate(45deg);
  flex-shrink: 0;
}

@keyframes beaconPulse {
  0%, 100% { opacity: 1; transform: rotate(45deg) scale(1); }
  50% { opacity: 0.4; transform: rotate(45deg) scale(0.75); }
}

.hud-status-text {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: #e2e8f0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hud-progress-percentage {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 12px var(--neon-cyan), 0 0 20px var(--neon-cyan);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

/* High-Tech Progress Track & Bar */
.hud-progress-track {
  position: relative;
  width: 100%;
  height: 12px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8);
}

.hud-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0099cc 0%, #00f0ff 40%, #ff8c00 80%, #ffd700 100%);
  box-shadow: 0 0 16px var(--neon-cyan), 0 0 24px rgba(255, 140, 0, 0.6);
  position: relative;
  transition: width 0.25s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.hud-progress-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.6) 50%, transparent 100%);
  animation: shimmerSweep 2.2s infinite linear;
}

@keyframes shimmerSweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* In-Game Star Rating Row */
.hud-stars-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}

.hud-star {
  color: #ff9f1a;
  font-size: 1.1rem;
  filter: drop-shadow(0 0 6px rgba(255, 159, 26, 0.8));
}

.hud-star-sub {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #94a3b8;
  margin-left: 8px;
  text-transform: uppercase;
}

/* ==========================================================================
   Rotating Tactical Intel / Tips Box
   ========================================================================== */
.tactical-tips-box {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 22px;
  background: rgba(5, 11, 20, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 6px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  width: 100%;
  max-width: 620px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.tactical-badge {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #ff8c00;
  background: rgba(255, 140, 0, 0.15);
  border: 1px solid rgba(255, 140, 0, 0.4);
  padding: 3px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.tactical-text {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.86rem;
  font-weight: 500;
  color: #e2e8f0;
  line-height: 1.35;
  margin: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tactical-text.tip-changing {
  opacity: 0;
  transform: translateY(4px);
}

/* ==========================================================================
   Footer System Data
   ========================================================================== */
.hud-footer {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.footer-item span {
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan-glow);
}

/* ==========================================================================
   Warnings and Error Dialogs
   ========================================================================== */
#unity-warning {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 90%;
  width: 480px;
  pointer-events: none;
}

.unity-toast {
  padding: 12px 18px;
  border-radius: 6px;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
  pointer-events: auto;
  animation: toastSlide 0.3s ease;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

@keyframes toastSlide {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.unity-toast-error {
  background: rgba(185, 28, 28, 0.9);
  border: 1px solid rgba(248, 113, 113, 0.6);
  color: #fff;
}

.unity-toast-warning {
  background: rgba(180, 83, 9, 0.9);
  border: 1px solid rgba(251, 191, 36, 0.6);
  color: #fff;
}

/* Error Modal */
#unity-error-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10002;
  background: rgba(3, 6, 12, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.error-card {
  max-width: 460px;
  width: 100%;
  background: rgba(10, 18, 30, 0.96);
  border: 2px solid rgba(239, 68, 68, 0.6);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 30px rgba(239, 68, 68, 0.25);
  clip-path: polygon(
    14px 0, calc(100% - 14px) 0, 
    100% 14px, 100% calc(100% - 14px), 
    calc(100% - 14px) 100%, 14px 100%, 
    0 calc(100% - 14px), 0 14px
  );
}

.error-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  color: #ef4444;
}

.error-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  color: #fff;
}

.error-msg {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.88rem;
  color: #94a3b8;
  line-height: 1.5;
  margin: 0 0 22px;
  word-break: break-word;
}

.retry-btn {
  background: linear-gradient(135deg, #00f0ff, #0099cc);
  color: #030810;
  border: none;
  padding: 12px 30px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 240, 255, 0.4);
  transition: transform 0.2s, filter 0.2s;
}

.retry-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 600px) {
  .loading-content {
    width: 95%;
    padding: 10px;
  }
  .game-logo-container {
    max-width: 320px;
    margin-bottom: 12px;
  }
  .game-logo-image {
    max-width: 300px;
  }
  .hud-card {
    padding: 18px 18px 16px;
  }
  .hud-status-text {
    font-size: 0.8rem;
  }
  .hud-progress-percentage {
    font-size: 1.15rem;
  }
  .tactical-tips-box {
    padding: 8px 14px;
  }
  .tactical-text {
    font-size: 0.78rem;
  }
  .hud-footer {
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.7rem;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .game-logo-container {
    max-width: 240px;
    margin-bottom: 6px;
  }
  .game-logo-image {
    max-width: 220px;
  }
  .hud-card {
    padding: 14px 18px 12px;
    margin-top: 4px;
  }
  .hud-status-row {
    margin-bottom: 8px;
  }
  .hud-stars-row {
    margin-top: 8px;
  }
  .tactical-tips-box {
    margin-top: 10px;
    padding: 6px 12px;
  }
  .hud-footer {
    margin-top: 10px;
  }
}
