:root {
  --pink: #f57890;
  --deep: #50333a;
  --mint: #70b8aa;
  --cream: #fff8f2;
  --card: rgba(255, 255, 255, 0.9);
  --shadow: 0 10px 28px rgba(88, 49, 61, 0.16);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: #f5e9e4;
  color: var(--deep);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--pink);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(245, 120, 144, 0.22);
}

button.secondary {
  background: var(--mint);
}

button.ghost {
  background: rgba(255, 255, 255, 0.85);
  color: var(--deep);
  box-shadow: none;
}

button:disabled {
  opacity: 0.45;
}

.app-shell {
  width: min(100vw, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  background: linear-gradient(180deg, #fff4f7 0%, #fff9f4 100%);
  overflow-x: hidden;
  position: relative;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 0 28px rgba(53, 32, 42, 0.16);
}

.topbar {
  padding: calc(14px + env(safe-area-inset-top)) 14px 10px;
  background: var(--pink);
  color: #fff;
}

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

.title-row h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  font-size: 12px;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat {
  min-width: 0;
  padding: 8px 5px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #84515e;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 11px;
  opacity: 0.72;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  color: var(--pink);
}

.room {
  margin: 12px;
  min-height: 432px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
}

.room::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.25), rgba(255, 238, 226, 0.52));
}

.scene-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
}

.scene-header button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.room-tabs {
  position: relative;
  z-index: 4;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 10px 8px;
  scrollbar-width: none;
}

.room-tabs::-webkit-scrollbar {
  display: none;
}

.room-tab {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #7d5361;
  box-shadow: 0 4px 12px rgba(72, 43, 52, 0.1);
  font-size: 12px;
  white-space: nowrap;
}

.room-tab.active {
  background: var(--pink);
  color: #fff;
}

.bubble {
  position: relative;
  z-index: 3;
  max-width: 78%;
  margin: 4px auto 0;
  padding: 11px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 8px 18px rgba(93, 60, 70, 0.12);
}

.avatar-wrap {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 136px;
  width: 170px;
  min-height: 210px;
  transform: translateX(-50%);
  animation: walk 6s ease-in-out infinite;
}

.avatar-wrap.slow {
  animation-duration: 10s;
}

.outfit-name {
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #8a5360;
  font-size: 11px;
  box-shadow: 0 4px 10px rgba(72, 43, 52, 0.12);
  white-space: nowrap;
}

.avatar-alert,
.cat-alert {
  position: absolute;
  right: 10px;
  top: -4px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #ffcc4d;
  color: #6b3b00;
  font-weight: 900;
  box-shadow: 0 5px 14px rgba(89, 50, 0, 0.2);
}

.avatar {
  width: 100%;
  height: 210px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 10px 12px rgba(83, 52, 46, 0.18));
}

.scene-image {
  position: absolute;
  z-index: 1;
  left: 18px;
  bottom: 126px;
  width: 92px;
  height: 82px;
  object-fit: cover;
  border-radius: 8px;
  opacity: 0.92;
}

.furniture-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

.furniture-layer.editing {
  pointer-events: auto;
}

.furniture-item {
  position: absolute;
  width: 74px;
  height: 62px;
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  transform: translate(-50%, -50%) scale(var(--scale, 1)) scaleX(var(--flip, 1));
  touch-action: none;
  cursor: grab;
}

.furniture-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 7px 8px rgba(70, 44, 38, 0.16));
}

.furniture-layer.editing .furniture-item {
  outline: 1px dashed rgba(245, 120, 144, 0.55);
  background: rgba(255, 255, 255, 0.18);
}

.furniture-item.selected {
  outline: 3px solid rgba(245, 120, 144, 0.9);
  background: rgba(255, 255, 255, 0.3);
}

.vase-flower-display {
  position: absolute;
  z-index: 4;
  left: 48%;
  top: 42%;
  width: 52px;
  height: 52px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 6px 6px rgba(70, 44, 38, 0.18));
}

.room-cat-wrap {
  position: absolute;
  z-index: 3;
  right: 34px;
  bottom: 128px;
  width: 96px;
  height: 92px;
  pointer-events: none;
}

.room-cat-bedroom {
  right: 24px;
  bottom: 154px;
  transform: scale(0.9);
}

.room-cat-kitchen {
  right: 44px;
  bottom: 128px;
  transform: scale(0.86);
}

.room-cat-studyroom {
  right: 48px;
  bottom: 142px;
  transform: scale(0.88);
}

.room-cat-bathroom {
  right: 38px;
  bottom: 136px;
  transform: scale(0.82);
}

.room-cat-balcony {
  right: 42px;
  bottom: 132px;
  transform: scale(0.86);
}

