/* Mother Tongue, Storybook Critters: Pip the parrot climbs the family tree
   toward the mystery's egg. Sky blue, chunky rounded type, white cards with a
   soft drop, sunflower buttons: the same storybook as Deep Cut. */

:root {
  color-scheme: light;
  --sky: #cfeaff;
  --ink: #2e2a3b;
  --ink-2: #3e3a52;
  --muted: #5b5670;
  --card: #ffffff;
  --card-edge: #9cc8ea;
  --track: #eaf4ff;
  --sun: #ffb938;
  --sun-edge: #d68a00;
  --coral: #ff6f61;
  --leaf: #7bc96f;
  --leaf-dark: #5daf55;
  --wood: #8a5a36;
  --plaque: #ffe7b8;
  --plaque-edge: #7a4e2e;
  --error: #b23a2e;
  --good: #2f7d3e;
  --link: #1f5f99;
  --display: Fredoka, Nunito, system-ui, sans-serif;
  font: 16px/1.5 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sky);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--link);
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

/* Header */

.top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  width: min(600px, 100%);
  margin: 0 auto;
  padding: 14px 16px 6px;
}

.wordmark {
  text-align: center;
}

.wordmark h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.1;
}

.day-label {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--card-edge);
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
}

/* Layout and shared pieces */

main {
  flex: 1;
  width: min(600px, 100%);
  margin: 0 auto;
  padding: 6px 16px 24px;
}

#game,
.done {
  display: grid;
  gap: 14px;
}

.done {
  margin-bottom: 18px;
}

.card {
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--card-edge);
}

.primary {
  min-height: 54px;
  padding: 12px 20px;
  border: 0;
  border-radius: 18px;
  background: var(--sun);
  box-shadow: 0 4px 0 var(--sun-edge);
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.primary:hover {
  filter: brightness(1.04);
}

.primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--sun-edge);
}

.secondary {
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
}

.link {
  justify-self: center;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
}

.kicker {
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.section-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Guesses left: one seed each */

.seeds-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.seeds {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.seeds span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--card);
}

.seeds span.used {
  background: var(--coral);
}

.counter {
  margin: 0;
  flex: none;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-2);
}

.lede {
  margin: 0;
  text-align: center;
  color: var(--ink-2);
}

/* The guess box */

.guess {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.combo {
  position: relative;
  min-width: 0;
}

.combo input {
  width: 100%;
  min-height: 54px;
  padding: 10px 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  font-size: 19px;
}

.combo input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--sun);
}

.suggestions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--card-edge), 0 16px 32px rgba(46, 42, 59, 0.18);
}

.suggestions li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.suggestions li[aria-selected="true"],
.suggestions li:hover {
  background: var(--sky);
}

.suggestions .also {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

/* What the last guess told you */

.feedback-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--card-edge);
}

.compass {
  width: 44px;
  height: 44px;
  flex: none;
}

#needle {
  transition: transform 0.8s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.feedback {
  margin: 0;
  font-weight: 700;
  color: var(--error);
}

.feedback.info {
  font-weight: 400;
  color: var(--ink);
}

.feedback.ok {
  color: var(--good);
}

/* The family tree: trunk at the bottom, the mystery's egg in its nest at the top */

.tree {
  position: relative;
}

.cloud {
  margin: 0 0 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--sky);
  font-size: 14px;
  text-align: center;
}

.cloud strong {
  color: var(--ink-2);
}

.nest {
  position: relative;
  display: grid;
  justify-items: center;
}

.nest svg {
  width: 120px;
  height: 92px;
}

.nest-label {
  margin: -6px 0 0;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--sky);
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
}

.limbs {
  position: relative;
  padding-bottom: 26px;
}

.limbs::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  bottom: 18px;
  width: 16px;
  margin-left: -8px;
  border-radius: 8px 8px 0 0;
  background: var(--wood);
}

.limbs::after {
  content: "";
  position: absolute;
  left: -16px;
  right: -16px;
  bottom: 0;
  height: 26px;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: var(--leaf);
}

.branch {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr);
  align-items: center;
  min-height: 62px;
}

.branch .side {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
}

.branch.left .side {
  grid-column: 1;
  align-items: flex-end;
  text-align: right;
}

.branch.right .side {
  grid-column: 3;
  align-items: flex-start;
}

.branch::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 34px;
  height: 10px;
  margin-top: -5px;
  border-radius: 5px;
  background: var(--wood);
}

.branch.left::before {
  right: 50%;
}

.branch.right::before {
  left: 50%;
}

.branch.found::after {
  content: "";
  position: absolute;
  top: calc(50% - 24px);
  width: 24px;
  height: 17px;
  border-radius: 60% 40% 60% 40%;
  background: var(--leaf-dark);
}

.branch.left.found::after {
  right: calc(50% + 10px);
}

.branch.right.found::after {
  left: calc(50% + 10px);
}

.branch.hidden::before {
  height: 0;
  margin-top: 0;
  border-top: 4px dashed #b08a6a;
  border-radius: 0;
  background: none;
}

.plaque {
  padding: 3px 12px;
  border: 2px solid var(--plaque-edge);
  border-radius: 9px;
  background: var(--plaque);
  font-family: var(--display);
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.25;
}

.branch.hidden .plaque {
  border-style: dashed;
  border-color: #b08a6a;
  background: var(--card);
  color: var(--muted);
  letter-spacing: 0.2em;
}

.branch.deepest .plaque {
  background: var(--sun);
}

.fruits {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.branch.left .fruits {
  justify-content: flex-end;
}

.fruit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 800;
}

.fruit::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.12);
}

.fruit.new::before {
  background: var(--sun);
}

