:root {
  --bg: #f8f1e7;
  --bg-strong: #f2ddc4;
  --panel: rgba(255, 249, 242, 0.75);
  --panel-strong: rgba(255, 253, 250, 0.92);
  --ink: #221b18;
  --muted: #63554e;
  --accent: #df6d2d;
  --accent-2: #1f7a5c;
  --accent-3: #1773b0;
  --line: rgba(34, 27, 24, 0.1);
  --shadow: 0 20px 60px rgba(109, 60, 23, 0.14);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 205, 130, 0.65), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(63, 173, 122, 0.18), transparent 25%),
    linear-gradient(180deg, #fff9f2 0%, #f7efe4 36%, #f5e7d6 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(34, 27, 24, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 27, 24, 0.02) 1px, transparent 1px);
  background-size: 28px 28px;
}

.page-shell {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero {
  min-height: 100vh;
  padding: 24px 0 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 42px;
  padding: 10px 12px 10px 18px;
  border: 1px solid rgba(34, 27, 24, 0.08);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.68);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 48px rgba(109, 60, 23, 0.1);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin-right: auto;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #f2b84b);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.46), 0 10px 20px rgba(223, 109, 45, 0.18);
}

.nav-pill,
.cta {
  text-decoration: none;
  color: inherit;
}

.nav-pill {
  border: 1px solid transparent;
  padding: 10px 16px;
  border-radius: 999px;
  background: transparent;
  font-weight: 700;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.nav-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 5px;
  border: 1px solid rgba(34, 27, 24, 0.07);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
}

.back-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border: 2px solid rgba(223, 109, 45, 0.28);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #f2b84b);
  color: #fffaf3;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(223, 109, 45, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.back-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 14px;
}

.back-icon::before,
.back-icon::after {
  content: "";
  position: absolute;
  left: 1px;
}

.back-icon::before {
  top: 5px;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
}

.back-icon::after {
  top: 2px;
  width: 9px;
  height: 9px;
  border-left: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: rotate(45deg);
}

.back-button:hover,
.back-button:focus-visible {
  transform: translateX(-2px) scale(1.04);
  background: linear-gradient(135deg, #c95720, var(--accent));
  color: #fffaf3;
  box-shadow: 0 18px 34px rgba(223, 109, 45, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.34);
  outline: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 36px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.8rem;
  color: var(--accent-2);
  font-weight: 800;
}

.hero-copy h1,
.section-heading h2 {
  margin: 0;
  font-family: "DM Serif Display", serif;
  letter-spacing: 0;
  line-height: 0.98;
}

.hero-copy h1 {
  font-size: clamp(2.8rem, 5.6vw, 4.8rem);
  max-width: 10ch;
}

.hero-text {
  margin: 24px 0 0;
  font-size: 1.08rem;
  line-height: 1.75;
  max-width: 60ch;
  color: var(--muted);
}

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

.cta {
  padding: 14px 20px;
  border-radius: 999px;
  font-weight: 800;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.cta.primary {
  background: linear-gradient(135deg, var(--accent), #f2b84b);
  color: #fffdf9;
  box-shadow: 0 18px 28px rgba(223, 109, 45, 0.22);
}

.cta.secondary {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(34, 27, 24, 0.08);
}

.cta:hover,
.nav-pill:hover {
  transform: translateY(-2px);
}

.nav-pill:hover,
.nav-pill:focus-visible {
  border-color: rgba(223, 109, 45, 0.18);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 22px rgba(109, 60, 23, 0.1);
  outline: none;
}

.hero-metrics {
  margin-top: 36px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.hero-metrics article,
.panel,
.pattern-card,
.compare-card,
.timeline-step,
.info-card,
.improvement-item {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
}

.hero-metrics article {
  padding: 18px 18px 16px;
  border-radius: 18px;
}

.hero-metrics strong {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
}

.hero-metrics span {
  color: var(--muted);
  font-size: 0.94rem;
}

.hero-visual {
  position: relative;
}

.visual-card {
  background: rgba(34, 27, 24, 0.96);
  color: #fffaf3;
  border-radius: 30px;
  padding: 18px;
  box-shadow: 0 28px 80px rgba(34, 27, 24, 0.26);
  position: relative;
  overflow: hidden;
}

.visual-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -25% auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 184, 75, 0.22), transparent 70%);
}

.visual-header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 250, 243, 0.8);
  font-size: 0.93rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5df2a5;
  box-shadow: 0 0 18px rgba(93, 242, 165, 0.8);
}

.board-preview {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  aspect-ratio: 1;
  margin: 18px 0;
}

.start-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 18px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.start-zone-label {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fffaf3;
  background: rgba(255, 255, 255, 0.1);
}

.start-zone-tokens {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 24px;
  flex-wrap: wrap;
}

.board-cell {
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255, 244, 228, 0.96), rgba(238, 224, 204, 0.88));
  color: #2a211d;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 6px;
  font-size: 0.72rem;
  position: relative;
  overflow: hidden;
}

