:root {
  --bg: #f7f1e8;
  --card: #fffaf1;
  --card-2: #ffe7c0;
  --ink: #493327;
  --muted: #80685c;
  --orange: #ff9f3f;
  --teal: #62c8b8;
  --pink: #ff94b5;
  --purple: #9b82d8;
  --shadow: rgba(73, 51, 39, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 8%, rgba(255, 148, 181, 0.1), transparent 18%),
    radial-gradient(circle at 88% 6%, rgba(98, 200, 184, 0.1), transparent 18%),
    var(--bg);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

button {
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: 16px;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--shadow);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  touch-action: manipulation;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: 1px 1px 0 var(--shadow);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 38px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
  line-height: 1.2;
}

.hidden {
  display: none !important;
}

.app,
.start-screen,
.home-screen,
.game-screen {
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
}

.app {
  min-height: 100vh;
}

.start-screen,
.home-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 10px 10px 16px;
}

.panel {
  max-width: 100%;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 55%),
    linear-gradient(180deg, var(--card), var(--card-2));
  box-shadow: 3px 3px 0 var(--shadow);
}

.start-card,
.home-card {
  width: 100%;
  padding: 16px 12px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.start-artwork {
  width: 100%;
  height: 350px;
  margin: 6px 0 10px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background:
    linear-gradient(rgba(255, 250, 241, 0.08), rgba(255, 250, 241, 0.08)),
    url("assets/backgrounds/start-bg.png") center 48% / cover no-repeat;
  background:
    linear-gradient(rgba(255, 250, 241, 0.08), rgba(255, 250, 241, 0.08)),
    image-set(
      url("assets/backgrounds/start-bg.webp") type("image/webp"),
      url("assets/backgrounds/start-bg.png") type("image/png")
    ) center 48% / cover no-repeat;
}

.home-subtitle {
  margin: 0 0 3px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.home-welcome {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.home-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: rgba(255, 250, 241, 0.72);
}

.home-hero-art {
  height: 250px;
  background:
    linear-gradient(rgba(255, 250, 241, 0.04), rgba(255, 250, 241, 0.08)),
    url("assets/backgrounds/start-bg.png") center 45% / cover no-repeat;
  background:
    linear-gradient(rgba(255, 250, 241, 0.04), rgba(255, 250, 241, 0.08)),
    image-set(
      url("assets/backgrounds/start-bg.webp") type("image/webp"),
      url("assets/backgrounds/start-bg.png") type("image/png")
    ) center 45% / cover no-repeat;
}

.home-crew {
  position: absolute;
  right: 10px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  padding: 4px 8px;
  border: 1.5px solid rgba(73, 51, 39, 0.35);
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.82);
  font-size: 18px;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.home-stats div {
  min-width: 0;
  padding: 7px 4px;
  border: 1.5px solid rgba(73, 51, 39, 0.3);
  border-radius: 13px;
  background: rgba(255, 250, 241, 0.75);
}

.home-stats span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-stats strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  line-height: 1;
}

.home-actions {
  display: grid;
  gap: 8px;
}

.home-feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.feature-btn {
  min-height: 44px;
  padding: 8px 6px;
  background: rgba(98, 200, 184, 0.9);
  font-size: 13px;
}

.start-crew {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 22px;
}

.start-actions {
  display: grid;
  width: min(220px, 100%);
  margin: 0 auto;
}

.primary-btn {
  min-height: 50px;
  padding: 10px 14px;
  background: var(--orange);
  font-size: 16px;
}

.secondary-btn {
  min-height: 44px;
  padding: 8px 10px;
  background: var(--teal);
  font-size: 13px;
}

.game-screen {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-height: 100vh;
  padding: 10px 10px 106px;
}

.back-home-btn {
  min-height: 34px;
  padding: 5px 10px;
  justify-self: start;
  width: auto;
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.85);
  color: var(--muted);
  font-size: 12px;
}

.resource-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  min-height: 60px;
  padding: 6px;
}

.resource-pill {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  grid-template-rows: 15px 21px;
  align-items: center;
  min-width: 0;
  padding: 5px 4px;
  border: 1.5px solid rgba(73, 51, 39, 0.32);
  border-radius: 13px;
  background: rgba(255, 250, 241, 0.82);
}

