:root {
  --ink: #0c1f22;
  --muted: #3f5c61;
  --paper: #f2f7f6;
  --paper-2: #e4efed;
  --teal: #08756f;
  --teal-deep: #033d3a;
  --mint: #b8e0db;
  --lime: #c6e36a;
  --bond: #0f7f78;
  --carbon: #0f2e32;
  --hydrogen: #5f9e98;
  --wrong: #b54a3c;
  --right: #1f7a4d;
  --radius: 4px;
  --font-display: "Syne", sans-serif;
  --font-body: "Manrope", sans-serif;
  --shadow-soft: 0 18px 50px rgba(16, 36, 40, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 90% 60% at 10% -10%, rgba(184, 224, 219, 0.9), transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 15%, rgba(198, 227, 106, 0.28), transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(11, 122, 116, 0.12), transparent 55%),
    linear-gradient(165deg, #eef6f4 0%, #f5f8f6 45%, #e8f1ef 100%);
  pointer-events: none;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%230b7a74' stroke-opacity='0.08' stroke-width='1'%3E%3Ccircle cx='8' cy='8' r='2'/%3E%3Ccircle cx='30' cy='22' r='2'/%3E%3Ccircle cx='52' cy='8' r='2'/%3E%3Cpath d='M8 8h22M30 22h22M8 8l22 14M30 22l22-14'/%3E%3C/g%3E%3C/svg%3E");
}

a {
  color: inherit;
  text-decoration: none;
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.nav a {
  color: var(--muted);
  transition: color 0.2s ease;
}

.nav a:hover {
  color: var(--teal-deep);
}

.hero {
  min-height: calc(100svh - 4rem);
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: clamp(1.25rem, 4vw, 3rem);
  align-items: center;
  padding: clamp(1rem, 3.5vh, 2.5rem) clamp(1.25rem, 4vw, 3rem) clamp(1.5rem, 5vh, 3rem);
}

.brand {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 6.2vw, 4.6rem);
  line-height: 0.92;
  letter-spacing: -0.05em;
  color: var(--teal-deep);
  animation: rise 0.8s ease both;
}

.hero h1 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.45rem, 3.2vw, 2.15rem);
  letter-spacing: -0.03em;
  max-width: 14ch;
  animation: rise 0.8s ease 0.08s both;
}

.lede {
  margin: 0 0 1.75rem;
  max-width: 34ch;
  color: var(--muted);
  font-size: 1.05rem;
  animation: rise 0.8s ease 0.16s both;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  animation: rise 0.8s ease 0.24s both;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  padding: 0 1.25rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--teal);
  color: #f7fffe;
}

.btn-primary:hover {
  background: var(--teal-deep);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(16, 36, 40, 0.18);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

.hero-visual {
  position: relative;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1rem 0.5rem 0.5rem;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(255, 255, 255, 0.85), transparent 70%),
    linear-gradient(145deg, rgba(184, 224, 219, 0.45), rgba(198, 227, 106, 0.18));
  border-radius: 12px;
  animation: fade-in 1s ease 0.2s both;
}

.chain-svg {
  width: 100%;
  height: auto;
  max-height: 360px;
}

.hero-caption {
  margin: 0.25rem 0 0;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.3s ease;
}

.hero-caption.is-updating {
  opacity: 0.35;
}

.section {
  padding: clamp(3rem, 8vh, 5.5rem) clamp(1.25rem, 4vw, 3rem);
}

.section-head {
  max-width: 38rem;
  margin-bottom: 2rem;
}

