/* Cosmic Pirates Auth Theme */
:root {
  --bg: #070617;
  --bg-deep: #050414;
  --space: #0b0a20;
  --ink: #e6e7ee;
  --muted: #9aa1b4;
  --accent: #8a4fff;
  --cyan: #00f0ff;
  --rose: #ff3e7f;
  --gold: #f7c948;
  --glass: rgba(255,255,255,0.06);
  --glass-strong: rgba(255,255,255,0.12);
  --card-radius: 18px;
  --shadow-strong: 0 10px 40px rgba(0,0,0,0.55);
}

/* Hide game chrome on auth */
.auth-cosmic .topbar,
.auth-cosmic .js-back-to-top,
.auth-cosmic .chat-dock,
.auth-cosmic .chat-dock-wrapper {
  display: none !important;
}

/* Page base */
body.auth-cosmic {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 800px at 70% 10%, rgba(138,79,255,0.16), transparent 60%),
              radial-gradient(900px 700px at 20% 80%, rgba(0,240,255,0.12), transparent 60%),
              linear-gradient(180deg, var(--bg), var(--bg-deep));
  color: var(--ink);
  overflow-x: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Starfield background */
.cosmic-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.cosmic-bg:before,
.cosmic-bg:after {
  content: "";
  position: absolute;
  inset: -10%;
  background-repeat: repeat;
  background-position: 0 0;
  filter: drop-shadow(0 0 2px rgba(255,255,255,0.5));
}

/* Layer 1: tiny stars */
.cosmic-bg:before {
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.85) 99%, transparent 100%),
    radial-gradient(1px 1px at 30% 80%, rgba(255,255,255,0.7) 99%, transparent 100%),
    radial-gradient(1px 1px at 55% 35%, rgba(255,255,255,0.8) 99%, transparent 100%),
    radial-gradient(1px 1px at 75% 60%, rgba(255,255,255,0.65) 99%, transparent 100%),
    radial-gradient(1px 1px at 85% 15%, rgba(255,255,255,0.75) 99%, transparent 100%);
  animation: driftA 180s linear infinite;
}

/* Layer 2: bright stars */
.cosmic-bg:after {
  background-image:
    radial-gradient(2px 2px at 18% 35%, rgba(255,255,255,0.9) 99%, transparent 100%),
    radial-gradient(2px 2px at 42% 70%, rgba(255,255,255,0.9) 99%, transparent 100%),
    radial-gradient(2px 2px at 66% 22%, rgba(255,255,255,0.95) 99%, transparent 100%),
    radial-gradient(2px 2px at 88% 78%, rgba(255,255,255,0.9) 99%, transparent 100%);
  mix-blend-mode: screen;
  animation: driftB 220s linear infinite;
}

@keyframes driftA {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(-10%, -6%, 0) scale(1.02); }
}
@keyframes driftB {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(6%, -8%, 0) scale(1.03); }
}

/* Decorative galaxy routes map */
.cosmic-routes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.25;
  filter: drop-shadow(0 0 6px rgba(138,79,255,0.6)) drop-shadow(0 0 10px rgba(0,240,255,0.35));
}
/* By default, hide mobile-specific planets group */
.cosmic-routes .planets-mobile { display: none; }

/* Animated route dash flow */
.cosmic-routes .route {
  stroke-dasharray: 10 22;
  animation: routeFlow 22s linear infinite;
}
.cosmic-routes .route.route-fast { animation-duration: 14s; }
.cosmic-routes .route.route-slow { animation-duration: 32s; }
@keyframes routeFlow { to { stroke-dashoffset: -1000; } }

/* Pulse the star nodes slightly */
.cosmic-routes .node {
  transform-origin: center center;
  animation: nodePulse 3.2s ease-in-out infinite; /* per-node delays inline via --d */
  animation-delay: var(--d, 0s);
}
@keyframes nodePulse { 0%,100% { transform: scale(1); opacity: .85 } 50% { transform: scale(1.25); opacity: 1 } }

/* Layout */
.auth-viewport { min-height: 100vh; display: grid; place-items: center; padding: 120px 20px 48px; }

