:root {
  color-scheme: light;
  --p: #f4efe4;
  --p2: #ece4d4;
  --s: #fbf7ee;
  --ink: #1b1916;
  --ink2: #544d42;
  --ink3: #6e6558;
  --line: rgba(27, 25, 22, 0.14);
  --line2: rgba(27, 25, 22, 0.3);
  --clay: #d97757;
  --clay2: #b5573a;
  --soft: #f0d5c7;
  --ok: #3f6b4f;
  --ok-bg: #e7eee2;
  --code: #191612;
  --code-ink: #f0e9da;
  --code-line: rgba(240, 233, 218, 0.13);
  --shadow: 0 30px 70px -44px rgba(62, 42, 24, 0.6);
  --sans: "Helvetica Neue", "Segoe UI", "Noto Sans", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "JetBrains Mono", "Menlo",
    "Consolas", "Noto Sans Mono", monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --p: #15120f;
  --p2: #1a1612;
  --s: #1e1a15;
  --ink: #f2ebde;
  --ink2: #c4b9a7;
  --ink3: #94897a;
  --line: rgba(242, 235, 222, 0.15);
  --line2: rgba(242, 235, 222, 0.34);
  --clay: #e58b69;
  --clay2: #f0a284;
  --soft: #4a2d22;
  --ok: #8fb79a;
  --ok-bg: #1f2a21;
  --code: #100e0b;
  --code-ink: #f0e9da;
  --code-line: rgba(240, 233, 218, 0.13);
  --shadow: 0 30px 70px -44px rgba(0, 0, 0, 0.9);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--p);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

img,
svg {
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--soft);
  color: var(--ink);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--clay2);
  outline-offset: 3px;
  border-radius: 2px;
}

[hidden] {
  display: none !important;
}

.wrap {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 32px);
}

.mark {
  width: 26px;
  height: auto;
  flex: 0 0 auto;
  color: var(--ink);
}

/* ---------- standalone header (hidden when embedded) ---------- */

.site-head {
  border-bottom: 1px solid var(--line);
}

.is-embedded .site-head {
  display: none;
}

.head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 66px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-tag {
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.head-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--ink2);
  font-size: 13px;
}

.head-nav a:hover {
  color: var(--clay2);
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  padding-block: 148px clamp(40px, 6vw, 64px);
  overflow: clip;
}

.is-standalone .hero {
  padding-top: 34px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    52% 58% at 76% 40%,
    rgba(217, 119, 87, 0.14),
    transparent 70%
  );
  pointer-events: none;
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.86fr);
  align-items: start;
  gap: clamp(32px, 5vw, 72px);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 20px;
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow-name {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: none;
}

.eyebrow-sep {
  width: 16px;
  height: 1px;
  background: var(--line2);
}