.room-plant-wrap {
  position: absolute;
  z-index: 0;
  left: 12px;
  right: 12px;
  bottom: 116px;
  height: 150px;
  pointer-events: none;
}

.plant-scene {
  position: relative;
  width: 100%;
  height: 100%;
}

.plant-cutout {
  position: absolute;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(62, 54, 42, 0.16));
}

.room-plant-bedroom .plant-floor .plant-cutout.monstera {
  right: 0;
  left: auto;
  bottom: -8px;
  width: 72px;
  height: 92px;
}

.room-plant-balcony .plant-floor .plant-cutout.monstera {
  left: 16px;
  bottom: -6px;
  width: 82px;
  height: 108px;
}

.plant-table {
  position: absolute;
  right: 30px;
  bottom: 64px;
  width: 74px;
  height: 82px;
}

.plant-table .plant-cutout.rose {
  left: 0;
  bottom: 0;
  width: 74px;
  height: 82px;
}

.cat-sprite {
  position: relative;
  width: 92px;
  height: 82px;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 8px rgba(83, 52, 46, 0.2));
}

.cat-sprite-img {
  position: relative;
  width: 108px;
  height: 98px;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 9px rgba(83, 52, 46, 0.22));
}

.cat-sprite-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cat-sprite-img.cat-happy,
.cat-sprite-img.cat-peek {
  animation: catBounce 1.7s ease-in-out infinite;
}

.cat-sprite-img.cat-sad {
  transform: scale(0.96) rotate(-2deg);
}

.cat-sprite-img.cat-hungry {
  transform: scale(1.02);
}

.cat-body,
.cat-head,
.cat-tail,
.cat-paw {
  position: absolute;
  display: block;
  background: #f2a03c;
}

.cat-body {
  left: 20px;
  bottom: 8px;
  width: 55px;
  height: 48px;
  border-radius: 44% 46% 42% 42%;
  background:
    radial-gradient(circle at 34% 40%, #ffc26b 0 16%, transparent 17%),
    radial-gradient(circle at 68% 34%, #de8124 0 10%, transparent 12%),
    #f2a03c;
}

.cat-head {
  left: 22px;
  top: 7px;
  width: 52px;
  height: 45px;
  border-radius: 48% 48% 43% 43%;
  background:
    radial-gradient(circle at 36% 58%, #ffd18b 0 8%, transparent 9%),
    radial-gradient(circle at 66% 58%, #ffd18b 0 8%, transparent 9%),
    linear-gradient(90deg, transparent 0 44%, #df8124 45% 53%, transparent 54%),
    #f3a543;
}

.cat-head::before,
.cat-head::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 12px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 210, 142, 0.62);
}

.cat-head::before {
  left: -6px;
}

.cat-head::after {
  right: -6px;
}

.ear {
  position: absolute;
  top: -5px;
  width: 18px;
  height: 18px;
  border-radius: 70% 30% 70% 30%;
  background: #dc8126;
  transform: rotate(-35deg);
}

.ear.left {
  left: 4px;
}

.ear.right {
  right: 4px;
  transform: rotate(125deg);
}

.eye {
  position: absolute;
  top: 18px;
  width: 8px;
  height: 10px;
  border-radius: 50%;
  background: #c9e759;
  box-shadow: inset 0 0 0 2px #3d4f29;
}

.eye.left {
  left: 15px;
}

.eye.right {
  right: 15px;
}

.nose {
  position: absolute;
  left: 24px;
  top: 30px;
  width: 7px;
  height: 5px;
  border-radius: 50%;
  background: #7d4b32;
}

.mouth {
  position: absolute;
  left: 22px;
  top: 36px;
  width: 12px;
  height: 6px;
  border-bottom: 2px solid #7d4b32;
  border-radius: 0 0 12px 12px;
}

.cat-tail {
  right: 4px;
  bottom: 20px;
  width: 30px;
  height: 16px;
  border-radius: 50%;
  background: #dd8326;
  transform: rotate(-30deg);
}

.cat-paw {
  bottom: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffd08b;
}

.cat-paw.left {
  left: 25px;
}

.cat-paw.right {
  right: 24px;
}

.cat-happy {
  animation: catBounce 1.7s ease-in-out infinite;
}

.cat-sad {
  transform: scale(0.96) rotate(-2deg);
  opacity: 0.88;
}

.cat-hungry .mouth {
  width: 10px;
  height: 8px;
  border: 2px solid #7d4b32;
  border-top: 0;
}

.cat-peek {
  width: 72px;
  height: 66px;
  margin: 0 auto;
  animation: catPop 0.18s ease-out;
}

.cat-sprite-img.cat-peek {
  width: 82px;
  height: 74px;
  margin: 0 auto;
  animation: catPop 0.18s ease-out;
}

.cat-peek .cat-body,
.cat-peek .cat-paw,
.cat-peek .cat-tail {
  display: none;
}

.cat-peek .cat-head {
  left: 10px;
  top: 14px;
}

.mini-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 0 5px rgba(245, 120, 144, 0.14);
}

.side-panels {
  position: absolute;
  z-index: 2;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-card {
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 5px 14px rgba(83, 50, 55, 0.1);
}

.mini-card h3 {
  margin: 0 0 5px;
  font-size: 13px;
}

.mini-card p {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: #7c5c62;
}

.mini-img-row {
  display: flex;
  gap: 7px;
  align-items: center;
}

.mini-img-row img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
}

.status-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -2px 12px 10px;
}

.status-tags span {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #815563;
  font-size: 12px;
  box-shadow: 0 4px 10px rgba(72, 43, 52, 0.08);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0 12px;
}

.tab {
  min-height: 38px;
  background: rgba(255, 255, 255, 0.8);
  color: #805462;
  box-shadow: none;
}

.tab.active {
  background: var(--pink);
  color: #fff;
  box-shadow: 0 6px 14px rgba(245, 120, 144, 0.22);
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px 12px 14px;
}

.utility-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 12px 10px;
}

