/* Title and button font: Fredoka; body text: Nunito. Both are under the SIL
   Open Font License (public/fonts/*-OFL.txt) and kept here rather than loaded
   from Google Fonts, so the page doesn't wait on, or tell, another site. */
@font-face {
  font-family: Fredoka;
  font-weight: 700;
  font-display: swap;
  src: url(./fonts/fredoka-700.woff2) format('woff2');
}

@font-face {
  font-family: Nunito;
  font-weight: 700;
  font-display: swap;
  src: url(./fonts/nunito-700.woff2) format('woff2');
}

:root {
  --sky: #bfe6ff;
  --ink: #1b2a4a;
  --sun: #ffd23f;
  --yellow: #ffc93c;
  --yellow-shadow: #c98f00;
  --cloud-shadow: #8fb8d6;
}

* {
  box-sizing: border-box;
}

/* Anything the game hides stays hidden, whatever its display style. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
  background: var(--sky);
  color: var(--ink);
  font-family: Nunito, system-ui, sans-serif;
  font-weight: 700;
  display: flex;
  flex-direction: column;
}

/* ---- Sky ---- */

.sun {
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 24px rgb(255 210 63 / 0.35);
}

/* A cloud is a long rounded bar with a bump on top (::before). */
.cloud {
  position: absolute;
  height: 64px;
  border-radius: 999px;
  background: #fff;
}

.cloud::before {
  content: '';
  position: absolute;
  left: 30%;
  bottom: 20px;
  width: 48%;
  height: 80px;
  border-radius: 999px;
  background: #fff;
}

.cloud-left {
  top: 7vh;
  left: 6vw;
  width: 200px;
}

.cloud-right {
  top: 16vh;
  right: 10vw;
  width: 240px;
}

/* ---- Title screen ---- */

.title-screen {
  position: relative; /* above the clouds */
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 1rem;
  text-align: center;
}

.rainbow {
  width: min(640px, 90vw);
  height: auto;
}

/* The stripes rise in one at a time, outside to inside. */
.stripe {
  animation: rise 0.5s ease-out both;
}
.stripe:nth-child(2) { animation-delay: 0.12s; }
.stripe:nth-child(3) { animation-delay: 0.24s; }
.stripe:nth-child(4) { animation-delay: 0.36s; }
.stripe:nth-child(5) { animation-delay: 0.48s; }
.stripe:nth-child(6) { animation-delay: 0.6s; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stripe {
    animation: none;
  }
}

.logo {
  margin: -1rem 0 0; /* tucked up a little toward the rainbow, with a small gap */
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(3rem, 9vw, 6rem);
  line-height: 1;
}

.tagline {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  text-wrap: balance; /* on phones, two even lines rather than one word alone */
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.75rem;
}

/* Big, chunky buttons with a solid drop shadow that squishes when pressed. */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 84px;
  padding: 0 2.5rem;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 700;
  text-decoration: none; /* some buttons are links */
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.button:active {
  transform: translateY(6px);
}

.button:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
}

.button-play {
  padding: 0 3.5rem;
  background: var(--yellow);
  box-shadow: 0 8px 0 var(--yellow-shadow);
  font-size: 2.5rem;
}

.button-play:active {
  box-shadow: 0 2px 0 var(--yellow-shadow);
}

.button-play svg {
  width: 34px;
  height: 34px;
  fill: currentColor;
}

/* The white button, for the second choice: Play again next to More levels. */
.button-secondary {
  background: #fff;
  box-shadow: 0 8px 0 var(--cloud-shadow);
  font-size: 2rem;
}

.button-secondary:active {
  box-shadow: 0 2px 0 var(--cloud-shadow);
}

/* ---- Inner pages (Pick a level) ---- */

.page {
  padding: 2rem clamp(1rem, 5vw, 4rem) 0;
  overflow: auto;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.page-title {
  margin: 0;
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  line-height: 1;
}

/* A round white button with an icon, like Back. */
.round-button {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 0 var(--cloud-shadow);
  color: var(--ink);
}

.round-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--cloud-shadow);
}

.round-button:focus-visible,
.level-card:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
}

.round-button svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* One to four columns, by screen width. levels-page.js reads --cols and
   fits as many rows as the screen has room for. */