.auth-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 18px clamp(18px, 4vw, 40px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(12px, 3vw, 32px);
  background: linear-gradient(90deg, rgba(8,8,26,0.92), rgba(8,8,26,0.78));
  border-bottom: 1px solid rgba(0,240,255,0.28);
  box-shadow: 0 10px 45px rgba(0,0,0,0.55);
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
  backdrop-filter: blur(16px);
}

.auth-topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% -40%, rgba(138,79,255,0.3), transparent 65%);
  pointer-events: none;
  opacity: 0.5;
}

.auth-topbar__nav {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.auth-topbar__nav--left { justify-self: start; }
.auth-topbar__nav--right { justify-self: end; }

.auth-topbar__link {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(230,231,238,0.85);
  text-decoration: none;
  padding: 6px 4px;
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
}

.auth-topbar__link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, rgba(138,79,255,0.9), rgba(0,240,255,0.9));
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .2s ease;
  border-radius: 999px;
}

.auth-topbar__link:hover::after,
.auth-topbar__link:focus-visible::after { transform: scaleX(1); }

.auth-topbar__branding {
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.auth-topbar__logo {
  height: 54px;
  width: 54px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(0,240,255,0.45));
}

.auth-topbar__wordmark {
  font-size: 20px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.auth-shell {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  align-items: stretch;
  gap: 28px;
  position: relative;
}

@media (max-width: 960px) {
  .auth-shell {
    grid-template-columns: 1fr;
    gap: 26px;
  }
}

@media (max-width: 720px) {
  .auth-shell { gap: 20px; }
}

@media (max-width: 900px) {
  .auth-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 12px clamp(10px, 5vw, 20px);
  }

  .auth-topbar__nav,
  .auth-topbar__nav--left,
  .auth-topbar__nav--right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
  }

  .auth-topbar__nav--left {
    justify-self: start;
    justify-content: flex-start;
    text-align: left;
  }

  .auth-topbar__nav--right {
    justify-self: end;
    justify-content: flex-end;
    text-align: right;
  }

  .auth-topbar__branding {
    justify-self: center;
  }

  .auth-topbar__logo {
    height: 42px;
    width: 42px;
  }
  
  .auth-topbar__link {
    font-size: 12.5px;
    letter-spacing: 0.07em;
    padding: 6px 8px;
    white-space: normal;
    line-height: 1.3;
    text-wrap: balance;
    word-break: break-word;
  }
}

@media (max-width: 640px) {
  .auth-topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
    padding: 12px clamp(8px, 6vw, 18px);
  }

  .auth-topbar__branding {
    order: -1;
    display: flex;
    justify-content: center;
  }

  .auth-topbar__nav,
  .auth-topbar__nav--left,
  .auth-topbar__nav--right {
    width: 100%;
    justify-content: center;
    text-align: center;
    flex-wrap: wrap;
    gap: 6px 10px;
  }
}

@media (max-width: 480px) {
  .auth-topbar {
    padding: 10px 12px;
    gap: 6px;
  }

  .auth-topbar__nav,
  .auth-topbar__nav--left,
  .auth-topbar__nav--right {
    gap: 8px 10px;
  }

  .auth-topbar__link {
    font-size: 11.5px;
    letter-spacing: 0.08em;
    padding: 6px 8px;
  }

  .auth-topbar__logo {
    height: 36px;
    width: 36px;
  }

  .auth-viewport {
    padding-top: 104px;
  }
}

@media (max-width: 380px) {
  .auth-topbar__link {
    font-size: 11px;
    letter-spacing: 0.06em;
  }
  .galactic-news { padding: 12px 14px; }
  .galactic-news__badge { font-size: 9px; letter-spacing: 0.18em; }
  .galactic-news__item { padding: 10px 12px; }
  .galactic-news__body { font-size: 12.5px; }
}

/* Brand panel */
.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow-strong);
}

.auth-brand .logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(138,79,255,0.85), rgba(138,79,255,0.35) 70%, transparent 71%);
  box-shadow: 0 0 0 2px rgba(138,79,255,0.5), 0 0 24px rgba(138,79,255,0.45), inset 0 0 16px rgba(0,0,0,0.35);
  position: relative;
  overflow: hidden;
}
.auth-brand .logo:after {
  content: "";
  position: absolute; inset: -40% -60% auto auto; height: 140%; width: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0));
  transform: rotate(25deg) translateY(-120%);
  animation: logoSheen 4.8s ease-in-out infinite;
}
.auth-brand .logo i { font-size: 28px; color: white; text-shadow: 0 0 8px rgba(255,255,255,0.6); }
.auth-brand .logo img {
  width: 100%;
  height: 100%;
  padding: 8px;
  border-radius: 50%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.35));
}
@keyframes logoSheen { 0%, 80% { transform: rotate(25deg) translateY(-120%); } 100% { transform: rotate(25deg) translateY(140%); } }

