:root {
  --ink: #0c1f22;
  --muted: #3f5c61;
  --paper: #f2f7f6;
  --paper-2: #e4efed;
  --teal: #08756f;
  --teal-deep: #033d3a;
  --mint: #b8e0db;
  --lime: #c6e36a;
  --amber: #d97706;
  --amber-deep: #92400e;
  --amber-light: #fef3c7;
  --bond: #0f7f78;
  --carbon: #0f2e32;
  --hydrogen: #5f9e98;
  --wrong: #b54a3c;
  --wrong-bg: #fdf0ee;
  --right: #1f7a4d;
  --right-bg: #eaf6ef;
  --radius: 8px;
  --radius-lg: 14px;
  --font-display: "Syne", sans-serif;
  --font-body: "Manrope", sans-serif;
  --font-math: "IBM Plex Sans", -apple-system, sans-serif;
  --shadow-soft: 0 16px 45px rgba(12, 31, 34, 0.07);
}

*,
*::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;
  -webkit-tap-highlight-color: transparent;
}

body.is-ordering {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing;
}

.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;
}

/* Navigation Bar */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(242, 247, 246, 0.88);
  border-bottom: 1px solid rgba(11, 122, 116, 0.12);
  padding: 0.75rem clamp(1.25rem, 4vw, 3rem);
}

.top-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
}

.nav-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--teal-deep);
  transition: color 0.18s ease, transform 0.18s ease;
}

.nav-back-link:hover {
  color: var(--teal);
  transform: translateX(-2px);
}

.nav-current {
  color: var(--muted);
  font-weight: 600;
  display: none;
}

@media (min-width: 640px) {
  .nav-current {
    display: inline;
  }
}

.nav-next-link {
  font-weight: 700;
  color: var(--teal);
  transition: color 0.18s ease;
}

.nav-next-link:hover {
  color: var(--teal-deep);
  text-decoration: underline;
}

.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(2rem, 5vh, 4rem) clamp(1.25rem, 4vw, 3rem) clamp(1.5rem, 5vh, 3rem);
  max-width: 1200px;
  margin: 0 auto;
}

.badge-topic {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--amber-light);
  color: var(--amber-deep);
  border: 1px solid rgba(217, 119, 6, 0.25);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.85rem;
}

.badge-chem-topic {
  background: #e1f4f1;
  color: #055f5a;
  border: 1px solid rgba(8, 117, 111, 0.2);
}

.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,
.hero-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  letter-spacing: -0.04em;
  line-height: 1.08;
  color: var(--teal-deep);
  animation: rise 0.8s ease 0.08s both;
}

.lede,
.hero-lede {
  margin: 0 0 1.75rem;
  max-width: 44ch;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
  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:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(35%);
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
}

.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: 1.5rem 1rem 1rem;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(255, 255, 255, 0.9), transparent 70%),
    linear-gradient(145deg, rgba(184, 224, 219, 0.45), rgba(198, 227, 106, 0.18));
  border: 1.5px solid rgba(8, 117, 111, 0.16);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  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 {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(3rem, 8vh, 5.5rem) clamp(1.25rem, 4vw, 3rem);
}

.section-head {
  max-width: 44rem;
  margin-bottom: 2.2rem;
}

.section-head h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.4vw, 2.4rem);
  letter-spacing: -0.03em;
  color: var(--teal-deep);
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.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.5rem, 3.5vw, 2.4rem);
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid rgba(8, 117, 111, 0.16);
  box-shadow: var(--shadow-soft);
  border-radius: var(--radius-lg);
  animation: stage-in 0.45s ease both;
}

.stage-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

.stage-heading 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;
}

.struct-toggle {
  flex-shrink: 0;
  min-height: 2.5rem;
  padding: 0.45rem 0.85rem;
  border: 1.5px solid rgba(16, 36, 40, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.struct-toggle:hover {
  border-color: var(--teal);
  color: var(--ink);
}

.struct-toggle[aria-pressed="true"] {
  background: rgba(11, 122, 116, 0.12);
  border-color: var(--teal);
  color: var(--teal-deep);
}

.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.04) 20%, rgba(11, 122, 116, 0.06));
}

.section.practice,
.practice-section {
  padding-top: 2rem;
}

