:root {
  --ink: #16333a;
  --night: #102d35;
  --teal: #47d8c2;
  --cyan: #5ce7ff;
  --mint: #bdf4d5;
  --gold: #ffc94f;
  --coral: #ff7168;
  --paper: #f8fbf4;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow: auto;
  background: #e9f1e9;
  color: var(--ink);
  font-family: ui-rounded, "Avenir Next", system-ui, sans-serif;
}
button,
input {
  font: inherit;
}
button:focus-visible,
input:focus-visible {
  outline: 4px solid #ffdd68;
  outline-offset: 4px;
}
.shell {
  width: min(1280px, calc(100vw - 54px));
  height: min(825px, calc(100vh - 34px));
  margin: 17px auto;
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr) 132px 150px;
  gap: 12px;
}
.topline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 10px;
}
.topline > div:first-child {
  display: flex;
  flex-direction: column;
}
.topline span,
.decision span {
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #1a6f6d;
}
.topline strong {
  font-size: 16px;
}
.pips {
  display: flex;
  gap: 8px;
}
.pips i {
  width: 38px;
  height: 7px;
  border-radius: 99px;
  background: #c7d6ce;
}
.pips i.on {
  background: var(--gold);
}
.pips i.done {
  background: #249c8f;
}
.mute {
  justify-self: end;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: #dce9e2;
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}
.habitat {
  position: relative;
  overflow: hidden;
  border-radius: 34px;
  background:
    radial-gradient(
      circle at 60% 16%,
      rgba(255, 208, 92, 0.34),
      transparent 25%
    ),
    linear-gradient(165deg, #194c55, #102d3b 62%, #0c2730);
  box-shadow: 0 20px 55px rgba(17, 50, 48, 0.2);
  isolation: isolate;
}
.sky-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 80%, #1f756a 0 10%, transparent 35%),
    radial-gradient(circle at 85% 90%, #236358 0 12%, transparent 36%);
}
.leaf {
  position: absolute;
  width: 250px;
  height: 190px;
  border-radius: 70% 10% 70% 20%;
  background: #2a7867;
  opacity: 0.7;
}
.leaf-a {
  left: -80px;
  bottom: -60px;
  transform: rotate(22deg);
}
.leaf-b {
  right: -50px;
  top: -60px;
  transform: rotate(-130deg);
}
.habitat > .shelter {
  position: absolute;
  right: 16%;
  bottom: 18px;
  width: 210px;
  height: 160px;
  border-radius: 55% 55% 20% 20%;
  background: #204a42;
  border: 12px solid #3e7a60;
  box-shadow: inset 0 0 0 5px #183d39;
}
.habitat > .shelter i {
  position: absolute;
  left: 55px;
  bottom: 0;
  width: 85px;
  height: 95px;
  border-radius: 50px 50px 0 0;
  background: #0b2228;
}
.rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(
    105deg,
    transparent 0 32px,
    rgba(92, 231, 255, 0.48) 33px 36px,
    transparent 37px 62px
  );
  transform: translateY(-20px);
}
.habitat.is-raining .rain {
  opacity: 1;
  animation: rain 0.5s linear infinite;
}
.creature {
  position: absolute;
  left: 47%;
  bottom: 34px;
  width: 180px;
  height: 170px;
  transform: translateX(-50%);
  transition: transform 0.22s ease-out;
}
.creature .body {
  position: absolute;
  left: 25px;
  top: 22px;
  width: 130px;
  height: 126px;
  border-radius: 48% 48% 42% 42%;
  background: linear-gradient(145deg, #c6ffdb, #5bd3b7);
  box-shadow:
    inset -12px -15px 0 rgba(26, 113, 106, 0.14),
    0 16px 22px rgba(0, 0, 0, 0.2);
}
.frill {
  position: absolute;
  top: 25px;
  width: 56px;
  height: 100px;
  background: var(--coral);
  border-radius: 60% 20%;
  opacity: 0.9;
}
.frill.left {
  left: 5px;
  transform: rotate(-25deg);
}
.frill.right {
  right: 5px;
  transform: scaleX(-1) rotate(-25deg);
}
.eye {
  position: absolute;
  top: 42px;
  width: 18px;
  height: 25px;
  border-radius: 50%;
  background: #17323a;
  box-shadow: inset 5px 3px 0 #fff;
}
.e1 {
  left: 32px;
}
.e2 {
  right: 32px;
}
.mouth {
  position: absolute;
  left: 53px;
  top: 76px;
  width: 25px;
  height: 13px;
  border: 4px solid #17323a;
  border-top: 0;
  border-radius: 0 0 20px 20px;
}
.creature > span {
  position: absolute;
  left: 125px;
  top: 4px;
  width: max-content;
  max-width: 140px;
  padding: 8px 12px;
  border-radius: 15px 15px 15px 3px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}
.creature.beg {
  transform: translateX(-50%) scale(0.96) rotate(-2deg);
}
.creature.dance {
  animation: dance 0.38s ease-in-out infinite alternate;
}
.creature.shelter {
  transform: translate(255px, 24px) scale(0.78);
}
.props {
  position: absolute;
  left: 28px;
  bottom: 26px;
  display: flex;
  gap: 12px;
}
.prop {
  width: 92px;
  min-height: 76px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(7px);
  transition:
    transform 0.15s,
    background 0.15s;
}
.prop:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.18);
}
.prop i {
  display: block;
  font-size: 25px;
  color: var(--gold);
  font-style: normal;
}
.prop strong {
  font-size: 13px;
}
.prop[hidden] {
  display: none;
}
.spark {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 25px 10px rgba(92, 231, 255, 0.45);
  opacity: 0;
}
.habitat.flash .spark {
  left: 28%;
  top: 56%;
  animation: spark 0.8s ease-out;
}
.rule-path {
  display: grid;
  grid-template-columns: 150px 1fr 150px 1fr 190px 175px;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 25px;
  background: #153942;
  color: #f4fff8;
  box-shadow: 0 12px 30px rgba(20, 50, 48, 0.13);
}
.node {
  height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
}
.node small {
  color: #8be5d4;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.12em;
}
.node strong {
  font-size: 14px;
}
.wire {
  height: 8px;
  border-radius: 99px;
  background: #294f56;
  overflow: visible;
  position: relative;
}
.wire i {
  position: absolute;
  left: 0;
  top: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0;
  box-shadow: 0 0 15px var(--cyan);
}
.rule-path.pulsing .wire i {
  animation: wire 650ms ease-in-out;
}
.jar-node {
  position: relative;
  display: grid;
  grid-template-columns: 48px 36px;
  grid-template-rows: 18px 46px;
  gap: 3px;
}
.jar-node small {
  grid-column: 1/-1;
}
.jar {
  width: 46px;
  height: 48px;
  padding: 5px;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px 8px 14px 14px;
}
.jar > div {
  height: 100%;
  display: flex;
  flex-wrap: wrap-reverse;
  align-content: flex-start;
  gap: 3px;
}
.jar b,
.jar-node #beads i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 5px var(--cyan);
}
.jar-node > strong {
  font-size: 28px;
  color: var(--gold);
}
.gate-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gate {
  height: 62px;
  border-color: rgba(255, 201, 79, 0.5);
}
.threshold {
  font-size: 10px;
  font-weight: 850;
  color: #b9ddd6;
}
.threshold input {
  width: 100%;
  accent-color: var(--gold);
}
.branches {
  display: grid;
  gap: 6px;
}
.branch {
  height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-radius: 13px;
  background: #294f56;
  color: #b8d5d0;
  font-size: 11px;
  font-weight: 900;
}
.branch.active {
  background: var(--gold);
  color: #3f2d06;
  box-shadow: 0 0 0 3px rgba(255, 201, 79, 0.2);
}
.decision {
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  align-items: center;
  gap: 30px;
  padding: 20px 28px;
  border-radius: 27px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(23, 58, 48, 0.11);
}
.decision h1 {
  margin: 4px 0 3px;
  font-size: 27px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}
