:root {
  --bg: #fdf6e9;
  --panel: #fffdf8;
  --accent: #8fc7b0;
  --accent-dark: #4f8f78;
  --ink: #3b3a36;
  --soft: #f1e6cf;
  --char: clamp(120px, 24vh, 180px);
  --shelf: clamp(96px, min(24vh, 26vw), 220px);
  --shadow: 0 4px 14px rgba(80, 70, 50, 0.12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#app {
  min-height: 100dvh;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.topbar { display: flex; justify-content: flex-end; }
.coins {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border-radius: 32px; padding: 8px 20px;
  font-size: 32px; box-shadow: var(--shadow);
}
.scene { display: flex; align-items: center; gap: 20px; }
.customer { font-size: clamp(64px, 14vh, 120px); line-height: 1; flex: 0 0 auto; }
.bubble {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 32px;
  background: var(--panel); border-radius: 40px; padding: 24px 32px;
  box-shadow: var(--shadow); min-height: 220px;
}
.bubble-char { font-size: var(--char); line-height: 1.1; min-height: 120px; white-space: nowrap; text-align: center; }
.bubble-side { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.bubble-row { display: flex; align-items: center; gap: 16px; }
.bubble-picture { font-size: 96px; line-height: 1; min-width: 96px; text-align: center; }
.pic-slot { position: relative; min-width: 96px; min-height: 96px; display: flex; align-items: center; justify-content: center; }
.pic-slot .hint-btn { position: absolute; inset: 0; margin: auto; }
.pinyin { font-size: 36px; color: var(--accent-dark); }
.btn {
  border: none; background: var(--soft); color: var(--ink);
  min-width: 64px; min-height: 64px; border-radius: 28px;
  font: inherit; font-size: 36px; cursor: pointer; box-shadow: var(--shadow);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: default; }
.round-btn { width: 72px; height: 72px; padding: 0; border-radius: 50%; }
.hint-btn { min-width: 96px; min-height: 96px; font-size: 52px; background: #fbeab8; }
.shelf { display: flex; justify-content: center; gap: 28px; flex-wrap: wrap; }
.shelf-item {
  width: var(--shelf); height: var(--shelf); font-size: calc(var(--shelf) * 0.55); line-height: 1;
  background: #f3e9d2; border: 3px solid #e3d5b6; border-radius: 36px; /* darker than the page so white pictures (白色, 白云) stay visible */
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.shelf-item.in-bag { opacity: 0.25; transform: scale(0.8); }
.bag {
  align-self: center; min-height: 96px; display: flex; align-items: center; gap: 12px;
  background: var(--soft); border-radius: 36px; padding: 8px 28px; font-size: 56px;
}
.bag-item { font-size: 56px; animation: drop 0.5s ease-out; }
@keyframes drop { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
.closed { margin: auto; text-align: center; padding: 40px; }
.closed-emoji { font-size: 120px; }
.closed-text { font-size: 40px; line-height: 1.4; }
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(253, 246, 233, 0.92); animation: fade 0.6s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  background: var(--panel); border-radius: 40px; padding: 32px 40px;
  box-shadow: var(--shadow); text-align: center; max-width: 90%;
}
.overlay-title { font-size: 40px; margin: 0 0 16px; }
.arrival-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-bottom: 24px; }
.arrival-item {
  font-size: 96px; line-height: 1; min-width: 120px; min-height: 120px; padding: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--soft); border-radius: 28px;
}
.ok-btn { min-width: 96px; min-height: 80px; background: var(--accent); }
@media (orientation: portrait) {
  .scene { flex-direction: column; }
  .customer { font-size: 96px; }
}
@media (max-width: 620px) {
  .bubble { flex-direction: column; gap: 12px; padding: 16px; }
  /* Phones only: two characters must fit the bubble (width minus app and bubble padding), floor 80px. */
  .bubble-char { font-size: clamp(80px, min(20vh, calc((100vw - 96px) / 2.2)), 180px); }
}
@media (max-height: 480px) {
  :root { --char: 120px; --shelf: 96px; }
  #app { padding: 8px 16px; gap: 8px; }
  .scene { flex-direction: row; gap: 12px; }
  .customer { font-size: 64px; }
  .bubble { min-height: 0; padding: 8px 24px; gap: 20px; }
  .bubble-char { font-size: 120px; line-height: 1.05; min-height: 120px; }
  .bubble-picture { font-size: 72px; min-width: 72px; }
  .pic-slot { min-width: 96px; min-height: 80px; }
  .pinyin { font-size: 24px; }
  .shelf { gap: 16px; flex-wrap: nowrap; }
  .bag { min-height: 64px; padding: 4px 20px; font-size: 40px; }
  .bag-item { font-size: 40px; }
  .topbar { position: fixed; right: 16px; bottom: 8px; }
  .coins { font-size: 24px; padding: 4px 14px; }
}
.start { margin: auto; }
.start-btn { width: 160px; height: 160px; font-size: 96px; border-radius: 48px; background: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .bag-item, .overlay { animation: none; }
  .shelf-item { transition: none; }
}
.topbar { align-items: center; gap: 16px; }
.shop-btn { width: 72px; height: 72px; padding: 0; border-radius: 50%; background: var(--accent); }
.decor-row { flex: 1; display: flex; gap: 12px; align-items: center; justify-content: center; font-size: 48px; line-height: 1; min-height: 56px; pointer-events: none; }
.drawer { z-index: 10; }
.drawer-card { width: min(900px, 94%); max-height: 94dvh; overflow: auto; }
.drawer-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.drawer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.decor-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; min-height: 120px; background: var(--panel); border-radius: 28px; }
.decor-emoji { font-size: 64px; line-height: 1; }
.decor-price { font-size: 28px; display: flex; gap: 6px; }
.decor-card.owned { background: var(--soft); }
.decor-card.dim .decor-emoji { opacity: 0.4; }
@media (max-width: 620px) { .drawer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-height: 480px) {
  .topbar { position: fixed; left: 16px; right: 16px; bottom: 8px; justify-content: space-between; pointer-events: none; }
  .topbar .btn, .topbar .coins { pointer-events: auto; }
  .shop-btn { width: 64px; height: 64px; font-size: 32px; }
  .decor-row { font-size: 28px; min-height: 64px; gap: 0 4px; flex-wrap: wrap; align-content: center; justify-content: flex-start; flex: 0 1 160px; margin-right: auto; }
  .drawer-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .decor-card { min-height: 80px; padding: 4px; }
  .decor-emoji { font-size: 40px; }
  .decor-price { font-size: 20px; }
  .drawer-card { padding: 12px 16px; }
  .drawer-top { margin-bottom: 8px; }
}

/* Chinese text: simplified-Chinese fonts first, so an English-locale browser does not
   pick Japanese or Traditional glyph shapes. */
:lang(zh) { font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Source Han Sans SC", system-ui, sans-serif; }

@media (max-height: 480px) {
  .overlay-card.delivery { padding: 12px 24px; }
  .delivery .overlay-title { font-size: 28px; margin-bottom: 8px; }
  .delivery .arrival-list { gap: 12px; margin-bottom: 12px; flex-wrap: nowrap; }
  .delivery .arrival-item { font-size: 96px; min-width: 112px; min-height: 112px; padding: 8px; }
  .delivery .ok-btn { min-height: 64px; }
}

/* Gate: small, quiet, out of the way */
.gear {
  position: fixed; bottom: 0; right: 0; z-index: 5;
  width: 56px; height: 56px; padding: 0; border: none; background: transparent;
  font-size: 16px; line-height: 1; opacity: 0.18; cursor: default;
  touch-action: none; -webkit-touch-callout: none;
  user-select: none; -webkit-user-select: none;
}
@media (max-height: 480px) { .gear { bottom: auto; top: 0; } }

/* Parent screen: ordinary readable text, big targets */
.parent {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto; background: var(--bg);
  padding: 16px 24px 32px; user-select: text; -webkit-user-select: text; font-size: 20px; line-height: 1.4;
}
.ptop { display: flex; justify-content: space-between; align-items: center; gap: 16px; max-width: 860px; margin: 0 auto 16px; }
.phead { font-size: 32px; margin: 0; }
.pbody { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.psection { background: var(--panel); border-radius: 24px; padding: 20px 24px; box-shadow: var(--shadow); }
.ptitle { font-size: 24px; margin: 0 0 12px; }
.pnote { margin: 12px 0 0; color: #6b675c; font-size: 18px; }
.pform { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.pfield { display: flex; flex-direction: column; gap: 4px; flex: 1 1 160px; }
.plabel { font-size: 18px; }
.pinput {
  font: inherit; font-size: 24px; min-height: 64px; padding: 8px 16px; border-radius: 16px;
  border: 2px solid #cfc3a6; background: #fff; color: var(--ink); width: 100%;
}
.pbtn {
  font: inherit; font-size: 20px; min-width: 64px; min-height: 64px; padding: 8px 24px; border-radius: 20px;
  border: none; background: var(--soft); color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
}
.pbtn:active { transform: scale(0.97); }
.pbtn.primary { background: var(--accent); }
.pbtn.danger { background: #f1b8a8; }
.pbtn.toggle.on { background: var(--accent); }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; }
.prow.wrap { flex-wrap: wrap; justify-content: flex-start; }
.pselect { width: auto; min-width: 0; flex: 1; max-width: 100%; }
.pmsg { margin: 12px 0 0; font-size: 18px; }
.pmsg.err { color: #a3361f; }
.pmsg.ok { color: var(--accent-dark); }
.pconfirm { margin-top: 12px; padding: 12px 16px; background: var(--soft); border-radius: 16px; }
.plist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; }
.pitem { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.pchar { font-size: 36px; min-width: 44px; text-align: center; }
.pemoji { font-size: 28px; }
.ppinyin { flex: 1; color: #6b675c; }
.pstage { white-space: nowrap; }
.pitem .pbtn { min-width: 64px; padding: 8px 12px; font-size: 16px; }
@media (max-width: 700px) { .plist { grid-template-columns: 1fr; } }
@media (max-height: 480px) {
  .parent { padding: 8px 16px 24px; }
  .psection { padding: 12px 16px; }
}

.parent:focus { outline: none; }
.pnote.storage { color: #a3361f; }
.plist { grid-template-columns: 1fr; }
.pitem { flex-wrap: wrap; }
.pitem.hidden-char .pchar, .pitem.hidden-char .pemoji { opacity: 0.4; }
.pinline { display: inline-flex; gap: 8px; flex-wrap: wrap; }