.section.practice .section-head,
.practice-section .section-head {
  max-width: 820px;
  margin: 0 auto 2rem;
  text-align: left;
}

.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 820px;
  margin: 0 auto 1.75rem;
}

.mode-btn {
  padding: 0.65rem 1.15rem;
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px solid rgba(8, 117, 111, 0.15);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s ease;
}

.mode-btn:hover {
  background: #fff;
  border-color: var(--teal);
  color: var(--teal-deep);
}

.mode-btn.is-active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  box-shadow: 0 4px 12px rgba(8, 117, 111, 0.25);
}

.trainer,
.trainer-card {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(1.5rem, 3.5vw, 2.5rem);
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid rgba(8, 117, 111, 0.18);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.score-bar,
.trainer-score-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid rgba(8, 117, 111, 0.12);
  font-size: 0.92rem;
  color: var(--muted);
}

.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.score-badge strong {
  color: var(--teal-deep);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.streak-badge strong {
  color: #d97706;
}

.prompt-block {
  text-align: center;
  padding: clamp(1.2rem, 3vw, 2rem) 1rem;
  background: linear-gradient(145deg, #f7faf9, #eef5f3);
  border-radius: var(--radius);
  border: 1px solid rgba(8, 117, 111, 0.12);
  margin-bottom: 1.75rem;
}

.prompt-label {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.prompt-main {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--teal-deep);
  margin-bottom: 0;
  min-height: 2.4em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.prompt-main:empty {
  min-height: 0;
}

.prompt-main .mini-struct {
  width: min(100%, 300px);
  height: auto;
  margin: 0 auto;
  display: block;
}

.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.answer-btn {
  min-height: 3.2rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(16, 36, 40, 0.14);
  border-radius: var(--radius);
  background: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--teal);
  transform: translateY(-1px);
}

.answer-btn:disabled {
  cursor: default;
}

.answer-btn.is-correct {
  background: var(--right-bg);
  border-color: var(--right);
  color: var(--right);
}

.answer-btn.is-wrong {
  background: var(--wrong-bg);
  border-color: var(--wrong);
  color: var(--wrong);
}

.order-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  min-height: 3.6rem;
  padding: 0.75rem;
  border: 1.5px dashed rgba(11, 122, 116, 0.35);
  border-radius: var(--radius);
  background: rgba(11, 122, 116, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.order-board.is-drop-target,
.order-pool.is-drop-target {
  border-color: var(--teal);
  background: rgba(11, 122, 116, 0.1);
}

.order-chip,
.pool-chip {
  padding: 0.65rem 0.9rem;
  min-height: 2.6rem;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 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-chip.is-dragging,
.pool-chip.is-dragging {
  opacity: 0.35;
}

.order-chip.is-drag-over,
.pool-chip.is-drag-over {
  box-shadow: inset 0 0 0 2px var(--lime);
}

.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  background: var(--teal);
  color: #f7fffe;
  font-family: var(--font-body);
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(16, 36, 40, 0.22);
  transform: translate(-50%, -50%) scale(1.04);
  white-space: nowrap;
}

.order-pool {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.35rem;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.order-hint {
  text-align: center;
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.feedback {
  margin-top: 1.25rem;
  padding: 1.15rem 1.4rem;
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 600;
  text-align: center;
  animation: rise 0.28s ease both;
}

.feedback.is-right {
  background: var(--right-bg);
  border: 1px solid rgba(31, 122, 77, 0.28);
  color: #0e4c2e;
}

.feedback.is-wrong {
  background: var(--wrong-bg);
  border: 1px solid rgba(181, 74, 60, 0.28);
  color: #782216;
}

.next-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  min-height: 2.85rem;
  padding: 0 1.5rem;
  margin: 1.25rem auto 0;
  border-radius: var(--radius);
  font-weight: 700;
}

.next-btn[hidden] {
  display: none !important;
}

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.45rem;
  padding: 2.5rem clamp(1.25rem, 4vw, 3rem) 3rem;
  border-top: 1px solid rgba(16, 36, 40, 0.08);
  background: linear-gradient(180deg, transparent, rgba(11, 122, 116, 0.06));
}

.footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.footer-nav a {
  color: var(--teal-deep);
  transition: color 0.18s ease;
}

.footer-nav a:hover {
  color: var(--teal);
  text-decoration: underline;
}

.footer-nav span {
  color: rgba(16, 36, 40, 0.28);
}

.footer-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.visit-stats {
  margin: 0.15rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}

.visit-stats strong {
  color: var(--teal-deep);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.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: max(1.25rem, env(safe-area-inset-top));
  }

  .hero-visual {
    order: -1;
    min-height: 220px;
  }

  .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;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
  }

  .alkane-btn {
    grid-template-columns: auto;
    min-width: 4.75rem;
    min-height: 3.35rem;
    border-left: 0;
    border-bottom: 3px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    justify-items: center;
    text-align: center;
    scroll-snap-align: start;
    touch-action: manipulation;
  }

  .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));
  }

  .mode-btn {
    min-height: 2.75rem;
    flex: 1 1 auto;
    touch-action: manipulation;
  }

  .answer-btn {
    min-height: 3.15rem;
    touch-action: manipulation;
  }

  .order-chip,
  .pool-chip {
    min-height: 2.85rem;
    padding: 0.7rem 0.95rem;
  }
}

