/* Key Entry Overlay */
.key-entry-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.key-entry-overlay.active {
  display: flex;
  animation: keyOverlayFadeIn 0.4s ease;
}

@keyframes keyOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.key-entry-overlay.active .key-entry-card {
  animation: keyCardSlideIn 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes keyCardSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.key-entry-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 45, 245, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(0, 45, 245, 0.08), transparent);
  pointer-events: none;
}

.key-entry-card {
  position: relative;
  background: rgba(15, 15, 30, 0.95);
  border: 1px solid rgba(0, 45, 245, 0.3);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.key-entry-card .key-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 16px;
  object-fit: contain;
}

.key-entry-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text-primary);
}

.key-entry-card p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  margin: 0 0 28px;
}

.key-entry-card input[type="password"],
.key-entry-card input[type="text"] {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 45, 245, 0.3);
  border-radius: 12px;
  color: white;
  font-size: 16px;
  text-align: center;
  letter-spacing: 2px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  box-sizing: border-box;
}

.key-entry-card input:focus {
  border-color: rgba(0, 45, 245, 0.7);
  box-shadow: 0 0 0 3px rgba(0, 45, 245, 0.15);
}

.key-entry-card input.error {
  border-color: rgba(0, 45, 245, 0.7);
  animation: shakeKey 0.4s ease;
}

@keyframes shakeKey {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.key-entry-card .key-error {
  color: #ef4444;
  font-size: 13px;
  margin-top: 10px;
  display: none;
}

.key-entry-card .key-error.show {
  display: block;
}

.key-entry-card .key-submit {
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: linear-gradient(135deg, #002df5, #0019d4);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.key-entry-card .key-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 45, 245, 0.4);
}

.key-entry-card .key-submit:active {
  transform: translateY(0);
}

/* Setup Overlay */
.setup-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.setup-overlay.active {
  display: flex;
  opacity: 1;
}

.setup-overlay::-webkit-scrollbar {
  display: none;
}

.setup-overlay {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.setup-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(167, 139, 250, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139, 92, 246, 0.1), transparent),
    radial-gradient(ellipse 50% 30% at 10% 80%, rgba(167, 139, 250, 0.08), transparent);
  pointer-events: none;
  animation: ambientShift 15s ease-in-out infinite;
}

@keyframes ambientShift {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.setup-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.setup-container {
  max-width: 580px;
  width: 95%;
  position: relative;
  z-index: 1;
  padding-top: 60px;
}

.setup-back-btn {
  position: fixed;
  top: calc(50% - 340px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0;
  visibility: hidden;
  z-index: 10;
}

.setup-back-btn.visible {
  opacity: 1;
  visibility: visible;
}

.setup-back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.setup-back-btn svg {
  transition: transform 0.3s ease;
}

.setup-back-btn:hover svg {
  transform: translateX(-3px);
}

.setup-progress {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  opacity: 0 !important;
  position: absolute;
  top: 0;
  right: 0 !important;
  margin-right: 20px !important;
  transform: translateY(-10px) !important;
  animation: progressFadeIn 0.6s 0.3s ease forwards;
}

@keyframes progressFadeIn {
  to { opacity: 1 !important; transform: translateY(0) !important; }
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.progress-dot::before,
.progress-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.progress-dot.active {
  background: var(--accent-primary);
  transform: scale(1.4);
  box-shadow: 0 0 12px var(--accent-glow);
}

.progress-dot.active::before {
  border: 2px solid var(--accent-primary);
  animation: dotRipple 2s ease-out infinite;
}

.progress-dot.active::after {
  border: 2px solid var(--accent-primary);
  animation: dotRipple 2s ease-out infinite 1s;
}

@keyframes dotRipple {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

.progress-dot.completed {
  background: var(--success);
  transform: scale(1);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.progress-dot.completed::before,
.progress-dot.completed::after {
  animation: none;
}

.progress-line {
  width: 28px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.progress-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--success);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 3px;
}

.progress-line.completed::after {
  transform: scaleX(1);
}


.setup-content {
  min-height: 420px;
  position: relative;
}

.setup-step {
  text-align: center;
  opacity: 0;
  visibility: hidden;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transform: translateX(40px);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
  pointer-events: none;
}

.setup-step.active {
  opacity: 1;
  visibility: visible;
  position: relative;
  transform: translateX(0);
  pointer-events: auto;
}

.setup-step.exit {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  transform: translateX(-40px);
  pointer-events: none;
}

.setup-step.exit-reverse {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  transform: translateX(40px);
  pointer-events: none;
}

.setup-step.enter-reverse {
  animation: stepEnterReverse 0.4s ease forwards;
}

@keyframes stepEnterReverse {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.setup-step.active.exit {
  position: absolute;
}

.setup-icon-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.setup-icon-bg {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.setup-icon {
  font-size: 36px;
  position: relative;
  z-index: 1;
  animation: iconPop 0.5s 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

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

.setup-note-card {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: rgba(52, 211, 153, 0.04);
  border: 1px solid rgba(52, 211, 153, 0.12);
  border-radius: 10px;
  text-align: center;
  font-size: 13px;
  color: rgba(52, 211, 153, 0.8);
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 10001;
}

.setup-note-card.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.setup-step h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  animation: textFadeUp 0.5s 0.1s ease backwards;
}

.setup-step h2::before {
  display: none;
}

.setup-step p {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 14px;
  animation: textFadeUp 0.5s 0.2s ease backwards;
}

@keyframes textFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.setup-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setup-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-primary);
  text-align: left;
  overflow: hidden;
  animation: optionSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.setup-option:nth-child(1) { animation-delay: 0.2s; }
.setup-option:nth-child(2) { animation-delay: 0.3s; }
.setup-option:nth-child(3) { animation-delay: 0.4s; }

@keyframes optionSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.setup-option::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.1), rgba(139, 92, 246, 0.05));
  opacity: 0;
  transition: opacity 0.3s ease;
}


.setup-option:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(167, 139, 250, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(167, 139, 250, 0.1);
}

.setup-option:hover::before {
  opacity: 1;
}

.setup-option:active {
  transform: scale(0.98);
}

.setup-option.selected {
  background: rgba(167, 139, 250, 0.1);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary), 0 8px 32px rgba(167, 139, 250, 0.2);
}

.setup-option.selected::before {
  opacity: 1;
}

.option-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  font-size: 24px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
}

.setup-option:hover .option-icon {
  background: rgba(167, 139, 250, 0.15);
  transform: scale(1.05);
}

.option-icon img,
.option-icon-img {
  width: 28px !important;
  height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  object-fit: contain !important;
}

.option-icon-img.option-icon-eac {
  width: 44px !important;
  height: 44px !important;
  max-width: 44px !important;
  max-height: 44px !important;
}

.option-icon-img.option-icon-ricochet {
  width: 30px !important;
  height: 30px !important;
  max-width: 30px !important;
  max-height: 30px !important;
}

img.option-icon-img.option-icon-fortnite {
  width: 40px !important;
  height: 40px !important;
  max-width: 40px !important;
  max-height: 40px !important;
}

.option-content {
  flex: 1;
  position: relative;
  z-index: 1;
}

.option-label {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
  transition: color 0.3s ease;
}

.setup-option:hover .option-label {
  color: var(--accent-primary);
}

.option-desc {
  font-size: 12px;
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.option-arrow {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-8px);
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

.setup-option:hover .option-arrow {
  opacity: 1;
  transform: translateX(0);
}

.setup-option.selected .option-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent-primary);
}