.hero h1 {
  max-width: 12em;
  font-size: clamp(2.5rem, 5vw, 4.1rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.h1-line {
  display: block;
}

.dot {
  color: var(--clay);
}

.lede {
  max-width: 27em;
  margin-top: 22px;
  color: var(--ink2);
  font-size: clamp(15px, 1.15vw, 16.5px);
  line-height: 1.8;
  text-wrap: pretty;
}

.endpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  margin-top: 26px;
  padding: 9px 12px;
  background: var(--s);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.endpoint code {
  color: var(--ink);
  font-size: 10.5px;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.hero-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 18px;
  color: var(--ink2);
  font-size: 12.5px;
}

.hero-links a {
  border-bottom: 1px solid var(--line2);
  padding-bottom: 1px;
}

.hero-links a:hover {
  color: var(--clay2);
  border-color: var(--clay);
}

.hero-links .sep {
  color: var(--line2);
}

.hero-art {
  justify-self: end;
  width: 100%;
  max-width: 426px;
}

/* ---------- pet ---------- */

.pet {
  position: relative;
  padding: 17px;
  background: var(--s);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .pet {
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.pet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pet-head b {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--clay2);
}

.live::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--clay);
  animation: pulse 2.4s steps(1, end) infinite;
}

@keyframes pulse {
  0%,
  55%,
  100% {
    opacity: 1;
  }
  60%,
  95% {
    opacity: 0.25;
  }
}

.pet-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 306px;
  margin-top: 13px;
  padding: 14px 14px 0;
  background: var(--p2);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.bubble {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 280px;
  min-height: 42px;
  margin-bottom: 15px;
  padding: 9px 12px;
  background: var(--s);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.55;
  text-align: center;
}

.bubble.is-new {
  animation: bubble-pop 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bubble-pop {
  0% {
    transform: translateY(3px) scale(0.985);
    opacity: 0.6;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}

.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  background: var(--s);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}

.ground {
  position: absolute;
  left: 11%;
  right: 11%;
  bottom: 19px;
  border-bottom: 1px dashed var(--line2);
}

.clawd {
  position: relative;
  z-index: 1;
  width: 168px;
  height: auto;
  margin-bottom: 23px;
  transform-origin: 50% 100%;
  animation: idle 4.2s ease-in-out infinite;
}

.eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 7.4s steps(1, end) infinite;
  transition: transform 0.15s ease;
}

.blush {
  opacity: 0;
  transition: opacity 0.2s ease;
}

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

@keyframes blink {
  0%,
  92%,
  96%,
  100% {
    opacity: 1;
  }
  93%,
  95% {
    opacity: 0;
  }
}

.token {
  position: absolute;
  top: 64px;
  right: 30px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  background: var(--clay);
  border-radius: 3px;
  color: #1b1916;
  font-family: var(--mono);
  font-size: 9px;
  opacity: 0;
}

/* JS state classes */

.pet.is-pat .blush {
  opacity: 0.6;
}

.pet.is-pat .clawd {
  animation: pat 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.pet.is-feed .clawd {
  animation: nom 0.8s ease-in-out;
}

.pet.is-feed .token {
  animation: feed 1.15s ease-in both;
}

.pet.is-poke .clawd {
  animation: poke 0.45s ease-in-out;
}

.pet.is-poke .eyes {
  transform: scaleY(0.32);
  animation: none;
}

@keyframes pat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  35% {
    transform: translateY(3px) scale(1.04, 0.94);
  }
  70% {
    transform: translateY(-1px) scale(0.98, 1.02);
  }
}

@keyframes nom {
  0%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
  55% {
    transform: translateY(2px) scale(1.03, 0.97);
  }
}

@keyframes poke {
  0%,
  100% {
    transform: translateX(0) rotate(0);
  }
  20% {
    transform: translateX(-4px) rotate(-1.5deg);
  }
  45% {
    transform: translateX(4px) rotate(1.5deg);
  }
  70% {
    transform: translateX(-2px) rotate(-0.8deg);
  }
}

@keyframes feed {
  0% {
    opacity: 0;
    transform: translate(34px, -18px) rotate(12deg) scale(0.8);
  }
  18% {
    opacity: 1;
  }
  65% {
    opacity: 1;
    transform: translate(0, 90px) rotate(-6deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-2px, 118px) rotate(-10deg) scale(0.6);
  }
}

.pet-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.pet-controls button {
  flex: 1 1 auto;
  padding: 8px 9px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink2);
  font-family: var(--mono);
  font-size: 9.5px;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease,
    color 0.16s ease;
}

.pet-controls button:hover {
  border-color: var(--line2);
  color: var(--ink);
}

.pet-controls button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--p);
}

.pet-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1.6;
}

/* ---------- play ---------- */

.play {
  padding-block: clamp(30px, 4vw, 44px) clamp(48px, 6vw, 80px);
  border-top: 1px solid var(--line);
}

.play-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: 22px;
  align-items: stretch;
}

.game {
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--s);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.game-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.game h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.game-sub {
  margin-top: 2px;
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.03em;
}

.game-hud {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex: 0 0 auto;
}