.cell-number {
  display: inline-flex;
  align-items: flex-start;
  gap: 4px;
}

.cell-jump {
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0.95;
}

.board-cell.snake {
  background: linear-gradient(135deg, rgba(255, 199, 185, 0.96), rgba(222, 110, 81, 0.84));
  color: #fff6ef;
}

.board-cell.ladder {
  background: linear-gradient(135deg, rgba(197, 255, 225, 0.98), rgba(38, 162, 121, 0.82));
  color: #f5fff9;
}

.token {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  top: 0;
  left: 0;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.26);
  transition: transform 850ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 3;
}

.start-token {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.26);
}

.token.p1 {
  background: #ff8f4e;
}

.token.p2 {
  background: #55d39c;
}

.token.p3 {
  background: #4ea1ff;
}

.token.p4 {
  background: #f4d35e;
}

.path-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.17;
}

.path-lines::before,
.path-lines::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  transform-origin: center;
}

.path-one::before {
  width: 10px;
  height: 200px;
  background: linear-gradient(180deg, transparent, #f48f52, transparent);
  left: 18%;
  top: 16%;
  transform: rotate(24deg);
}

.path-one::after {
  width: 10px;
  height: 170px;
  background: linear-gradient(180deg, transparent, #52f1a2, transparent);
  right: 19%;
  top: 24%;
  transform: rotate(-30deg);
}

.path-two::before {
  width: 180px;
  height: 10px;
  background: linear-gradient(90deg, transparent, #f0bf4d, transparent);
  left: 32%;
  top: 48%;
  transform: rotate(-24deg);
}

.path-two::after {
  width: 10px;
  height: 150px;
  background: linear-gradient(180deg, transparent, #53aef1, transparent);
  left: 46%;
  bottom: 10%;
  transform: rotate(18deg);
}

.turn-console {
  display: grid;
  gap: 10px;
}

.console-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.console-row span {
  color: rgba(255, 250, 243, 0.7);
}

.dice-readout {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.dice-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #fffaf3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 4px;
  gap: 2px;
  box-shadow: inset 0 0 0 1px rgba(34, 27, 24, 0.08);
}

.pip {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #2f241f;
  opacity: 0;
  place-self: center;
}

.dice-icon[data-roll="1"] .pip-1,
.dice-icon[data-roll="2"] .pip-2,
.dice-icon[data-roll="2"] .pip-3,
.dice-icon[data-roll="3"] .pip-1,
.dice-icon[data-roll="3"] .pip-2,
.dice-icon[data-roll="3"] .pip-3,
.dice-icon[data-roll="4"] .pip-2,
.dice-icon[data-roll="4"] .pip-3,
.dice-icon[data-roll="4"] .pip-4,
.dice-icon[data-roll="4"] .pip-5,
.dice-icon[data-roll="5"] .pip-1,
.dice-icon[data-roll="5"] .pip-2,
.dice-icon[data-roll="5"] .pip-3,
.dice-icon[data-roll="5"] .pip-4,
.dice-icon[data-roll="5"] .pip-5,
.dice-icon[data-roll="6"] .pip-2,
.dice-icon[data-roll="6"] .pip-3,
.dice-icon[data-roll="6"] .pip-4,
.dice-icon[data-roll="6"] .pip-5,
.dice-icon[data-roll="6"] .pip-6,
.dice-icon[data-roll="6"] .pip-7 {
  opacity: 1;
}

.pip-1 { grid-column: 2; grid-row: 2; }
.pip-2 { grid-column: 1; grid-row: 1; }
.pip-3 { grid-column: 3; grid-row: 3; }
.pip-4 { grid-column: 3; grid-row: 1; }
.pip-5 { grid-column: 1; grid-row: 3; }
.pip-6 { grid-column: 1; grid-row: 2; }
.pip-7 { grid-column: 3; grid-row: 2; }

.section {
  padding: 72px 0;
}

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

.section-heading h2 {
  font-size: clamp(2.2rem, 5vw, 4rem);
  max-width: 14ch;
}

.logic-grid,
.pattern-grid,
.compare-grid,
.split-layout {
  display: grid;
  gap: 18px;
}

.logic-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.info-card,
.pattern-card,
.compare-card,
.panel {
  border-radius: var(--radius);
  padding: 24px;
}

.info-card h3,
.pattern-card h3,
.compare-card h3,
.panel h3,
.timeline-step h3 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.info-card p,
.pattern-card p,
.compare-card p,
.panel p,
.timeline-step p,
.improvement-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.accent-orange {
  background: linear-gradient(180deg, rgba(255, 239, 224, 0.96), rgba(255, 249, 242, 0.88));
}

.accent-green {
  background: linear-gradient(180deg, rgba(227, 252, 238, 0.96), rgba(255, 249, 242, 0.88));
}

.accent-blue {
  background: linear-gradient(180deg, rgba(228, 245, 255, 0.96), rgba(255, 249, 242, 0.88));
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-step {
  border-radius: 24px;
  padding: 20px;
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: start;
  gap: 18px;
}

.step-number {
  font-family: "DM Serif Display", serif;
  font-size: 2.2rem;
  color: var(--accent);
  line-height: 1;
}

.split-layout {
  grid-template-columns: 1fr 1fr;
}

.panel.warm {
  background: linear-gradient(180deg, rgba(255, 236, 205, 0.96), rgba(255, 249, 242, 0.88));
}

.clean-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.clean-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.mini-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.mini-steps span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.92rem;
  font-weight: 700;
}

.pattern-grid,
.compare-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compiler-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.code-panel,
.compiler-panel {
  min-height: 820px;
}

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

.compiler-note {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.6;
}

.copy-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: linear-gradient(135deg, var(--accent-2), #4dbf8d);
  color: #fffaf3;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
  box-shadow: 0 14px 24px rgba(31, 122, 92, 0.2);
}

.copy-button:hover {
  transform: translateY(-2px);
}

.code-textarea {
  width: 100%;
  min-height: 680px;
  resize: vertical;
  border-radius: 20px;
  border: 1px solid rgba(34, 27, 24, 0.12);
  background: rgba(34, 27, 24, 0.96);
  color: #fff7ee;
  padding: 18px;
  line-height: 1.55;
  font-size: 0.92rem;
  font-family: "Courier New", monospace;
}

.compiler-actions {
  margin-top: 14px;
}

.compiler-frame {
  width: 100%;
  min-height: 750px;
  border: 1px solid rgba(34, 27, 24, 0.1);
  border-radius: 20px;
  background: #fff;
}

.compare-card.bad {
  background: linear-gradient(180deg, rgba(255, 232, 227, 0.98), rgba(255, 249, 242, 0.88));
}

.compare-card.good {
  background: linear-gradient(180deg, rgba(229, 255, 238, 0.98), rgba(255, 249, 242, 0.88));
}

code {
  font-family: "Courier New", monospace;
  font-size: 0.95em;
  background: rgba(34, 27, 24, 0.06);
  padding: 2px 7px;
  border-radius: 7px;
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms ease, transform 700ms ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .hero-grid,
  .logic-grid,
  .split-layout,
  .compiler-layout,
  .pattern-grid,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-bottom: 36px;
  }

  .hero-copy h1 {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 18px, 1500px);
  }

  .topbar {
    gap: 14px;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 34px;
    border-radius: 24px;
    padding: 14px;
  }

  .nav-group {
    width: 100%;
    justify-content: flex-start;
    border-radius: 20px;
  }

  .hero-copy h1 {
    font-size: 2.4rem;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
  }

  .timeline-step {
    grid-template-columns: 1fr;
  }

  .code-panel,
  .compiler-panel {
    min-height: auto;
  }

  .step-number {
    font-size: 1.8rem;
  }

  .section {
    padding: 54px 0;
  }
}

pre {
  position: relative;
}

.snippet-expand-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.15);
  color: #fffaf3;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.expand-icon {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-block;
}

