:root {
  color-scheme: light;
  --ink: #193650;
  --muted: #4f667a;
  --action: #255984;
  --action-hover: #17466d;
  --line: #d5e4ee;
  --sky: #e7f2fa;
  --sun: #ffe09a;
  --page: #f6fafc;
  --serif: "Songti SC", "Noto Serif CJK SC", "STSong", SimSun, serif;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; overflow: hidden; overscroll-behavior: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p, figure { margin: 0; }
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid #1b679f; outline-offset: 4px; }
[tabindex="-1"]:focus { outline: none; }

.spark {
  display: inline-block;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  background: #e8b755;
  clip-path: polygon(50% 0, 61% 37%, 100% 50%, 61% 63%, 50% 100%, 39% 63%, 0 50%, 39% 37%);
}

.title-first { font-size: .72em; letter-spacing: -.024em; }

.title-mark {
  position: relative;
  isolation: isolate;
  color: var(--action);
}

.title-mark::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: auto -2% .035em -2%;
  height: .225em;
  border-radius: 54% 45% 38% 48%;
  background: #ffdf93;
  transform: rotate(-3deg);
}

.button {
  display: inline-flex;
  min-height: 48px;
  padding: 10px 19px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 12px;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  line-height: 1.3;
  touch-action: manipulation;
  transition: background .16s, border-color .16s, box-shadow .16s, transform .16s;
}