.pip {
  position: absolute;
  left: 50%;
  bottom: calc(50% + 2px);
  width: 46px;
  height: 62px;
  margin-left: -23px;
  z-index: 2;
}

.roots-pip {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 46px;
  height: 62px;
  margin-left: 14px;
  z-index: 2;
}

.tip {
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* "Reveal the answer?" */

.confirm {
  display: grid;
  gap: 10px;
  text-align: center;
}

.confirm p {
  margin: 0;
  font-weight: 700;
}

.confirm-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Hints */

.hints:empty {
  display: none;
}

.hints {
  display: grid;
  gap: 8px;
}

.hints p {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.hints svg {
  width: 26px;
  height: 26px;
  flex: none;
}

.hints .next-hint {
  font-size: 14px;
  color: var(--muted);
}

/* Guesses, closest first */

.guesses {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guesses li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--card-edge);
}

.guesses li.latest {
  box-shadow: 0 0 0 3px var(--sun), 0 3px 0 var(--card-edge);
}

.g-name {
  font-weight: 800;
}

.g-branch {
  font-size: 14px;
  color: var(--muted);
}

.g-meter {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  width: 92px;
  height: 12px;
  border-radius: 6px;
  background: var(--track);
  overflow: hidden;
}

.g-meter span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--c);
}

/* The end: the egg hatches */

.hatch {
  position: relative;
  display: grid;
  justify-items: center;
}

.hatch svg {
  width: 300px;
  max-width: 100%;
  height: auto;
}

.say {
  position: absolute;
  top: 0;
  left: 4px;
  max-width: 44%;
  padding: 8px 14px;
  border-radius: 18px;
  background: var(--sky);
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  transform-origin: 100% 100%;
  animation: say 0.5s 0.6s both cubic-bezier(0.3, 1.6, 0.5, 1);
}

.say::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: -12px;
  border: 7px solid transparent;
  border-top-color: var(--sky);
  border-right-color: var(--sky);
}

@keyframes say {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

.done-title {
  margin: -10px 0 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(32px, 9vw, 40px);
  line-height: 1.1;
}

.done-note {
  margin: -6px 0 0;
  text-align: center;
  color: var(--ink-2);
}

.tier-list {
  display: grid;
  gap: 2px;
  padding: 6px;
  border-radius: 16px;
  background: var(--sky);
}

.tier {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 14px;
}

.tier svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.tier b {
  flex: 1;
  font-family: var(--display);
  font-weight: 600;
}

.tier span {
  color: var(--muted);
}

.tier.now {
  min-height: 40px;
  background: var(--sun);
}

.tier.now span {
  color: var(--ink);
  font-weight: 800;
}

.lineage {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

.wiki {
  margin: 0;
}

.next-in {
  margin: 0;
  text-align: center;
  color: var(--ink-2);
}

.next-in strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Pip, the egg and the chick */

.hop {
  animation: hop 1.6s ease-in-out infinite;
}

@keyframes hop {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  70% {
    transform: translateY(-8px);
  }
  80% {
    transform: translateY(0);
  }
  86% {
    transform: translateY(-3px);
  }
}

.tilt {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: tilt 3s ease-in-out infinite;
}

@keyframes tilt {
  0%,
  40%,
  100% {
    transform: rotate(0deg);
  }
  50%,
  70% {
    transform: rotate(-14deg);
  }
}

.flap-l,
.flap-r {
  transform-box: fill-box;
  animation: 0.35s ease-in-out infinite alternate;
}

.flap-l {
  transform-origin: 100% 100%;
  animation-name: flap-l;
}

.flap-r {
  transform-origin: 0% 100%;
  animation-name: flap-r;
}

@keyframes flap-l {
  from {
    transform: rotate(10deg);
  }
  to {
    transform: rotate(-25deg);
  }
}

@keyframes flap-r {
  from {
    transform: rotate(-10deg);
  }
  to {
    transform: rotate(25deg);
  }
}

.egg-wobble {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: wobble 2.6s ease-in-out infinite;
}

.egg-wobble.fast {
  animation-duration: 1.4s;
}

@keyframes wobble {
  0%,
  46%,
  100% {
    transform: rotate(0deg);
  }
  52% {
    transform: rotate(-11deg);
  }
  60% {
    transform: rotate(10deg);
  }
  68% {
    transform: rotate(-6deg);
  }
  76% {
    transform: rotate(3deg);
  }
}

.glow {
  animation: glow 1.2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    opacity: 0.35;
  }
  to {
    opacity: 1;
  }
}

.bounce {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: bounce 1.4s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0) scale(1, 1);
  }
  40% {
    transform: translateY(-8px) scale(0.96, 1.04);
  }
  60% {
    transform: translateY(0) scale(1.04, 0.96);
  }
}

.zzz {
  animation: zzz 2.4s ease-in-out infinite;
}

@keyframes zzz {
  from {
    transform: translate(0, 0);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  to {
    transform: translate(10px, -22px);
    opacity: 0;
  }
}

/* Dialogs */

.sheet {
  width: min(480px, calc(100% - 32px));
  padding: 20px;
  border: 0;
  border-radius: 24px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--card-edge);
}

.sheet::backdrop {
  background: rgba(46, 42, 59, 0.45);
}

.sheet h2 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 700;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-head h2 {
  margin: 0;
}

.sheet-pip {
  width: 48px;
  height: 64px;
  flex: none;
}

.sheet ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
  padding-left: 20px;
}

.sheet .primary {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  padding: 12px 6px;
  border-radius: 16px;
  background: var(--sky);
  text-align: center;
}

.stat strong {
  display: block;
  font-family: var(--display);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: 12px;
  color: var(--ink-2);
}

.foot {
  width: min(600px, 100%);
  margin: 0 auto;
  padding: 10px 16px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-2);
}

.foot p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
