.letter-shop {
  --shop-ink:#344e2b;
  --shop-line:#b7bc93;
  box-sizing:border-box;
  position:fixed;
  inset:0;
  width:min(362px,calc(100vw - 24px));
  height:fit-content;
  max-height:calc(100dvh - 24px);
  margin:auto;
  padding:0;
  color:var(--shop-ink);
  border:1px solid #788858;
  border-radius:17px 20px 18px 15px;
  background:#fff8e9;
  box-shadow:0 12px 25px #253c2b58, inset 0 0 0 4px #e5ddbd99;
}
.letter-shop[open] { display:flex; flex-direction:column; }
.letter-shop::backdrop { background:#23372288; }
.letter-shop h2,.letter-shop h3,.letter-shop p { margin:0; }
.letter-shop-heading {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-inline:16px;
  min-height:58px;
  border-bottom:1px dashed var(--shop-line);
}
.letter-shop-heading h2 { font:400 29px/1.2 var(--kv-writing,'Kaiti SC',serif); }
.letter-shop-close {
  width:44px;
  height:44px;
  flex:0 0 auto;
  color:var(--shop-ink);
  background:transparent;
  border:0;
  border-radius:50%;
  font:400 29px/1 sans-serif;
}
.letter-shop-content {
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
  padding:10px 15px 4px;
}
.letter-shop-preview {
  display:grid;
  grid-template-columns:minmax(105px,1fr) minmax(120px,1fr);
  gap:11px;
  align-items:center;
  min-height:126px;
  border-radius:10px 12px 10px 13px;
  padding:8px 11px;
  background:#eceacf;
  box-shadow:inset 0 0 0 1px #c0c39b;
}
.letter-shop-sheet { position:relative; width:100%; height:103px; }
.letter-shop-envelope-art {
  display:block;
  position:absolute;
  inset:auto 0 0;
  width:100%;
  height:auto;
  pointer-events:none;
}
.letter-finish-applique { display:block; pointer-events:none; }
.letter-envelope-trim {
  position:absolute;
  inset:auto 1.5% 2%;
  display:block;
  width:97%;
  height:auto;
  pointer-events:none;
}
.letter-shop-sheet > .letter-finish-applique {
  position:absolute;
  inset:auto 7% 37% auto;
  width:32%;
  transform:rotate(6deg);
}
.letter-shop-preview p { font-size:12px; line-height:1.5; }
.letter-shop-preview .letter-shop-wallet {
  display:flex;
  align-items:center;
  gap:4px;
  margin-bottom:5px;
  font-weight:600;
  white-space:nowrap;
}
.letter-shop-wallet strong { font-size:18px; font-variant-numeric:tabular-nums; }
.letter-shop-coin-icon { width:19px; height:19px; flex:0 0 auto; }
.letter-shop-group { margin-top:12px; }
.letter-shop-group h3 { margin-bottom:6px; font-size:14px; line-height:1.2; }
.letter-shop-grid { display:grid; gap:5px; }
.letter-shop-grid-envelope { grid-template-columns:repeat(3,minmax(0,1fr)); }
.letter-shop-grid-decoration { grid-template-columns:repeat(4,minmax(0,1fr)); }
.letter-shop .letter-shop-item {
  display:grid;
  grid-template-rows:35px auto auto;
  justify-items:center;
  min-width:0;
  min-height:77px;
  gap:2px;
  padding:4px 1px;
  color:#41533b;
  background:#fbf6e6;
  border:1px solid #c5c4a4;
  border-radius:7px;
  font:inherit;
  white-space:nowrap;
}
.letter-shop .letter-shop-item[aria-pressed="true"] {
  border-color:#587042;
  color:#314c29;
  background:#e5ebc9;
  box-shadow:inset 0 0 0 1px #718752;
}
.letter-shop-item-art { position:relative; display:block; width:49px; height:34px; isolation:isolate; }
.letter-shop-item-art .letter-finish-applique,
.letter-shop-no-decoration { display:block; width:34px; height:34px; margin-inline:auto; }
.letter-shop-no-decoration { color:#788858; }
.letter-shop-item b { font-size:12px; }
.letter-shop-item small { font-size:11px; }
.letter-shop-footer {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  padding:10px 15px 12px;
}
.letter-shop-footer:empty { display:none; }
.letter-shop-footer button {
  min-height:44px;
  padding:7px 13px;
  color:#fff8e9;
  background:#3b6030;
  border:1px solid #345429;
  border-radius:8px 10px 8px 9px;
  font:600 14px/1.25 var(--kv-label,'PingFang SC',sans-serif);
}
.letter-shop-footer button[data-shop-revert] { background:#f7f2df; color:var(--shop-ink); border-color:#a6ad83; }
.letter-shop-footer button:disabled { color:#4e5a41; background:#dfe1c9; border-color:#b7bea1; }
.letter-shop button:focus-visible { outline:2px solid #607841; outline-offset:2px; }
.letter-shop .letter-shop-status { min-height:22px; margin:0 15px 9px; font-size:12px; }
.letter-shop .letter-shop-status:empty { display:none; }

[data-letter-envelope="amber"] { --letter-filter:sepia(.78) saturate(1.12) hue-rotate(350deg); --letter-paper:#fff2e0; }
[data-letter-envelope="river"] { --letter-filter:sepia(.12) hue-rotate(103deg) saturate(.83); --letter-paper:#eff7f3; }
[data-letter-envelope] :is(.letter-shop-envelope-art,.receive-mail-frame) { filter:var(--letter-filter,none); }
[data-letter-envelope="amber"] :is(.receive-envelope-front,.receive-envelope-flap) { filter:sepia(.36); }
[data-letter-envelope="river"] :is(.receive-envelope-front,.receive-envelope-flap) { filter:sepia(.4) hue-rotate(118deg); }
#game-stage #app .receive-envelope-art > .letter-finish-applique {
  position:absolute;
  top:38px;
  right:24px;
  z-index:2;
  width:42px;
  transform:rotate(6deg);
}
#game-stage #app .receive-envelope-art > .letter-envelope-trim {
  inset:auto 13px 3px;
  width:calc(100% - 26px);
  z-index:1;
}
#game-stage #app .receive-envelope.opening :is(.letter-finish-applique,.letter-envelope-trim) { opacity:0; transition:opacity .18s ease; }
#game-stage #app .receive-read .read-paper.receive-letter-paper[data-letter-envelope] {
  background:linear-gradient(135deg,#e7d8ac3b,transparent 28%),var(--letter-paper,var(--kv-paper,#fff8e9));
}
.receive-letter-paper > .letter-finish-applique { width:52px; margin:8px 2px 0 auto; transform:rotate(7deg); }
.receive-read-pocket > .letter-finish-applique { position:absolute; width:44px; inset:auto auto 10px 15px; z-index:3; }
