:root {
  --page: #f7f9ff;
  --panel: #ffffff;
  --panel-header: #dfe8ff;
  --border: #d7e2ff;
  --ink: #06175c;
  --muted: #5060a0;
  --base-blue: #0052ff;
}

* {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  min-width: 0;
}

button,
input,
summary {
  max-width: 100%;
}

span,
strong,
small,
em,
p,
h1,
h2,
h3,
li,
button,
input {
  overflow-wrap: anywhere;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 18%, rgba(0, 82, 255, 0.08), transparent 340px),
    var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.page {
  min-height: 100vh;
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.board {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

.title-block {
  min-height: 92px;
  padding: 16px 22px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0052ff, #0047e8);
  color: #fff;
  box-shadow: 0 14px 28px rgba(0, 82, 255, 0.18);
}

.title-block h1 {
  margin: 0;
  font-family: "Courier New", Courier, monospace;
  font-size: 35px;
  line-height: 1;
  font-weight: 900;
}

.title-block p {
  margin: 9px 0 0;
  font-size: 17px;
  font-weight: 800;
}

.left {
  display: grid;
  gap: 18px;
}

.preview-card,
.palette,
.panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(18, 35, 83, 0.06);
}

.preview-card {
  min-height: 310px;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 14px;
}

.preview {
  width: 330px;
  height: 245px;
  display: grid;
  place-items: center;
}

.current {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef4ff;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
}

.current span {
  color: var(--muted);
  font-weight: 900;
}

.current strong {
  color: var(--base-blue);
}

.palette {
  padding: 18px;
}

.palette h2,
.panel h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1;
  font-weight: 900;
}

.palette h2 {
  margin-bottom: 18px;
}

.palette div {
  display: grid;
  grid-template-columns: 24px 1fr 72px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  font-size: 10px;
}

.palette span {
  width: 24px;
  height: 24px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--c);
}

.palette b {
  font-weight: 900;
}

.palette em {
  color: var(--muted);
  font-style: normal;
}

