@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@400;500;600;700&display=swap');

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

:root {
  --bg-primary: #0a0015;
  --bg-secondary: #120022;
  --accent-purple: #a855f7;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-gold: #fbbf24;
  --text-primary: #f0e6ff;
  --text-secondary: #a78abf;
  --glass-bg: rgba(168, 85, 247, 0.08);
  --glass-border: rgba(168, 85, 247, 0.2);
  --card-bg: rgba(18, 0, 34, 0.8);
  --shadow-glow: 0 0 30px rgba(168, 85, 247, 0.3);
}

html, body {
  height: 100%;
  overflow-x: hidden;
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(168, 85, 247, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(236, 72, 153, 0.05) 0%, transparent 50%),
    linear-gradient(180deg, #0a0015 0%, #120022 50%, #0d0018 100%);
}

#starsCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#floatingParticles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

/* ===== Loading Screen ===== */
#loadingScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 100;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loadingScreen.hidden {
  opacity: 0;
  visibility: hidden;
}

.galaxy-loader {
  position: relative;
  width: 120px;
  height: 120px;
}

.ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border: 2px solid transparent;
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spinRing 1.5s linear infinite;
  transform: translate(-50%, -50%);
}
.ring:nth-child(2) {
  width: 80%;
  height: 80%;
  border-top-color: var(--accent-cyan);
  animation-duration: 2s;
  animation-direction: reverse;
}
.ring:nth-child(3) {
  width: 60%;
  height: 60%;
  border-top-color: var(--accent-pink);
  animation-duration: 1s;
}

.planet-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.6), 0 0 60px rgba(236, 72, 153, 0.3);
  animation: pulsePlanet 1.5s ease-in-out infinite;
}

.loading-text {
  margin-top: 24px;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 4px;
  text-transform: uppercase;
  animation: fadeText 2s ease-in-out infinite;
}

@keyframes spinRing {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes pulsePlanet {
  0%, 100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 20px rgba(168,85,247,0.4); }
  50% { transform: translate(-50%, -50%) scale(1.2); box-shadow: 0 0 40px rgba(168,85,247,0.8), 0 0 80px rgba(236,72,153,0.4); }
}

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

/* ===== Header ===== */
#header {
  position: relative;
  margin-bottom: 20px;
}

.header-glow {
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  height: 120px;
  background: radial-gradient(ellipse at center, rgba(168, 85, 247, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.profile-section {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--shadow-glow);
}

.avatar-container {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.user-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 2;
}

.avatar-ring {
  position: absolute;
  top: -3px;
  left: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan), var(--accent-pink), var(--accent-purple));
  background-size: 300% 300%;
  animation: gradientShift 3s ease infinite;
  z-index: 1;
  filter: blur(1px);
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-info h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-handle {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.points-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(251, 191, 36, 0.05));
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 16px;
  flex-shrink: 0;
}

.points-glow {
  position: absolute;
  inset: -2px;
  border-radius: 16px;
  background: radial-gradient(ellipse at center, rgba(251, 191, 36, 0.2) 0%, transparent 70%);
  animation: glowPulse 2s ease-in-out infinite;
  pointer-events: none;
}

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

.points-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--accent-gold);
  margin-bottom: 2px;
}

.points-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-gold) 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.cosmic-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  gap: 12px;
}

.cosmic-divider::before,
.cosmic-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-purple), transparent);
}

.divider-star {
  color: var(--accent-gold);
  font-size: 18px;
  animation: spinStar 4s linear infinite;
  display: inline-block;
}

@keyframes spinStar {
  to { transform: rotate(360deg); }
}

/* ===== Tabs ===== */
#tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--text-secondary);
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.tab-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 12px;
}

.tab-btn:hover {
  color: var(--text-primary);
  transform: translateY(-1px);
}

.tab-btn.active {
  color: var(--text-primary);
}

.tab-btn.active::before {
  opacity: 1;
}

.tab-btn .tab-icon,
.tab-btn .tab-label {
  position: relative;
  z-index: 1;
}

.tab-icon {
  font-size: 16px;
}

/* ===== Tab Content ===== */
.tab-content {
  animation: fadeSlideIn 0.4s ease;
}

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

/* ===== Harem Section ===== */
.harem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.harem-header h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 2px;
}

.harem-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 10px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border-radius: 14px;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: white;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