.button:active:not(:disabled) { transform: translateY(1px); }
.primary { background: var(--action); color: #fff; box-shadow: 0 4px 10px #1e518420; }
.primary:hover:not(:disabled) { background: var(--action-hover); }
.primary:disabled { background: #e6eef5; color: #526b81; box-shadow: none; }
.secondary { border-color: #b9d0e4; background: #ffffffa6; color: var(--action); }
.secondary:hover:not(:disabled) { background: #fff; border-color: #91b5d5; }

.store { position: absolute; inset: 0; }

.store-window {
  position: absolute;
  overflow: hidden;
  inset: 15% 9% 12% 8%;
  border: 1px solid #94bada;
  border-radius: 22px 22px 11px 11px;
  background:
    repeating-linear-gradient(90deg, transparent 0 24%, #f8fdffab 24% 24.6%, transparent 24.6% 25%),
    linear-gradient(154deg, #c0dcec 8%, #e8f6fe 53%, #c6e1f2 105%);
  box-shadow: inset 0 8px 34px #6e9aba45;
}

.store-window::before {
  content: "";
  position: absolute;
  inset: 14% 8% 0;
  border: 1px solid #fafcffbc;
  border-radius: 65% 65% 0 0;
  background: linear-gradient(180deg, #ffffff1c, #f6fcff90);
}

.awning {
  position: absolute;
  z-index: 3;
  display: flex;
  inset: 6% 5.5% auto 4.5%;
  height: 19.5%;
  padding: 0 1%;
  filter: drop-shadow(0 6px 6px #33536b24);
}

.awning i {
  flex: 1;
  height: 100%;
  border-bottom: 1px solid #85b2d3;
  border-radius: 0 0 48% 48% / 0 0 24% 24%;
  background: linear-gradient(#c0d8ef, #a7c9e6 76%, #91b9da 77%);
}

.awning i:nth-child(even) { background: linear-gradient(#fdfefe, #f2f7f9 76%, #dceaf1 77%); }
.awning i:first-child { border-top-left-radius: 20px; }
.awning i:last-child { border-top-right-radius: 20px; }

.shopkeeper {
  position: absolute;
  z-index: 2;
  object-fit: contain;
  left: 15%;
  bottom: 15%;
  width: 38%;
  height: auto;
  filter: drop-shadow(0 8px 10px #265e6d29);
}

.counter {
  position: absolute;
  z-index: 3;
  inset: auto 3% 6% 3%;
  height: 12%;
  border: 1px solid #a7c5df;
  border-radius: 6px 6px 13px 13px;
  background:
    linear-gradient(180deg, #e3f4fc 7%, #bfddec 12% 24%, #0000 25%),
    repeating-linear-gradient(90deg, #b9d5ec 0 42px, #c6def0 42px 43px, #b7d3ea 43px 45px);
  box-shadow: 0 12px 15px #3b68851e, inset 0 -3px #a3c5e27a;
}

.scene-spark { position: absolute; z-index: 1; background: #ffe7a5; }
.scene-spark-a { width: 25px; height: 25px; top: 30%; left: 11%; transform: rotate(-9deg); }
.scene-spark-b { width: 15px; height: 15px; top: 31%; left: 51%; }
.scene-spark-c { width: 14px; height: 14px; top: 55%; right: 8%; background: #fff8db; }

.sample-card {
  position: absolute;
  z-index: 4;
  bottom: 10%;
  right: 8%;
  width: 34%;
  max-width: 174px;
  padding: 5px 5px 0;
  border: 1px solid #d4e3ed;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 8px 20px #2d5f8435, 0 1px 1px #2d5f8440;
  transform: rotate(8deg);
}

.sample-card::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 34%;
  top: -7px;
  width: 33%;
  height: 13px;
  background: #ffe7a5ec;
  clip-path: polygon(0 0, 96% 4%, 100% 95%, 4% 100%);
  transform: rotate(-13deg);
}

.sample-print { aspect-ratio: 3 / 4; background: #e6f2fa; }
.sample-print img { width: 100%; height: auto; }
img:not([src]) { visibility: hidden; }
.sample-card figcaption { padding: 4px 0 5px; text-align: center; color: #52687b; font-size: .75rem; font-weight: 650; line-height: 1.2; }

.packing-panel { width: min(100%, 346px); text-align: center; }
.packing-panel h2 { margin-top: 19px; font-family: var(--serif); font-size: clamp(1.55rem, 4.5vw, 2rem); letter-spacing: -.035em; }
.packing-scene { position: relative; isolation: isolate; height: 231px; }
.packing-bag, .packing-mouth { position: absolute; left: 50%; width: 167px; transform: translateX(-50%); }

.packing-mouth {
  z-index: -1;
  top: 102px;
  height: 34px;
  border: 1px solid #79a4ca;
  border-radius: 50%;
  background: #729fc6;
}

.packing-handle {
  position: absolute;
  z-index: -2;
  top: 67px;
  left: calc(50% - 38px);
  width: 76px;
  height: 56px;
  border: 4px solid #84acce;
  border-bottom: 0;
  border-radius: 48% 48% 0 0;
}

.packing-bag {
  top: 115px;
  height: 115px;
  border: 1px solid #82aace;
  border-radius: 3px 3px 20px 20px;
  background: linear-gradient(115deg, #d1e6f7, #a6c9e6 78%);
  box-shadow: inset -12px -8px 0 #7eabd02e, 0 13px 19px #38699225;
}

.packing-fold {
  height: 21px;
  border-bottom: 1px dashed #789ebc;
  border-radius: 3px 3px 9px 9px;
  background: #dff0fa;
  transform-origin: top;
  animation: fold-bag 420ms 890ms both;
}

.packing-products img {
  position: absolute;
  top: 3px;
  left: calc(50% + var(--offset));
  width: 62px;
  height: 62px;
  object-fit: contain;
  animation: drop-gift 650ms var(--delay) both;
}

.packing-seal {
  position: absolute;
  display: grid;
  place-content: center;
  top: 23px;
  left: calc(50% - 30px);
  width: 60px;
  height: 60px;
  border: 1px solid #dbb96d;
  border-radius: 50%;
  outline: 1px dashed #b18a38;
  outline-offset: -5px;
  color: #594618;
  background: #ffe6a3;
  font-size: .8375rem;
  font-weight: 800;
  line-height: 1.2;
  animation: stamp 480ms 1350ms both;
}

.stamp-helper { position: absolute; top: 92px; left: calc(50% + 58px); width: 91px; height: 91px; object-fit: contain; filter: drop-shadow(0 5px 5px #23456427); animation: helper 520ms 1120ms both; }
.pack-spark { position: absolute; background: #e5b95e; animation: glint 440ms 1480ms both; }
.pack-spark-a { left: 21%; top: 38%; }
.pack-spark-b { right: 15%; top: 29%; width: 21px; height: 21px; }

@keyframes drop-gift {
  from { transform: translate(-50%, -10px) rotate(var(--tilt)); opacity: 0; }
  23% { opacity: 1; }
  76% { opacity: 1; }
  to { transform: translate(-50%, 122px) rotate(0) scale(.66); opacity: 0; }
}
@keyframes fold-bag { from { transform: rotateX(-120deg); } to { transform: rotateX(0); } }
@keyframes stamp {
  from { transform: scale(1.6) rotate(-19deg); opacity: 0; }
  60% { transform: scale(.94) rotate(-10deg); opacity: 1; }
  to { transform: scale(1) rotate(-9deg); opacity: 1; }
}
@keyframes helper {
  from { transform: translate(34px, 12px) rotate(14deg); opacity: 0; }
  to { transform: translate(0, 0) rotate(-8deg); opacity: 1; }
}
@keyframes glint { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}

.app {
  --inset: clamp(14px, 4.5vw, 23px);
  width: min(100%, 490px);
  height: 100vh;
  height: 100dvh;
  height: var(--visual-height, 100dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  margin-inline: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: radial-gradient(ellipse at 55% 20%, #fff 2%, #f6fafc 46%, #e6f1f8 100%);
}

.site-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding-inline: var(--inset);
  border-bottom: 1px solid #d5e4ee;
  background: #f6fafcd9;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 750;
  letter-spacing: .045em;
  white-space: nowrap;
}
.brand img { width: 27px; height: 27px; object-fit: contain; }
.header-button {
  display: grid;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  background: transparent;
  border: 0;
  color: var(--action);
  font-weight: 750;
  touch-action: manipulation;
}
.back-button { padding: 0; width: 44px; margin-left: -11px; font-size: 2rem; line-height: 1; }
.share-link { margin-left: auto; margin-right: -8px; font-size: .82rem; white-space: nowrap; }
.stage { min-width: 0; min-height: 0; }
.screen {
  height: 100%;
  display: grid;
  min-width: 0;
  min-height: 0;
  gap: 10px;
  gap: clamp(8px, 1.65dvh, 15px);
  padding: 12px var(--inset);
  padding: clamp(10px, 2.3dvh, 24px) var(--inset) clamp(12px, 2.4dvh, 26px);
}
.screen-heading { text-align: center; }
.screen-heading h2 {
  font: 900 clamp(1.55rem, 6.9vw, 2.15rem)/1.15 var(--serif);
  letter-spacing: -.025em;
}
.screen-heading p, .screen-note { color: var(--muted); font-size: .86rem; line-height: 1.45; }
.screen-heading p { margin-top: 5px; }
.screen-note { text-align: center; }
.button { min-height: 47px; padding: 7px 9px; font-size: .94rem; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions > .button { min-width: 0; }
.actions > #native-poster { grid-column: 1 / -1; }

.home-screen { grid-template-rows: auto minmax(0, 1fr) auto; }
.intro { align-self: center; text-align: center; }
.intro h1 {
  font: 900 clamp(2.8rem, 12vw, 4rem)/1.02 var(--serif);
  letter-spacing: -.045em;
}
.hero-copy { margin-top: 11px; color: var(--muted); font-size: .96rem; line-height: 1.4; }
.hero-art {
  display: grid;
  container-type: size;
  min-height: 0;
  place-items: center;
}
.shop-scene {
  position: relative;
  width: min(100%, 53vh);
  width: min(100cqw, 137cqh);
  aspect-ratio: 1.37;
}
.home-actions { grid-template-columns: minmax(0, 1fr); }
.home-actions .primary { min-height: 53px; }

.pick-screen { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.product-grid {
  display: grid;
  grid-template: repeat(2, minmax(0, 1fr)) / repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 2vw, 10px);
  min-height: 0;
}
.product-card {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  justify-items: center;
  align-items: center;
  min-width: 0;
  min-height: 0;
  padding: 5px 4px 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #ffffffd9;
  box-shadow: 0 3px 9px #3057750c;
  color: var(--ink);
  text-align: center;
  touch-action: manipulation;
}
.product-card[aria-pressed="true"] { border-color: #6799bf; box-shadow: inset 0 0 0 1px #6799bf; background: #f7fcff; }
.product-photo {
  container-type: size;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  background: var(--item-tint);
}
.product-photo img {
  width: min(77%, 72px);
  width: min(78cqw, 90cqh, 115px);
  height: auto;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px #273e5620);
}
.product-name { margin-top: 6px; font-size: clamp(.73rem, 3.4vw, 1rem); font-weight: 800; line-height: 1.17; }
.product-detail { margin-top: 4px; color: var(--muted); font-size: clamp(.625rem, 2.6vw, .79rem); line-height: 1.16; }
.product-toggle {
  position: absolute;
  inset: 8px 7px auto auto;
  display: grid;
  width: 21px;
  height: 21px;
  place-content: center;
  border: 1px solid #b9d0e4;
  border-radius: 50%;
  color: var(--action);
  background: #fff;
  font-size: .95rem;
  line-height: 1;
}
.product-toggle::before { content: "+"; }
.product-card[aria-pressed="true"] .product-toggle { border-color: var(--action); background: var(--action); color: #fff; }
.product-card[aria-pressed="true"] .product-toggle::before { content: "✓"; font-size: .77rem; }

.bag-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f8fcff;
}
.bag-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 6px; }
.bag-heading h3 { font-size: .83rem; line-height: 1.2; }
.bag-count { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.bag-count strong { color: var(--action); }
.bag-slots { grid-column: 2; grid-row: 1 / 3; display: flex; gap: 3px; }
.bag-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(32px, 10vw, 44px);
  height: 44px;
  padding: 2px;
  border: 1px dashed #b4c9dc;
  border-radius: 7px;
  background: #ecf5fb;
  color: var(--action);
  touch-action: manipulation;
}
.bag-slot:not(:disabled) { border-style: solid; background: #fff; }
.bag-slot img { width: 29px; height: 29px; object-fit: contain; }
.slot-remove { position: absolute; top: 1px; right: 3px; font-size: .7rem; line-height: 1; }
.shop-message { min-block-size: 2.5em; color: var(--muted); font-size: .73rem; line-height: 1.25; }

.packing-screen { place-items: center; }
.result-screen { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.save-screen { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.share-screen { grid-template-rows: auto minmax(0, 1fr) auto; }
.poster-frame, .share-art {
  min-height: 0;
  display: grid;
  place-items: center;
}
.poster-frame img, .share-art img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
.nickname-field, .share-copy {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.nickname-field label { font-size: .82rem; font-weight: 750; white-space: nowrap; }
.nickname-field label span { color: var(--muted); font-size: .75rem; font-weight: 500; }
.nickname-field input, .share-copy input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 7px 9px;
  border: 1px solid #b9d0e4;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}
.share-copy { grid-template-columns: minmax(0, 1fr) max-content; }
.share-controls { display: grid; gap: 8px; }
.share-status { color: var(--action); font-size: .8rem; line-height: 1.3; text-align: center; }
.share-status:empty { display: none; }

.app[data-screen="capture"] { grid-template-rows: minmax(0, 1fr); background: #f5ebd9; }
.app[data-screen="capture"] .site-header { display: none; }
.capture-screen { padding: 0; }
.capture-image {
  border: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: transparent;
  touch-action: manipulation;
}
.capture-image img { width: 100%; height: 100%; object-fit: contain; }

@media (min-width: 491px) {
  body { background: #dceaf3; }
  .app { box-shadow: 0 0 42px #21456222; }
}
@media (max-height: 625px) {
  .screen { gap: 8px; }
  .intro h1 { font-size: clamp(2.5rem, 10vw, 3.15rem); }
  .product-name { margin-top: 4px; }
  .product-detail { margin-top: 3px; }
}
@media (min-width: 550px) and (max-height: 500px) {
  .app { width: min(100%, 690px); }
  .site-header { min-height: 46px; }
  .screen { padding-block: 8px; }
  .home-screen { grid-template: 1fr auto / 1fr 1fr; align-items: center; }
  .home-screen .hero-art { grid-column: 2; grid-row: 1 / 3; height: 100%; }
  .result-screen, .save-screen { grid-template: auto minmax(0, 1fr) auto / 1fr 1fr; }
  .result-screen .poster-frame, .save-screen .poster-frame { grid-area: 1 / 2 / 4 / 3; }
  .result-screen .nickname-field, .save-screen .screen-note { align-self: center; }
  .share-screen { grid-template: 1fr 1fr / 1fr 1fr; align-items: center; }
  .share-art { grid-area: 1 / 2 / 3 / 3; height: 100%; }
  .share-controls { align-self: start; }
  .pick-screen { grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr) 140px; }
  .pick-screen .screen-heading { grid-column: 1 / -1; }
  .product-grid { grid-row: 2 / 4; }
  .bag-dock { grid-template-columns: 1fr; grid-template-rows: auto auto auto; align-self: end; }
  .bag-slots { grid-column: 1; grid-row: auto; }
  .bag-slot { width: min(100%, 37px); }
}
@media (max-width: 549px) and (max-height: 415px) {
  .result-screen .screen-heading p { display: none; }
}
