:root {
  --bg-deep: #050210;
  --card: rgba(12, 13, 35, 0.86);
  --text-primary: #f8f6ff;
  --text-muted: #b2b3d9;
  --accent: #ff6c63;
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Nunito', sans-serif;
  color: var(--text-primary);
  background: radial-gradient(circle at 15% 20%, rgba(255, 108, 99, 0.25), transparent 55%),
    radial-gradient(circle at 70% 10%, rgba(124, 93, 255, 0.25), transparent 50%), var(--bg-deep);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 4rem;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('assets/pattern4.webp');
  background-size: 320px;
  opacity: 0.06;
  z-index: -1;
}

header {
  width: min(1100px, calc(100% - 2rem));
  margin-top: 1.5rem;
  padding: 1rem 1.5rem;
  border-radius: 999px;
  background: rgba(5, 3, 22, 0.85);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

header img {
  height: 48px;
}

header h1 {
  font-size: 1.35rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0;
}

header a.back-link {
  margin-left: auto;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.3s ease, transform 0.3s ease;
}

header a.back-link:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

main {
  width: min(900px, calc(100% - 2.5rem));
  margin-top: 2.5rem;
}

.challenge-shell {
  background: var(--card);
  border-radius: 32px;
  padding: 2.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  min-height: 300px;
}

.markdown-body {
  background: transparent;
  color: var(--text-primary);
  animation: fadeIn 0.5s ease forwards;
}

.markdown-body:not(.is-visible) {
  opacity: 0.25;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  color: var(--text-primary);
}

.markdown-body a {
  color: var(--accent);
}

.markdown-body pre {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

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

@media (max-width: 640px) {
  header {
    flex-direction: column;
    border-radius: 24px;
  }

  header a.back-link {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }

  .challenge-shell {
    padding: 1.5rem;
  }
}