.harem-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.harem-card {
  position: relative;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  animation: cardAppear 0.4s ease backwards;
}

.harem-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan), var(--accent-pink));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.harem-card:hover {
  transform: translateY(-4px);
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 8px 32px rgba(168, 85, 247, 0.2);
}

.harem-card:hover::before {
  opacity: 1;
}

.harem-card:active {
  transform: translateY(-2px) scale(0.98);
}

@keyframes cardAppear {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.harem-card:nth-child(1) { animation-delay: 0.05s; }
.harem-card:nth-child(2) { animation-delay: 0.1s; }
.harem-card:nth-child(3) { animation-delay: 0.15s; }
.harem-card:nth-child(4) { animation-delay: 0.2s; }
.harem-card:nth-child(5) { animation-delay: 0.25s; }
.harem-card:nth-child(6) { animation-delay: 0.3s; }

.card-image-container {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(168,85,247,0.1), rgba(59,130,246,0.1));
}

.card-image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-image-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--accent-purple);
}

.card-rarity {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 8px;
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.rarity-legendary { background: linear-gradient(135deg, #f59e0b, #d97706); color: #1a0000; }
.rarity-epic { background: linear-gradient(135deg, #a855f7, #7c3aed); color: white; }
.rarity-rare { background: linear-gradient(135deg, #3b82f6, #2563eb); color: white; }
.rarity-common { background: linear-gradient(135deg, #6b7280, #4b5563); color: white; }

.card-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-id {
  font-size: 11px;
  color: var(--text-secondary);
}

.card-points {
  font-size: 11px;
  color: var(--accent-gold);
  font-weight: 600;
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-planet {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  box-shadow: 0 0 40px rgba(168, 85, 247, 0.3), inset -20px -10px 30px rgba(0,0,0,0.3);
  margin-bottom: 20px;
  animation: floatPlanet 3s ease-in-out infinite;
  position: relative;
}

.empty-planet::before {
  content: '';
  position: absolute;
  top: 20%;
  left: -10%;
  width: 60%;
  height: 30%;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  transform: rotate(-30deg);
}

@keyframes floatPlanet {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.empty-state p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-sub {
  font-size: 13px;
  opacity: 0.6;
}

/* ===== Stats Tab ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  position: relative;
  padding: 20px 16px;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  text-align: center;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(168,85,247,0.05) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover::after {
  opacity: 1;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(168, 85, 247, 0.4);
}

.stat-icon {
  font-size: 24px;
  margin-bottom: 8px;
  display: block;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-value {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== About Tab ===== */
.about-card {
  padding: 32px 24px;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.about-planet {
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #3b82f6, #06b6d4);
  box-shadow: 0 0 60px rgba(168,85,247,0.3), inset -30px -15px 40px rgba(0,0,0,0.4);
  animation: floatPlanet 4s ease-in-out infinite;
  position: relative;
}

.about-planet::before {
  content: '';
  position: absolute;
  top: 15%;
  left: -15%;
  width: 70%;
  height: 25%;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  transform: rotate(-25deg);
}

.about-planet::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: inset -20px -10px 30px rgba(0,0,0,0.4);
}

.about-card h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.about-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.about-stats {
  display: flex;
  justify-content: center;
}

.about-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}

.about-stat-icon {
  color: var(--accent-gold);
}

.about-stat-value {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 50;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--accent-purple);
  border-radius: 2px;
}

/* ===== Media Queries ===== */
@media (max-width: 400px) {
  #app { padding: 12px; }
  .profile-section { padding: 14px 12px; gap: 12px; }
  .avatar-container { width: 52px; height: 52px; }
  .user-info h1 { font-size: 15px; }
  .points-container { padding: 8px 12px; }
  .points-value { font-size: 18px; }
  .harem-grid { gap: 10px; }
  .harem-card { padding: 12px; }
}

/* ===== Rarity Animation ===== */
@keyframes legendaryGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(251,191,36,0.3); }
  50% { box-shadow: 0 0 40px rgba(251,191,36,0.6), 0 0 60px rgba(245,158,11,0.3); }
}

.harem-card[data-rarity="legendary"] {
  animation: cardAppear 0.4s ease backwards, legendaryGlow 2s ease-in-out infinite;
  border-color: rgba(251, 191, 36, 0.3);
}
