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

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

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #111128;
  --bg-card: #16163a;
  --bg-input: #1c1c45;
  --border: #2a2a5a;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --accent-dim: rgba(167, 139, 250, 0.15);
  --text-primary: #e8e8f0;
  --text-secondary: #9898b8;
  --text-muted: #6868a0;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
}

html { scrollbar-gutter: stable; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(167,139,250,0.04) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(99,102,241,0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Mobile Block */
.mobile-block {
  display: none;
  position: fixed; inset: 0; z-index: 99999;
  background: var(--bg-primary);
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px;
}
.mobile-block-icon { width: 64px; height: 64px; margin-bottom: 24px; }
.mobile-block h1 { font-size: 24px; font-weight: 700; margin-bottom: 12px; color: var(--accent); }
.mobile-block p { color: var(--text-secondary); font-size: 15px; line-height: 1.6; max-width: 360px; }

/* Header */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: 64px;
  background: rgba(10,10,26,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; z-index: 100;
}
.logo { font-size: 22px; font-weight: 700; color: var(--accent); text-decoration: none; letter-spacing: -0.5px; cursor: pointer; user-select: none; }
.logo span { color: var(--text-primary); }
.nav { display: flex; gap: 8px; align-items: center; }
.nav-link {
  padding: 8px 20px; border-radius: 10px; color: var(--text-secondary);
  text-decoration: none; font-size: 14px; font-weight: 500;
  transition: color 0.2s, background 0.2s; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-link svg { flex-shrink: 0; }
.nav-link:hover { color: var(--text-primary); background: var(--accent-dim); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

.nav-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 14px 4px 4px; border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: border-color 0.2s; user-select: none;
}
.nav-user:hover { border-color: var(--accent); }
.nav-user img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.nav-user span { font-size: 13px; font-weight: 500; color: var(--text-primary); }

/* Main */
.main { padding-top: 64px; min-height: 100vh; position: relative; z-index: 1; }

/* Page transitions */
.page { position: relative; transition: opacity 0.3s ease, transform 0.3s ease; }
.page.hidden { display: none; }
.page.page-enter { opacity: 0; transform: translateY(12px); }
.page.page-enter-active { opacity: 1; transform: translateY(0); }

/* Hero */
.hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 100px 24px 60px;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px; background: var(--accent-dim);
  border: 1px solid rgba(167,139,250,0.2); border-radius: 100px;
  font-size: 13px; color: var(--accent); margin-bottom: 24px;
}
.hero h1 { font-size: 52px; font-weight: 700; line-height: 1.1; margin-bottom: 20px; letter-spacing: -1.5px; }
.hero h1 .gradient {
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 50%, #ec4899 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero p { font-size: 17px; color: var(--text-secondary); max-width: 520px; line-height: 1.7; margin-bottom: 36px; }
.hero p strong { color: var(--accent); font-weight: 600; }
.hero-buttons { display: flex; gap: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border-radius: 12px; font-size: 15px; font-weight: 600;
  text-decoration: none; border: none; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  font-family: inherit;
}
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #0a0a1a; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 8px 30px rgba(167,139,250,0.3); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn-sm { padding: 8px 18px; font-size: 13px; border-radius: 8px; }
.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 15px; }
.btn.loading { pointer-events: none; opacity: 0.7; }

/* Features */
.features { padding: 20px 24px 80px; max-width: 1000px; margin: 0 auto; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 32px;
  transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
}
.feature-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: 0 12px 40px rgba(167,139,250,0.1); }
.feature-icon {
  width: 48px; height: 48px; border-radius: 12px; background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
}
.feature-card h3 { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.feature-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* Page Back Button */
.page-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  font-size: 13px; font-weight: 600; color: var(--accent);
  cursor: pointer; transition: background 0.2s, transform 0.15s;
  background: var(--accent-dim);
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: 10px;
  margin: 24px auto 0;
  max-width: 900px;
  width: fit-content;
  position: relative;
  left: -370px;
}
.page-back:hover { background: rgba(167, 139, 250, 0.25); transform: translateX(-2px); }
.page-back svg { transition: transform 0.2s; }
.page-back:hover svg { transform: translateX(-3px); }

.page-back-inline {
  left: 0;
  margin: 0 0 4px 0;
}

/* Page Header */
.page-header { padding: 48px 24px 24px; text-align: center; }
.page-header h2 { font-size: 32px; font-weight: 700; margin-bottom: 10px; }
.page-header p { color: var(--text-secondary); font-size: 15px; }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 60px 24px 100px;
}
.empty-state-icon { width: 80px; height: 80px; margin-bottom: 24px; opacity: 0.5; }
.empty-state h3 { font-size: 20px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state p { font-size: 14px; color: var(--text-muted); max-width: 320px; line-height: 1.6; }

/* Auth */
.auth-container { max-width: 420px; margin: 60px auto; padding: 0 24px; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 40px 32px; }
.auth-card h2 { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.auth-card .subtitle { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 32px; }

.auth-tabs { display: flex; background: var(--bg-primary); border-radius: 12px; padding: 4px; margin-bottom: 28px; }
.auth-tab {
  flex: 1; padding: 10px; text-align: center; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; transition: background 0.2s, color 0.2s;
  border: none; background: none; font-family: inherit;
}
.auth-tab.active { background: var(--accent); color: #0a0a1a; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 12px 16px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary);
  font-size: 15px; font-family: inherit; transition: border-color 0.2s; outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); }

.form-input-with-suffix {
  display: flex; align-items: center; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  transition: border-color 0.2s;
}
.form-input-with-suffix:focus-within { border-color: var(--accent); }
.form-input-with-suffix input {
  flex: 1; padding: 12px 16px; background: none; border: none;
  color: var(--text-primary); font-size: 15px; font-family: inherit; outline: none;
}
.form-input-with-suffix input::placeholder { color: var(--text-muted); }
.form-input-with-suffix .suffix { padding: 12px 16px; background: rgba(167,139,250,0.1); color: var(--accent); font-size: 14px; font-weight: 600; white-space: nowrap; }

.domain-status { font-size: 12px; margin-top: 4px; min-height: 16px; }
.domain-status.available { color: var(--success); }
.domain-status.taken { color: var(--error); }

.code-input-row { display: flex; gap: 10px; }
.code-input-row .form-input { flex: 1; }
.code-input-row .btn { white-space: nowrap; flex-shrink: 0; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 13px; color: var(--error); margin-top: 4px; transition: opacity 0.2s; }
.form-error.hidden { opacity: 0; height: 0; margin: 0; overflow: hidden; }

.avatar-upload { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.avatar-preview {
  width: 64px; height: 64px; border-radius: 14px; background: var(--bg-input);
  border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer; transition: border-color 0.2s; flex-shrink: 0;
}
.avatar-preview:hover { border-color: var(--accent); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-preview .placeholder { font-size: 24px; color: var(--text-muted); }
.avatar-upload-text { font-size: 13px; color: var(--text-secondary); }
.avatar-upload-text span { color: var(--accent); cursor: pointer; }

.steps { display: flex; gap: 8px; margin-bottom: 28px; }
.step { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background 0.3s; }
.step.active { background: var(--accent); }
.step.done { background: var(--success); }

/* Profile */
.profile-container { max-width: 500px; margin: 60px auto; padding: 0 24px; }
.profile-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 40px 32px; text-align: center; }
.profile-avatar { width: 96px; height: 96px; border-radius: 20px; object-fit: cover; margin-bottom: 16px; border: 3px solid var(--accent-dim); }
.profile-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.profile-domain { font-size: 14px; color: var(--accent); margin-bottom: 4px; }
.profile-email { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

.profile-stats {
  display: flex; justify-content: center; gap: 32px;
  padding: 20px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.profile-stat { text-align: center; }
.profile-stat .value { font-size: 20px; font-weight: 700; }
.profile-stat .label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.profile-actions { display: flex; flex-direction: column; gap: 10px; }

/* Profile edit transition */
#profile-view, #profile-edit {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#profile-view.fade-out { opacity: 0; transform: translateY(-8px); }
#profile-edit.fade-in { opacity: 0; transform: translateY(8px); }
#profile-edit.fade-in-active { opacity: 1; transform: translateY(0); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 14px 24px; border-radius: 12px; font-size: 14px; font-weight: 500;
  z-index: 1000; transform: translateY(100px); opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: #065f46; color: var(--success); border: 1px solid #10b981; }
.toast.error { background: #7f1d1d; color: var(--error); border: 1px solid #ef4444; }

/* Spinner */
.spinner { width: 18px; height: 18px; border: 2px solid transparent; border-top: 2px solid currentColor; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== CAVE ========== */
.cave-scene {
  position: relative;
  max-width: 900px;
  min-height: 480px;
  margin: 0 auto;
  padding: 0 24px 80px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.cave-bg {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  background: #08081a;
  border: 1px solid var(--border);
}

.cave-bg-svg {
  width: 100%;
  height: 100%;
}

/* Floating particles animation */
.cave-particle {
  opacity: 0.5;
  animation: caveFloat 4s ease-in-out infinite;
}
.cave-particle.p1 { animation-delay: 0s; animation-duration: 3.5s; }
.cave-particle.p2 { animation-delay: 0.8s; animation-duration: 4.2s; }
.cave-particle.p3 { animation-delay: 1.5s; animation-duration: 3.8s; }
.cave-particle.p4 { animation-delay: 0.3s; animation-duration: 5s; }
.cave-particle.p5 { animation-delay: 2s; animation-duration: 4s; }
.cave-particle.p6 { animation-delay: 1s; animation-duration: 4.5s; }
.cave-particle.p7 { animation-delay: 0.5s; animation-duration: 3.2s; }

@keyframes caveFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.3; }
  50% { transform: translateY(-12px) scale(1.4); opacity: 0.8; }
}

/* Doors container */
.cave-doors {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 32px;
  padding: 0 40px 40px;
}

/* Individual door */
.cave-door {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.cave-door:hover {
  transform: translateY(-6px);
}

.cave-door:active {
  transform: translateY(-2px);
}

.cave-door-locked {
  cursor: default;
  opacity: 0.5;
}

.cave-door-locked:hover {
  transform: none;
}

/* Door frame */
.cave-door-frame {
  position: relative;
  width: 140px;
  height: 190px;
}

.cave-door-arch {
  position: absolute;
  inset: 0;
  border-radius: 70px 70px 4px 4px;
  background: linear-gradient(180deg, #1a1a40 0%, #12122e 100%);
  border: 2px solid #2a2a5a;
  transition: border-color 0.3s;
}

.cave-door:hover .cave-door-arch {
  border-color: var(--accent);
}

.cave-door-locked:hover .cave-door-arch {
  border-color: #2a2a5a;
}

/* Door panel (inner door) */
.cave-door-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  bottom: 4px;
  border-radius: 54px 54px 2px 2px;
  background: linear-gradient(180deg, #1e1e4a 0%, #141438 100%);
  border: 1px solid #333370;
  transition: background 0.3s, border-color 0.3s;
}

.cave-door:hover .cave-door-panel {
  background: linear-gradient(180deg, #252560 0%, #1a1a48 100%);
  border-color: rgba(167, 139, 250, 0.4);
}

.cave-door-locked:hover .cave-door-panel {
  background: linear-gradient(180deg, #1e1e4a 0%, #141438 100%);
  border-color: #333370;
}

.door-locked-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.door-lock-icon {
  opacity: 0.4;
}

/* Door handle */
.cave-door-handle {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555588;
  border: 1px solid #6666aa;
  transition: background 0.3s, box-shadow 0.3s;
}

.cave-door:hover .cave-door-handle {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.5);
}

/* Door glow */
.cave-door-glow {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 40px;
  border-radius: 50%;
  filter: blur(16px);
  opacity: 0;
  transition: opacity 0.4s;
}

.glow-blue { background: #6366f1; }
.glow-green { background: #22c55e; }
.glow-dim { background: #555; }

.cave-door:hover .cave-door-glow {
  opacity: 0.4;
}

.cave-door-locked:hover .cave-door-glow {
  opacity: 0;
}

/* Door bottom glow line */
.cave-door-frame::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.3s;
  box-shadow: 0 0 8px var(--accent);
}

.cave-door:hover .cave-door-frame::after {
  opacity: 0.6;
}

.cave-door-locked:hover .cave-door-frame::after {
  opacity: 0;
}

/* Door label */
.cave-door-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.3s, border-color 0.3s, background 0.3s;
  white-space: nowrap;
}

.cave-door:hover .cave-door-label {
  color: var(--text-primary);
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.08);
}

.cave-door-locked .cave-door-label {
  color: var(--text-muted);
}

.cave-door-locked:hover .cave-door-label {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-card);
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .features-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 36px; }
}