.level-grid {
  --cols: 1;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 1rem;
  align-content: start;
}

@media (min-width: 600px) {
  .level-grid {
    --cols: 2;
    gap: 2rem;
  }
}

@media (min-width: 900px) {
  .level-grid {
    --cols: 3;
  }
}

@media (min-width: 1200px) {
  .level-grid {
    --cols: 4;
  }
}

/* Once levels-page.js has measured the screen, a page has --rows rows,
   each --row tall, so the cards fill the room there is. A last page with
   fewer cards keeps its empty rows, so the buttons below don't move. */
.level-grid[style*='--row'] {
  flex: 0 0 auto;
  grid-template-rows: repeat(var(--rows), var(--row));
}

.level-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 220px;
  padding: 2rem;
  border: 0;
  border-radius: 32px;
  background: #fff;
  box-shadow: 0 8px 0 var(--cloud-shadow);
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none; /* built levels' cards are links */
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.level-card:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--cloud-shadow);
}

.level-top {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.level-number {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--level-color);
  color: #fff;
  font-family: Fredoka, system-ui, sans-serif;
  font-size: 2.5rem;
}

.level-name {
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  line-height: 1.1;
}

.level-hint {
  font-size: 1.5rem;
}

.level-picture {
  width: 118px;
  height: 75px;
}

/* On phones each card is one short row: number, name and hint, picture.
   Four fit on a small screen. */
@media (max-width: 599px) {
  .level-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      'number name picture'
      'number hint picture';
    align-items: center;
    gap: 0.1rem 0.75rem;
    min-height: 0;
    padding: 0.75rem 1rem;
    border-radius: 24px;
  }

  .level-top {
    display: contents;
  }

  .level-number {
    grid-area: number;
    width: 48px;
    height: 48px;
    font-size: 1.75rem;
  }

  .level-name {
    grid-area: name;
    align-self: end;
    font-size: 1.35rem;
  }

  .level-hint {
    grid-area: hint;
    align-self: start;
    font-size: 1rem;
  }

  .level-picture {
    grid-area: picture;
    width: 64px;
    height: 41px;
  }
}

/* On bigger screens a card is two short rows: number and name, then the
   hint and picture. Short enough for two rows of four on a laptop. */
@media (min-width: 600px) {
  .level-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      'number name name'
      'hint hint picture';
    align-items: center;
    align-content: center;
    gap: 0.5rem 1rem;
    min-height: 0;
    padding: 1rem 1.25rem;
    border-radius: 28px;
  }

  .level-top {
    display: contents;
  }

  .level-number {
    grid-area: number;
    width: 60px;
    height: 60px;
    font-size: 2.1rem;
  }

  .level-name {
    grid-area: name;
    font-size: clamp(1.4rem, 1.8vw, 1.8rem);
  }

  .level-hint {
    grid-area: hint;
    font-size: 1.15rem;
  }

  .level-picture {
    grid-area: picture;
    width: 80px;
    height: 51px;
  }
}

/* Bigger cards, when the rows have room for them (levels-page.js sets
   data-roomy): number and name on top, a big picture of the level in the
   middle, and the hint underneath. */
@media (min-width: 600px) {
  .level-grid[data-roomy] .level-card {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 1.5rem 1.75rem;
    border-radius: 32px;
    text-align: center;
  }

  .level-grid[data-roomy] .level-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: left;
  }

  .level-grid[data-roomy] .level-number {
    width: 72px;
    height: 72px;
    font-size: 2.5rem;
  }

  .level-grid[data-roomy] .level-name {
    font-size: clamp(1.75rem, 2.2vw, 2.4rem);
  }

  .level-grid[data-roomy] .level-picture {
    flex: 1 1 0;
    align-self: center;
    width: 100%;
    max-width: min(85%, 440px);
    height: auto;
    min-height: 0;
  }

  .level-grid[data-roomy] .level-hint {
    font-size: clamp(1.15rem, 1.4vw, 1.45rem);
  }
}

/* Back and More levels, under the level cards: outlined pills. */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 0 0.5rem;
}

.pager-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 60px;
  padding: 0 1.75rem;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: Fredoka, system-ui, sans-serif;
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}