.expand-icon::before,
.expand-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-color: currentColor;
}

.expand-icon::before {
  top: 0;
  right: 0;
  border-top: 2px solid;
  border-right: 2px solid;
}

.expand-icon::after {
  left: 0;
  bottom: 0;
  border-left: 2px solid;
  border-bottom: 2px solid;
}

.code-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border: 1px solid rgba(34, 27, 24, 0.1);
  box-shadow: none;
}

.code-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  grid-template-rows: auto 1fr;
  background: rgba(18, 15, 13, 0.98);
  padding: 18px;
}

.code-modal.open {
  display: grid;
}

.modal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  color: #fffaf3;
  padding-bottom: 14px;
}

.modal-code {
  width: 100%;
  min-height: 0;
  resize: none;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f1512;
  color: #f5fff9;
  padding: 22px;
  line-height: 1.58;
  font-size: 1rem;
  font-family: "Courier New", monospace;
}

body.modal-open {
  overflow: hidden;
}
.algorithm-stack {
  display: grid;
  gap: 18px;
}

.algorithm-card {
  border-radius: var(--radius);
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr 0.9fr;
  gap: 18px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
}

.algorithm-tag {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.algorithm-copy h3 {
  margin: 0 0 12px;
  font-size: 1.3rem;
}

.algorithm-copy p,
.visual-note {
  color: var(--muted);
  line-height: 1.7;
}

.algorithm-visual {
  border-radius: 22px;
  padding: 18px;
  background: rgba(34, 27, 24, 0.95);
  color: #fffaf3;
  min-height: 260px;
}

.visual-title {
  font-weight: 800;
  margin-bottom: 18px;
}

.reason-card {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 250, 243, 0.86);
}

@media (max-width: 980px) {
  .algorithm-card {
    grid-template-columns: 1fr;
  }
}