.utility-row button {
  min-height: 38px;
  font-size: 12px;
}

.modal-mask {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(38, 24, 29, 0.38);
  padding: 16px 10px calc(16px + env(safe-area-inset-bottom));
}

.modal {
  width: min(100%, 430px);
  max-height: min(82dvh, 680px);
  overflow: auto;
  border-radius: 8px;
  background: #fffaf7;
  box-shadow: 0 -10px 30px rgba(40, 25, 30, 0.22);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: #fffaf7;
  border-bottom: 1px solid #f1dfd8;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.modal-head button {
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.modal-body {
  padding: 12px;
}

.modal-body > img.hero {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
}

.modal-body p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.item-card {
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 14px rgba(72, 43, 52, 0.08);
}

.item-card.locked {
  filter: grayscale(1);
  opacity: 0.58;
}

.item-card img {
  width: 100%;
  aspect-ratio: 1 / 0.82;
  object-fit: cover;
  border-radius: 6px;
  background: #f3ece7;
}

.item-card h3 {
  margin: 7px 0 3px;
  font-size: 13px;
}

.item-card p {
  margin: 0 0 8px;
  font-size: 11px;
  color: #7c5c62;
}

.outfit-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.9;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #fff3ec;
  overflow: hidden;
}

.outfit-preview img {
  position: relative;
  z-index: 1;
  width: 86%;
  height: 86%;
  object-fit: contain;
  background: transparent;
}


.option-list {
  display: grid;
  gap: 8px;
}

.option-list button {
  width: 100%;
}

.whack-info {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  color: #7d5361;
  font-weight: 700;
}

.whack-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.whack-hole {
  position: relative;
  display: grid;
  place-items: end center;
  min-height: 92px;
  overflow: hidden;
  background: linear-gradient(180deg, #ffefd6, #d69b63);
  box-shadow: inset 0 -10px 0 rgba(105, 67, 44, 0.16);
}

.whack-hole.active {
  background: linear-gradient(180deg, #fff4dc, #cc8a56);
}

.hole-shadow {
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 7px;
  height: 22px;
  border-radius: 50%;
  background: #6c4b38;
  opacity: 0.38;
}

.whack-hole .cat-sprite,
.whack-hole .cat-sprite-img {
  z-index: 1;
}

.blackjack-table {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.blackjack-hand {
  padding: 12px;
  border-radius: 8px;
  background: #fff7f0;
  border: 1px solid rgba(246, 128, 150, 0.2);
}

.blackjack-hand h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.playing-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.playing-card {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 58px;
  border-radius: 7px;
  background: #fff;
  color: #34303a;
  border: 1px solid rgba(50, 45, 55, 0.16);
  box-shadow: 0 6px 12px rgba(90, 70, 65, 0.12);
  font-weight: 800;
  font-size: 15px;
}

.playing-card.red {
  color: #e64f6a;
}

.hidden-card {
  background: repeating-linear-gradient(45deg, #f57890 0, #f57890 6px, #ffb1bf 6px, #ffb1bf 12px);
  color: #fff;
}

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

@keyframes catPop {
  from { transform: translateY(24px) scale(0.9); }
  to { transform: translateY(0) scale(1); }
}

@keyframes walk {
  0%, 100% { transform: translateX(-56%); }
  50% { transform: translateX(-42%); }
}

@media (max-width: 360px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .room {
    min-height: 410px;
  }

  .avatar-wrap {
    width: 148px;
  }
}
