:root {
  --orange: #FF8A3D;
  --orange-deep: #F26E1F;
  --gold: #F7B733;
  --cream: #FFF8EE;
  --ink: #4A2E1E;
  --ink-soft: #6E4B33;
  --muted: #8E6C51;
  --line: rgba(205, 155, 105, 0.2);
  --shadow: 0 12px 30px rgba(150, 90, 40, 0.14);
  --sheet-overlap: clamp(64px, 12dvh, 112px);
}

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

html {
  min-height: 100%;
  background: #F3E0CB;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: #F3E0CB;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
}

button {
  padding: 0;
  border: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  position: relative;
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: linear-gradient(180deg, #FFF4E5 0%, #FFF9F1 48%, #FFEEDB 100%);
  overflow: hidden;
  isolation: isolate;
}

@media (min-width: 520px) {
  body {
    background:
      radial-gradient(circle at 50% 8%, #FFF1DE 0%, #F1D8BC 46%, #E4C6A6 100%);
  }
  .app {
    min-height: min(920px, 100dvh);
    border-radius: 0 0 30px 30px;
    box-shadow: 0 30px 80px rgba(112, 65, 28, 0.28);
  }
}

/* ---------- scene ---------- */

.stage {
  position: relative;
  height: 62vh;
  height: clamp(360px, 62dvh, 560px);
  overflow: hidden;
  background: #EAD3B8;
  isolation: isolate;
  touch-action: manipulation;
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  z-index: 0;
}

.fade-top,
.fade-left,
.fade-right,
.fade-bottom {
  position: absolute;
  pointer-events: none;
  z-index: 2;
}

.fade-top {
  inset: 0 0 auto 0;
  height: 20%;
  min-height: 78px;
  background: linear-gradient(180deg,
    rgba(255, 247, 237, 0.99) 0%,
    rgba(255, 247, 237, 0.97) 45%,
    rgba(255, 247, 237, 0.62) 78%,
    rgba(255, 247, 237, 0) 100%);
}

.fade-left {
  inset: 0 auto 0 0;
  width: 11%;
  background: linear-gradient(90deg, rgba(255, 246, 235, 0.5) 0%, rgba(255, 246, 235, 0) 100%);
}

.fade-right {
  inset: 19% 0 auto auto;
  width: 25%;
  height: 46%;
  background: radial-gradient(ellipse at 100% 50%,
    rgba(255, 245, 232, 0.99) 0%,
    rgba(255, 245, 232, 0.95) 38%,
    rgba(255, 245, 232, 0.6) 70%,
    rgba(255, 245, 232, 0) 100%);
}

.fade-bottom {
  inset: auto 0 0 0;
  height: 70px;
  background: linear-gradient(180deg,
    rgba(255, 243, 228, 0) 0%,
    rgba(255, 243, 228, 0.55) 70%,
    rgba(255, 243, 228, 0.92) 100%);
}

/* ---------- top hud ---------- */

.hud {
  position: absolute;
  z-index: 5;
  top: calc(10px + env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.profile,
.wallet {
  display: flex;
  align-items: center;
  pointer-events: auto;
  background: rgba(255, 251, 245, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 7px 18px rgba(119, 69, 33, 0.18);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.profile {
  gap: 9px;
  padding: 6px 13px 6px 6px;
  border-radius: 22px;
  min-width: 0;
}

.avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  overflow: hidden;
  background: #F6E5D1;
  box-shadow: 0 0 0 2px #FFF, 0 3px 9px rgba(120, 70, 30, 0.2);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.p-meta {
  display: block;
  min-width: 0;
}

.p-line {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.p-name {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.lv {
  flex: none;
  padding: 3px 6px;
  border-radius: 7px;
  background: linear-gradient(180deg, #FFC46B, #FF9B3D);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 5px rgba(226, 125, 36, 0.32);
}

.lv b {
  font-size: 10px;
}

.xp-track {
  display: block;
  width: 76px;
  height: 5px;
  margin-top: 5px;
  border-radius: 99px;
  background: #F2E1CD;
  overflow: hidden;
}

.xp-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFC15E, #FF8A3D);
  transition: width 0.4s ease;
}

.wallet {
  gap: 6px;
  padding: 5px 12px 5px 7px;
  border-radius: 18px;
}

.coin {
  width: 30px;
  height: 30px;
  flex: none;
  filter: drop-shadow(0 2px 3px rgba(180, 110, 15, 0.25));
}

.wallet-txt {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.wallet-txt b {
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-txt small {
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* ---------- mood ---------- */

.mood {
  position: absolute;
  z-index: 4;
  top: 18.2%;
  left: 50%;
  width: min(62%, 252px);
  height: 32px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 250, 246, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: 0 6px 16px rgba(126, 55, 62, 0.2);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.mood-ico {
  width: 25px;
  height: 25px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #FF7FA3;
  background: #FFE6ED;
}

.mood-ico .mp-icon {
  width: 15px;
  height: 15px;
}

.mood-track {
  flex: 1;
  height: 9px;
  border-radius: 99px;
  background: #F9DFE5;
  overflow: hidden;
}

.mood-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFB4C8, #FF6E95);
  transition: width 0.38s ease;
}

.mood-num {
  min-width: 21px;
  text-align: right;
  font-size: 10px;
  font-weight: 900;
  color: #B84867;
  font-variant-numeric: tabular-nums;
}

/* ---------- petting ---------- */

.pet-zone {
  position: absolute;
  z-index: 3;
  left: 18%;
  top: 25%;
  width: 64%;
  height: 54%;
  border-radius: 44% 44% 34% 34%;
}

.pet-zone:active {
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 68%);
}

.pet-hint {
  position: absolute;
  z-index: 4;
  top: 67%;
  right: 5%;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.93);
  border: 1px solid #FFE1C2;
  color: #B0662A;
  font-size: 10.5px;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(140, 80, 30, 0.16);
  pointer-events: none;
  animation: hintBob 2.4s ease-in-out infinite;
}

.pet-hint .mp-icon {
  width: 13px;
  height: 13px;
}

.pet-hint.hide {
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.3s, transform 0.3s;
  animation: none;
}

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

/* ---------- floating effects ---------- */

.fx {
  position: absolute;
  inset: 0;
  z-index: 7;
  overflow: hidden;
  pointer-events: none;
}

.float {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  place-items: center;
  opacity: 0;
  animation: floatUp 0.95s cubic-bezier(0.16, 0.8, 0.36, 1) forwards;
  will-change: transform, opacity;
}

.float .mp-icon {
  width: 24px;
  height: 24px;
}

.float.hearts {
  color: #FF6E96;
  filter: drop-shadow(0 2px 4px rgba(190, 60, 100, 0.18));
}

.float.food {
  color: #E98A2D;
  filter: drop-shadow(0 2px 4px rgba(150, 90, 25, 0.16));
}

.float.coin img {
  width: 23px;
  height: 23px;
  filter: drop-shadow(0 2px 3px rgba(180, 110, 15, 0.24));
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 2px) scale(0.55); }
  18% { opacity: 1; transform: translate(-50%, -6px) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), -64px) scale(1.12); }
}

/* ---------- level up ---------- */

.levelup {
  position: absolute;
  z-index: 9;
  top: 47%;
  left: 50%;
  padding: 11px 24px;
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(0.78);
  background: linear-gradient(180deg, #FFF9EC, #FFE2AE);
  border: 2px solid #FFF0CF;
  color: #8A470F;
  font-size: 17px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 12px 30px rgba(193, 111, 32, 0.3), inset 0 1px 0 #FFF;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 1.5, 0.4, 1);
}

.levelup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ---------- bottom sheet ---------- */

.sheet {
  position: relative;
  z-index: 6;
  margin-top: calc(-1 * var(--sheet-overlap));
  min-height: calc(100vh - clamp(360px, 62vh, 560px) + var(--sheet-overlap));
  min-height: calc(100dvh - clamp(360px, 62dvh, 560px) + var(--sheet-overlap));
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: linear-gradient(180deg, #FFF9F1 0%, #FFF4E6 55%, #FFEEDB 100%);
  box-shadow:
    0 -14px 40px rgba(126, 70, 30, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(130px 76px at 92% 2%, rgba(255, 191, 122, 0.24), transparent 72%),
    radial-gradient(180px 110px at 2% 36%, rgba(255, 245, 228, 0.95), transparent 70%);
}

.grip {
  width: 40px;
  height: 5px;
  margin: 2px auto 0;
  border-radius: 999px;
  background: #E8D2B9;
}

/* ---------- idle card ---------- */

.idle-card {
  position: relative;
  padding: 13px 14px 11px;
  border-radius: 22px;
  background: linear-gradient(145deg, #FFFDF8 0%, #FFF6E7 56%, #FFEFD5 100%);
  border: 1px solid rgba(255, 198, 133, 0.62);
  box-shadow:
    0 10px 24px rgba(214, 143, 63, 0.14),
    inset 0 1px 0 #FFF;
  overflow: hidden;
}

.idle-card::after {
  content: "";
  position: absolute;
  right: -36px;
  top: -52px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 199, 107, 0.34), rgba(255, 199, 107, 0) 70%);
  pointer-events: none;
}

.idle-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.idle-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.title-ico {
  width: 27px;
  height: 27px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #FFF;
  background: linear-gradient(150deg, #FFB45C, #FF8433);
  box-shadow: 0 4px 10px rgba(255, 132, 51, 0.34);
}

.title-ico .mp-icon {
  width: 16px;
  height: 16px;
}

.rate {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #B06924;
  background: #FFF0D1;
  border: 1px solid #FFDDAB;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.rate .mp-icon {
  width: 12px;
  height: 12px;
}

.idle-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
}

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

.coin-big {
  width: 36px;
  height: 36px;
  flex: none;
  filter: drop-shadow(0 3px 5px rgba(186, 115, 18, 0.24));
}

.pending-txt {
  display: block;
  min-width: 0;
}

.pending-txt b {
  display: block;
  font-size: 31px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #57331C;
  font-variant-numeric: tabular-nums;
}

.pending-txt small {
  display: block;
  margin-top: 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: #8E6C51;
  letter-spacing: 0.03em;
}

.collect {
  flex: none;
  min-width: 104px;
  height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(180deg, #FFAA4F 0%, #FF802A 56%, #F26F1B 100%);
  color: #FFF;
  font-size: 15px;
  font-weight: 900;
  box-shadow:
    0 8px 16px rgba(240, 110, 30, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.2s ease;
}

.collect .mp-icon {
  width: 19px;
  height: 19px;
}

.collect:active {
  transform: scale(0.95) translateY(1px);
  filter: brightness(1.06);
}

.collect:disabled {
  opacity: 0.42;
  filter: saturate(0.55);
  box-shadow: none;
}

.idle-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(205, 158, 108, 0.32);
  color: #8E6C51;
  font-size: 10px;
  font-weight: 600;
}

.idle-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.idle-meta .mp-icon {
  width: 12px;
  height: 12px;
  flex: none;
}

.idle-meta b {
  color: #846046;
  font-weight: 800;
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 16px;
  background: rgba(255, 252, 246, 0.9);
  border: 1px solid rgba(224, 193, 157, 0.48);
  box-shadow: 0 4px 12px rgba(170, 110, 60, 0.06);
}

.stat-ico {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.stat-ico .mp-icon {
  width: 17px;
  height: 17px;
}

.stat.food .stat-ico {
  color: #F08A2E;
  background: #FFE9D2;
}

.stat.love .stat-ico {
  color: #F2658D;
  background: #FFE3EA;
}

.stat-body {
  flex: 1;
  min-width: 0;
}

.stat-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #977257;
}

.stat-line b {
  font-size: 12px;
  font-weight: 900;
  color: #5C3B25;
  font-variant-numeric: tabular-nums;
}

.stat .track {
  height: 7px;
  margin-top: 5px;
  border-radius: 99px;
  background: #F2E5D7;
  overflow: hidden;
}

.stat .track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 0.38s ease;
}

.stat.food .track i {
  background: linear-gradient(90deg, #FFCF7C, #FF9D3B);
}

.stat.love .track i {
  background: linear-gradient(90deg, #FFAFC5, #FF6F95);
}

/* ---------- actions ---------- */

.actions {
  display: grid;
  grid-template-columns: 1fr 1.16fr;
  gap: 10px;
}

.act {
  height: 56px;
  padding: 0 12px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.act:active {
  transform: scale(0.965);
}

.act-ico {
  width: 31px;
  height: 31px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
}

.act-ico .mp-icon {
  width: 18px;
  height: 18px;
}

.act-txt {
  display: block;
  min-width: 0;
}

.act-txt b {
  display: block;
  font-size: 13.5px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
}

.act-txt small {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 600;
  opacity: 0.78;
  white-space: nowrap;
}

.act.ghost {
  color: #A75B22;
  background: #FFF9F0;
  border: 1.5px solid #FFD2A2;
  box-shadow: 0 5px 12px rgba(200, 130, 60, 0.1);
}

.act.ghost .act-ico {
  color: #F0782A;
  background: #FFEBD5;
}

.act.primary {
  color: #FFF;
  background: linear-gradient(180deg, #FFAA4F 0%, #FF802A 58%, #F4711C 100%);
  box-shadow:
    0 9px 18px rgba(240, 110, 30, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.act.primary .act-ico {
  color: #FFF;
  background: rgba(255, 255, 255, 0.22);
}

.act.shake {
  animation: shake 0.36s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ---------- whisper ---------- */

.whisper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 1px 4px;
  color: #8B684D;
}

.whisper img {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: #F6E5D1;
  box-shadow: 0 0 0 1.5px #FFF, 0 2px 6px rgba(130, 80, 40, 0.14);
}

.whisper p {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.45;
  color: #8B684D;
}

/* ---------- tip / toast ---------- */

.tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0;
  padding-bottom: 2px;
  color: #8E6C51;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.tip .mp-icon {
  width: 12px;
  height: 12px;
  flex: none;
}

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: calc(100% - 48px);
  padding: 10px 16px;
  border-radius: 999px;
  transform: translate(-50%, 14px);
  background: rgba(63, 38, 22, 0.93);
  color: #FFF7EC;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 10px 24px rgba(60, 30, 10, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

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

/* ---------- compact phones ---------- */

@media (max-height: 720px) {
  .hud {
    top: calc(8px + env(safe-area-inset-top));
  }
  .avatar {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }
  .profile {
    padding: 5px 11px 5px 5px;
  }
  .sheet {
    gap: 10px;
    padding-top: 7px;
  }
  .idle-card {
    padding: 11px 13px 10px;
  }
  .pending-txt b {
    font-size: 27px;
  }
  .collect {
    height: 44px;
    min-width: 96px;
  }
  .act {
    height: 52px;
  }
  .tip {
    font-size: 9.5px;
  }
}

@media (min-height: 800px) {
  .sheet {
    gap: 15px;
    padding-top: 10px;
  }
  .idle-card {
    padding: 16px 16px 13px;
  }
  .pending-txt b {
    font-size: 34px;
  }
  .stat {
    padding: 11px 12px;
  }
  .act {
    height: 60px;
  }
  .idle-meta {
    margin-top: 10px;
    padding-top: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pet-hint {
    animation: none;
  }
  .float {
    animation-duration: 0.5s;
  }
  .levelup,
  .collect,
  .act,
  .mood-track i,
  .xp-track i {
    transition: none;
  }
}