.section-head h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  letter-spacing: -0.04em;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.explore-layout {
  display: grid;
  grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.alkane-rail {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.alkane-btn {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.alkane-btn:hover {
  background: rgba(11, 122, 116, 0.08);
}

.alkane-btn.is-active {
  background: rgba(11, 122, 116, 0.12);
  border-left-color: var(--teal);
  transform: translateX(2px);
}

.alkane-btn .n {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--teal-deep);
  font-variant-numeric: tabular-nums;
}

.alkane-btn .label {
  font-weight: 600;
}

.alkane-btn .formula {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.molecule-stage {
  padding: clamp(1.25rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(16, 36, 40, 0.06);
  box-shadow: var(--shadow-soft);
  border-radius: 8px;
  animation: stage-in 0.45s ease both;
}

.stage-top h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.04em;
}

.mol-latin {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-transform: lowercase;
}

.structure-wrap {
  margin: 1.25rem 0 1.5rem;
  min-height: 220px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(184, 224, 219, 0.45), transparent 65%);
  border-radius: 6px;
}

.structure-svg {
  width: min(100%, 460px);
  height: auto;
  overflow: visible;
}

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 0 0 1.25rem;
}

.facts dt {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.facts dd {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mnemonic {
  margin: 0;
  padding: 0.9rem 1rem;
  background: rgba(198, 227, 106, 0.28);
  border-left: 3px solid var(--teal);
  border-radius: 0 6px 6px 0;
  color: var(--ink);
  font-weight: 500;
}

.practice {
  background: linear-gradient(180deg, transparent, rgba(11, 122, 116, 0.05) 20%, rgba(11, 122, 116, 0.07));
}

.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.mode-btn {
  padding: 0.65rem 1rem;
  border: 1.5px solid rgba(16, 36, 40, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.mode-btn:hover {
  color: var(--ink);
  border-color: var(--teal);
}

.mode-btn.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #f7fffe;
}

.trainer {
  max-width: 44rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(16, 36, 40, 0.06);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.score-bar {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.score-bar strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.prompt-label {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.prompt-main {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 1.5rem;
  min-height: 2.8em;
  display: flex;
  align-items: center;
}

.prompt-main:empty {
  min-height: 0;
  margin-bottom: 0.75rem;
}

.prompt-main .mini-struct {
  width: min(100%, 280px);
  height: auto;
}

.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.answer-btn {
  min-height: 3rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(16, 36, 40, 0.12);
  border-radius: var(--radius);
  background: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--teal);
  transform: translateY(-1px);
}

.answer-btn:disabled {
  cursor: default;
}

.answer-btn.is-correct {
  background: rgba(31, 122, 77, 0.12);
  border-color: var(--right);
  color: var(--right);
}

.answer-btn.is-wrong {
  background: rgba(181, 74, 60, 0.1);
  border-color: var(--wrong);
  color: var(--wrong);
}

.order-board {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  min-height: 3.2rem;
  padding: 0.75rem;
  border: 1.5px dashed rgba(11, 122, 116, 0.35);
  border-radius: 6px;
  background: rgba(11, 122, 116, 0.04);
}

.order-chip,
.pool-chip {
  padding: 0.55rem 0.85rem;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.order-chip {
  background: var(--teal);
  color: #f7fffe;
}

.pool-chip {
  background: #fff;
  border: 1.5px solid rgba(16, 36, 40, 0.12);
}

.pool-chip:hover,
.order-chip:hover {
  transform: translateY(-1px);
}

.order-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.feedback {
  margin: 1rem 0 0;
  font-weight: 600;
}

.feedback.is-right {
  color: var(--right);
}

.feedback.is-wrong {
  color: var(--wrong);
}

.next-btn {
  margin-top: 1.25rem;
}

.next-btn[hidden] {
  display: none !important;
}

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 2rem clamp(1.25rem, 4vw, 3rem) 2.75rem;
  border-top: 1px solid rgba(16, 36, 40, 0.08);
  background: linear-gradient(180deg, transparent, rgba(11, 122, 116, 0.07));
}

.footer-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.made-by {
  margin: 0;
  font-family: "IBM Plex Sans", var(--font-body), sans-serif;
  font-weight: 600;
  font-size: clamp(0.92rem, 1.6vw, 1.05rem);
  letter-spacing: 0.01em;
  color: var(--ink);
  line-height: 1.35;
}

.made-name {
  color: var(--teal-deep);
}

.made-handle {
  color: var(--teal);
  text-decoration: none;
  border-bottom: 2px solid rgba(8, 117, 111, 0.35);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.made-handle:hover {
  color: var(--teal-deep);
  border-bottom-color: var(--teal-deep);
}

.made-cursor {
  color: var(--teal-deep);
}

.atom-c {
  fill: var(--carbon);
}

.atom-h {
  fill: var(--hydrogen);
}

.bond-line,
.struct-bond {
  fill: none;
  stroke: #0f7f78;
  stroke-width: 4;
  stroke-linecap: round;
}

.chain-svg {
  overflow: visible;
}

.atom-label {
  fill: #f4fffd;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.atom-label-h {
  fill: #102428;
  font-size: 10px;
}

.chain-node {
  opacity: 1;
  transform-origin: center;
  animation: pop-in 0.45s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes stage-in {
  from {
    opacity: 0.4;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 2rem;
  }

  .hero-visual {
    order: -1;
    min-height: 240px;
  }

  .brand {
    font-size: clamp(2.4rem, 12vw, 3.6rem);
  }

  .explore-layout {
    grid-template-columns: 1fr;
  }

  .alkane-rail {
    flex-direction: row;
    overflow-x: auto;
    gap: 0.4rem;
    padding-bottom: 0.35rem;
    scrollbar-width: thin;
  }

  .alkane-btn {
    grid-template-columns: auto;
    min-width: 5.5rem;
    border-left: 0;
    border-bottom: 3px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    justify-items: center;
    text-align: center;
  }

  .alkane-btn .formula {
    display: none;
  }

  .alkane-btn.is-active {
    transform: none;
    border-bottom-color: var(--teal);
  }

  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .answers {
    grid-template-columns: 1fr;
  }

  .nav {
    gap: 1rem;
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}