.decision p {
  margin: 0;
  color: #62746f;
  font-size: 14px;
  font-weight: 650;
}
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.actions button,
.trace button,
.finale button {
  min-height: 56px;
  padding: 12px 20px;
  border: 0;
  border-radius: 17px;
  background: #dfeae3;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}
.actions .primary,
.trace button,
.finale button {
  background: #1a8f82;
  color: #fff;
  box-shadow: 0 6px 0 #0c625c;
}
.actions button:hover,
.trace button:hover,
.finale button:hover {
  transform: translateY(-2px);
}
.trace {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 10;
  transform: translate(-50%, -50%);
  width: 540px;
  padding: 24px;
  border-radius: 25px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.trace div {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 20px;
}
.trace i {
  display: grid;
  place-items: center;
  width: 90px;
  height: 70px;
  border-radius: 18px;
  background: #e7f3ef;
  font-style: normal;
  font-size: 24px;
}
.finale {
  position: absolute;
  inset: 17px 27px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 34px;
  background: rgba(10, 40, 48, 0.96);
  color: #fff;
}
.finale span {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: #8be5d4;
}
.finale strong {
  margin: 12px 0 25px;
  font-size: 42px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.is-pointed {
  animation: point 700ms ease-out 2;
}
@keyframes rain {
  to {
    background-position: 62px 80px;
  }
}
@keyframes dance {
  to {
    transform: translateX(-50%) translateY(-10px) rotate(4deg);
  }
}
@keyframes spark {
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    left: 72%;
    top: 42%;
  }
}
@keyframes wire {
  0% {
    opacity: 0;
    left: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    left: calc(100% - 20px);
  }
}
@keyframes wire-down {
  0% {
    opacity: 0;
    top: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    top: calc(100% - 20px);
  }
}
@keyframes point {
  50% {
    filter: brightness(1.3);
    box-shadow: 0 0 0 5px var(--gold);
  }
}
@media (max-width: 960px), (max-height: 700px) {
  .shell {
    width: min(100% - 24px, 760px);
    height: auto;
    min-height: calc(100vh - 24px);
    margin: 12px auto;
    grid-template-rows: 50px minmax(350px, 56vh) auto auto;
  }
  .rule-path {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 8px;
  }
  .node {
    width: 100%;
    height: 74px;
  }
  .wire {
    width: 8px;
    height: 24px;
    justify-self: center;
  }
  .wire i {
    left: -6px;
    top: 0;
  }
  .rule-path.pulsing .wire i {
    animation-name: wire-down;
  }
  .jar-node {
    grid-template-columns: 48px 42px;
    grid-template-rows: 18px 46px;
    justify-content: center;
  }
  .gate-wrap,
  .branches {
    width: 100%;
  }
  .decision {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 22px;
  }
  .actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .trace {
    position: fixed;
    top: 50%;
    width: min(540px, calc(100vw - 28px));
  }
  .finale {
    inset: 12px;
  }
}
@media (max-width: 560px) {
  .shell {
    width: calc(100% - 16px);
    margin: 8px auto;
    grid-template-rows: auto 390px auto auto;
    gap: 8px;
  }
  .topline {
    grid-template-columns: 1fr auto;
    padding: 0 4px;
  }
  .pips {
    grid-column: 1/-1;
    grid-row: 2;
    justify-content: center;
    margin-top: 6px;
  }
  .pips i {
    width: 28px;
  }
  .habitat {
    border-radius: 24px;
  }
  .props {
    left: 14px;
    bottom: 14px;
    gap: 8px;
  }
  .prop {
    width: 76px;
    min-height: 68px;
    border-radius: 18px;
  }
  .creature {
    left: 56%;
    transform: translateX(-50%) scale(0.82);
  }
  .creature.beg {
    transform: translateX(-50%) scale(0.78) rotate(-2deg);
  }
  .creature.shelter {
    transform: translate(96px, 30px) scale(0.62);
  }
  .habitat > .shelter {
    right: -12px;
    width: 165px;
    height: 132px;
  }
  .decision h1 {
    font-size: 24px;
  }
  .actions button,
  .trace button,
  .finale button {
    width: 100%;
  }
  .finale strong {
    font-size: 30px;
    text-align: center;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