.pager-button:hover {
  background: #e8f6ff;
}

.pager-button:active {
  transform: translateY(2px);
}

.pager-button:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 3px;
}

/* On phones and short screens, less room around the header and the page
   arrows leaves more for the cards. */
@media (max-width: 599px), (max-height: 760px) {
  .level-picker {
    padding-top: 1rem;
  }

  .level-picker .page-header {
    margin-bottom: 1rem;
  }

  .pager {
    padding: 0.75rem 0 0;
  }

  .pager-button {
    min-height: 52px;
    padding: 0 1.25rem;
    font-size: 1.2rem;
  }
}

/* Swiping sideways on the cards turns the page, so leave that to us. */
.level-grid {
  touch-action: pan-y;
}

/* ---- Level pages (shared by every level) ---- */

/* The shared page pieces from game/components.js (<level-header>,
   <helper-bubble>, ...) are just wrappers: lay out what they hold as if
   they weren't there. */
level-header,
helper-bubble,
level-done,
rainbow-stripes,
level-picture {
  display: contents;
}

.level-page {
  padding-bottom: 0;
}

.level-page .page-header {
  margin-bottom: 1rem;
}

.level-title {
  margin: 0;
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 3.5vw, 2rem);
}

.header-end {
  margin-left: auto;
  border: 0;
  cursor: pointer;
}

.build {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

button.round-button {
  border: 0;
  cursor: pointer;
}

.progress-pill {
  margin: 0 0 0 auto;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  background: #fff;
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  white-space: nowrap;
}

/* On phones, the question counter moves under the level name. */
@media (max-width: 600px) {
  .progress-pill {
    order: 3;
    margin: -0.5rem 0 0 calc(68px + 1.5rem);
  }

  .level-page .page-header {
    flex-wrap: wrap;
  }

  .level-page .level-title {
    flex: 1 1 calc(100% - 68px * 2 - 1.5rem * 2 - 1px);
  }
}

@keyframes pop {
  50% {
    transform: scale(1.04);
  }
}

.helper {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  max-width: 100%; /* hugs the words, so no empty space at the end */
  padding: 0.75rem 1.75rem 0.75rem 1rem;
  border-radius: 28px;
  background: #fff;
}

.helper-face {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--sun);
}

.helper-face svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.helper-face circle {
  fill: var(--ink);
}

.helper-text {
  margin: 0;
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.15;
}

.tray {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  width: min(1080px, 100%);
}

@media (max-width: 760px) {
  .tray {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 132px;
  padding: 0.5rem;
  border: 0;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 7px 0 var(--cloud-shadow);
  color: var(--ink);
  font-family: Fredoka, system-ui, sans-serif;
  font-size: 1.6rem;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}

.swatch:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--cloud-shadow);
}

.swatch:disabled {
  opacity: 0.3;
  cursor: default;
}

.swatch-dot {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.swatch.is-wrong {
  animation: wiggle 0.4s;
}

@keyframes wiggle {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.swatch:focus-visible,
.header-end:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
}

.level-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.level-done h2 {
  margin: 0;
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  line-height: 1;
  outline: none;
}

.fun-fact {
  margin: 0;
  max-width: 34ch;
  font-size: 1.4rem;
}

.level-done .button {
  font-size: 2rem;
}

/* On a phone, Play again and More levels sit side by side, a bit smaller,
   so More levels isn't pushed off the bottom of the screen. */
@media (max-width: 600px) {
  .level-done {
    gap: 0.75rem;
  }

  .fun-fact {
    font-size: 1.15rem;
  }

  .level-done .buttons {
    flex-wrap: nowrap;
    gap: 0.75rem;
    width: 100%;
    max-width: 420px;
  }

  .level-done .button {
    flex: 1 1 0;
    justify-content: center;
    min-height: 64px;
    padding: 0 0.75rem;
    font-size: clamp(1.15rem, 5.5vw, 1.5rem);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .swatch.is-wrong {
    animation: none;
  }
}

/* ---- Color order ---- */

.build-rainbow {
  width: min(700px, 100%);
  height: auto;
}

/* An empty stripe is a dashed outline; the one that goes next is darker. */
.build-stripe {
  stroke: #7fa9cc;
  stroke-width: 3;
  stroke-dasharray: 10 8;
  fill-opacity: 0.55;
  transition: fill 0.3s, fill-opacity 0.3s;
}

.build-stripe.is-next {
  stroke: var(--ink);
}

.build-stripe.is-filled {
  stroke: none;
  fill-opacity: 1;
  animation: pop 0.35s ease-out;
  transform-box: fill-box;
  transform-origin: center bottom;
}

@media (prefers-reduced-motion: reduce) {
  .build-stripe.is-filled {
    animation: none;
  }
}

/* ---- Memory rainbow ---- */

/* Twelve cards in four columns, on phones too, so they all fit at once. */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.5rem, 2vw, 1.1rem);
  width: min(620px, 100%);
}