.content {
  display: grid;
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel h2 {
  height: 39px;
  padding: 12px 18px;
  background: var(--panel-header);
}

.grid {
  display: grid;
  align-items: end;
  gap: 12px;
  padding: 22px 22px 18px;
}

.six {
  grid-template-columns: repeat(6, 1fr);
  min-height: 235px;
}

.five {
  grid-template-columns: repeat(5, 1fr);
  min-height: 220px;
}

.three {
  grid-template-columns: repeat(3, 1fr);
  min-height: 250px;
}

.four {
  grid-template-columns: repeat(4, 1fr);
  min-height: 220px;
}

.card {
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 8px;
  min-width: 0;
  padding: 10px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.card:hover,
.card.active {
  border-color: var(--border);
  background: #f8fbff;
}

.sprite-stage {
  width: 112px;
  height: 104px;
  display: grid;
  place-items: end center;
}

.preview .sprite-stage {
  width: 310px;
  height: 230px;
}

.sprite-name {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.sprite-note {
  margin: -5px 0 0;
  min-height: 24px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.buddy-svg {
  display: block;
  overflow: visible;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(9px 10px 0 rgba(0, 26, 102, 0.14));
}

.preview .buddy-svg {
  filter: drop-shadow(18px 16px 0 rgba(0, 26, 102, 0.18));
}

.memorial-svg,
.preview .memorial-svg {
  filter: none;
}

.memorial-stage {
  place-items: center;
}

.buddy-core,
.seed-core,
.body,
.face,
.eye,
.mouth,
.reaction,
.prop,
.tear,
.alert-mark {
  transform-box: fill-box;
  transform-origin: center;
}

.seed-idle .seed-core {
  animation: seed-breathe 1300ms steps(2, end) infinite;
}

.seed-pulse .seed-core {
  animation: seed-pulse 780ms steps(2, end) infinite;
}

.seed-crack .seed-core {
  animation: seed-hatch 640ms steps(2, end) infinite;
}

.seed-pulse .seed-crack-line,
.seed-crack .seed-crack-line,
.seed-crack .seed-sprout {
  animation: seed-glow 760ms steps(2, end) infinite;
}

.grave-petal {
  animation: petal-drift 5200ms steps(12, end) infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.grave-petal.p2 {
  animation-duration: 6100ms;
  animation-delay: -1200ms;
}

.grave-petal.p3 {
  animation-duration: 4800ms;
  animation-delay: -1900ms;
}

.grave-petal.p4 {
  animation-duration: 6900ms;
  animation-delay: -900ms;
}

.grave-petal.p5 {
  animation-duration: 5600ms;
  animation-delay: -2500ms;
}

.grave-petal.p6 {
  animation-duration: 7400ms;
  animation-delay: -3400ms;
}

.grave-petal.p7 {
  animation-duration: 6300ms;
  animation-delay: -2800ms;
}

.grave-petal.p8 {
  animation-duration: 5300ms;
  animation-delay: -3900ms;
}

.grave-petal.p9 {
  animation-duration: 6200ms;
  animation-delay: -2300ms;
}

.grave-petal.p10 {
  animation-duration: 6800ms;
  animation-delay: -4800ms;
}

.grave-petal.p11 {
  animation-duration: 5700ms;
  animation-delay: -3300ms;
}

.grave-petal.p12 {
  animation-duration: 7200ms;
  animation-delay: -1400ms;
}

.grave-petal.p13 {
  animation-duration: 6400ms;
  animation-delay: -5200ms;
}

.grave-petal.p14 {
  animation-duration: 5900ms;
  animation-delay: -700ms;
}

.grave-petal.p15 {
  animation-duration: 7600ms;
  animation-delay: -3600ms;
}

.grave-petal.p16 {
  animation-duration: 6600ms;
  animation-delay: -1800ms;
}

.grave-petal.p17 {
  animation-duration: 7000ms;
  animation-delay: -4300ms;
}

.grave-petal.p18 {
  animation-duration: 5900ms;
  animation-delay: -5100ms;
}

.grave-petal.p19 {
  animation-duration: 7800ms;
  animation-delay: -2500ms;
}

.grave-petal.p20 {
  animation-duration: 5400ms;
  animation-delay: -3100ms;
}

.grave-petal.p21 {
  animation-duration: 7300ms;
  animation-delay: -900ms;
}

.grave-petal.p22 {
  animation-duration: 6200ms;
  animation-delay: -4700ms;
}

.grave-petal.p23 {
  animation-duration: 6900ms;
  animation-delay: -5700ms;
}

.grave-petal.p24 {
  animation-duration: 8100ms;
  animation-delay: -3900ms;
}

.anim-idle .buddy-core,
.anim-happy .buddy-core {
  animation: body-breathe 1100ms steps(2, end) infinite;
}

.anim-idle .eye,
.anim-eat .eye,
.anim-clean .eye {
  animation: blink 3400ms steps(1, end) infinite;
}

.anim-happy .mouth,
.anim-joyful .mouth,
.anim-play .mouth {
  animation: smile-open 820ms steps(2, end) infinite;
}

.anim-happy .eye,
.anim-play .eye {
  animation: kawaii-blink 3000ms steps(1, end) infinite;
}

.anim-joyful .eye {
  animation: joyful-blink 2200ms steps(1, end) infinite;
}

.anim-joyful .buddy-core,
.anim-play .buddy-core,
.anim-surprised .buddy-core {
  animation: jump 640ms steps(3, end) infinite;
}

.anim-surprised .buddy-core {
  animation-duration: 520ms;
}

.anim-sad .buddy-core,
.anim-tired .buddy-core,
.anim-sick .buddy-core,
.anim-critical .buddy-core {
  animation: low-breathe 1100ms steps(2, end) infinite;
}

.anim-sad .mouth,
.anim-sick .mouth,
.anim-critical .mouth {
  animation: frown-wobble 1300ms steps(2, end) infinite;
}

.anim-sad .eye,
.anim-sick .eye,
.anim-critical .eye {
  animation: heavy-blink 2600ms steps(1, end) infinite;
}

.anim-sad .tear,
.anim-sick .tear,
.anim-danger .tear,
.anim-critical .tear {
  animation: tear-drop 1200ms steps(2, end) infinite;
}

.anim-sad .tear-right,
.anim-critical .tear-right {
  animation-delay: 180ms;
}

.anim-angry .buddy-core {
  animation: low-breathe 1300ms steps(2, end) infinite;
}

.anim-angry .eye {
  animation: hungry-blink 2300ms steps(1, end) infinite;
}

.anim-angry .hungry-drool {
  animation: drool-drop 1200ms steps(2, end) infinite;
}

.anim-angry .hungry-burger {
  animation: hungry-burger-pop 1150ms steps(2, end) infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.anim-tired .eye {
  animation: tired-blink 1900ms steps(1, end) infinite;
}

.anim-sleep .eye {
  animation: sleep-eye 1800ms steps(2, end) infinite;
}

.anim-sleep .buddy-core {
  animation: sleep-breathe 1800ms steps(2, end) infinite;
}

.anim-eat .mouth {
  animation: chew 460ms steps(2, end) infinite;
}

.anim-eat .prop {
  animation: snack 460ms steps(2, end) infinite;
}

.anim-play .prop {
  animation: ball-bounce 680ms steps(3, end) infinite;
}

.anim-clean .prop {
  animation: bubbles-rise 1200ms steps(2, end) infinite;
}

.anim-clean .reaction,
.anim-sick .reaction {
  animation: detail-float 900ms steps(2, end) infinite;
}

.anim-sick .sick-nose-bubble {
  animation: sick-bubble-pulse 1500ms steps(2, end) infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.anim-warning .alert-mark {
  animation: alert-pulse 1800ms steps(2, end) infinite;
}

.anim-danger .alert-mark {
  animation: alert-pulse 720ms steps(2, end) infinite;
}

.anim-critical .alert-mark {
  animation: alert-pulse 520ms steps(2, end) infinite;
}

[data-id^="transition"] .reaction {
  animation: none;
}

[data-id^="transition-charge"] .buddy-core {
  animation: seed-hatch 760ms steps(2, end) infinite;
}

[data-id^="transition-charge"] .body,
[data-id^="transition-charge"] .face,
[data-id^="transition-charge"] .prop {
  animation: none;
}

[data-id^="transition-charge"] .buddy-svg {
  animation: none;
}

[data-id^="transition-charge"] .eye {
  animation: evolution-blink 680ms steps(1, end) infinite;
}

.anim-happy .reaction,
.anim-play .reaction,
.anim-tired .reaction,
.anim-surprised .reaction {
  animation: detail-float 1300ms steps(2, end) infinite;
}

.anim-sleep .reaction {
  animation: snore-pulse 1800ms steps(2, end) infinite;
}

.anim-surprised .mouth {
  animation: gasp 620ms steps(2, end) infinite;
}

.anim-surprised .eye {
  animation: surprised-blink 2600ms steps(1, end) infinite;
}

@keyframes body-breathe {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1px);
  }
}

@keyframes seed-breathe {
  0%,
  100% {
    transform: translateY(0) scaleX(1);
  }
  50% {
    transform: translateY(-1px) scaleX(1.02);
  }
}

@keyframes seed-pulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
    filter: none;
  }
  50% {
    transform: translateY(-2px) scale(1.04);
    filter: drop-shadow(0 0 8px rgba(185, 212, 255, 0.95));
  }
}

@keyframes seed-hatch {
  0%,
  100% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 0 8px rgba(185, 212, 255, 0.5));
  }
  50% {
    transform: translateY(-3px) scale(1.08);
    filter:
      drop-shadow(0 0 10px rgba(255, 255, 255, 1))
      drop-shadow(0 0 18px rgba(77, 139, 255, 0.85));
  }
}

@keyframes seed-glow {
  0%,
  100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

@keyframes petal-drift {
  0% {
    transform: translate(0, 0);
    opacity: 0;
  }
  10% {
    opacity: 0.95;
  }
  35% {
    transform: translate(-22px, 5px);
    opacity: 0.95;
  }
  70% {
    transform: translate(-54px, 12px);
    opacity: 0.75;
  }
  100% {
    transform: translate(-86px, 20px);
    opacity: 0;
  }
}

@keyframes blink {
  0%,
  90%,
  100% {
    transform: scaleY(1);
  }
  94%,
  97% {
    transform: scaleY(0.18);
  }
}

@keyframes kawaii-blink {
  0%,
  84%,
  100% {
    transform: translateY(0) scaleY(1);
  }
  88%,
  92% {
    transform: translateY(1px) scaleY(0.22);
  }
}

@keyframes joyful-blink {
  0%,
  78%,
  100% {
    transform: translateY(0) scaleY(1);
  }
  82%,
  86% {
    transform: translateY(0.5px) scaleY(0.38);
  }
}

@keyframes smile-open {
  0%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(1.2) translateY(0.35px);
  }
}

@keyframes jump {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes low-breathe {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(0);
  }
}

@keyframes tiny-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-1px);
  }
}