.game-hud > div {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.hud-num {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}

.game-hud small {
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 8px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 74px;
  padding: 0;
  background: var(--p2);
  border: 1px solid var(--line2);
  border-radius: 8px;
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease,
    color 0.12s ease, transform 0.12s ease;
}

.cell:empty::before {
  content: "200";
  font-size: 11px;
  letter-spacing: 0.04em;
  opacity: 0.28;
}

.cell:hover {
  border-color: var(--clay);
}

.cell:focus-visible {
  outline: 2px solid var(--clay2);
  outline-offset: 2px;
}

.cell.is-bug {
  background: var(--soft);
  border-color: var(--clay);
  color: var(--clay2);
  animation: bug-pop 0.16s ease-out;
}

.cell.is-ok {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
  animation: ok-pop 0.18s ease-out;
}

.cell.is-miss {
  background: var(--soft);
  border-color: var(--clay);
  color: var(--clay2);
  animation: miss 0.2s ease-in-out;
}

@keyframes bug-pop {
  0% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes ok-pop {
  0% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes miss {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-2px);
  }
  70% {
    transform: translateX(2px);
  }
}

.game-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 8px;
  color: var(--p);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease,
    border-color 0.16s ease, transform 0.16s ease;
}

.btn:hover {
  background: var(--clay);
  border-color: var(--clay);
  color: #1b1916;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: default;
  opacity: 0.55;
}

.btn:disabled:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--p);
}

.game-msg {
  color: var(--ink2);
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.6;
}

.game-best {
  margin-top: 10px;
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.02em;
}

/* ---------- api card ---------- */

.api {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 24px;
  background: var(--code);
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--code-ink);
}

[data-theme="dark"] .api {
  border-color: var(--line);
}

.api-tag {
  color: #e8a07e;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.api h2 {
  color: #f6f0e4;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.api p {
  max-width: 28em;
  color: #a89e8f;
  font-size: 12px;
  line-height: 1.75;
}

.api-code {
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--code-line);
  border-radius: 7px;
  color: #f0e9da;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.api-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.api-chips span {
  padding: 4px 8px;
  border: 1px solid var(--code-line);
  border-radius: 6px;
  color: #c9bfae;
  font-family: var(--mono);
  font-size: 8.5px;
}

.api-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: auto;
  padding-top: 4px;
  color: #e8a07e;
  font-size: 11.5px;
}

.api-links a {
  border-bottom: 1px solid rgba(232, 160, 126, 0.35);
  padding-bottom: 1px;
}

.api-links a:hover {
  color: #ffc3a4;
  border-color: #ffc3a4;
}

.api-joke {
  color: #857b6c;
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1.7;
}

/* ---------- footer ---------- */

.foot {
  padding-block: 22px 30px;
  border-top: 1px solid var(--line);
  color: var(--ink3);
  font-size: 10.5px;
}

.foot-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.brand-small {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.brand-small .mark {
  width: 22px;
}

.brand-small b {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-small span {
  color: var(--ink3);
  font-family: var(--mono);
  font-size: 8px;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.foot-links a:hover {
  color: var(--clay2);
}

.foot-legal {
  flex-basis: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 9.5px;
  line-height: 1.7;
}

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .hero-art {
    justify-self: start;
    max-width: 440px;
  }

  .play-grid {
    grid-template-columns: 1fr;
  }

  .api {
    min-height: 250px;
  }
}

@media (max-width: 700px) {
  .hero {
    padding-top: 100px;
  }

  .is-standalone .hero {
    padding-top: 26px;
  }

  .hero h1 {
    font-size: clamp(2.2rem, 9vw, 3rem);
  }

  .brand-tag {
    display: none;
  }

  .pet {
    padding: 13px;
  }

  .pet-stage {
    min-height: 280px;
  }

  .clawd {
    width: 146px;
  }

  .bubble {
    max-width: 100%;
  }

  .game-head {
    align-items: flex-start;
  }

  .game-hud {
    gap: 12px;
  }

  .hud-num {
    font-size: 18px;
  }

  .cell {
    height: 64px;
  }

  .game-foot {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .hero-art {
    max-width: 100%;
  }

  .head-inner {
    min-height: 60px;
  }

  .head-nav {
    gap: 12px;
    font-size: 12px;
  }

  .pet-controls button {
    flex: 1 1 40%;
  }

  .game,
  .api {
    padding: 18px;
  }

  .game-grid {
    gap: 6px;
  }

  .cell {
    height: 58px;
    font-size: 12px;
  }

  .game-foot {
    gap: 10px;
  }

  .game-msg {
    flex-basis: 100%;
  }

  .foot-inner {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