.memory-rainbow {
  width: min(480px, 100%);
  height: auto;
}

/* Each card is a button; the page sets --card-color to its color. Its
   inside turns over to show the face when the card is .is-up. */
.memory-card {
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(0.85rem, 3.6vw, 1.4rem);
  cursor: pointer;
  perspective: 600px;
}

.card-inner {
  position: relative;
  display: block;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s;
}

.memory-card.is-up .card-inner {
  transform: rotateY(180deg);
}

.card-back,
.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  border-radius: clamp(12px, 3vw, 22px);
  box-shadow: 0 6px 0 var(--cloud-shadow);
  backface-visibility: hidden;
}

/* The back: pale sky with a little rainbow on two clouds. It shows every
   color, so it can't be mistaken for a face-up card. */
.card-back {
  background: linear-gradient(#e8f6ff, #cdeaff);
  border: 4px solid #ffffff;
}

.card-back svg {
  width: 96%;
  height: auto;
}

.card-face {
  background: #ffffff;
  transform: rotateY(180deg);
}

.card-dot {
  width: 56%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--card-color);
}

/* A found pair gets an outline in its color. */
.memory-card.is-matched {
  cursor: default;
  animation: pop 0.35s ease-out 0.3s;
}

.memory-card.is-matched .card-face {
  box-shadow: inset 0 0 0 5px var(--card-color), 0 6px 0 var(--cloud-shadow);
}

.memory-card.is-wrong {
  animation: wiggle 0.4s;
}

.memory-card:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
  border-radius: 22px;
}

@media (prefers-reduced-motion: reduce) {
  .card-inner {
    transition: none;
  }

  .memory-card.is-wrong,
  .memory-card.is-matched {
    animation: none;
  }
}

/* ---- Color sort ---- */

/* The thing to sort, big enough to grab. It follows the finger while
   dragged, and pops in when it's new. */
.sort-stage {
  display: flex;
  justify-content: center;
}

.sort-thing {
  width: clamp(120px, 30vw, 180px);
  aspect-ratio: 1;
  cursor: grab;
  touch-action: none; /* dragging it doesn't scroll the page */
  user-select: none;
}

.sort-thing svg {
  display: block;
  width: 100%;
  height: 100%;
  animation: pop-in 0.35s ease-out;
}

.sort-thing.is-dragging {
  position: relative;
  z-index: 2;
  cursor: grabbing;
}

.sort-thing.is-dragging svg {
  transform: scale(1.1);
  filter: drop-shadow(0 8px 6px rgb(27 42 74 / 0.25));
}

.sort-thing.is-wrong {
  animation: wiggle 0.4s;
}

@keyframes pop-in {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

/* Six baskets in a row; three and three on phones. */
.baskets {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  width: min(1080px, 100%);
}

@media (max-width: 760px) {
  .baskets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.basket {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.5rem 0.75rem;
  border: 4px solid transparent;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 7px 0 var(--cloud-shadow);
  color: var(--ink);
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.basket-picture {
  width: min(96px, 80%);
}

.basket-picture svg {
  display: block;
  width: 100%;
  height: auto;
}

.basket-thing {
  animation: pop-in 0.35s ease-out;
  transform-box: fill-box;
  transform-origin: center bottom;
}

/* The basket a thing is being dragged over, or pressed. */
.basket.is-over,
.basket:active:not(:disabled) {
  border-color: var(--ink);
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--cloud-shadow);
}

.basket:disabled {
  cursor: default;
}

.basket.is-wrong {
  animation: wiggle 0.4s;
}

.basket:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .sort-thing svg,
  .sort-thing.is-wrong,
  .basket-thing,
  .basket.is-wrong {
    animation: none;
  }
}

/* ---- Mix a color ---- */

.mix {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.5rem, 3vw, 2.25rem);
  width: 100%;
  margin: clamp(0.5rem, 3vh, 2.5rem) 0;
}