/* Gentle float for panels */
.auth-brand, .auth-card { will-change: transform; }
.auth-brand { animation: floatY 12s ease-in-out infinite; }
.auth-card { animation: floatY 14s ease-in-out infinite reverse; }
@keyframes floatY { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }

.auth-brand h1 { margin: 0; font-size: clamp(26px, 3.2vw, 42px); letter-spacing: 0.5px; }
.auth-brand p { margin: 0; color: var(--muted); max-width: 54ch; }

.auth-gallery {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 220px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(0,240,255,0.2);
  background: radial-gradient(circle at 20% 20%, rgba(138,79,255,0.35), rgba(11,10,32,0.85));
  box-shadow: inset 0 0 40px rgba(0,240,255,0.08), 0 18px 40px rgba(0,0,0,0.45);
}

.auth-gallery__slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: stretch;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity .7s ease, transform .7s ease;
  background: rgba(0,0,0,0.35);
}

.auth-gallery__slide.is-active {
  opacity: 1;
  transform: scale(1);
  z-index: 2;
}

.auth-gallery__slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.05);
}

.auth-gallery__slide figcaption {
  position: relative;
  width: 100%;
  padding: 18px 18px 20px;
  font-size: 14px;
  color: rgba(230,231,238,0.95);
  backdrop-filter: blur(12px);
  background: linear-gradient(180deg, rgba(5,4,20,0) 0%, rgba(5,4,20,0.85) 100%);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  margin-top: auto;
}

.galactic-news {
  display: grid;
  gap: 14px;
  padding: 20px 22px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(8,8,26,0.85), rgba(8,8,26,0.55));
  border: 1px solid rgba(138,79,255,0.24);
  box-shadow: 0 14px 36px rgba(0,0,0,0.45), inset 0 0 36px rgba(138,79,255,0.1);
  position: relative;
  overflow: hidden;
}

.galactic-news:before {
  content: "";
  position: absolute;
  top: -60px;
  right: -120px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(0,240,255,0.25), transparent 65%);
  filter: blur(10px);
  opacity: 0.4;
}

.galactic-news__header { display: flex; align-items: center; justify-content: space-between; }

.galactic-news__badge {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(138,79,255,0.55), rgba(0,240,255,0.55));
  color: var(--ink);
  box-shadow: inset 0 0 12px rgba(255,255,255,0.12), 0 0 18px rgba(0,240,255,0.25);
}

.galactic-news__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.galactic-news__item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(12,11,28,0.72);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: inset 0 0 16px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(14px);
  animation: newsPop .6s ease forwards;
  animation-delay: calc(var(--i, 0) * 0.14s + 0.2s);
}

.galactic-news__item.is-highlighted {
  border-color: rgba(0,240,255,0.45);
  box-shadow: 0 0 0 1px rgba(0,240,255,0.35), inset 0 0 18px rgba(0,240,255,0.18);
}

.galactic-news__time {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(0,240,255,0.75);
  margin-top: 2px;
}

.galactic-news__body {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 14px;
  color: var(--ink);
}