.resource-pill span:first-child {
  grid-column: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-icon {
  grid-row: 1 / 3;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
}

.resource-icon .safe-image,
.resource-icon img {
  width: 20px;
  height: 20px;
}

.resource-pill strong {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-panel,
.service-panel,
.selection-panel,
.action-bar {
  padding: 9px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.customer-panel {
  min-height: 160px;
  max-height: 175px;
}

.customer-main {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
}

.avatar {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #ffe4ef;
}

.avatar .safe-image,
.avatar img {
  width: 100%;
  height: 100%;
}

.muted-text {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.3;
}

.need-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.need-tags span {
  padding: 2px 7px;
  border: 1.5px solid rgba(73, 51, 39, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.stress-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 5px;
  font-size: 13px;
  font-weight: 900;
}

.stress-track {
  height: 16px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff1df;
}

.stress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--orange));
  transition: width 700ms ease;
}

.event-notice {
  min-height: 24px;
  margin-top: 7px;
  padding: 4px 8px;
  border: 1.5px solid rgba(73, 51, 39, 0.22);
  border-radius: 12px;
  background: rgba(255, 250, 241, 0.68);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.service-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 182px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 250, 241, 0.04), rgba(255, 250, 241, 0.24)),
    url("assets/backgrounds/massage-room.png") center 56% / cover no-repeat;
  background:
    linear-gradient(rgba(255, 250, 241, 0.04), rgba(255, 250, 241, 0.24)),
    image-set(
      url("assets/backgrounds/massage-room.webp") type("image/webp"),
      url("assets/backgrounds/massage-room.png") type("image/png")
    ) center 56% / cover no-repeat;
}

.service-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.service-title strong {
  max-width: 66%;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-scene {
  position: relative;
  min-height: 110px;
}

.scene-bed {
  position: absolute;
  left: 34px;
  right: 66px;
  bottom: 8px;
  height: 50px;
  border: 2px solid var(--ink);
  border-radius: 24px;
  background: rgba(243, 210, 160, 0.9);
  box-shadow: inset 0 -6px 0 rgba(184, 121, 67, 0.14);
}

.scene-pillow {
  position: absolute;
  left: 16px;
  top: -17px;
  width: 48px;
  height: 24px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--pink);
}

.stage-customer {
  position: absolute;
  left: 26px;
  bottom: 8px;
  z-index: 2;
  display: grid;
  width: 92px;
  height: 72px;
  place-items: center;
}

.stage-employee {
  position: absolute;
  right: 8px;
  bottom: 12px;
  z-index: 3;
  display: grid;
  width: 68px;
  height: 76px;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 17px;
  background: rgba(255, 250, 241, 0.76);
}

.stage-customer .safe-image,
.stage-customer img,
.stage-employee .safe-image,
.stage-employee img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.stage-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.is-serving .stage-employee {
  animation: massage-bounce 0.82s ease-in-out infinite;
}

.is-serving .stage-customer {
  animation: relax-float 1.25s ease-in-out infinite;
}

.is-serving.item-aroma .service-scene::after {
  position: absolute;
  left: 26px;
  bottom: 72px;
  width: 42px;
  height: 54px;
  content: "";
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 75%, rgba(255, 255, 255, 0.7), transparent 36%),
    radial-gradient(circle at 34% 48%, rgba(155, 130, 216, 0.34), transparent 32%),
    radial-gradient(circle at 66% 26%, rgba(98, 200, 184, 0.34), transparent 34%);
  opacity: 0.75;
  pointer-events: none;
  animation: steam-float 1.6s ease-in-out infinite;
}

.is-serving.item-hot-towel .scene-bed {
  animation: pulse-glow 1.2s ease-in-out infinite;
}

.is-serving.item-comb .stage-employee {
  animation: comb-sway 0.78s ease-in-out infinite;
}

.service-status-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px 8px;
  border: 1.5px solid rgba(73, 51, 39, 0.28);
  border-radius: 12px;
  background: rgba(255, 250, 241, 0.82);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.service-status-bar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-status-bar strong {
  color: var(--ink);
}

.selection-panel {
  overflow: hidden;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  padding: 2px;
}

.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  height: 112px;
  min-height: 112px;
  padding: 6px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: rgba(255, 250, 241, 0.92);
  text-align: center;
}

.choice-card.selected {
  border-color: var(--teal);
  background: #e2fbf5;
  box-shadow: 0 0 0 2px var(--teal), 3px 3px 0 var(--shadow);
  transform: scale(1.02);
}

.checkmark {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.choice-art {
  display: grid;
  width: 100%;
  height: 54px;
  flex: 0 0 54px;
  margin-bottom: 4px;
  place-items: center;
  overflow: hidden;
  border: 1.5px solid rgba(73, 51, 39, 0.22);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.45);
}

.choice-art .safe-image,
.choice-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#itemList .choice-card {
  height: 98px;
  min-height: 98px;
}

#itemList .choice-art {
  height: 42px;
  flex-basis: 42px;
}