.blob-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* Paint blobs: a little lumpy, not perfect circles. */
.blob {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(80px, 17vw, 200px);
  aspect-ratio: 1;
  border-radius: 50%;
}

.blob-left {
  border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%;
}

.blob-right {
  border-radius: 52% 48% 45% 55% / 48% 55% 45% 52%;
}

.blob-mystery .blob {
  border: 5px dashed var(--ink);
  background: rgb(255 255 255 / 0.6);
  transition: background 0.3s;
}

.blob-mystery.is-solved .blob {
  border-color: transparent;
  border-radius: 50% 50% 46% 54% / 52% 48% 52% 48%;
  animation: pop 0.35s ease-out;
}

.blob-mark {
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 1;
}

.blob-name {
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(1.25rem, 3vw, 2.1rem);
}

.mix-sign {
  flex-shrink: 0;
  width: clamp(32px, 5vw, 64px);
  height: clamp(32px, 5vw, 64px);
  fill: none;
  stroke: var(--ink);
  stroke-width: 3.2;
  stroke-linecap: round;
}

.tray-3,
.tray.tray-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr)); /* 3 across on phones too */
  width: min(760px, 100%);
}

#next svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

@media (prefers-reduced-motion: reduce) {
  .blob-mystery.is-solved .blob {
    animation: none;
  }
}

/* ---- Sun and rain ---- */

.sky-scene {
  width: min(760px, 100%);
  height: auto;
}

/* Cloudy grey until the sun comes out. */
.sky {
  fill: #d3dde7;
  transition: fill 0.4s;
}

.has-sun:not(.has-clouds) .sky {
  fill: #e8f6ff;
}

.sky-ground {
  fill: #7cc59a;
}

.sky-cloud {
  fill: #9aa8b8;
  transition: fill 0.4s;
}

.has-sun:not(.has-rain):not(.has-snow):not(.has-clouds) .sky-cloud {
  fill: #ffffff;
}

/* Sun, rain, snow, wind and the rainbow are drawn but invisible until
   turned on. */
.sky-sun,
.sky-rain,
.sky-snow,
.sky-clouds,
.sky-wind,
.sky-rainbow {
  opacity: 0;
  transition: opacity 0.4s, transform 0.4s;
}

.sky-sun {
  transform: translateY(40px);
}

.sky-clouds {
  fill: #8492a3;
  transform: translateX(-60px);
}

.has-clouds .sky-clouds {
  opacity: 1;
  transform: none;
}

.sky-sun circle {
  fill: var(--sun);
}

.sun-rays {
  stroke: #f2b705;
  stroke-width: 7;
  stroke-linecap: round;
}

.sky-rain {
  stroke: #277da1;
  stroke-width: 5;
  stroke-linecap: round;
}

.sky-snow {
  fill: #ffffff;
  stroke: #7fa9cc;
  stroke-width: 2;
}

.has-sun .sky-sun {
  opacity: 1;
  transform: none;
}

.has-rain .sky-rain,
.has-snow .sky-snow {
  opacity: 1;
  animation: fall 0.9s linear infinite;
}

.has-snow .sky-snow {
  animation-duration: 2.4s;
}

@keyframes fall {
  from { transform: translateY(-12px); }
  to { transform: translateY(12px); }
}

/* Wind: gusts whoosh across, and the rain and snow blow sideways. */
.sky-wind {
  fill: none;
  stroke: #ffffff;
  stroke-width: 7;
  stroke-linecap: round;
}

.has-wind .sky-wind {
  opacity: 0.9;
  animation: gust 1.6s ease-in-out infinite alternate;
}

.has-wind.has-rain .sky-rain,
.has-wind.has-snow .sky-snow {
  animation-name: blow;
}

@keyframes gust {
  from { transform: translateX(-24px); }
  to { transform: translateX(24px); }
}

