:root {
  --ink: #1d1646;
  --paper: #fff8f1;
  --pink: #ff4fa3;
  --pink-light: #ff91c8;
  --yellow: #ffd84d;
  --blue: #60d7ff;
  --purple: #9c65ff;
  --orange: #ff8359;
  --mint: #55e2bb;
  --border: 3px solid var(--ink);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 16%, rgb(255 79 163 / 9%) 0 7%, transparent 7.2%),
    radial-gradient(circle at 90% 44%, rgb(96 215 255 / 11%) 0 8%, transparent 8.2%),
    var(--paper);
  color: var(--ink);
  font-family: "Avenir Next Rounded", "Arial Rounded MT Bold", "Avenir Next", system-ui, sans-serif;
}

button, a { font: inherit; }
button { color: inherit; }

button:focus-visible, a:focus-visible {
  outline: 4px solid #fff;
  box-shadow: 0 0 0 7px var(--ink);
}

.topbar {
  align-items: center;
  border-bottom: var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px clamp(20px, 5vw, 76px);
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-size: 1.15rem;
  font-weight: 900;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--pink);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  color: #fff;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  transform: rotate(-7deg);
  width: 40px;
}

.source-pill {
  align-items: center;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  display: inline-flex;
  font-size: .74rem;
  font-weight: 800;
  gap: 8px;
  letter-spacing: .03em;
  padding: 8px 12px;
  text-transform: uppercase;
}

.source-dot {
  background: var(--mint);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  height: 10px;
  width: 10px;
}

.install-button {
  align-items: center;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-size: .78rem;
  font-weight: 900;
  gap: 7px;
  padding: 9px 14px;
}

.install-button:hover {
  background: var(--mint);
  transform: translate(-1px, -1px);
}

.install-button span {
  font-size: 1.15rem;
  line-height: .7;
}

.step-label, .modal-kicker {
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .12em;
  margin: 0 0 13px;
  text-transform: uppercase;
}

.bubble-face::after {
  background: rgb(255 255 255 / 72%);
  border-radius: 50%;
  content: "";
  height: 15%;
  left: 23%;
  position: absolute;
  top: 18%;
  transform: rotate(-24deg);
  width: 27%;
}

.playground {
  background: #fff;
  border-bottom: var(--border);
  padding: 38px clamp(22px, 5vw, 76px) 72px;
}

.section-heading {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin: 0 auto 28px;
  max-width: 1180px;
}

.section-heading h2 {
  font-size: clamp(2rem, 4vw, 3.65rem);
  letter-spacing: -.055em;
  line-height: 1;
  margin: 0;
}

.section-heading h1 {
  font-size: clamp(2rem, 4vw, 3.65rem);
  letter-spacing: -.055em;
  line-height: 1;
  margin: 0;
}

[hidden] { display: none !important; }

.step-label { color: #694ec6; }

.bubble-cloud {
  background:
    linear-gradient(90deg, rgb(29 22 70 / 5%) 1px, transparent 1px),
    linear-gradient(rgb(29 22 70 / 5%) 1px, transparent 1px),
    #fff8fd;
  background-size: 28px 28px;
  border: var(--border);
  border-radius: 40px;
  height: clamp(500px, 58vh, 650px);
  margin: 0 auto;
  max-width: 1180px;
  overflow: hidden;
  position: relative;
}

.cloud-scribble {
  font-size: 2rem;
  opacity: .55;
  position: absolute;
}
.cloud-scribble-one { left: 3%; top: 8%; transform: rotate(-12deg); }
.cloud-scribble-two { bottom: 9%; right: 4%; transform: rotate(15deg); }

.load-error {
  font-weight: 800;
  left: 50%;
  margin: 0;
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 80%);
}

.word-bubble {
  background: transparent;
  border: 0;
  cursor: pointer;
  height: var(--bubble-size);
  left: 0;
  opacity: 0;
  padding: 0;
  position: absolute;
  top: 0;
  transition: opacity .18s ease;
  will-change: transform;
  width: var(--bubble-size);
  z-index: 1;
}

.word-bubble[data-ready="true"] { opacity: 1; }

.bubble-face {
  align-items: center;
  background: var(--pink);
  border: var(--border);
  border-radius: 50%;
  box-shadow: 5px 7px 0 var(--ink);
  display: flex;
  font-size: var(--word-size);
  font-weight: 950;
  height: 100%;
  justify-content: center;
  letter-spacing: -.045em;
  padding: 18px 12px;
  position: relative;
  transform: rotate(var(--bubble-rotate));
  transition: filter .2s ease, box-shadow .2s ease, transform .2s ease;
  width: 100%;
}

