:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ink: #382e35;
  --muted: #8b7682;
  --rose: #c45c82;
  --rose-dark: #9d3e66;
  --panel: rgb(255 255 255 / 76%);
  --line: rgb(112 73 91 / 12%);
  --sprite-scale: 1;
  --pet-x: 0px;
  --pet-y: 0px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f9eef1;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  overscroll-behavior: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 520px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgb(255 255 255 / 88%) 0 7%, transparent 30%),
    linear-gradient(165deg, #fffaf8 0%, #fbe8ee 46%, #f4d8e5 100%);
}

.topbar {
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 75%);
  border-radius: 14px;
  color: #b24670;
  background: rgb(255 255 255 / 68%);
  box-shadow: 0 8px 22px rgb(141 66 96 / 12%);
  font-size: 22px;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.08em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.install-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgb(255 255 255 / 75%);
  border-radius: 999px;
  color: var(--rose-dark);
  background: rgb(255 255 255 / 72%);
  box-shadow: 0 8px 24px rgb(124 62 87 / 10%);
  font-size: 13px;
  font-weight: 700;
}

.install-button:active,
.action-button:active,
.primary-button:active {
  transform: scale(0.96);
}

.pet-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(1px);
  pointer-events: none;
}

.orb-one {
  top: 12%;
  right: -42px;
  width: 150px;
  height: 150px;
  background: rgb(164 124 198 / 10%);
}

.orb-two {
  bottom: 8%;
  left: -36px;
  width: 116px;
  height: 116px;
  background: rgb(247 179 81 / 12%);
}

.speech {
  position: absolute;
  z-index: 3;
  top: 8%;
  left: 50%;
  max-width: min(72%, 270px);
  padding: 9px 15px;
  transform: translateX(-50%);
  border: 1px solid rgb(255 255 255 / 88%);
  border-radius: 18px 18px 18px 7px;
  color: #725362;
  background: rgb(255 255 255 / 78%);
  box-shadow: 0 10px 30px rgb(123 61 88 / 10%);
  font-size: 13px;
  text-align: center;
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(16px);
}

.speech.is-changing {
  opacity: 0;
  transform: translate(-50%, 5px);
}

.pet-shell {
  position: absolute;
  z-index: 2;
  top: 55%;
  left: 50%;
  width: calc(192px * var(--sprite-scale));
  height: calc(208px * var(--sprite-scale));
  transform: translate(-50%, -50%) translate(var(--pet-x), var(--pet-y));
  cursor: grab;
  touch-action: none;
  will-change: transform;
}

.pet-shell.is-dragging {
  cursor: grabbing;
}

.pet-hit-area {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.pet-hit-area:focus-visible {
  border-radius: 34%;
  outline: 3px solid rgb(179 65 109 / 35%);
  outline-offset: 5px;
}

.pet-sprite {
  display: block;
  width: 100%;
  height: 100%;
  background-image: url("assets/huayang.webp");
  background-repeat: no-repeat;
  image-rendering: auto;
  pointer-events: none;
  filter: drop-shadow(0 16px 14px rgb(78 40 58 / 13%));
}

.ground-glow {
  position: absolute;
  z-index: 1;
  right: 16%;
  bottom: 1%;
  left: 16%;
  height: 10%;
  border-radius: 50%;
  background: rgb(117 63 84 / 10%);
  filter: blur(10px);
  pointer-events: none;
}

.stage-hint {
  position: absolute;
  right: 20px;
  bottom: 6px;
  left: 20px;
  margin: 0;
  color: rgb(111 86 98 / 66%);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: center;
  pointer-events: none;
}

.control-panel {
  z-index: 5;
  margin: 8px 12px calc(12px + env(safe-area-inset-bottom));
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgb(95 49 69 / 16%);
  backdrop-filter: blur(22px) saturate(1.12);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.action-button {
  display: grid;
  min-width: 0;
  min-height: 54px;
  padding: 7px 2px 5px;
  place-items: center;
  border: 0;
  border-radius: 17px;
  color: #8c6878;
  background: transparent;
  transition: transform 120ms ease, color 160ms ease, background 160ms ease;
}

.action-button > span {
  font-size: 19px;
  line-height: 1;
}

.action-button small {
  margin-top: 4px;
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button.is-active {
  color: var(--rose-dark);
  background: linear-gradient(145deg, rgb(255 235 241 / 94%), rgb(249 213 227 / 72%));
  box-shadow: inset 0 0 0 1px rgb(181 70 110 / 8%);
}

.size-control {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 8px 8px 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.size-control input {
  width: 100%;
  accent-color: var(--rose);
}

.install-guide {
  width: min(calc(100% - 32px), 390px);
  padding: 0;
  border: 1px solid rgb(255 255 255 / 78%);
  border-radius: 28px;
  color: var(--ink);
  background: rgb(255 250 251 / 97%);
  box-shadow: 0 28px 80px rgb(62 29 44 / 28%);
}

.install-guide::backdrop {
  background: rgb(60 38 50 / 28%);
  backdrop-filter: blur(5px);
}

.install-guide form {
  position: relative;
  padding: 26px 24px 22px;
  text-align: center;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: #f6e9ed;
  font-size: 22px;
}

.guide-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 4px auto 14px;
  place-items: center;
  border-radius: 18px;
  color: white;
  background: linear-gradient(145deg, #da7c9d, #a74670);
  font-size: 28px;
  box-shadow: 0 12px 28px rgb(155 56 94 / 24%);
}

.install-guide h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.install-guide p,
.install-guide ol {
  color: #775f6b;
  font-size: 14px;
  line-height: 1.7;
  text-align: left;
}

.install-guide ol {
  padding-left: 22px;
}

.primary-button {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 15px;
  color: white;
  background: linear-gradient(135deg, #c85e84, #a13f68);
  font-weight: 700;
  box-shadow: 0 12px 24px rgb(156 56 94 / 20%);
}

.toast {
  position: fixed;
  z-index: 20;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: calc(100% - 40px);
  padding: 10px 16px;
  transform: translate(-50%, 14px);
  border-radius: 999px;
  color: white;
  background: rgb(61 45 53 / 88%);
  opacity: 0;
  pointer-events: none;
  font-size: 12px;
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(10px);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-height: 650px) {
  .topbar {
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .speech {
    top: 2%;
  }

  .control-panel {
    margin-top: 4px;
    padding: 9px;
  }

  .action-button {
    min-height: 46px;
  }

  .size-control {
    margin-top: 4px;
    padding-top: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