@keyframes blow {
  from { transform: translate(18px, -12px); }
  to { transform: translate(-18px, 12px); }
}

.has-rainbow .sky-rainbow {
  opacity: 1;
  transition-duration: 1.2s;
}

@media (prefers-reduced-motion: reduce) {
  .has-rain .sky-rain,
  .has-snow .sky-snow,
  .has-wind .sky-wind {
    animation: none;
  }
}

.weather-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  width: min(900px, 100%);
}

@media (max-width: 600px) {
  .weather-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.weather-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 132px;
  padding: 0.5rem;
  border: 4px solid transparent;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 7px 0 var(--cloud-shadow);
  color: var(--ink);
  font-family: Fredoka, system-ui, sans-serif;
  font-size: 1.6rem;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, background 0.2s;
}

.weather-toggle svg {
  width: 64px;
  height: 64px;
}

/* A weather that's on looks pressed in, with a dark outline. */
.weather-toggle[aria-pressed='true'] {
  border-color: var(--ink);
  background: #fff6d6;
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--cloud-shadow);
}

.weather-toggle:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
}

/* ---- Paint a rainbow ---- */

/* Blank stripes are dashed outlines, like Color order's. */
.paint-stripe {
  stroke: #7fa9cc;
  stroke-width: 3;
  stroke-dasharray: 10 8;
  cursor: pointer;
  transition: fill 0.2s;
}

.paint-stripe.is-painted {
  stroke: #ffffff;
  stroke-dasharray: none;
}

.paint-stripe:hover:not(.is-painted) {
  fill: #f3faff;
}

.paint-stripe:focus {
  outline: none; /* no box around a tapped stripe */
}

.paint-stripe:focus-visible {
  stroke: var(--ink);
  stroke-width: 6;
  stroke-dasharray: none;
}

/* Once Done is tapped, the painting is finished and can't be changed. */
.paint-rainbow.is-finished .paint-stripe {
  cursor: default;
}

/* A little smaller than the other levels' rainbows, so the paints fit. */
.paint-rainbow {
  width: min(560px, 100%);
}

.palette {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  width: min(520px, 100%);
}

/* A paint is a round blob of color in a white button. */
.paint {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-height: 56px;
  justify-self: center;
  width: 100%;
  max-width: 78px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 0 var(--cloud-shadow);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.paint::before {
  content: '';
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--paint);
}

/* The paint on the brush is pressed in, with a dark ring. */
.paint[aria-pressed='true'] {
  transform: translateY(4px);
  box-shadow: 0 0 0 5px var(--ink);
}

.paint:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 6px;
}

/* ---- Rainbow road ---- */

.road-scene {
  width: min(540px, 100%);
  height: auto;
}

.grass {
  fill: #a8dcb5;
}

.road {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center bottom;
}

.road-surface {
  fill: none;
  stroke-width: 56;
  transition: stroke 0.3s;
}

/* The grey road in and the ring, with a grassy island in the middle. */
.asphalt {
  fill: none;
  stroke: #7d8a99;
  stroke-width: 56;
}

.ring-line {
  fill: none;
  stroke: rgb(255 255 255 / 0.8);
  stroke-width: 4;
  stroke-dasharray: 14 14;
}

.island {
  fill: #7cc59a;
  stroke: #ffffff;
  stroke-width: 4;
}

.flower {
  fill: var(--sun);
  stroke: #ffffff;
  stroke-width: 3;
}

/* A dashed white line down the middle of each road. */
.road-line {
  fill: none;
  stroke: rgb(255 255 255 / 0.8);
  stroke-width: 4;
  stroke-dasharray: 14 14;
  pointer-events: none;
}

/* The road's color name, in a white halo so it reads on grass. */
.road-label {
  font-family: Fredoka, system-ui, sans-serif;
  font-size: 30px;
  fill: var(--ink);
  stroke: #ffffff;
  stroke-width: 8px;
  stroke-linejoin: round;
  paint-order: stroke;
}

.road:focus {
  outline: none;
}

.road:focus-visible .road-surface {
  stroke-width: 68;
}

.road.is-wrong {
  animation: wiggle 0.4s;
}

