:root {
  color-scheme: dark;
  --bg: #0f1720;
  --bg-elevated: #182332;
  --panel: #1f2d40;
  --panel-soft: #26384d;
  --text: #edf2f7;
  --muted: #b8c5d6;
  --gold: #d7b56d;
  --emerald: #5dc08e;
  --rose: #ef7c7c;
  --border: rgba(215, 181, 109, 0.28);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", sans-serif;
  background:
    radial-gradient(circle at top, rgba(215, 181, 109, 0.18), transparent 30%),
    linear-gradient(180deg, #091019 0%, var(--bg) 45%, #0d131d 100%);
  color: var(--text);
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.hero-panel,
.story-card,
.game-panel {
  background: rgba(20, 30, 43, 0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Cinzel", serif;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  margin-bottom: 10px;
}

.lede {
  margin: 0;
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.6;
}

.hero-panel {
  padding: 24px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 14px;
}

.sigil {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(215, 181, 109, 0.18);
  border: 1px solid rgba(215, 181, 109, 0.4);
  color: var(--gold);
  font-size: 2rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.3fr);
  gap: 24px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.story-card {
  padding: 20px;
}

.stage-panel {
  background: rgba(20, 30, 43, 0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.stage-panel-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.stage-kicker {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stage-panel-header h3 {
  font-size: 1rem;
}

.stage-progress {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.stage-track {
  width: 100%;
  height: 10px;
  background: #0d1520;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stage-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), #f0d29a);
  transition: width 180ms ease;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stage-item {
  min-height: 86px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stage-item.current {
  border-color: rgba(215, 181, 109, 0.45);
  box-shadow: inset 0 0 0 1px rgba(215, 181, 109, 0.18);
}

.stage-item.completed {
  border-color: rgba(93, 192, 142, 0.35);
}

.stage-item.locked {
  opacity: 0.5;
}

.stage-item-index {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
}

.stage-item-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
}

.stage-item-meta {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.story-entry + .story-entry {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.story-entry h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.story-entry p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.story-entry.locked {
  opacity: 0.45;
}

.game-panel {
  padding: 20px;
}

.challenge-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  padding: 8px 12px;
  background: rgba(93, 192, 142, 0.15);
  color: #bfeccf;
  border: 1px solid rgba(93, 192, 142, 0.3);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}

.challenge-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.challenge-text,
#goal-text,
.hint-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.reference-box,
.hint-box {
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 16px;
}

.reference-box h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: #dfe8f2;
  line-height: 1.5;
}

.hint-box {
  margin-top: 14px;
}

.hint-box strong {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
}

.editor-label {
  display: inline-block;
  margin-bottom: 8px;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0d1520;
  color: var(--text);
  font: 0.95rem/1.55 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--gold);
  color: #1b1a16;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  background: #33465f;
  color: var(--text);
}

button:hover {
  filter: brightness(1.06);
}

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #13202d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  min-height: 54px;
}

.feedback.success {
  border-color: rgba(93, 192, 142, 0.34);
  color: #d7f6e4;
}

.feedback.error {
  border-color: rgba(239, 124, 124, 0.34);
  color: #ffd5d5;
}

@media (max-width: 900px) {
  .hero,
  .layout,
  .reference-grid {
    grid-template-columns: 1fr;
  }

  .stage-list {
    grid-template-columns: 1fr;
  }

  .stage-panel-header {
    align-items: start;
    flex-direction: column;
  }

  .page-shell {
    width: min(100% - 20px, 1200px);
  }
}