@keyframes hungry-burger-pop {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-1px) scale(1.04);
  }
}

@keyframes hungry-blink {
  0%,
  62%,
  100% {
    transform: translateY(0) scaleY(1);
  }
  70%,
  84% {
    transform: translateY(1px) scaleY(0.45);
  }
}

@keyframes drool-drop {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.9;
  }
  50% {
    transform: translateY(1px);
    opacity: 0.72;
  }
}

@keyframes frown-wobble {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(1px);
  }
}

@keyframes heavy-blink {
  0%,
  68%,
  100% {
    transform: translateY(0) scaleY(1);
  }
  74%,
  86% {
    transform: translateY(1px) scaleY(0.32);
  }
}

@keyframes tear-drop {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.82;
  }
  50% {
    transform: translateY(1px);
    opacity: 1;
  }
}

@keyframes tired-blink {
  0%,
  55%,
  100% {
    transform: translateY(0) scaleY(1);
  }
  64%,
  86% {
    transform: translateY(1px) scaleY(0.45);
  }
}

@keyframes sleep-eye {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(1px);
  }
}

@keyframes sleep-breathe {
  0%,
  100% {
    transform: translateY(0) scaleX(1.02);
  }
  50% {
    transform: translateY(0) scaleX(1);
  }
}

@keyframes chew {
  0%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.55);
  }
}