.car-body {
  fill: #ffffff;
  stroke: var(--ink);
  stroke-width: 4;
}

.car-window {
  fill: #8ecae6;
}

.car-wheel {
  fill: var(--ink);
}

/* The finish: the roads fade back and the rainbow and pot of gold show. */
.road-finish {
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
}

.pot circle {
  fill: var(--sun);
  stroke: #c98f00;
  stroke-width: 2;
}

.pot-body {
  fill: var(--ink);
}

.is-done .road-finish {
  opacity: 1;
}

.is-done .road,
.is-done .roundabout {
  opacity: 0.25;
  cursor: default;
  transition: opacity 0.6s;
}

.is-done .car {
  opacity: 0; /* parked out of sight; the pot of gold is the star */
}

@media (prefers-reduced-motion: reduce) {
  .road.is-wrong {
    animation: none;
  }
}

/* ---- Word scramble ---- */

.scramble-clue {
  display: contents;
}

.scramble-rainbow,
.scramble-sun,
.scramble-clouds {
  width: min(260px, 60%);
  height: auto;
}

.scramble-sun-rays {
  fill: none;
  stroke: #f2b705;
  stroke-width: 10;
  stroke-linecap: round;
}

.scramble-sun-face {
  fill: var(--sun);
}

.scramble-cloud-back {
  fill: #e3eaf1;
}

.scramble-cloud-outline {
  fill: #9aa8b8;
  stroke: #9aa8b8;
  stroke-width: 8;
}

.scramble-cloud-front {
  fill: #ffffff;
}

/* One box per letter; the page sets --letters to the word's length. */
.letter-boxes {
  display: grid;
  grid-template-columns: repeat(var(--letters, 7), minmax(0, 1fr));
  gap: clamp(0.35rem, 1.5vw, 0.9rem);
  width: min(700px, 100%);
}

/* An empty box is a dashed outline; the one that's next is darker. When its
   letter goes in, it gets a thick border in its rainbow color. */
.letter-box {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 4px dashed #7fa9cc;
  border-radius: 22%; /* stays a rounded square at any size */
  background: rgb(255 255 255 / 0.55);
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(1.8rem, 6vw, 3.75rem);
  line-height: 1;
}

.letter-box.is-next {
  border-color: var(--ink);
}

.letter-box.is-filled {
  border: clamp(5px, 1vw, 8px) solid var(--box-color);
  background: #ffffff;
  animation: pop 0.35s ease-out;
}

.letter-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  width: min(820px, 100%);
}

.letter-tile {
  width: clamp(64px, 11vw, 96px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 7px 0 var(--cloud-shadow);
  color: var(--ink);
  font-family: Fredoka, system-ui, sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}

.letter-tile:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--cloud-shadow);
}

.letter-tile:disabled {
  opacity: 0.3;
  cursor: default;
}

.letter-tile.is-wrong {
  animation: wiggle 0.4s;
}

.letter-tile:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .letter-box.is-filled,
  .letter-tile.is-wrong {
    animation: none;
  }
}

/* ---- Fix the rainbow ---- */

.fix-stripe {
  stroke: #ffffff;
  stroke-width: 3;
  cursor: pointer;
  transition: fill 0.3s;
}

.fix-stripe:focus {
  outline: none; /* no box around a tapped stripe */
}

/* The picked-up stripe gently pulses, with a dark outline drawn on top. */
.fix-highlight {
  fill: none;
  stroke: var(--ink);
  stroke-width: 7;
  stroke-linejoin: round;
  pointer-events: none;
}

.fix-stripe:focus-visible {
  stroke: var(--ink);
  stroke-width: 7;
}

.fix-stripe.is-selected {
  animation: picked 0.9s ease-in-out infinite alternate;
}

@keyframes picked {
  to { opacity: 0.6; }
}

.fix-rainbow.is-fixed .fix-stripe {
  cursor: default;
  animation: pop 0.5s ease-out;
  transform-box: fill-box;
  transform-origin: center bottom;
}

@media (prefers-reduced-motion: reduce) {
  .fix-stripe.is-selected,
  .fix-rainbow.is-fixed .fix-stripe {
    animation: none;
  }
}

.signature {
  position: relative;
  padding: 1rem;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.7;
}
