:root {
  --bg-primary: #0a0b0e;
  --bg-secondary: #12141a;
  --bg-card: rgba(18, 20, 28, 0.75);
  --bg-card-hover: rgba(26, 30, 42, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(255, 255, 255, 0.15);
  --text-main: #f0f2f7;
  --text-muted: #9ba3b5;
  --text-dim: #60687a;
  --font-display: 'Cinzel', serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --magus-gold: #e5b35a;
  --magus-blue: #38bdf8;
  --magus-glow: rgba(229, 179, 90, 0.25);
  --wod-red: #ef4444;
  --wod-purple: #c084fc;
  --wod-glow: rgba(239, 68, 68, 0.25);
  --grim-emerald: #10b981;
  --grim-cyan: #06b6d4;
  --grim-glow: rgba(16, 185, 129, 0.28);
  --transition-smooth: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.ambient-background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: 
    radial-gradient(circle at 15% 20%, rgba(229, 179, 90, 0.04) 0%, transparent 45%),
    radial-gradient(circle at 85% 35%, rgba(239, 68, 68, 0.04) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(249, 115, 22, 0.04) 0%, transparent 50%),
    #0a0b0e;
}

.grid-overlay {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 1;
}

.portal-wrapper {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.portal-header {
  text-align: center;
  margin-bottom: 3.5rem;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 1.1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.brand-badge .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulseAnim 2s infinite ease-in-out;
}

@keyframes pulseAnim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.portal-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffffff 20%, #a6b0c3 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  margin-bottom: 0.85rem;
}

.portal-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto;
  font-weight: 400;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 2rem;
  margin-bottom: 4rem;
}

.realm-card {
  position: relative;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: var(--transition-smooth);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.realm-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), transparent 70%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.realm-card:hover {
  transform: translateY(-8px);
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
}

.card-magus:hover {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 35px var(--magus-glow);
  border-color: rgba(229, 179, 90, 0.35);
}

.card-wod:hover {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 35px var(--wod-glow);
  border-color: rgba(239, 68, 68, 0.35);
}

.card-grim:hover {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 35px var(--grim-glow);
  border-color: rgba(16, 185, 129, 0.4);
}

.card-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  display: block;
}

.realm-card:hover .card-image {
  transform: scale(1.06);
}

.card-image-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 11, 14, 0.1) 0%, rgba(10, 11, 14, 0.75) 75%, var(--bg-card) 100%);
}

.card-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.badge-live {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.badge-dev {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

.badge-progress {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.55);
  color: #34d399;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

.card-content {
  padding: 1.75rem 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-universe-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.card-magus .card-universe-eyebrow { color: var(--magus-gold); }
.card-wod .card-universe-eyebrow { color: var(--wod-red); }
.card-grim .card-universe-eyebrow { color: #34d399; }

.card-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
  color: #ffffff;
}

.card-description {
  font-size: 0.94rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.4rem;
  flex: 1;
}

.card-features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.feature-pill {
  padding: 0.25rem 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 0.78rem;
  color: #c4cad8;
}

.feature-pill.pill-active {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.45);
  color: #34d399;
  font-weight: 600;
}

.feature-pill.pill-muted {
  opacity: 0.45;
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.04);
  color: #7a8294;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.subdomain-tag {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  transition: color 0.2s ease;
}

.realm-card:hover .subdomain-tag {
  color: #ffffff;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.2s ease, gap 0.2s ease;
}

.card-magus .cta-btn { color: var(--magus-gold); }
.card-wod .cta-btn { color: var(--wod-red); }
.card-grim .cta-btn { color: #34d399; }

.realm-card:hover .cta-btn {
  gap: 0.7rem;
}

.portal-footer {
  margin-top: auto;
  padding-top: 3rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.footer-brand {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: #ffffff;
}

@media (max-width: 768px) {
  .portal-wrapper {
    padding: 2rem 1.2rem 3rem;
  }
  .portal-header {
    margin-bottom: 2.5rem;
  }
  .portal-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
  .portal-footer {
    flex-direction: column;
    text-align: center;
  }
}
.portal-nav-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 100;
}

.login-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.15rem;
  background: rgba(18, 20, 28, 0.85);
  border: 1px solid rgba(229, 179, 90, 0.4);
  border-radius: 999px;
  color: #e5b35a;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  backdrop-filter: blur(12px);
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.login-nav-btn:hover {
  background: rgba(229, 179, 90, 0.15);
  border-color: #e5b35a;
  color: #ffffff;
  transform: translateY(-1px);
}

.user-menu-container {
  position: relative;
  display: inline-block;
}

.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 1.1rem;
  background: rgba(18, 20, 28, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #f3f4f6;
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  backdrop-filter: blur(16px);
  transition: all 0.25s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.user-menu-btn:hover, .user-menu-btn[aria-expanded="true"] {
  border-color: rgba(229, 179, 90, 0.4);
  background: rgba(24, 27, 38, 0.95);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4), 0 0 15px rgba(229, 179, 90, 0.15);
}

.user-avatar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(229, 179, 90, 0.2);
  color: #e5b35a;
  font-size: 0.85rem;
}

.user-name-text {
  font-weight: 600;
  color: #ffffff;
}

.user-2fa-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #34d399;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.user-menu-caret {
  font-size: 0.75rem;
  color: #9ba3b5;
  transition: transform 0.25s ease;
}

.user-menu-btn[aria-expanded="true"] .user-menu-caret {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.65rem);
  min-width: 290px;
  background: rgba(15, 17, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(24px);
  padding: 0.65rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.97);
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
  pointer-events: none;
}

.user-dropdown-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.user-dropdown-header {
  padding: 0.75rem 0.85rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.user-dropdown-role {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #e5b35a;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.user-dropdown-name {
  font-size: 0.95rem;
  color: #ffffff;
}

.user-dropdown-user {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #9ba3b5;
}

.user-dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0.45rem 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: #d1d5db;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  text-align: left;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  transform: translateX(3px);
}

.dropdown-item .item-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.dropdown-item .item-text {
  display: flex;
  flex-direction: column;
}

.dropdown-item .item-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: #f3f4f6;
}

.dropdown-item .item-sub {
  font-size: 0.74rem;
  color: #9ca3af;
  margin-top: 0.1rem;
}

.dropdown-item.item-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.dropdown-item.item-logout:hover .item-title {
  color: #fca5a5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: #0f1118;
  border: 1px solid rgba(229, 179, 90, 0.3);
  border-radius: 20px;
  padding: 2.25rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(229, 179, 90, 0.15);
  position: relative;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.is-open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #9ba3b5;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.modal-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: #ffffff;
  margin-bottom: 0.4rem;
}

.modal-sub {
  color: #9ba3b5;
  font-size: 0.88rem;
  line-height: 1.5;
}

.modal-qr-frame {
  background: #ffffff;
  padding: 14px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 1.25rem auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-key-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  margin-top: 0.5rem;
}

.modal-key-text {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.15em;
  color: #e5b35a;
  font-weight: 600;
  flex: 1;
  user-select: all;
}

.modal-copy-btn {
  padding: 0.4rem 0.8rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e5e7eb;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.modal-copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.modal-copy-btn.copied {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
}
