:root {
  --bg: #f8f1e6;
  --bg-2: #f2e7d4;
  --ink: #1f1c17;
  --ink-2: #3d352b;
  --accent: #d76c2a;
  --accent-2: #1d6c8f;
  --card: #fff8ef;
  --card-2: #fef4e2;
  --shadow: rgba(28, 20, 12, 0.15);
  --mono: "Fira Code", "Consolas", "Courier New", monospace;
  --serif: "Palatino", "Book Antiqua", "Times New Roman", serif;
  --sans: "Trebuchet MS", "Verdana", "Geneva", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: radial-gradient(circle at top, var(--bg), var(--bg-2));
  font-family: var(--sans);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 10%, rgba(215, 108, 42, 0.15), transparent 55%),
    radial-gradient(circle at 80% 15%, rgba(29, 108, 143, 0.2), transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(215, 108, 42, 0.12), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

header {
  position: relative;
  z-index: 1;
  padding: 32px 24px 8px;
}

nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

nav a {
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(31, 28, 23, 0.15);
  background: rgba(255, 255, 255, 0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

nav a:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px -12px var(--shadow);
}

.hero {
  padding: 12px 24px 32px;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 4vw, 3.6rem);
  margin: 12px 0 6px;
}

.hero p {
  font-size: 1.05rem;
  color: var(--ink-2);
  max-width: 720px;
  line-height: 1.6;
}

.hero .pill {
  align-self: start;
  width: fit-content;
  background: var(--accent);
  color: #fffaf2;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

main {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto 60px;
  padding: 0 24px;
  display: grid;
  gap: 28px;
}

.section {
  background: linear-gradient(140deg, var(--card), var(--card-2));
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 18px 40px -28px var(--shadow);
  border: 1px solid rgba(31, 28, 23, 0.08);
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.6s ease forwards;
}

.section:nth-of-type(1) { animation-delay: 0.05s; }
.section:nth-of-type(2) { animation-delay: 0.12s; }
.section:nth-of-type(3) { animation-delay: 0.2s; }
.section:nth-of-type(4) { animation-delay: 0.28s; }
.section:nth-of-type(5) { animation-delay: 0.36s; }

.section h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
}

.section p {
  color: var(--ink-2);
  margin: 0 0 16px;
  line-height: 1.5;
}

.example-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.example-card {
  background: #fffdf7;
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(31, 28, 23, 0.08);
  display: grid;
  gap: 10px;
}

.example-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--ink);
}

.level-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: stretch;
}

.level-btn {
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  color: #1f1c17;
  height: 100%;
}

.level-btn.green { background: #cfe9c9; }
.level-btn.yellow { background: #f7e5a3; }
.level-btn.red { background: #f4c1b8; }

.level-btn.active {
  outline: 2px solid rgba(31, 28, 23, 0.25);
}

.code-info {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.info-term {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(29, 108, 143, 0.12);
  color: var(--ink);
  font-size: 0.8rem;
  cursor: help;
  border: 1px solid rgba(29, 108, 143, 0.25);
}

.info-tooltip {
  position: fixed;
  max-width: 280px;
  background: #fffdf7;
  border: 1px solid rgba(31, 28, 23, 0.25);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 16px 30px -20px rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  color: var(--ink-2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 20;
}

.info-tooltip.visible {
  opacity: 1;
}
.code-area {
  font-family: var(--mono);
  font-size: 0.9rem;
  width: 100%;
  min-height: 160px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(31, 28, 23, 0.2);
  background: #10100f;
  color: #f9f4e7;
  resize: none;
  overflow: hidden;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

button.run {
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 18px -12px var(--shadow);
}

button.reset {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(31, 28, 23, 0.2);
  background: #fff6ea;
  color: var(--ink-2);
  font-weight: 700;
  cursor: pointer;
}

button.debug {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(29, 108, 143, 0.3);
  background: rgba(29, 108, 143, 0.12);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.output {
  color: #e5f3f6;
  font-family: var(--mono);
  white-space: pre-wrap;
}

.terminal {
  background: #0c1417;
  border-radius: 16px;
  padding: 12px;
  border: 1px solid rgba(229, 243, 246, 0.12);
  display: grid;
  gap: 10px;
}

.example-card:not(.has-run) .terminal {
  display: none;
}

.input-line {
  display: none;
  grid-template-columns: 18px 1fr;
  gap: 6px;
  align-items: center;
  font-family: var(--mono);
  color: #7cc0d6;
}

.input-line input {
  background: #101f25;
  color: #e5f3f6;
  border: 1px solid rgba(229, 243, 246, 0.2);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: var(--mono);
}

.input-line.active {
  display: grid;
}

.debug-modal {
  position: fixed;
  inset: 0;
  background: transparent;
  display: block;
  z-index: 10;
  pointer-events: none;
}

.debug-modal.hidden {
  display: none;
}

.debug-code-view {
  font-family: var(--mono);
  background: #10100f;
  color: #f9f4e7;
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  border: 1px solid rgba(31, 28, 23, 0.2);
}

.debug-code-view.hidden {
  display: none;
}

.debug-code-view.report {
  background: #fff;
  color: #1f1c17;
  border: 1px dashed rgba(31, 28, 23, 0.3);
}

.debug-line {
  padding: 2px 6px;
  border-radius: 8px;
}

.debug-line.active {
  border: 2px solid var(--accent-2);
  background: rgba(29, 108, 143, 0.12);
}

.code-area.debug-hidden {
  display: none;
}
.debug-window {
  position: absolute;
  top: 80px;
  left: calc(50% - 360px);
  width: min(720px, 92vw);
  background: #e9f4fb;
  border-radius: 20px;
  border: 1px solid rgba(31, 28, 23, 0.2);
  box-shadow: 0 30px 60px -40px rgba(0, 0, 0, 0.5);
  display: grid;
  gap: 12px;
  padding: 18px;
  pointer-events: auto;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  cursor: move;
  user-select: none;
}

.debug-body {
  display: grid;
  gap: 12px;
}

.debug-explain {
  background: #f6efe2;
  border-radius: 12px;
  padding: 12px;
  color: var(--ink-2);
  line-height: 1.4;
}

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

.debug-actions button {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(31, 28, 23, 0.2);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(215, 108, 42, 0.15);
  color: var(--ink-2);
  font-size: 0.8rem;
}

.lang-banner {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.lang-banner h1 {
  margin: 0;
}

.lang-banner .accent {
  color: var(--accent-2);
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

footer {
  text-align: center;
  padding: 20px;
  color: var(--ink-2);
  font-size: 0.9rem;
}

@media (max-width: 720px) {
  header {
    padding: 24px 16px 8px;
  }
  main {
    padding: 0 16px;
  }
  .hero {
    padding: 12px 16px 24px;
  }
}