.bubble-word {
  line-height: 1;
  max-width: 100%;
  position: relative;
  white-space: nowrap;
  z-index: 1;
}

.word-bubble:hover .bubble-face { box-shadow: 8px 10px 0 var(--ink); filter: saturate(1.2); transform: rotate(var(--bubble-rotate)) scale(1.04); }
.word-bubble.color-0 .bubble-face { background: var(--pink); color: #fff; }
.word-bubble.color-1 .bubble-face { background: var(--yellow); }
.word-bubble.color-2 .bubble-face { background: var(--blue); }
.word-bubble.color-3 .bubble-face { background: var(--purple); color: #fff; }
.word-bubble.color-4 .bubble-face { background: var(--orange); }
.word-bubble.color-5 .bubble-face { background: var(--mint); }
.word-bubble.is-popping .bubble-face { animation: pop .24s ease-in forwards; }
.word-bubble.is-new .bubble-face { animation: arrive .58s cubic-bezier(.18,.89,.32,1.5); }

.sentence-stage {
  background: var(--ink);
  border: var(--border);
  border-radius: 30px;
  color: #fff;
  margin: 22px auto 0;
  max-width: 1180px;
  min-height: 170px;
  padding: clamp(25px, 4vw, 48px);
  position: relative;
}

.sentence-stage.has-discovery { background: #f2eaff; color: var(--ink); }
.sentence-label { align-items: center; display: flex; font-size: .8rem; font-weight: 800; gap: 9px; letter-spacing: .03em; text-transform: uppercase; }
.pop-spark { align-items: center; background: var(--yellow); border: 2px solid var(--ink); border-radius: 50%; display: inline-flex; height: 30px; justify-content: center; width: 30px; }
.sentence-stage blockquote { font-family: Georgia, serif; font-size: clamp(1.45rem, 3vw, 2.55rem); font-weight: 600; letter-spacing: -.035em; line-height: 1.2; margin: 24px 0 22px; max-width: 1040px; }
.article-origin { background: transparent; border: 0; border-bottom: 2px solid currentColor; cursor: pointer; padding: 0 0 3px; }
.article-origin:hover { color: #694ec6; }
.next-hint { background: var(--yellow); border: 2px solid var(--ink); border-radius: 999px; display: table; font-size: .74rem; font-weight: 900; margin: 28px 0 0; padding: 7px 12px; }
.empty-discovery { align-items: center; display: flex; gap: 22px; margin: auto; max-width: 660px; min-height: 70px; }
.empty-icon { align-items: center; background: var(--pink); border: 2px solid #fff; border-radius: 50%; display: flex; flex: 0 0 64px; font-size: 1.9rem; height: 64px; justify-content: center; }
.empty-discovery strong { font-size: 1.3rem; }
.empty-discovery p { color: #ded8f7; font-family: "Avenir Next", system-ui, sans-serif; line-height: 1.45; margin: 5px 0 0; }

.article-section {
  margin: 0 auto;
  max-width: 1320px;
  padding: 72px clamp(22px, 5vw, 76px) 86px;
}

.article-heading { margin-bottom: 34px; }
.related-word { color: #7448df; }
.shuffle-button { align-items: center; background: #fff; border: 2px solid var(--ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; display: flex; font-size: .86rem; font-weight: 900; gap: 7px; padding: 10px 16px; }
.shuffle-button:hover { background: var(--yellow); transform: translate(-1px, -1px); }
.shuffle-button span { font-size: 1.25rem; line-height: .7; }

.article-grid { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.article-card { background: var(--yellow); border: var(--border); border-radius: 24px; box-shadow: 7px 8px 0 var(--ink); cursor: pointer; display: flex; min-height: 365px; padding: 26px; text-align: left; flex-direction: column; transition: transform .18s ease, box-shadow .18s ease; }
.article-card:hover { box-shadow: 11px 12px 0 var(--ink); transform: translate(-3px, -4px) rotate(-.4deg); }
.article-card.card-1 { background: var(--blue); transform: rotate(1deg); }
.article-card.card-1:hover { transform: translate(-3px, -4px) rotate(.4deg); }
.article-card.card-2 { background: var(--pink-light); transform: rotate(-1deg); }
.article-card.card-2:hover { transform: translate(-3px, -4px) rotate(-1.4deg); }
.article-number { align-items: center; background: var(--ink); border-radius: 50%; color: #fff; display: flex; font-weight: 900; height: 42px; justify-content: center; margin-bottom: 26px; width: 42px; }
.article-category { font-size: .68rem; font-weight: 950; letter-spacing: .1em; margin-bottom: 9px; text-transform: uppercase; }
.article-card strong { font-size: clamp(1.35rem, 2.2vw, 2rem); letter-spacing: -.04em; line-height: 1.05; }
.article-preview { display: -webkit-box; font-family: "Avenir Next", system-ui, sans-serif; font-size: .92rem; line-height: 1.5; margin: 16px 0 28px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.open-label { border-top: 2px solid var(--ink); font-size: .8rem; font-weight: 900; margin-top: auto; padding-top: 16px; }

footer { align-items: center; background: var(--ink); color: #fff; display: flex; font-size: .75rem; font-weight: 700; justify-content: space-between; min-height: 86px; padding: 20px clamp(22px, 5vw, 76px); }

.modal-backdrop { align-items: center; background: rgb(29 22 70 / 75%); display: flex; inset: 0; justify-content: center; padding: 20px; position: fixed; z-index: 50; }
.article-modal { background: var(--paper); border: var(--border); border-radius: 30px; box-shadow: 12px 14px 0 var(--pink); max-height: min(780px, 88vh); max-width: 760px; overflow: auto; padding: clamp(28px, 5vw, 55px); position: relative; width: 100%; }
.article-modal h2 { font-size: clamp(2.1rem, 5vw, 4rem); letter-spacing: -.06em; line-height: .95; margin: 0 55px 28px 0; }
.modal-kicker { color: #694ec6; }
.modal-copy { font-family: Georgia, serif; font-size: 1.08rem; line-height: 1.68; }
.modal-close { align-items: center; background: var(--yellow); border: 2px solid var(--ink); border-radius: 50%; cursor: pointer; display: flex; font-size: 1.8rem; height: 44px; justify-content: center; line-height: 1; position: absolute; right: 20px; top: 20px; width: 44px; }
.wikipedia-link { background: var(--pink); border: 2px solid var(--ink); border-radius: 999px; color: #fff; display: inline-block; font-size: .86rem; font-weight: 900; margin-top: 22px; padding: 12px 18px; text-decoration: none; }

.install-modal { box-shadow: 12px 14px 0 var(--blue); max-width: 680px; }
.install-modal h2 { max-width: 500px; }
.install-intro { font-family: "Avenir Next", system-ui, sans-serif; font-size: 1rem; line-height: 1.55; margin: -4px 0 24px; }
.install-steps { display: grid; gap: 12px; list-style: none; margin: 0; padding: 0; }
.install-steps li { align-items: center; background: #fff; border: 2px solid var(--ink); border-radius: 18px; display: grid; gap: 2px 14px; grid-template-columns: 44px 1fr; padding: 13px 16px; }
.install-steps li > span { align-items: center; background: var(--yellow); border: 2px solid var(--ink); border-radius: 50%; display: flex; font-weight: 950; grid-row: 1 / span 2; height: 42px; justify-content: center; width: 42px; }
.install-steps strong { font-size: 1rem; }
.install-steps small { color: #5f587c; font-family: "Avenir Next", system-ui, sans-serif; font-size: .8rem; line-height: 1.35; }

@keyframes pop {
  0% { opacity: 1; transform: scale(1) rotate(var(--bubble-rotate)); }
  55% { opacity: 1; transform: scale(1.2) rotate(var(--bubble-rotate)); }
  100% { opacity: 0; transform: scale(.05) rotate(18deg); }
}

@keyframes arrive {
  0% { opacity: 0; transform: scale(.1) translateY(80px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 860px) {
  .article-grid { grid-template-columns: 1fr; }
  .article-card { min-height: 300px; transform: none !important; }
  .bubble-cloud { height: 560px; }
}

@media (max-width: 560px) {
  .topbar { padding-inline: 16px; }
  .source-pill { display: none; }
  .install-button { padding: 9px 12px; }
  .source-dot { height: 12px; width: 12px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 18px; }
  .article-heading { align-items: flex-start; }
  .bubble-cloud { border-radius: 26px; height: 620px; }
  .sentence-stage { border-radius: 24px; }
  .sentence-stage blockquote { font-size: 1.35rem; }
  footer { align-items: flex-start; flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .bubble-face { animation: none !important; }
}