.galactic-news__source {
  font-weight: 600;
  color: rgba(255,62,127,0.9);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes newsPop {
  0% { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Auth card */
.auth-card {
  position: relative;
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, rgba(11,10,32,0.85), rgba(11,10,32,0.65));
  border: 1px solid rgba(0,240,255,0.25);
  box-shadow: 0 0 0 1px rgba(138,79,255,0.25), 0 20px 50px rgba(0,0,0,0.65), inset 0 0 40px rgba(138,79,255,0.08);
  padding: 26px 22px;
  width: 100%;
  max-width: min(520px, 100%);
  margin: 0;
}

@media (max-width: 960px) {
  .auth-card { margin: 0 auto; }
}

.auth-card header { margin-bottom: 14px; }
.auth-card h2 { margin: 0 0 6px; font-size: 22px; }
.auth-card .sub { margin: 0; color: var(--muted); font-size: 14px; }

/* Form styles */
.auth-form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 6px; }
.form-row label { font-size: 13px; color: var(--muted); }
.input, .select {
  appearance: none;
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.35);
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder { color: #7e8597; }
.input:focus, .select:focus {
  border-color: rgba(0,240,255,0.55);
  box-shadow: 0 0 0 3px rgba(0,240,255,0.18), 0 0 0 1px rgba(0,240,255,0.4) inset;
  background: rgba(0,0,0,0.42);
}

.actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }

.btn-primary {
  --g1: var(--accent);
  --g2: var(--cyan);
  position: relative;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--g1), var(--g2));
  color: #0b0a12;
  font-weight: 700;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform .08s ease, filter .2s ease;
  text-shadow: none;
  background-size: 200% 100%;
  animation: gradientShift 6s linear infinite;
}
.btn-primary:hover { filter: brightness(1.05) saturate(1.05); }
.btn-primary:active { transform: translateY(1px); }
@keyframes gradientShift { 0% { background-position: 0% 50% } 100% { background-position: 200% 50% } }

.btn-secondary {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
}

/* Messages */
.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.notice.error { background: rgba(255,62,127,0.12); border: 1px solid rgba(255,62,127,0.45); }
.notice.success { background: rgba(0,240,255,0.12); border: 1px solid rgba(0,240,255,0.45); }

.helper { font-size: 13px; color: var(--muted); margin-top: 10px; }
.helper a { color: var(--cyan); text-decoration: none; }
.helper a:hover { text-decoration: underline; }

/* Small twinkles in card corners */
.auth-card:before, .auth-card:after {
  content: ""; position: absolute; width: 8px; height: 8px; border-radius: 100%;
  background: radial-gradient(circle, #fff 0%, #fff 55%, transparent 56%);
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.8));
  animation: twinkle 2.8s ease-in-out infinite;
  opacity: 0.9;
}
.auth-card:before { top: 10px; left: 10px; animation-delay: .3s; }
.auth-card:after { bottom: 10px; right: 10px; animation-delay: 1.6s; }

@keyframes twinkle {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.35); opacity: 1; }
}

/* Footer link group */
.auth-footer { margin-top: 12px; display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.auth-footer a { color: var(--gold); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  /* Stop CSS animations and hide moving ships; keep planets visible but static */
  .cosmic-bg:before, .cosmic-bg:after,
  .cosmic-routes .route,
  .cosmic-routes .node,
  .auth-brand, .auth-card,
  .btn-primary,
  .auth-card:before, .auth-card:after,
  .auth-brand .logo:after {
    animation: none !important;
  }
  .cosmic-routes .ships { display: none !important; }
  /* Disable inline SVG motion */
  .cosmic-routes .planets animateTransform,
  .cosmic-routes .planets-mobile animateTransform,
  .cosmic-routes .ships animateMotion { display: none !important; }
}

/* Mobile tuning: increase visibility and use centered planets layout */
@media (max-width: 640px) {
  .cosmic-routes { opacity: 0.34; }
  .cosmic-routes .planets { display: none; }
  .cosmic-routes .planets-mobile { display: block; }
  .auth-gallery { min-height: 200px; aspect-ratio: 5 / 6; }
  .galactic-news {
    padding: 14px 16px;
    gap: 10px;
    border-radius: 12px;
    box-shadow: 0 10px 26px rgba(0,0,0,0.38), inset 0 0 24px rgba(138,79,255,0.1);
  }
  .galactic-news__header { flex-direction: column; gap: 6px; align-items: flex-start; }
  .galactic-news__badge {
    font-size: 10px;
    letter-spacing: 0.22em;
    padding: 5px 10px;
  }
  .galactic-news__list { gap: 10px; }
  .galactic-news__item {
    grid-template-columns: 1fr;
    padding: 12px 13px;
    border-radius: 12px;
    gap: 10px;
  }
  .galactic-news__time {
    order: 2;
    font-size: 11px;
    letter-spacing: 0.1em;
  }
  .galactic-news__body { font-size: 13px; }
  
  /* Optimize auth card for small screens */
  .auth-card {
    padding: 20px 16px;
    border-radius: 14px;
  }
  
  .auth-viewport {
    padding: 100px 14px 40px;
  }
}