@media (max-width: 520px) {
  .answers {
    grid-template-columns: 1fr;
  }

  .section,
  .hero,
  .site-footer {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .site-footer {
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }

  .score-bar {
    font-size: 0.88rem;
    gap: 0.55rem 1rem;
  }

  .struct-toggle {
    width: 100%;
  }

  .prompt-main {
    min-height: 2.2em;
  }
}

/* ==========================================================================
   Hub Portal (Main Page) Styles
   ========================================================================== */

.portal-hero {
  text-align: center;
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(3rem, 7vh, 5.5rem) clamp(1rem, 3vw, 2rem) clamp(1.5rem, 4vh, 3rem);
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  background: rgba(8, 117, 111, 0.1);
  color: var(--teal-deep);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
  animation: rise 0.7s ease both;
}

.portal-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 5.5vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--teal-deep);
  animation: rise 0.75s ease 0.08s both;
}

.portal-subtitle {
  margin: 0 auto;
  max-width: 58ch;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--muted);
  line-height: 1.55;
  animation: rise 0.75s ease 0.16s both;
}

.portal-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem clamp(1.25rem, 4vw, 3rem) clamp(3.5rem, 7vh, 5rem);
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: clamp(1.5rem, 3vw, 2.5rem);
  margin-bottom: clamp(3.5rem, 7vh, 5rem);
}

.material-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.82);
  border: 1.5px solid rgba(8, 117, 111, 0.15);
  border-radius: 16px;
  padding: clamp(1.6rem, 3.5vw, 2.4rem);
  box-shadow: 0 16px 40px rgba(12, 31, 34, 0.06);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, border-color 0.28s ease;
  overflow: hidden;
}

.material-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--teal), var(--lime));
  opacity: 0;
  transition: opacity 0.25s ease;
}

.material-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 24px 55px rgba(8, 117, 111, 0.14);
  border-color: rgba(8, 117, 111, 0.35);
}

.material-card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}

.card-category {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
}

.badge-chem {
  background: #e1f4f1;
  color: #055f5a;
  border: 1px solid rgba(8, 117, 111, 0.2);
}

.badge-math {
  background: #fdf3d8;
  color: #8c5b05;
  border: 1px solid rgba(184, 134, 11, 0.25);
}

.card-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  color: var(--teal);
  transition: background 0.2s ease, transform 0.2s ease;
}

.material-card:hover .card-icon-wrap {
  background: var(--mint);
  transform: scale(1.06);
}

.card-title {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.8vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.15;
}

.card-desc {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  flex-grow: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.tag-pill {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--carbon);
  background: rgba(184, 224, 219, 0.4);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(8, 117, 111, 0.12);
}

.card-action {
  margin-top: auto;
}

.card-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 1.02rem;
  padding: 0.95rem 1.4rem;
  border-radius: 8px;
}

.portal-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  padding: 2.2rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  border: 1px solid rgba(8, 117, 111, 0.1);
}

.highlight-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.highlight-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--paper-2);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.highlight-text h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.highlight-text p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}

@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;
  }
}