@keyframes snack {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  50% {
    transform: translateX(-1px) rotate(-2deg);
  }
}

@keyframes ball-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes bubbles-rise {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes detail-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-0.75px);
  }
}

@keyframes sick-bubble-pulse {
  0%,
  100% {
    transform: scale(0.88);
  }
  50% {
    transform: scale(1.12);
  }
}

@keyframes alert-pulse {
  0%,
  70%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  78% {
    transform: translateY(-1px) scale(1.16);
    opacity: 1;
  }
  86% {
    transform: translateY(-1px) scale(1.08);
    opacity: 1;
  }
}

@keyframes snore-pulse {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(1px, -1px) scale(1.08);
  }
}

@keyframes evolution-charge {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-6px) scale(1.14);
  }
}

@keyframes evolution-glow-filter {
  0%,
  100% {
    filter: drop-shadow(9px 10px 0 rgba(0, 26, 102, 0.14)) brightness(1);
  }
  50% {
    filter:
      drop-shadow(0 0 0 #ffffff)
      drop-shadow(0 0 16px rgba(255, 255, 255, 1))
      drop-shadow(0 0 28px rgba(219, 242, 255, 0.98))
      drop-shadow(0 0 44px rgba(105, 190, 255, 0.95))
      drop-shadow(0 0 64px rgba(56, 167, 255, 0.86))
      brightness(2.35)
      contrast(1.18)
      saturate(1.35);
  }
}

@keyframes evolution-blink {
  0%,
  28%,
  100% {
    transform: scaleY(1);
  }
  44%,
  70% {
    transform: translateY(1px) scaleY(0.12);
  }
}

@keyframes gasp {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

@keyframes surprised-blink {
  0%,
  88%,
  100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.08);
  }
  92%,
  95% {
    transform: translateY(1px) scaleY(0.22);
  }
}

@media (max-width: 1100px) {
  .board {
    grid-template-columns: 1fr;
  }

  .six,
  .five,
  .four,
  .three {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .page {
    padding: 10px;
  }

  .title-block h1 {
    font-size: 28px;
  }

  .six,
  .five,
  .four,
  .three {
    grid-template-columns: repeat(2, 1fr);
  }

  .preview {
    width: 100%;
  }
}