.choice-card strong {
  display: block;
  overflow: hidden;
  margin-bottom: 3px;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-card p {
  display: block;
  width: 100%;
  overflow: hidden;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag,
.selected-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 19px;
  padding: 1px 5px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: #ffe5ee;
  font-size: 10px;
  font-weight: 900;
}

.selected-badge {
  margin-top: 2px;
  background: var(--teal);
}

.action-bar {
  position: fixed;
  bottom: 6px;
  left: 50%;
  width: min(370px, calc(100% - 20px));
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 7px;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.action-bar .primary-btn {
  grid-column: 1 / -1;
  min-height: 46px;
  font-size: 16px;
}

.action-bar .secondary-btn {
  min-height: 38px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(73, 51, 39, 0.22);
  animation: fade-in 180ms ease;
}

.app-modal-card {
  width: min(360px, calc(100% - 24px));
  max-height: min(82vh, 620px);
  overflow: hidden;
  padding: 14px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
}

.modal-close-btn {
  width: auto;
  min-height: 34px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.8);
  color: var(--muted);
  font-size: 12px;
}

.app-modal-body {
  max-height: 68vh;
  overflow-y: auto;
}

.book-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.book-card,
.upgrade-card,
.reward-card,
.setting-row {
  border: 1.5px solid rgba(73, 51, 39, 0.3);
  border-radius: 14px;
  background: rgba(255, 250, 241, 0.78);
}

.book-card {
  min-width: 0;
  padding: 8px;
  text-align: center;
}

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

.book-avatar {
  display: grid;
  width: 72px;
  height: 64px;
  margin: 0 auto 6px;
  place-items: center;
  overflow: hidden;
}

.book-avatar .safe-image,
.book-avatar img {
  width: 100%;
  height: 100%;
}

.book-card strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.upgrade-card,
.reward-card {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.upgrade-card p,
.reward-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding: 10px;
  font-weight: 900;
}

.setting-row input {
  width: 22px;
  height: 22px;
}

.danger-btn {
  background: var(--pink);
}

.settlement-card {
  width: min(340px, calc(100% - 24px));
  padding: 22px;
  text-align: center;
}

.reward-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 18px;
}

.reward-list div {
  padding: 9px;
  border: 1.5px solid rgba(73, 51, 39, 0.28);
  border-radius: 13px;
  background: rgba(255, 250, 241, 0.76);
  font-weight: 900;
  animation: reward-pop 240ms ease both;
}

.safe-image {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
  border-radius: inherit;
}

.safe-image img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.fallback-icon {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: inherit;
  background: rgba(255, 250, 241, 0.72);
  font-size: 26px;
}

.image-loading .fallback-icon {
  color: rgba(73, 51, 39, 0.55);
}

.image-placeholder {
  user-select: none;
}

.image-fallback {
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 196, 207, 0.38), transparent 34%),
    rgba(255, 250, 241, 0.78);
}

@keyframes massage-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px) rotate(-1deg);
  }
}

@keyframes relax-float {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-3px) scale(1.015);
  }
}

@keyframes steam-float {
  0% {
    transform: translateY(8px) scale(0.92);
    opacity: 0.28;
  }
  50% {
    opacity: 0.78;
  }
  100% {
    transform: translateY(-10px) scale(1.08);
    opacity: 0.18;
  }
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: inset 0 -6px 0 rgba(184, 121, 67, 0.14), 0 0 0 rgba(255, 159, 63, 0);
  }
  50% {
    box-shadow: inset 0 -6px 0 rgba(184, 121, 67, 0.14), 0 0 16px rgba(255, 159, 63, 0.42);
  }
}

@keyframes comb-sway {
  0%, 100% {
    transform: translateX(0) rotate(0deg);
  }
  35% {
    transform: translateX(-3px) rotate(-2deg);
  }
  70% {
    transform: translateX(3px) rotate(2deg);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes reward-pop {
  from {
    transform: scale(0.94);
  }
  to {
    transform: scale(1);
  }
}

@media (min-width: 431px) {
  .app,
  .start-screen,
  .home-screen,
  .game-screen {
    max-width: 430px;
  }
}

@media (max-width: 360px) {
  .game-screen {
    gap: 8px;
    padding: 8px 8px 104px;
  }

  .resource-bar {
    gap: 4px;
  }

  .resource-pill {
    grid-template-columns: 18px minmax(0, 1fr);
    padding: 4px 3px;
  }

  .resource-icon,
  .resource-icon .safe-image,
  .resource-icon img {
    width: 18px;
    height: 18px;
  }

  .service-panel {
    height: 178px;
  }

  .stage-customer {
    left: 26px;
    width: 88px;
  }

  .stage-employee {
    right: 6px;
    width: 66px;
  }
}