.setup-building {
  display: none;
  text-align: center;
}

.setup-building.active {
  display: block;
  animation: stepEnter 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.building-animation {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-stack-container {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-stack {
  width: 100%;
  height: 100%;
  color: rgba(255, 255, 255, 0.2);
  filter: drop-shadow(0 0 20px rgba(52, 211, 153, 0.3));
}

.stack-outline {
  opacity: 1;
}

.stack-fill path {
  opacity: 0.9;
}

.setup-building h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.setup-building h2::before {
  display: none;
}

.building-status {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}

.building-progress {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 32px;
  position: relative;
  border: 1px solid var(--glass-border);
}

.building-progress::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
  border-radius: 6px;
}

.building-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
  background-size: 200% 100%;
  border-radius: 6px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  animation: progressShimmer 2s linear infinite;
  box-shadow: 0 0 20px var(--accent-glow);
}

.building-progress-bar::after {
  content: '';
  position: absolute;
  right: 0;
  top: -3px;
  bottom: -3px;
  width: 12px;
  background: var(--accent-primary);
  border-radius: 50%;
  box-shadow: 0 0 16px var(--accent-glow), 0 0 32px var(--accent-glow);
}

@keyframes progressShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.building-steps {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.building-step {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 6px 0;
  position: relative;
}

.building-step.active {
  color: var(--text-primary);
  transform: scale(1.05);
}

.building-step.completed {
  color: var(--success);
}

.building-step.completed .building-step-text::before {
  content: '✓ ';
}

.building-step-connector {
  width: 2px;
  height: 16px;
  background: var(--glass-border);
  transition: all 0.4s ease;
  border-radius: 2px;
}

.building-step-connector.active {
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

.building-step-connector.completed {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.building-step-text {
  transition: color 0.3s ease;
}

.building-step-check {
  width: 18px;
  height: 18px;
  margin-left: auto;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.building-step-check svg {
  width: 18px;
  height: 18px;
  stroke: var(--success);
}

.building-step.completed .building-step-check {
  opacity: 1;
  transform: scale(1);
}

@keyframes iconPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@media (max-width: 500px) {
  .setup-container {
    width: 95%;
  }

  .setup-option {
    padding: 14px 18px;
  }

  .option-icon {
    width: 42px;
    height: 42px;
  }

  .setup-step h2 {
    font-size: 20px;
  }
}
