.game-shell:is([data-view="mail"], [data-view="bag"], [data-view="guide"], [data-view="profile"], [data-view="friends"]) {
  width: min(100%, 52rem);
  padding-inline: 0;
  background: #f5e9d9;
  box-shadow: 0 0 65px #271c1726;
}

.game-shell[data-view="bag"] { width: min(100%, 40rem); }

body:has(.game-shell:not([hidden]):is([data-view="mail"], [data-view="bag"], [data-view="guide"], [data-view="profile"], [data-view="friends"])) {
  background: linear-gradient(155deg, #f8efe4, #e8d8c7);
}

.collection-page {
  --font-title: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  --collection-ink: #4b3026;
  --collection-muted: #77563e;
  --collection-line: #c69b736d;
  --collection-surface: linear-gradient(145deg, #fffaf0, #f3e3cf);
  --collection-gutter: clamp(10px, 4vw, 24px);
  display: flex;
  flex-direction: column;
  gap: clamp(9px, 2.5vw, 13px);
  padding: max(10px, var(--top)) max(var(--collection-gutter), var(--safe-right))
    max(12px, var(--bottom)) max(var(--collection-gutter), var(--safe-left));
  background: radial-gradient(ellipse at 15% 0%, #fffaf3, transparent 67%), linear-gradient(150deg, #f7eddf, #ead9c7);
  color: var(--collection-ink);
}

.collection-heading-bar {
  flex: none;
  margin: 0;
  padding-block: 2px 5px;
}

.collection-heading-bar :is(h1, h2) {
  gap: clamp(6px, 3vw, 13px);
  font-size: clamp(21px, 5.5vw, 30px);
  letter-spacing: .09em;
}

.collection-heading-bar .player-back .icon { width: 20px; height: 20px; }

.collection-tabs {
  display: grid;
  flex: none;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--collection-line);
  border-top-color: #fff8ec;
  border-radius: 7px 15px;
  background: linear-gradient(145deg, #e8d3b9, #fcf0df);
  box-shadow: inset 0 1px 2px #90664038;
}

.collection-tabs button {
  min-width: 0;
  min-height: 39px;
  padding: 4px 2px;
  border: 1px solid transparent;
  border-radius: 5px 11px;
  background: transparent;
  color: #684632;
  font-size: clamp(12px, 3.5vw, 14px);
  font-weight: 700;
}

.collection-tabs button[aria-pressed="true"] {
  border-color: #a47753;
  border-top-color: #edc896;
  background: linear-gradient(153deg, #875b3f, #634231);
  box-shadow: inset 0 0 0 1px #ffedcf3d;
  color: #fff5e5;
}

.collection-page :is(button, [tabindex="0"]):focus-visible {
  outline: 2px solid #885630;
  outline-offset: -2px;
}

.mail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  gap: clamp(9px, 2vw, 14px);
}

.mail-layout[data-split] { grid-template-columns: minmax(0, .8fr) minmax(0, 1.4fr); }

.mail-inbox,
.mail-reader {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--collection-line);
  border-top-color: #fffcf4;
  border-radius: 9px 19px;
  background: var(--collection-surface);
  box-shadow: inset 0 0 0 1px #fff9ee, 1px 3px 5px #976a4324;
  overflow: hidden;
}

.mail-reader { background: linear-gradient(145deg, #f5eadd, #ead9c5); }

.mail-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: clamp(7px, 2vw, 11px) clamp(7px, 2vw, 11px) 0;
}

.mail-list {
  display: grid;
  align-content: start;
  flex: 1;
  min-height: 0;
  gap: 6px;
  margin: 0;
  padding: clamp(7px, 2vw, 11px);
  list-style: none;
  overflow: auto;
  overscroll-behavior: contain;
}

.mail-list:empty { padding: 0; flex: 0 1 auto; }

.mail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 5px 9px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #c9a58488;
  border-top-color: #fffdf7;
  border-radius: 6px 14px;
  background: #fff9ee;
  color: var(--collection-ink);
  text-align: start;
}

.mail-row[aria-pressed="true"] {
  border-color: #c19467;
  background: linear-gradient(125deg, #fff3de, #f1d5b4);
  box-shadow: inset 0 0 0 1px #fff8e8ae;
}

.mail-row strong {
  grid-area: 1 / 1;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: clamp(13px, 3.75vw, 15px);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.mail-row small,
.mail-row-meta {
  color: var(--collection-muted);
  font-size: 12px;
  line-height: 1.25;
}

.mail-row small { grid-area: 2 / 1; }
.mail-row small.mail-waiting-reward { color: #884521; font-weight: 800; }
.mail-row-meta { grid-area: 1 / 2; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.mail-row-flags { display: inline-flex; align-items: center; gap: 4px; }
.mail-row-flags .icon { width: 12px; height: 12px; fill: #e7b66b; color: #9c643d; }
.mail-unread { width: 7px; height: 7px; border-radius: 50%; background: #bb523e; }

.mail-empty {
  display: grid;
  flex: 1;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 13px;
  color: var(--collection-muted);
  text-align: center;
}

.mail-empty-art { width: min(55%, 166px); height: auto; opacity: .68; }
.mail-empty p { margin: 0; overflow-wrap: anywhere; }
.mail-empty button { padding-inline: 16px; }
.mail-inbox-actions,
.mail-receipt {
  display: flex;
  justify-content: center;
  flex: none;
  gap: 7px;
  padding: 8px;
  border-top: 1px solid var(--collection-line);
  background: #f8ead8cc;
}

.collection-page :is(.player-dialog-action, .nickname-cancel) { font-size: 13px; margin: 0; }
.collection-page .nickname-cancel:enabled, .collection-dialog-actions .nickname-cancel:enabled { border-top-color: #c6a17f; }
.mail-inbox-actions button { flex: 1 1 0; }
.collection-page :is(.player-dialog-action, .nickname-cancel):disabled {
  border-color: #c9ad92;
  background: #edddc7;
  color: #795e49;
  text-shadow: none;
}

.mail-detail { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mail-letter-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: clamp(11px, 3vw, 21px); }
.mail-letter-heading { padding-bottom: 8px; border-bottom: 1px solid var(--collection-line); }
.mail-letter-heading h3 {
  margin: 0 0 6px;
  font: 750 clamp(18px, 5vw, 26px)/1.35 var(--font-title);
  overflow-wrap: anywhere;
}

.mail-letter-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.mail-letter-meta > span { display: flex; flex-wrap: wrap; gap: 3px 8px; color: var(--collection-muted); font-size: 12px; }
.mail-letter-tools { display: flex; flex: none; gap: 5px; }
.mail-letter-tools button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #caa5879e;
  border-top-color: #fff9ef;
  border-radius: 6px 11px;
  background: #fff5e6;
}

.mail-letter-tools .icon { width: 16px; height: 16px; }
.mail-letter-tools button[aria-pressed="true"] { background: #f5dab0; color: #91552d; }
.mail-letter-tools button[aria-pressed="true"] .icon { fill: #e7b467; }
.mail-letter {
  margin: 12px 0 0;
  padding: clamp(13px, 4vw, 24px);
  border: 1px solid #cfb18a;
  border-top-color: #fffaf0;
  border-radius: 6px 12px;
  background: #fff4db url("assets/mailbox-stationery.webp") center top / cover no-repeat;
  box-shadow: inset 0 1px 0 #fff9ed, 0 3px 7px #79523024;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mail-attachments { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--collection-line); }
.mail-attachments h4 { margin: 0 0 7px; color: var(--collection-muted); font-size: 13px; }
.mail-rewards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 64px), 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.mail-rewards > li { display: grid; align-content: start; justify-items: center; gap: 4px; min-width: 0; text-align: center; font-size: 12px; overflow-wrap: anywhere; }
.mail-reward-art {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 63px);
  aspect-ratio: 1;
  border: 1px solid #c9a483;
  border-top-color: #fffdf5;
  border-radius: 7px 13px;
  background: linear-gradient(145deg, #fff9ef, #f1ddc4);
}

.mail-reward-art > img { width: 78%; height: 78%; object-fit: contain; }
.mail-reward-art b,
.bag-content .inventory-badge {
  position: absolute;
  inset: auto 2px 2px auto;
  padding: 1px 4px;
  border-radius: 5px;
  background: #785039;
  color: #fff7e9;
  font-size: 11px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.mail-receipt button { width: min(100%, 15rem); }
.mail-receipt p { display: flex; align-items: center; gap: 5px; min-height: 39px; margin: 0; color: #6b543b; font-size: 13px; font-weight: 750; }
.mail-receipt .icon { width: 16px; height: 16px; }

.bag-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.bag-content {
  flex: 0 1 auto;
  min-height: 0;
  padding: clamp(8px, 2.5vw, 13px);
  border: 1px solid var(--collection-line);
  border-top-color: #fffaf3;
  border-radius: 8px 20px;
  background: var(--collection-surface);
  box-shadow: inset 0 0 0 1px #fff9ed, 1px 3px 5px #976a4324;
  overflow: auto;
  overscroll-behavior: contain;
}

.bag-content .inventory-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(69px, 22vw, 104px)), 1fr));
  gap: 6px;
}

.bag-content .inventory-tile {
  padding: 7px 4px 6px;
  border-color: #c4a17d9c;
  border-top-color: #fffaf2;
  border-radius: 7px 14px;
  background: linear-gradient(145deg, #fff8e9, #f1dfc9);
  box-shadow: inset 0 0 0 1px #fff9ec;
  color: var(--collection-ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.bag-content .inventory-tile[data-equipped="true"] {
  border-color: #b07b4e;
  background: linear-gradient(145deg, #fff0cd, #eac7a1);
  box-shadow: inset 0 0 0 1px #fff8e6, 0 2px 4px #94663d31;
}

.bag-content .inventory-tile:is([data-equipped], :has(.inventory-badge)) { padding-top: 19px; }
.bag-content .inventory-tile img { pointer-events: none; }
.bag-content .inventory-badge { inset: 3px 3px auto auto; }
.bag-content .inventory-name { font-size: 12px; font-weight: 700; }
.bag-empty { margin: 0; padding: 16px 0; text-align: center; color: var(--collection-muted); font-size: 14px; }

.collection-dialog {
  width: min(calc(100% - 26px), 398px);
  padding: 14px clamp(13px, 4vw, 19px) 17px;
  overflow: hidden;
}

.collection-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.collection-dialog .player-dialog-close { width: 44px; height: 44px; font-size: 25px; }
.collection-dialog-body { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.collection-dialog-body p { margin: 0; color: #6b4935; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }

.collection-item-hero {
  display: grid;
  grid-template-columns: minmax(62px, 28%) minmax(0, 1fr);
  align-items: center;
  gap: clamp(7px, 3.6vw, 15px);
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #c59d779c;
  border-top-color: #fffbf1;
  border-radius: 8px 18px;
  background: radial-gradient(ellipse at 13% 40%, #ffefd2, transparent 70%), linear-gradient(145deg, #f2dbc0, #fff5e5);
  box-shadow: inset 0 0 0 1px #fff8e8be;
}

.collection-item-hero[data-currency="mouse-diamond"] {
  background: radial-gradient(ellipse at 13% 40%, #eef4f2, transparent 67%), linear-gradient(145deg, #e6ddd1, #fff7e8);
}

.collection-item-hero img { width: 100%; aspect-ratio: 1; max-height: 90px; object-fit: contain; }
.collection-item-hero:not(:has(.collection-detail-state)) { grid-template-columns: min(36%, 84px); justify-content: center; }
.collection-detail-state { color: #694734; overflow-wrap: anywhere; }
.collection-detail-state > span { display: block; color: #78563c; font-size: 13px; }
.collection-detail-state > span + p { margin-top: 3px; }
.collection-detail-state strong { font-size: clamp(18px, 5.7vw, 29px); font-variant-numeric: tabular-nums; }
.collection-dialog-actions { display: flex; justify-content: flex-end; gap: 7px; padding-top: 10px; }
.collection-dialog-actions button { flex: 0 1 auto; width: auto; margin: 0; padding-inline: 15px; }
.collection-dialog-actions .player-dialog-action { background: linear-gradient(150deg, #916a4e, #674435); }
.collection-dialog-actions > button:only-child { flex: 1; }
.collection-dialog-actions .player-dialog-action:disabled {
  border-color: #b98d6966;
  background: #ead6be;
  color: #72543e;
  text-shadow: none;
  cursor: default;
}

.bag-potion-energy {
  padding: 10px 13px;
  border: 1px solid #bb947057;
  border-radius: 7px 13px;
  background: #fff7e69c;
}

.bag-potion-energy dl { display: flex; justify-content: space-between; gap: 10px; margin: 0; }
.bag-potion-energy dl > div:last-child { text-align: end; }
.bag-potion-energy dt { color: #77563e; font-size: 12px; }
.bag-potion-energy dd { margin: 0; color: #5c3b2c; font-weight: 750; font-variant-numeric: tabular-nums; }
.bag-potion-energy progress {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 1rem;
  appearance: none;
  background: #e4cfb8;
}

.bag-potion-energy progress::-webkit-progress-bar { background: #e4cfb8; }
.bag-potion-energy progress::-webkit-progress-value { background: linear-gradient(90deg, #b67d51, #d7a266); }
.bag-potion-energy progress::-moz-progress-bar { background: linear-gradient(90deg, #b67d51, #d7a266); }
.bag-potion-energy p { margin-top: 6px; color: #824d32; font-size: 12px; }
.collection-dialog-body .collection-action-feedback { margin: 8px 2px 0; font-size: 13px; }
.collection-action-feedback[data-error] { color: #903a2b; }

.guide-counter {
  justify-self: end;
  padding: 5px 7px;
  border: 1px solid var(--collection-line);
  border-radius: 4px 9px;
  background: #fff5e6;
  color: var(--collection-muted);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.guide-tabs { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.guide-style-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.guide-style-tabs button { min-height: 33px; }
@media (min-width: 680px) {
  .guide-style-tabs { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

.guide-scroll {
  flex: 1;
  min-height: 0;
  padding: 1px 1px 5px;
  overflow: auto;
  overscroll-behavior: contain;
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 107px), 1fr));
  gap: clamp(6px, 2vw, 13px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.guide-grid > li { min-width: 0; }
.guide-card {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  height: 100%;
  padding: 4px;
  border: 1px solid var(--collection-line);
  border-top-color: #fffaf1;
  border-radius: 7px 16px;
  background: var(--collection-surface);
  box-shadow: inset 0 0 0 1px #fff9ed, 0 2px 4px #8f5d3c1f;
  color: var(--collection-ink);
  text-align: start;
}
.guide-card:active { transform: translateY(1px); }
.guide-card-art,
.guide-appearance-art {
  --guide-sprite: clamp(54px, 19vw, 80px);
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: calc(var(--guide-sprite) + 13px);
  padding: 13px 5px 5px;
  overflow: hidden;
  border: 1px solid #b48b632e;
  border-radius: 5px 13px;
  background: radial-gradient(ellipse at 50% 36%, #fff7e8 6%, var(--guide-art-color, #ebd1ad) 80%);
}
.guide-card-art[data-group="干扰"] { --guide-art-color: #e5ccd9; }
.guide-card-art[data-group="助力"] { --guide-art-color: #dbe2bd; }
.guide-card-art[data-group="障碍"] { --guide-art-color: #d8dce0; }
.guide-card-art:not(.guide-entry-art)::before,
.guide-appearance-art::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 24% 13% 14%;
  border: 1px solid #fffdf39c;
  border-radius: 50%;
  transform: rotate(-14deg);
}
.guide-card-art .mini-target {
  width: var(--guide-sprite);
  height: var(--guide-sprite);
  filter: drop-shadow(0 3px 3px #5b402839);
}
.guide-card-art .mole { width: 96%; height: 100%; }
.guide-card-art .mini-helmet { width: 83%; height: 30%; left: 7%; top: -1%; }
.guide-card-art .mini-target-badge { width: 21px; height: 21px; right: -2px; bottom: 3px; }
.guide-card-art > small {
  position: absolute;
  inset: 3px auto auto 4px;
  padding: 2px 4px;
  border-radius: 3px 6px;
  background: #fff7e6e8;
  color: #684832;
  font-size: 10px;
  font-weight: 750;
}
.guide-card-info { display: grid; align-content: end; gap: 2px; padding: 5px 3px 3px; }
.guide-card-info strong { font-size: var(--text-label); overflow-wrap: anywhere; }
.guide-card-info small { color: var(--collection-muted); font-size: var(--text-small); }
.guide-appearance-art > :is(img, .portrait-composition) { width: 82%; height: var(--guide-sprite); object-fit: contain; }
.guide-appearance-art > .portrait-composition { width: var(--guide-sprite); }
.guide-appearance-art { padding: 5px; }
.guide-appearance-card[data-acquired="false"] {
  border-color: #c6c1b9;
  background: linear-gradient(149deg, #f3f1ed, #e8e4df);
}
:is(.guide-appearance-card[data-acquired="false"] .guide-appearance-art, .guide-appearance-preview[data-acquired="false"]) {
  filter: grayscale(1);
  opacity: .76;
}
.guide-appearance-card[data-acquired="false"] .guide-card-info { color: #5f594f; }

.guide-entry-art {
  --guide-sprite: clamp(82px, 24vw, 109px);
  min-height: clamp(123px, 36vw, 162px);
  background: radial-gradient(ellipse at 50% 55%, #ffedd258, #80533956),
    var(--guide-scene, url("assets/map-meadow.webp")) center 57% / cover;
}
.guide-entry-art[data-kind="gold"],
.guide-entry-art[data-kind="clock"] { --guide-scene: url("assets/map-orchard.webp"); }
.guide-entry-art[data-kind="armor"],
.guide-entry-art[data-kind="decoy"] { --guide-scene: url("assets/map-grove.webp"); }
.guide-entry-art[data-kind="frost"] { --guide-scene: url("assets/stage-winter.webp"); }
.guide-entry-art > small { inset: 6px auto auto 7px; }
.guide-entry-art .frost-steps { margin-top: 11px; gap: 4px; }
.guide-entry-art .frost-steps .mini-target { width: min(90%, var(--guide-sprite)); height: auto; }
.guide-entry-art .frost-steps > div > span:last-child { color: #593e2c; }
.guide-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin: 8px 0;
  text-align: center;
}
.guide-facts > div {
  min-width: 0;
  padding: 6px 3px;
  border: 1px solid #bc947659;
  border-radius: 5px 9px;
  background: #fff6e4a3;
}
.guide-facts dt { color: #79563e; font-size: var(--text-small); }
.guide-facts dd { margin: 2px 0 0; font-size: var(--text-label); font-weight: 750; overflow-wrap: anywhere; }
.guide-entry-note {
  padding: 8px 11px;
  border-inline-start: 2px solid #c59b67;
  border-radius: 2px 10px 10px 2px;
  background: #fff4df9c;
}
.guide-entry-note > span { color: #79563e; font-size: 12px; }
.guide-entry-note > p:not(:first-child) { margin-top: 4px; }
.guide-appearance-preview {
  display: grid;
  place-items: center;
  min-height: 117px;
  margin-bottom: 9px;
  padding: 7px;
  border: 1px solid #b48b635c;
  border-radius: 7px 13px;
  background: radial-gradient(ellipse at 50% 44%, #fff7e6, #e9c9a5);
}
.guide-appearance-preview > :is(img, .portrait-composition) { width: 93px; height: 93px; object-fit: contain; }
.guide-appearance-preview[data-preview="background"] img { width: auto; max-width: 100%; height: min(42dvh, 235px); border-radius: 4px; }
:is(.guide-appearance-art, .guide-appearance-preview) [data-frame="none"] .portrait-window::after {
  content: "";
  position: absolute;
  inset: 50% 31% auto;
  height: 1px;
  background: #ae8156;
}

@media (hover: hover) and (pointer: fine) {
  .collection-page :is(.mail-row, .inventory-tile, .collection-tabs button, .guide-card):hover { filter: brightness(1.045); }
}
