:root {
  --space-deep: #050510;
  --space-mid: #0d0d2b;
  --space-light: #1a1a3e;
  --mars-red: #c1440e;
  --mars-orange: #e85d04;
  --mars-glow: #ff6b35;
  --accent-cyan: #00d4ff;
  --accent-gold: #ffd166;
  --text-primary: #f0f0ff;
  --text-muted: #8b8bb8;
  --glass: rgba(15, 15, 40, 0.65);
  --glass-border: rgba(255, 107, 53, 0.25);
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Exo 2', sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--space-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ─── Starfield canvas ─── */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ─── Nebula overlays ─── */
.nebula {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: nebulaDrift 20s ease-in-out infinite alternate;
}

.nebula-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--mars-red) 0%, transparent 70%);
  top: -100px;
  right: -150px;
}

.nebula-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #4a0e8f 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  animation-delay: -10s;
}

@keyframes nebulaDrift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.1); }
}

/* ─── Scanlines ─── */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* ─── Header ─── */
.header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 3rem;
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  background: rgba(5, 5, 16, 0.6);
  animation: slideDown 0.8s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.mars-orbit {
  position: relative;
  width: 56px;
  height: 56px;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.mars-planet {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8c5a, var(--mars-red) 50%, #6b1a00);
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.6), inset -4px -4px 8px rgba(0,0,0,0.4);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: planetSpin 30s linear infinite;
}

@keyframes planetSpin {
  from { background-position: 0 0; }
  to   { filter: hue-rotate(10deg); }
}

.orbit-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 107, 53, 0.4);
  border-radius: 50%;
  animation: ringPulse 3s ease-in-out infinite;
}

@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50%      { transform: scale(1.15); opacity: 0.2; }
}

.logo-sub {
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--accent-cyan);
  text-transform: uppercase;
  display: block;
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: linear-gradient(90deg, var(--text-primary), var(--mars-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--glass-border);
  border-radius: 2rem;
  font-size: 0.8rem;
  background: var(--glass);
  transition: all 0.3s;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: statusBlink 2s ease-in-out infinite;
}

.status-badge.online .status-dot {
  background: #2ecc71;
  box-shadow: 0 0 8px #2ecc71;
}

.status-badge.offline .status-dot {
  background: #e74c3c;
  box-shadow: 0 0 8px #e74c3c;
}

@keyframes statusBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ─── Main layout ─── */
.main {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* ─── Hero ─── */
.hero {
  text-align: center;
  margin-bottom: 3rem;
  animation: fadeIn 1s ease-out 0.3s both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-tagline {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.typing-text {
  border-right: 2px solid var(--accent-cyan);
  animation: blink 0.8s step-end infinite;
  padding-right: 4px;
}

@keyframes blink {
  50% { border-color: transparent; }
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1.25rem 2rem;
  min-width: 140px;
  backdrop-filter: blur(8px);
  transition: transform 0.3s, box-shadow 0.3s;
  animation: statPop 0.6s ease-out both;
}

.stat-card:nth-child(1) { animation-delay: 0.5s; }
.stat-card:nth-child(2) { animation-delay: 0.65s; }
.stat-card:nth-child(3) { animation-delay: 0.8s; }

@keyframes statPop {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(255, 107, 53, 0.2);
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--mars-glow);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ─── Workspace panels ─── */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 4rem;
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .header { padding: 1rem 1.5rem; }
}

.panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.75rem;
  backdrop-filter: blur(16px);
  animation: panelIn 0.8s ease-out both;
}

.upload-panel { animation-delay: 0.4s; }
.results-panel { animation-delay: 0.6s; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.panel-icon { font-size: 1.4rem; }

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── Dropzone ─── */
.dropzone {
  position: relative;
  border: 2px dashed rgba(255, 107, 53, 0.4);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s;
  overflow: hidden;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--mars-glow);
  background: rgba(255, 107, 53, 0.05);
  transform: scale(1.01);
}

.dropzone-glow {
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, transparent, var(--mars-glow), transparent);
  opacity: 0;
  transition: opacity 0.4s;
  animation: rotateGlow 4s linear infinite;
}

.dropzone:hover .dropzone-glow,
.dropzone.dragover .dropzone-glow {
  opacity: 0.08;
}

@keyframes rotateGlow {
  to { transform: rotate(360deg); }
}

.dropzone-content { position: relative; z-index: 1; }

.upload-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  color: var(--mars-glow);
}

.upload-ring {
  animation: spinSlow 8s linear infinite;
  transform-origin: center;
}

@keyframes spinSlow {
  to { transform: rotate(360deg); }
}

.dropzone-title {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.dropzone-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Preview ─── */
.preview-area { animation: fadeIn 0.5s ease-out; }

.preview-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  margin-bottom: 1.25rem;
}

.preview-frame img {
  width: 100%;
  display: block;
  max-height: 280px;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.scan-overlay.active {
  opacity: 1;
}

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  box-shadow: 0 0 20px var(--accent-cyan);
  animation: scanMove 1.5s ease-in-out infinite;
}

@keyframes scanMove {
  0%   { top: 0; }
  100% { top: 100%; }
}

.scan-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
}

.preview-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ─── Buttons ─── */
.btn {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--mars-red), var(--mars-orange));
  color: white;
  box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(255, 107, 53, 0.6);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary.loading .btn-icon {
  animation: rocketShake 0.5s ease-in-out infinite;
}

@keyframes rocketShake {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--mars-glow);
}

/* ─── Results ─── */
.result-hero {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 2rem;
  animation: resultReveal 0.8s ease-out;
}

@keyframes resultReveal {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.result-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--glass);
  border: 2px solid var(--mars-glow);
  box-shadow: 0 0 30px rgba(255, 107, 53, 0.3);
  animation: badgePulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 30px rgba(255, 107, 53, 0.3); }
  50%      { box-shadow: 0 0 50px rgba(255, 107, 53, 0.6); }
}

.result-main { flex: 1; }

.result-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent-cyan);
}

.result-class {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0.25rem 0 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confidence-ring {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 1rem;
}

.confidence-ring svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 6;
}

.ring-fill {
  fill: none;
  stroke: var(--mars-glow);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 6px var(--mars-glow));
}

.confidence-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.result-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ─── Predictions list ─── */
.predictions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pred-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: all 0.3s;
  animation: predSlide 0.5s ease-out both;
}

.pred-item.top {
  border-color: var(--glass-border);
  background: rgba(255, 107, 53, 0.08);
}

@keyframes predSlide {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.pred-icon { font-size: 1.2rem; text-align: center; }

.pred-info { min-width: 0; }

.pred-name {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: capitalize;
  margin-bottom: 0.35rem;
}

.pred-bar-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.pred-bar-fill {
  height: 100%;
  border-radius: 2px;
  width: 0;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pred-pct {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 42px;
  text-align: right;
}

/* ─── Terrain gallery ─── */
.section-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  color: var(--text-muted);
}

.title-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
}

.terrain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.terrain-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: all 0.4s;
  animation: cardFloat 0.6s ease-out both;
  cursor: default;
}

.terrain-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--mars-glow);
  box-shadow: 0 12px 40px rgba(255, 107, 53, 0.15);
}

@keyframes cardFloat {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.terrain-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.terrain-card-icon {
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.terrain-card-name {
  font-family: var(--font-display);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.terrain-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Footer ─── */
.footer {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-sub {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  opacity: 0.6;
}

/* ─── Utilities ─── */
.hidden { display: none !important; }
