/*
 * Zenow final-iteration visual layer.
 * Keep this stylesheet last in index.html so legacy and agent-authored styles
 * cannot silently override release-critical mobile layout fixes.
 */

.building-layer[data-building-layer="aiCottage"] {
  overflow: hidden;
}

/* Compact, high-contrast journal task creation control. */
body .town-view > .task-preview .section-heading .task-preview-add {
  width: auto;
  min-width: 0;
  height: 24px;
  min-height: 24px;
  gap: 3px;
  padding: 0 8px 1px 6px;
  border: 1px solid #31553b;
  border-radius: 999px;
  color: #fff1bd;
  background: #426d4b;
  box-shadow: 0 3px 7px rgba(42, 67, 43, .22);
  font: 700 .66rem/1 "Noto Serif SC", "Songti SC", Georgia, serif;
  letter-spacing: .02em;
}

body .town-view > .task-preview .section-heading .task-preview-add > span,
body .town-view > .task-preview .section-heading .task-preview-add .task-preview-add-label {
  color: #fff1bd;
  font-size: inherit;
  line-height: 1;
  letter-spacing: inherit;
}

body .town-view > .task-preview .section-heading .task-preview-add > span:first-child {
  font-size: .8rem;
  transform: translateY(-.5px);
}

body .town-view > .task-preview .section-heading .task-preview-add:hover,
body .town-view > .task-preview .section-heading .task-preview-add:focus-visible {
  color: #fff7d3;
  background: #365f41;
  box-shadow: 0 4px 9px rgba(42, 67, 43, .28);
}

/* Agile UI fixes: optically centred skill-book close and reachable task creation. */
.map-panel .skill-card-tray[open] > summary::before,
.map-panel .skill-card-tray[open] > summary::after {
  content: "";
  width: 17px;
  height: 2px;
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: currentColor;
  box-shadow: none;
  transform-origin: center;
}

.map-panel .skill-card-tray[open] > summary::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.map-panel .skill-card-tray[open] > summary::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.town-view > .task-preview .section-heading {
  position: relative;
}

.town-view > .task-preview .task-preview-add {
  width: auto;
  min-width: 29px;
  height: 29px;
  min-height: 29px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  place-items: center;
  padding: 0 10px 0 8px;
  border: 1px solid rgba(70, 92, 60, 0.24);
  border-radius: 999px;
  color: #fff8dd;
  background: linear-gradient(145deg, #6f9365, #3f6849);
  box-shadow: 0 5px 11px rgba(45, 70, 48, 0.2);
  font: 600 .75rem/1.1 Georgia, "Noto Serif SC", serif;
}

.town-view > .task-preview .task-preview-add > span:first-child {
  font-size: 1.05rem;
  line-height: 1;
}

.town-view > .task-preview .task-preview-add-label {
  white-space: nowrap;
}

@media (max-width: 430px) {
  .town-view > .task-preview .task-preview-add {
    padding-inline: 8px;
  }

  .town-view > .task-preview .task-preview-add-label {
    font-size: .68rem;
  }
}

.town-view > .task-preview .task-preview-add:hover,
.town-view > .task-preview .task-preview-add:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 7px 14px rgba(45, 70, 48, 0.26);
}

.town-view > .task-preview .task-preview-add:focus-visible {
  outline: 2px solid rgba(241, 203, 104, 0.9);
  outline-offset: 2px;
}

/* Release C.4 — tactile field-journal navigation. */
body .town-view > .task-preview {
  overflow: visible;
  transition: width .32s cubic-bezier(.22,.82,.24,1), min-height .32s cubic-bezier(.22,.82,.24,1), transform .32s ease;
  transform-origin: 100% 100%;
}

body .town-view > .task-preview .task-book-toggle {
  position: absolute;
  z-index: 8;
  border: 0;
  background: transparent;
  color: #f5eccf;
  cursor: pointer;
}

body .town-view > .task-preview:not(.is-collapsed) .task-book-toggle {
  top: -17px;
  left: -18px;
  width: 42px;
  height: 42px;
  padding: 0;
  filter: drop-shadow(0 4px 5px rgba(42, 51, 30, .28));
}

body .town-view > .task-preview:not(.is-collapsed) .task-book-toggle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

body .town-view > .task-preview:not(.is-collapsed) .task-book-toggle span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

body .town-view > .task-preview.is-collapsed {
  right: 9px;
  bottom: max(88px, calc(var(--safe-bottom) + 82px));
  width: 122px;
  max-width: 122px;
  min-height: 98px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: rotate(-2.5deg);
}

body .town-view > .task-preview.is-collapsed::before,
body .town-view > .task-preview.is-collapsed::after,
body .town-view > .task-preview.is-collapsed > :not(.task-book-toggle) {
  display: none !important;
}

body .town-view > .task-preview.is-collapsed .task-book-toggle {
  inset: -13px -5px -7px -15px;
  padding: 0;
  filter: drop-shadow(0 10px 8px rgba(36, 48, 24, .35));
}

body .town-view > .task-preview.is-collapsed .task-book-toggle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

body .town-view > .task-preview.is-collapsed .task-book-toggle span {
  position: absolute;
  right: 4px;
  bottom: 10px;
  padding: 4px 8px 5px;
  border: 1px solid rgba(109, 86, 40, .42);
  border-radius: 2px;
  background: url("../../assets/runtime/ui/optimized/task-journal-pattern-today.webp") center / cover;
  color: #3e4c31;
  font: 700 .68rem/1 Georgia, "Noto Serif SC", serif;
  letter-spacing: .08em;
  box-shadow: 0 2px 4px rgba(43, 49, 30, .22);
  white-space: nowrap;
}

body .town-view > .task-preview .journal-section-tabs {
  position: absolute;
  z-index: -1;
  top: 31px;
  right: -40px;
  display: grid;
  gap: 3px;
  width: 43px;
}

body .town-view > .task-preview .journal-section-tabs button {
  width: 43px;
  min-height: 42px;
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 4px 2px 3px 8px;
  border: 1px solid rgba(69, 76, 48, .38);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: #9a9d74 url("../../assets/runtime/ui/optimized/task-journal-pattern-records.webp") center / cover;
  color: #37402d;
  box-shadow: 3px 3px 5px rgba(39, 45, 29, .18);
  cursor: pointer;
}

body .town-view > .task-preview .journal-section-tabs button:nth-child(2) { background-color: #85906c; transform: translateX(3px); }
body .town-view > .task-preview .journal-section-tabs button:nth-child(3) { background-color: #aaa392; transform: translateX(1px); }
body .town-view > .task-preview .journal-section-tabs button:nth-child(4) { background-color: #b49a72; transform: translateX(4px); }
body .town-view > .task-preview .journal-section-tabs button:nth-child(5) { background-color: #87936e; transform: translateX(2px); }

body .town-view > .task-preview .journal-section-tabs button.is-active {
  filter: brightness(1.12);
}

body .town-view > .task-preview .journal-section-tabs img {
  width: 19px;
  height: 19px;
  object-fit: contain;
  border-radius: 3px;
}

body .town-view > .task-preview .journal-section-tabs span {
  font: 700 .56rem/1 "Noto Serif SC", Georgia, serif;
}

@media (max-width: 360px), (max-height: 700px) {
  body .town-view > .task-preview.is-collapsed {
    width: 108px;
    max-width: 108px;
    min-height: 86px;
  }

  body .town-view > .task-preview .journal-section-tabs {
    right: -36px;
    width: 39px;
  }

  body .town-view > .task-preview .journal-section-tabs button {
    width: 39px;
    min-height: 38px;
  }
}

/* Keep collectible artwork crisp even when a card cannot be used this turn. */
.map-panel .skill-card-button.is-unavailable {
  opacity: 1;
  filter: none;
}

.map-panel .skill-card-button.is-unavailable .skill-card-artwork {
  opacity: 1;
  filter: drop-shadow(0 5px 7px rgba(54, 44, 24, .2));
}

.map-panel .skill-card-button.is-unavailable .skill-card-copy {
  opacity: .72;
}

/* Release C.2 — the create-task form is a page pulled from the travel journal. */
.task-add-form {
  --quest-ink: #304f3c;
  --quest-sage: #66815f;
  --quest-honey: #d9a943;
  --quest-paper: #f8f0d8;
  top: 50%;
  bottom: auto;
  width: min(376px, calc(100% - 20px));
  max-height: min(670px, calc(100% - 24px));
  gap: 12px;
  padding: 22px 18px 17px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(111, 92, 52, .3);
  border-radius: 12px 20px 18px 10px;
  background:
    linear-gradient(90deg, rgba(111, 86, 43, .08) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(180deg, rgba(255, 253, 243, .76), rgba(244, 235, 207, .9)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 320px auto repeat;
  box-shadow:
    0 24px 56px rgba(31, 45, 35, .3),
    0 2px 0 rgba(255, 255, 255, .7) inset,
    7px 0 0 rgba(92, 113, 75, .13) inset;
  transform: translate(-50%, -50%) rotate(-.2deg);
  isolation: isolate;
  animation: quest-page-enter .34s cubic-bezier(.2, .86, .28, 1.12);
  scrollbar-width: thin;
  scrollbar-color: rgba(95, 119, 82, .38) transparent;
}

.task-add-form::before {
  position: absolute;
  z-index: -1;
  inset: 8px;
  border: 1px solid rgba(126, 101, 53, .22);
  border-radius: 7px 15px 14px 6px;
  box-shadow: 0 0 0 3px rgba(255, 253, 241, .36) inset;
  content: "";
  pointer-events: none;
}

.task-add-form::after {
  position: absolute;
  z-index: -1;
  top: 5px;
  right: 44px;
  width: 76px;
  height: 76px;
  background: url("../../assets/runtime/ui/growth/growth-daisy-stage-05-bloom.png") center / contain no-repeat;
  content: "";
  opacity: .18;
  pointer-events: none;
  transform: rotate(13deg);
}

.task-add-form-bookmark {
  position: absolute;
  z-index: -1;
  top: -3px;
  left: 14px;
  width: 8px;
  height: 86px;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(90deg, #415f48, #789072 48%, #395440);
  box-shadow: 2px 2px 4px rgba(38, 55, 43, .2);
  pointer-events: none;
}

@keyframes quest-page-enter {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 22px)) rotate(1.2deg) scale(.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-.2deg) scale(1);
  }
}

.task-add-form-head {
  position: relative;
  min-height: 57px;
  padding: 0 44px 10px 4px;
  border-bottom: 1px solid rgba(96, 78, 40, .2);
}

.task-add-form-head::after {
  position: absolute;
  right: 0;
  bottom: -3px;
  left: 4px;
  height: 5px;
  background: radial-gradient(circle, rgba(92, 112, 75, .32) 1px, transparent 1.5px) 0 0 / 10px 5px;
  content: "";
  opacity: .52;
}

.task-add-form-head strong {
  display: block;
  color: var(--quest-ink);
  font: 700 1.12rem/1.3 "Songti SC", "STSong", Georgia, serif;
  letter-spacing: .03em;
}

.task-add-form-head small {
  margin-bottom: 3px;
  color: #997332;
  font: 800 .58rem/1.3 Georgia, "Times New Roman", serif;
  letter-spacing: .17em;
}

.task-add-form-head span {
  display: block;
  margin-top: 3px;
  color: rgba(50, 73, 56, .64);
  font: .67rem/1.4 "Songti SC", "STSong", serif;
}

.task-add-form-close {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 9px;
  color: #fff9e8;
  background: linear-gradient(145deg, #54705a, #2e513e);
  box-shadow: 0 5px 11px rgba(39, 69, 51, .2), inset 0 1px rgba(255, 255, 255, .18);
  font: 400 1.35rem/1 Georgia, serif;
}

.task-add-form-close:hover {
  transform: translateY(-1px) rotate(2deg);
}

.task-add-choice {
  gap: 8px;
}

.task-add-choice legend,
.task-add-field > span {
  color: var(--quest-ink);
  font: 700 .73rem/1.3 "Songti SC", "STSong", serif;
  letter-spacing: .04em;
}

.task-add-choice legend::before,
.task-add-field > span::before {
  margin-right: 5px;
  color: #b38835;
  content: "✦";
  font-size: .61rem;
}

.task-add-choice label > span {
  min-height: 61px;
  padding: 10px 10px 9px 32px;
  border: 1px solid rgba(107, 89, 48, .22);
  border-radius: 8px 13px 11px 7px;
  background:
    linear-gradient(145deg, rgba(255, 253, 239, .82), rgba(238, 235, 209, .72)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 250px auto;
  box-shadow: 0 3px 8px rgba(61, 67, 45, .06), inset 0 1px rgba(255, 255, 255, .72);
}

.task-add-choice label > span::before {
  position: absolute;
  top: 50%;
  left: 10px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid rgba(94, 117, 78, .34);
  border-radius: 50%;
  color: transparent;
  background: rgba(255, 253, 239, .64);
  content: "✓";
  font: 700 .62rem/1 sans-serif;
  transform: translateY(-50%);
}

.task-add-choice input:checked + span {
  border-color: rgba(72, 104, 73, .62);
  background:
    linear-gradient(145deg, rgba(225, 235, 204, .94), rgba(249, 235, 186, .76)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 250px auto;
  box-shadow: 0 6px 14px rgba(59, 81, 55, .12), inset 0 0 0 1px rgba(255, 255, 255, .58);
}

.task-add-choice input:checked + span::before {
  border-color: #507454;
  color: #fffaf0;
  background: #507454;
  box-shadow: 0 0 0 3px rgba(213, 182, 87, .18);
}

.task-add-choice label > span strong {
  color: #385341;
  font: 700 .78rem/1.25 "Songti SC", "STSong", serif;
}

.task-add-choice label > span small {
  color: rgba(55, 74, 59, .64);
  font-size: .62rem;
}

.task-add-field input,
.task-add-field select,
.task-add-field textarea {
  border: 1px solid rgba(96, 82, 47, .24);
  border-radius: 7px 11px 9px 6px;
  background:
    linear-gradient(rgba(255, 254, 247, .88), rgba(252, 247, 229, .86)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 260px auto;
  box-shadow: inset 0 1px 4px rgba(68, 59, 36, .06);
  color: var(--quest-ink);
  font-family: "Songti SC", "STSong", Georgia, serif;
}

.task-add-field input:focus,
.task-add-field select:focus,
.task-add-field textarea:focus {
  border-color: rgba(70, 111, 74, .62);
  box-shadow: 0 0 0 3px rgba(91, 129, 83, .14), inset 0 1px 4px rgba(68, 59, 36, .05);
}

.task-add-difficulty label > span {
  min-height: 58px;
  padding: 8px 5px 7px;
  text-align: center;
}

.task-add-difficulty label > span::before {
  display: none;
}

.task-add-difficulty label:nth-of-type(1) strong::before {
  content: "· ";
  color: #b58b36;
}

.task-add-difficulty label:nth-of-type(2) strong::before {
  content: "·· ";
  color: #b58b36;
}

.task-add-difficulty label:nth-of-type(3) strong::before {
  content: "✿ ";
  color: #b58b36;
}

.task-add-form-actions {
  position: sticky;
  bottom: -17px;
  z-index: 2;
  margin: 0 -4px -2px;
  padding: 8px 4px 2px;
  background: linear-gradient(180deg, transparent, rgba(246, 238, 216, .96) 32%);
}

.task-add-form-actions button {
  min-height: 44px;
  border-radius: 7px 13px 10px 7px;
  font-family: "Songti SC", "STSong", Georgia, serif;
  letter-spacing: .04em;
}

.task-add-form-cancel {
  border-color: rgba(101, 86, 51, .24);
  color: #61705e;
  background: rgba(255, 252, 237, .72);
}

.task-add-form-submit {
  position: relative;
  overflow: hidden;
  border-color: rgba(255, 255, 255, .34);
  color: #fff8de;
  background:
    linear-gradient(135deg, rgba(54, 88, 64, .98), rgba(91, 121, 76, .94)),
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / 220px auto;
  box-shadow: 0 8px 16px rgba(44, 73, 53, .2), inset 0 1px rgba(255, 255, 255, .2);
}

.task-add-form-submit::after {
  margin-left: 7px;
  color: #e8c766;
  content: "❦";
}

@media (max-height: 700px) {
  .task-add-form {
    gap: 9px;
    max-height: calc(100% - 14px);
    padding-top: 16px;
    padding-bottom: 12px;
  }

  .task-add-form-head {
    min-height: 50px;
    padding-bottom: 7px;
  }

  .task-add-form-head span {
    display: none;
  }

  .task-add-choice label > span {
    min-height: 52px;
    padding-block: 7px;
  }

  .task-add-field textarea {
    min-height: 62px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .task-add-form {
    animation: none;
  }
}

/* Make quick AI actions visibly arrive at the conversation workbench. */
.ai-conversation-card {
  scroll-margin-block: 12px;
}

.ai-conversation-card:focus {
  outline: none;
}

.ai-conversation-card.is-focus-arrival {
  animation: ai-conversation-arrival 1s ease-out;
}

@keyframes ai-conversation-arrival {
  0% {
    box-shadow: 0 0 0 0 rgba(218, 173, 70, 0), 0 12px 28px rgba(43, 59, 44, .1);
  }
  35% {
    box-shadow: 0 0 0 4px rgba(218, 173, 70, .25), 0 16px 34px rgba(43, 59, 44, .16);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(218, 173, 70, 0), 0 12px 28px rgba(43, 59, 44, .1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-conversation-card.is-focus-arrival {
    animation: none;
  }
}

/* Release C.4: keep coins, dice, sync and owned buildings in dedicated HUD lanes.
   The building badge used to be a third flex child inside two 50% resource pills,
   so it overlaid the dice count on phone widths. */
.hud-card .resource-cluster {
  width: min(210px, 54vw);
  flex: 0 1 210px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px;
  align-items: center;
  gap: 0;
  padding: 8px 10px;
}

.hud-card .resource-cluster > .resource-pill {
  width: 100%;
  padding-inline: 5px;
}

.hud-card .resource-cluster > .sync-indicator {
  position: absolute;
  top: 6px;
  right: 7px;
  z-index: 2;
  width: 7px;
  height: 7px;
  pointer-events: none;
}

.hud-card .resource-cluster > .building-summary {
  position: static;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  grid-template-columns: 20px 10px;
  gap: 0;
  padding: 0 1px 0 4px;
  border: 0;
  border-left: 1px solid rgba(82, 73, 46, .18);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.hud-card .resource-cluster > .building-summary img {
  width: 20px;
  height: 20px;
}

.hud-card .resource-cluster > .building-summary strong {
  min-width: 10px;
  font: 700 .75rem/1 Georgia, "Times New Roman", serif;
  text-align: center;
}

@media (max-width: 430px) {
  .hud-card {
    gap: 7px;
  }

  .hud-card .player-chip {
    max-width: min(44vw, 170px);
  }

  .hud-card .resource-cluster {
    width: min(190px, 50vw);
    flex-basis: 190px;
    padding-inline: 8px;
  }

  .hud-card .resource-cluster > .resource-pill {
    grid-template-columns: 20px minmax(14px, 1fr);
    column-gap: 3px;
    padding-inline: 3px;
  }

  .hud-card .resource-cluster > .resource-pill .resource-label {
    display: none;
  }

  .hud-card .resource-cluster > .resource-pill strong {
    font-size: .91rem;
  }
}

@media (max-width: 370px) {
  .hud-card .player-chip {
    max-width: 43vw;
  }

  .hud-card .resource-cluster {
    width: 51vw;
    flex-basis: 51vw;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 31px;
    padding-inline: 6px;
  }

  .hud-card .resource-cluster > .building-summary {
    width: 31px;
    min-width: 31px;
    grid-template-columns: 18px 9px;
    padding-left: 3px;
  }

  .hud-card .resource-cluster > .building-summary img {
    width: 18px;
    height: 18px;
  }
}

/* Mobile WebView scale lock: feature layers must stay in the same coordinate
   system as the map instead of inheriting desktop text autosizing. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (max-width: 600px) {
  .app-shell {
    width: 100vw;
    max-width: 100vw;
    padding: 0;
  }

  .phone-frame,
  .app-surface,
  .building-layer,
  .building-layer > [data-ai-mount],
  .building-layer > [data-shop-mount],
  .building-layer > [data-profile-mount] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    zoom: 1 !important;
  }

  .phone-frame,
  .app-surface {
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .building-layer {
    inset-inline: 0 !important;
    transform: none !important;
    contain: layout paint;
  }

  .feature-page,
  .home-page,
  .shop-page,
  .ai-cottage-page,
  .task-journal-shell {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    transform: none;
  }

  .feature-page input,
  .feature-page select,
  .feature-page textarea {
    font-size: 16px;
  }
}

.ai-cottage-page {
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  padding-top: max(76px, calc(var(--safe-top) + 68px));
  padding-bottom: max(34px, calc(var(--safe-bottom) + 24px));
  scroll-padding-block: 84px 30px;
}

.ai-home-hero {
  min-height: 168px;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
}

.ai-companion-orb {
  width: 84px;
  height: 84px;
}

.ai-companion-orb img[src*="ai-leaf-ear-companion-transparent"] {
  width: 100%;
  max-width: 100%;
  height: 100%;
  align-self: center;
  justify-self: center;
  object-fit: contain;
  object-position: center bottom;
}

.ai-status-grid,
.ai-status-grid span {
  min-width: 0;
}

.ai-status-grid span {
  overflow: hidden;
}

.home-character-grid {
  grid-template-columns: 1fr;
  align-items: start;
}

.home-character-card {
  width: 100%;
  min-height: 164px;
  max-height: 190px;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: stretch;
  align-self: start;
}

.home-character-card-art {
  height: 142px;
  min-height: 0;
}

.home-character-card-portrait {
  position: absolute;
  inset: 5px;
  width: calc(100% - 10px);
  max-width: calc(100% - 10px);
  height: calc(100% - 10px);
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 10px 14px rgba(41, 76, 59, 0.14));
}

.home-character-card-map {
  width: 44px;
  height: 44px;
}

.home-character-card-copy {
  align-content: center;
  padding: 24px 6px 8px 0;
}

.home-character-card-copy small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

@media (max-width: 380px) {
  .ai-cottage-page {
    gap: 11px;
    padding-inline: 12px;
  }

  .ai-home-hero {
    min-height: 150px;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 11px;
    padding: 12px;
  }

  .ai-companion-orb {
    width: 72px;
    height: 72px;
    border-radius: 24px 32px 30px 34px;
  }

  .ai-status-grid {
    gap: 5px;
  }

  .ai-status-grid span {
    padding: 8px 6px;
  }

  .ai-assistant-grid {
    grid-template-columns: 1fr;
  }

  .ai-assistant-card {
    min-height: 68px;
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .ai-assistant-card img {
    width: 48px;
    height: 48px;
  }

  .home-character-card {
    min-height: 152px;
    max-height: 174px;
    grid-template-columns: 98px minmax(0, 1fr);
  }

  .home-character-card-art {
    height: 132px;
  }
}

/* Memory Galaxy — the night-sky chapter, adapted from galaxy-template.html. */
.home-page.is-galaxy-chapter {
  width: 100%;
  max-width: none;
  min-height: 100%;
  display: block;
  margin: 0;
  padding: 0;
}

.home-page.is-galaxy-chapter .memory-galaxy {
  border-radius: 0;
}

.memory-galaxy-entry {
  position: relative;
  width: 100%;
  min-height: 142px;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: end;
  gap: 15px;
  margin-top: 14px;
  padding: 22px 18px 18px;
  border: 1px solid rgba(226, 206, 244, 0.34);
  border-radius: 23px;
  color: #f8effb;
  text-align: left;
  background:
    radial-gradient(circle at 17% 12%, rgba(255, 173, 218, 0.27), transparent 34%),
    linear-gradient(135deg, #130b22, #27133a 54%, #10182f);
  box-shadow: 0 14px 32px rgba(20, 8, 35, 0.24);
  overflow: hidden;
}

.memory-galaxy-entry-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 72% 36%, rgba(195, 123, 230, 0.25), transparent 34%),
    radial-gradient(ellipse at 45% 115%, rgba(86, 116, 196, 0.3), transparent 52%);
}

.memory-galaxy-entry-sky i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff3c6;
  box-shadow: 0 0 9px #f4c8ff;
}

.memory-galaxy-entry-sky i:nth-child(1) { left: 13%; top: 18%; }
.memory-galaxy-entry-sky i:nth-child(2) { left: 47%; top: 23%; }
.memory-galaxy-entry-sky i:nth-child(3) { left: 72%; top: 15%; }
.memory-galaxy-entry-sky i:nth-child(4) { left: 88%; top: 48%; }
.memory-galaxy-entry-sky i:nth-child(5) { left: 57%; top: 68%; }

.memory-galaxy-entry-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.memory-galaxy-entry strong {
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 1.18rem;
  letter-spacing: 0.08em;
}

.memory-galaxy-entry-copy small {
  color: rgba(231, 211, 242, 0.62);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
}

.memory-galaxy-entry-copy em {
  color: rgba(244, 230, 250, 0.74);
  font-size: 0.69rem;
  font-style: normal;
}

.memory-galaxy-entry b {
  position: absolute;
  z-index: 2;
  right: 16px;
  bottom: 14px;
  color: rgba(244, 220, 250, 0.7);
  font-size: 0.62rem;
  font-weight: 400;
}

.memory-galaxy-entry-orbit {
  width: 68px;
  height: 68px;
  position: relative;
  z-index: 1;
  display: block;
  border-radius: 50%;
  background: radial-gradient(circle, #fff5d7 0 5%, #efacd7 7%, rgba(183, 129, 230, 0.4) 17%, transparent 49%);
  box-shadow: 0 0 22px rgba(222, 143, 220, 0.46);
}

.memory-galaxy-entry-orbit::before,
.memory-galaxy-entry-orbit::after {
  content: "";
  position: absolute;
  inset: 7px -2px;
  border: 1px solid rgba(223, 188, 243, 0.42);
  border-radius: 50%;
  transform: rotate(-22deg);
}

.memory-galaxy-entry-orbit::after {
  inset: 14px -5px;
  transform: rotate(25deg);
}

.memory-galaxy-entry-orbit i {
  width: 3px;
  height: 3px;
  position: absolute;
  border-radius: 50%;
  background: #fff1be;
  box-shadow: 0 0 7px #f6c9f2;
}

.memory-galaxy-entry-orbit i:nth-child(1) { top: 9px; right: 7px; }
.memory-galaxy-entry-orbit i:nth-child(2) { bottom: 9px; left: 5px; }
.memory-galaxy-entry-orbit i:nth-child(3) { bottom: 4px; right: 13px; }

.memory-galaxy.home-memory-card,
.memory-galaxy.is-three-galaxy {
  min-height: min(760px, calc(100dvh - 94px));
  grid-template-rows: 0 minmax(520px, 1fr) auto;
  margin: 0;
  border: 0;
  border-radius: 28px;
  background: #050209;
  box-shadow: 0 24px 50px rgba(7, 2, 14, 0.34);
  isolation: isolate;
}

.memory-galaxy .home-memory-card-head {
  height: 0;
  position: relative;
  z-index: 8;
  padding: 24px 20px 0;
  text-align: center;
  pointer-events: none;
}

.memory-galaxy .home-memory-card-head .feature-kicker {
  color: #f7eefa;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-style: italic;
  letter-spacing: 0.04em;
  text-transform: none;
  text-shadow: 0 0 28px rgba(210, 150, 230, 0.65);
}

.memory-galaxy .home-memory-card-head h2 {
  margin-top: 3px;
  color: rgba(225, 205, 240, 0.52);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.73rem;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.17em;
}

.memory-galaxy .home-memory-card-head p:last-child {
  margin: 12px 0 0;
  color: rgba(224, 208, 238, 0.46);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 0.67rem;
  letter-spacing: 0.1em;
}

.home-memory-card .memory-galaxy-stage,
.home-memory-card .memory-galaxy-canvas,
.memory-galaxy-stage,
.memory-galaxy-canvas {
  min-height: min(760px, calc(100dvh - 94px));
}

.memory-galaxy-stage {
  background:
    radial-gradient(ellipse at 49% 51%, rgba(180, 111, 222, 0.15), transparent 16%),
    radial-gradient(ellipse at 67% 43%, rgba(96, 109, 223, 0.11), transparent 31%),
    radial-gradient(ellipse at 30% 62%, rgba(232, 130, 194, 0.1), transparent 30%),
    #050209;
}

.memory-galaxy-signature {
  z-index: 2;
  background:
    radial-gradient(circle at 50% 48%, transparent 0 22%, rgba(5, 2, 9, 0.08) 45%, rgba(5, 2, 9, 0.56) 100%),
    linear-gradient(180deg, rgba(5, 2, 9, 0.36), transparent 25%, transparent 70%, rgba(5, 2, 9, 0.7));
}

.memory-galaxy-hint {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: 15px;
  left: 0;
  margin: 0;
  color: rgba(225, 205, 240, 0.35);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.65rem;
  font-style: italic;
  letter-spacing: 0.12em;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.memory-galaxy.has-open-memory .memory-galaxy-hint {
  opacity: 0;
}

.memory-star-list .memory-star {
  right: 12px;
  bottom: calc(62px + var(--star-offset, 0px));
  z-index: 5;
  max-width: 42%;
  border: 0;
  padding: 2px 6px;
  color: rgba(238, 219, 245, 0.58);
  background: transparent;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-weight: 400;
  text-shadow: 0 0 10px rgba(237, 177, 228, 0.7);
}

.memory-star-list .memory-star:not(.is-selected) {
  opacity: 0;
}

.memory-star-list .memory-star.is-selected {
  color: #fbeffa;
  background: transparent;
}

.memory-notes {
  position: absolute;
  z-index: 7;
  inset: auto 0 0;
  pointer-events: none;
}

.memory-detail,
.home-memory-card .memory-detail {
  max-height: 52vh;
  position: relative;
  margin: 0;
  padding: 50px 24px calc(24px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 0;
  color: rgba(246, 235, 248, 0.92);
  background: linear-gradient(to top, rgba(5, 2, 12, 0.97) 38%, rgba(5, 2, 12, 0.64) 76%, transparent);
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  pointer-events: auto;
  animation: memory-note-rise 0.48s cubic-bezier(0.22, 0.8, 0.25, 1) both;
}

.memory-detail[hidden] {
  display: none;
}

.memory-detail .feature-kicker {
  color: rgba(232, 198, 238, 0.64);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
}

.memory-detail input,
.memory-detail textarea {
  border: 0;
  border-bottom: 1px solid rgba(231, 186, 229, 0.12);
  border-radius: 0;
  color: #fcf0fa;
  background: transparent;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.memory-detail input {
  padding: 4px 0 7px;
  font-size: 1.05rem;
  font-weight: 500;
}

.memory-detail textarea {
  min-height: 72px;
  max-height: 20vh;
  padding: 6px 0;
  line-height: 1.9;
}

.memory-detail small {
  color: rgba(230, 207, 240, 0.46);
}

.memory-detail-close {
  width: 34px;
  height: 34px;
  position: absolute;
  top: 34px;
  right: 20px;
  border: 0;
  color: rgba(234, 207, 240, 0.55);
  background: transparent;
  font-size: 1.3rem;
}

.memory-detail-actions {
  display: flex;
  gap: 10px;
}

.memory-detail-actions button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(231, 186, 229, 0.18);
  color: rgba(244, 221, 241, 0.76);
  background: rgba(210, 140, 200, 0.1);
}

.memory-restore-bar {
  position: absolute;
  z-index: 10;
  right: 12px;
  bottom: 12px;
  left: 12px;
  margin: 0;
  border-color: rgba(230, 170, 220, 0.2);
  color: rgba(232, 211, 240, 0.66);
  background: rgba(16, 8, 24, 0.68);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

@keyframes memory-note-rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .memory-detail,
  .memory-galaxy-signature span,
  .memory-galaxy-entry-orbit {
    animation: none !important;
  }
}

/* Final concept-board sizing wins over the legacy compact task-card rules. */
body .town-view > .task-preview {
  right: 15px;
  bottom: max(96px, calc(var(--safe-bottom) + 90px));
  width: min(76vw, 326px);
  max-width: 326px;
  min-height: 326px;
}

@media (max-width: 380px), (max-height: 740px) {
  body .town-view > .task-preview {
    right: 10px;
    bottom: max(90px, calc(var(--safe-bottom) + 84px));
    width: min(76vw, 292px);
    max-width: 292px;
    min-height: 278px;
  }
}

/* C.1 final cascade guard. */
.hud-card .player-chip,
.hud-card .resource-cluster {
  background: url("../../assets/runtime/ui/hud-torn-paper-v1.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 6px 7px rgba(42, 54, 34, .2));
  box-shadow: none;
}

body .town-view > .task-preview {
  right: 15px;
  bottom: max(98px, calc(var(--safe-bottom) + 92px));
  width: min(69vw, 286px);
  max-width: 286px;
  min-height: 294px;
  padding: 25px 21px 23px 34px;
}

body .town-view > .task-preview::before {
  width: 17px;
}

body .town-view > .task-preview .task-preview-row {
  min-height: 65px;
  grid-template-columns: 51px minmax(0, 1fr) auto 23px;
  gap: 6px;
  padding: 6px 6px 6px 5px;
}

body .town-view > .task-preview .task-preview-row > img {
  width: 51px;
  height: 51px;
}

@media (max-width: 380px), (max-height: 740px) {
  body .town-view > .task-preview {
    right: 9px;
    bottom: max(92px, calc(var(--safe-bottom) + 86px));
    width: min(70vw, 270px);
    max-width: 270px;
    min-height: 272px;
    padding: 21px 16px 18px 30px;
  }

  body .town-view > .task-preview .task-preview-row {
    min-height: 58px;
    grid-template-columns: 45px minmax(0, 1fr) auto 22px;
    padding: 5px;
  }

  body .town-view > .task-preview .task-preview-row > img {
    width: 45px;
    height: 45px;
  }
}

/* C.2: skill-book page-corner controls share one optical baseline. */
.map-panel .skill-card-tray[open] {
  overflow: hidden auto;
}

.map-panel .skill-card-tray[open] > summary {
  top: 14px;
  right: 14px;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  margin: 0;
  line-height: 1;
  transform: none;
}

.map-panel .skill-card-tray[open] > summary::before {
  display: block;
  line-height: 1;
  transform: translateY(-1px);
}

.map-panel .skill-card-tray[open] .skill-card-book-head {
  position: relative;
  margin-right: 0;
  padding-right: 112px;
}

.map-panel .skill-card-tray[open] .skill-card-book-head > span {
  position: absolute;
  top: 3px;
  right: 50px;
  height: 32px;
  min-width: 62px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 9px;
  line-height: 1;
}

@media (max-width: 360px) {
  .map-panel .skill-card-tray[open] .skill-card-book-head {
    padding-right: 102px;
  }

  .map-panel .skill-card-tray[open] .skill-card-book-head > span {
    min-width: 56px;
    padding-inline: 6px;
  }
}

/* C.3: one-line wallet typography and a compact lower-right task folio. */
.hud-card .resource-cluster {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 14px;
}

.hud-card .resource-pill,
.hud-card .resource-pill-coin,
.hud-card .resource-pill-dice {
  min-width: 0;
  min-height: 36px;
  display: grid;
  grid-template-columns: 21px max-content minmax(14px, 1fr);
  align-items: center;
  align-content: center;
  column-gap: 4px;
  padding: 0 7px;
  line-height: 1;
}

.hud-card .resource-pill + .resource-pill {
  border-left: 1px solid rgba(91, 76, 45, .16);
}

.hud-card .resource-icon {
  width: 21px;
  height: 21px;
  align-self: center;
}

.hud-card .resource-label {
  align-self: center;
  color: rgba(56, 67, 43, .72);
  font-size: .62rem;
  line-height: 1;
  white-space: nowrap;
}

.hud-card .resource-pill strong {
  align-self: center;
  min-width: 0;
  color: #31462f;
  font: 700 .98rem/1 Georgia, "Times New Roman", serif;
  text-align: right;
}

body .town-view > .task-preview {
  right: 12px;
  bottom: max(96px, calc(var(--safe-bottom) + 90px));
  width: min(56vw, 210px);
  max-width: 210px;
  min-height: 126px;
  padding: 15px 13px 12px 24px;
}

body .town-view > .task-preview::before {
  width: 14px;
}

body .town-view > .task-preview .section-heading {
  min-height: 27px;
  margin-bottom: 6px;
  padding-bottom: 5px;
}

body .town-view > .task-preview .section-heading span {
  font-size: .9rem;
}

body .town-view > .task-preview .section-heading small {
  font-size: .5rem;
}

body .town-view > .task-preview .task-preview-list {
  gap: 6px;
}

body .town-view > .task-preview .task-preview-row {
  min-height: 48px;
  grid-template-columns: 38px minmax(0, 1fr) auto 20px;
  gap: 5px;
  padding: 4px;
}

body .town-view > .task-preview .task-preview-row > img {
  width: 38px;
  height: 38px;
}

body .town-view > .task-preview .task-preview-book-crest {
  margin-bottom: 3px;
}

body .town-view > .task-preview .section-heading {
  margin-bottom: 6px;
}

body .town-view > .task-preview .section-heading small,
body .town-view > .task-preview .task-preview-page-foot,
body .town-view > .task-preview .task-preview-row:nth-child(n + 2) {
  display: none;
}

body .town-view > .task-preview .task-preview-row-copy small {
  max-width: 15ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .town-view > .task-preview .task-preview-row-copy strong {
  font-size: .68rem;
}

body .town-view > .task-preview .task-preview-row-copy small {
  font-size: .51rem;
}

body .town-view > .task-preview .task-preview-row-enter {
  width: 21px;
  height: 21px;
  font-size: .94rem;
}

@media (max-width: 360px), (max-height: 700px) {
  .hud-card .resource-cluster {
    padding-inline: 10px;
  }

  .hud-card .resource-pill,
  .hud-card .resource-pill-coin,
  .hud-card .resource-pill-dice {
    grid-template-columns: 19px max-content minmax(12px, 1fr);
    column-gap: 3px;
    padding-inline: 4px;
  }

  .hud-card .resource-icon {
    width: 19px;
    height: 19px;
  }

  body .town-view > .task-preview {
    right: 8px;
    bottom: max(88px, calc(var(--safe-bottom) + 82px));
    width: min(57vw, 196px);
    max-width: 196px;
    min-height: 116px;
    padding: 13px 10px 10px 22px;
  }

  body .town-view > .task-preview .task-preview-row {
    min-height: 49px;
    grid-template-columns: 38px minmax(0, 1fr) auto 20px;
    gap: 4px;
    padding: 4px;
  }

body .town-view > .task-preview .task-preview-row > img {
    width: 38px;
    height: 38px;
  }
}

/* Release C.1: collectible skill-card artwork and centered branch ritual. */
.map-panel .skill-card-button {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 118px;
  padding: 9px 11px 9px 8px;
  overflow: hidden;
  text-align: left;
}

.skill-card-artwork {
  position: relative;
  display: block;
  width: 72px;
  aspect-ratio: .56;
  flex: 0 0 auto;
  filter: drop-shadow(0 5px 7px rgba(54, 44, 24, .2));
}

.skill-card-artwork img {
  position: absolute;
  display: block;
  pointer-events: none;
}

.skill-card-art-frame {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.skill-card-art-symbol {
  z-index: 1;
  top: 22%;
  left: 50%;
  width: 58%;
  height: 45%;
  object-fit: contain;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 2px rgba(61, 50, 26, .16));
}

.skill-card-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.skill-card-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.skill-card-title-row em {
  padding: 2px 7px;
  border: 1px solid rgba(105, 86, 43, .18);
  border-radius: 999px;
  color: #876729;
  background: rgba(235, 216, 153, .38);
  font: 700 .58rem/1.4 "Songti SC", "STSong", serif;
  font-style: normal;
  letter-spacing: .08em;
}

.skill-card-button[data-skill-rarity="rare"] .skill-card-title-row em {
  color: #526c82;
  border-color: rgba(82, 108, 130, .22);
  background: rgba(184, 210, 221, .34);
}

.map-panel .skill-card-button > .skill-card-copy > small {
  display: -webkit-box;
  overflow: hidden;
  color: rgba(49, 70, 56, .78);
  font-size: .7rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.map-panel .skill-card-button.is-unavailable .skill-card-artwork {
  opacity: .9;
  filter: grayscale(.06) drop-shadow(0 4px 6px rgba(54, 44, 24, .16));
}

.skill-card-reveal-art {
  width: 116px;
  margin: 4px auto 2px;
  filter: drop-shadow(0 9px 14px rgba(56, 43, 18, .24));
}

.skill-card-reveal-front .skill-card-reveal-art {
  position: relative;
}

.skill-card-reveal-front > .skill-card-artwork img {
  position: absolute;
}

.map-choice-panel {
  position: absolute;
  z-index: 48;
  inset: -10px;
  width: auto;
  display: grid;
  place-items: center;
  padding: 18px;
  color: #314638;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 251, 228, .12), transparent 42%),
    rgba(24, 43, 31, .42);
  border: 0;
  border-radius: inherit;
  box-shadow: none;
  transform: none;
  backdrop-filter: blur(5px) saturate(.88);
  animation: branch-backdrop-in 220ms ease-out both;
}

.map-choice-panel[hidden] {
  display: none;
}

.map-choice-card {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: min(344px, calc(100vw - 42px));
  padding: 28px 20px 17px;
  overflow: visible;
  border: 1px solid rgba(93, 73, 37, .34);
  border-radius: 6px 22px 9px 18px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .55), transparent 42%),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 480px auto repeat;
  box-shadow: 0 24px 60px rgba(23, 38, 28, .38), inset 0 0 0 3px rgba(255, 255, 255, .24);
  animation: branch-note-arrive 420ms cubic-bezier(.18, .86, .24, 1.08) both;
}

.map-choice-card::before {
  content: none;
}

.map-choice-tape {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 84px;
  height: 19px;
  background: rgba(221, 190, 104, .72);
  box-shadow: 0 2px 3px rgba(77, 57, 24, .12);
  transform: translateX(-50%) rotate(-1.8deg);
}

.map-choice-daisy {
  position: absolute;
  top: -25px;
  right: -14px;
  width: 74px;
  height: 74px;
  object-fit: contain;
  transform: rotate(9deg);
  filter: drop-shadow(0 5px 7px rgba(63, 50, 22, .18));
  pointer-events: none;
}

.map-choice-kicker {
  margin: 0 0 4px;
  color: #a47a2d;
  font: 700 .58rem/1.2 Georgia, "Times New Roman", serif;
  letter-spacing: .18em;
}

.map-choice-card h2 {
  margin: 0;
  color: #294b38;
  font: 700 1.45rem/1.25 "STKaiti", "KaiTi", "FangSong", serif;
  letter-spacing: .08em;
}

.map-choice-description {
  margin: 6px 12px 14px;
  color: rgba(49, 70, 56, .72);
  font-size: .76rem;
  line-height: 1.55;
}

.map-choice-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.map-choice-actions button {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 67px;
  padding: 8px 9px;
  border: 1px solid rgba(72, 94, 69, .24);
  border-radius: 7px 15px 8px 13px;
  color: #304c3a;
  text-align: left;
  background:
    linear-gradient(145deg, rgba(248, 244, 214, .94), rgba(220, 229, 194, .82)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 260px auto repeat;
  box-shadow: 0 5px 12px rgba(48, 61, 39, .12), inset 0 0 0 2px rgba(255, 255, 255, .26);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.map-choice-actions button:hover,
.map-choice-actions button:focus-visible {
  border-color: rgba(169, 126, 43, .52);
  box-shadow: 0 9px 18px rgba(48, 61, 39, .18), inset 0 0 0 2px rgba(255, 255, 255, .34);
  transform: translateY(-2px) rotate(-.4deg);
}

.map-choice-actions button:active {
  transform: translateY(1px) scale(.98);
}

.map-choice-arrow {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(255, 248, 214, .42);
  border-radius: 50% 46% 52% 44%;
  color: #fff9df;
  background: radial-gradient(circle at 35% 28%, rgba(255, 255, 255, .22), transparent 32%), #416d50;
  box-shadow: 0 4px 8px rgba(42, 67, 49, .2);
  font: 700 1.25rem/1 Georgia, serif;
}

.map-choice-option-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.map-choice-option-copy strong {
  font: 700 .88rem/1.2 "STKaiti", "KaiTi", "FangSong", serif;
}

.map-choice-option-copy small {
  overflow: hidden;
  color: rgba(49, 70, 56, .63);
  font-size: .6rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-choice-card footer {
  margin-top: 13px;
  padding-top: 9px;
  border-top: 1px solid rgba(89, 73, 41, .16);
  color: rgba(59, 76, 58, .68);
  font-size: .66rem;
  letter-spacing: .04em;
}

.map-choice-card footer span {
  color: #c69235;
}

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

@keyframes branch-note-arrive {
  from { opacity: 0; transform: translateY(-22px) scale(.94) rotate(-1.4deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

@media (max-width: 370px) {
  .map-choice-card {
    width: calc(100vw - 30px);
    padding-right: 15px;
    padding-left: 15px;
  }

  .map-choice-actions {
    gap: 7px;
  }

  .map-choice-actions button {
    grid-template-columns: 36px minmax(0, 1fr);
    min-height: 61px;
    padding: 7px;
  }

  .map-choice-arrow {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-choice-panel,
  .map-choice-card {
    animation: none;
  }
}

/* Final cascade guard: draw the × from two centered strokes, never a glyph. */
body .map-panel .skill-card-tray[open] > summary::before,
body .map-panel .skill-card-tray[open] > summary::after {
  content: "";
  width: 17px;
  height: 2px;
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: currentColor;
  box-shadow: none;
  transform-origin: center;
}

body .map-panel .skill-card-tray[open] > summary::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

body .map-panel .skill-card-tray[open] > summary::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* Release C.4 map-first guard: keep the journal glanceable without turning
   the lower half of the town into a permanent modal. */
body .town-view > .task-preview {
  right: 12px;
  bottom: max(96px, calc(var(--safe-bottom) + 90px));
  width: min(56vw, 210px);
  max-width: 210px;
  min-height: 126px;
  padding: 15px 13px 12px 24px;
}

body .town-view > .task-preview .task-preview-book-crest {
  margin-bottom: 3px;
}

body .town-view > .task-preview .section-heading {
  margin-bottom: 6px;
}

body .town-view > .task-preview .section-heading small,
body .town-view > .task-preview .task-preview-page-foot,
body .town-view > .task-preview .task-preview-row:nth-child(n + 2) {
  display: none;
}

body .town-view > .task-preview .task-preview-row {
  min-height: 48px;
  grid-template-columns: 38px minmax(0, 1fr) auto 20px;
  padding: 4px;
}

body .town-view > .task-preview .task-preview-row > img {
  width: 38px;
  height: 38px;
}

body .town-view > .task-preview .task-preview-row-copy small {
  max-width: 15ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 360px), (max-height: 700px) {
  body .town-view > .task-preview {
    right: 8px;
    width: min(57vw, 196px);
    max-width: 196px;
    min-height: 116px;
    padding: 13px 10px 10px 22px;
  }
}

/* Release C.1 · generated deckle-edge paper and a smaller field-book page. */
.hud-card .player-chip,
.hud-card .resource-cluster {
  background: url("../../assets/runtime/ui/hud-torn-paper-v1.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 6px 7px rgba(42, 54, 34, .2));
  box-shadow: none;
}

.hud-card .player-chip {
  padding-right: 20px;
  padding-left: 10px;
}

.hud-card .resource-cluster {
  padding-right: 14px;
  padding-left: 14px;
}

body .town-view > .task-preview {
  right: 15px;
  bottom: max(98px, calc(var(--safe-bottom) + 92px));
  width: min(69vw, 286px);
  max-width: 286px;
  min-height: 294px;
  padding: 25px 21px 23px 34px;
  border: 1px solid rgba(67, 75, 47, .2);
  box-shadow:
    -10px 12px 22px rgba(35, 46, 30, .28),
    -6px 7px 0 rgba(218, 203, 160, .82),
    -11px 11px 0 rgba(76, 94, 68, .86);
}

body .town-view > .task-preview::before {
  width: 17px;
}

.town-view > .task-preview .section-heading {
  min-height: 30px;
  margin-bottom: 8px;
  padding-bottom: 6px;
}

.town-view > .task-preview .section-heading span {
  font-size: 1rem;
}

.task-preview-list {
  gap: 7px;
}

.task-preview-row {
  min-height: 65px;
  grid-template-columns: 51px minmax(0, 1fr) auto 23px;
  gap: 6px;
  padding: 6px 6px 6px 5px;
}

.task-preview-row > img {
  width: 51px;
  height: 51px;
}

.task-preview-row-enter {
  width: 23px;
  height: 23px;
}

.town-view > .task-preview.is-emphasized {
  animation: task-book-callout 720ms cubic-bezier(.2, .84, .2, 1);
}

@keyframes task-book-callout {
  0%, 100% { transform: rotate(.2deg) translateY(0); }
  42% { transform: rotate(-.7deg) translateY(-8px) scale(1.025); }
}

@media (max-width: 380px), (max-height: 740px) {
  body .town-view > .task-preview {
    right: 9px;
    bottom: max(92px, calc(var(--safe-bottom) + 86px));
    width: min(70vw, 270px);
    max-width: 270px;
    min-height: 272px;
    padding: 21px 16px 18px 30px;
  }

  .task-preview-row {
    min-height: 58px;
    grid-template-columns: 45px minmax(0, 1fr) auto 22px;
    padding: 5px;
  }

  .task-preview-row > img {
    width: 45px;
    height: 45px;
  }
}

/* Release B.5: the wallet reads as a small memo pinned to the sky. */
.hud-card .resource-cluster {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(172px, 45vw);
  min-height: 58px;
  gap: 2px;
  padding: 12px 7px 7px;
  overflow: visible;
  border: 1px solid rgba(126, 96, 43, 0.22);
  border-radius: 3px 14px 6px 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.68), rgba(246, 231, 175, 0.24)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 310px auto repeat;
  box-shadow:
    0 10px 22px rgba(59, 75, 52, 0.16),
    0 2px 0 rgba(255, 255, 255, 0.65) inset;
  transform: rotate(0.8deg);
}

.hud-card .resource-cluster::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: -6px;
  left: 50%;
  width: 47px;
  height: 13px;
  border: 1px solid rgba(157, 126, 55, 0.12);
  background: rgba(235, 211, 133, 0.7);
  box-shadow: 0 2px 4px rgba(70, 60, 33, 0.08);
  transform: translateX(-50%) rotate(-2deg);
}

.hud-card .resource-cluster::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 15px;
  height: 15px;
  border-radius: 8px 0 5px;
  background: linear-gradient(135deg, rgba(215, 195, 135, 0.38) 49%, rgba(255, 252, 231, 0.88) 51%);
  filter: drop-shadow(-2px -1px 2px rgba(93, 73, 35, 0.08));
}

.hud-card .resource-pill {
  min-width: 0;
  min-height: 36px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 3px;
  align-content: center;
  padding: 1px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.hud-card .resource-pill + .resource-pill {
  border-left: 1px dashed rgba(111, 89, 48, 0.2);
}

.hud-card .resource-icon {
  grid-row: 1 / 3;
  width: 22px;
  height: 22px;
  align-self: center;
}

.hud-card .resource-label {
  display: inline;
  min-width: 0;
  color: #7a6842;
  font: 600 0.59rem/1.05 "Noto Serif SC", "Songti SC", serif;
  white-space: nowrap;
}

.hud-card .resource-pill strong {
  color: #324838;
  font: 800 0.82rem/1.05 ui-rounded, "Microsoft YaHei", sans-serif;
}

/* Keep the book count and close control in separate, stable header lanes. */
.map-panel .skill-card-tray[open] > summary {
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  margin: 0;
  list-style: none;
  line-height: 1;
  transform: none;
}

.map-panel .skill-card-tray[open] > summary::-webkit-details-marker {
  display: none;
}

.map-panel .skill-card-tray[open] > summary::before {
  content: "×";
  display: block;
  width: auto;
  height: auto;
  margin: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font: 400 25px/1 Georgia, serif;
  transform: translateY(-1px);
}

.skill-card-book-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  margin: 0 0 10px;
  padding: 0 54px 11px 0;
}

.skill-card-book-head > span {
  align-self: center;
  white-space: nowrap;
}

@media (max-width: 370px) {
  .hud-card .resource-cluster {
    width: min(164px, 46vw);
    padding-right: 5px;
    padding-left: 5px;
  }
}

/* Release B.6: opening a cottage conversation lands on a full writing page. */
.ai-cottage-page .ai-conversation-card {
  position: relative;
  isolation: isolate;
  min-height: clamp(590px, 78dvh, 760px);
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto auto;
  gap: 12px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 252, 237, 0.74), rgba(244, 236, 208, 0.88)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 520px auto repeat;
}

.ai-cottage-page .ai-conversation-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(248, 240, 212, 0.18), rgba(248, 240, 212, 0.72) 76%),
    url("../../assets/runtime/ui/optimized/ai-cottage-background.webp") center 34% / cover no-repeat;
  opacity: 0.3;
  filter: saturate(0.82) sepia(0.08);
  pointer-events: none;
}

.ai-cottage-page .ai-message-list {
  min-height: 360px;
  max-height: none;
  align-content: start;
  overscroll-behavior: contain;
  background: rgba(255, 252, 237, 0.58);
  box-shadow: inset 0 0 0 1px rgba(89, 77, 48, 0.08);
}

.ai-cottage-page .ai-empty-workbench {
  min-height: 100%;
  background: rgba(255, 252, 237, 0.34);
}

.ai-cottage-page .ai-composer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 8px;
  border: 1px solid rgba(91, 76, 43, 0.14);
  border-radius: 5px 13px 6px 11px;
  background:
    linear-gradient(145deg, rgba(255, 253, 244, 0.94), rgba(237, 229, 197, 0.9)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 420px auto;
  box-shadow: 0 8px 20px rgba(50, 54, 34, 0.12);
}

@media (max-width: 390px) {
  .ai-cottage-page .ai-conversation-card {
    min-height: max(610px, calc(100dvh - 118px));
    padding: 13px 11px;
    grid-template-rows: auto minmax(390px, 1fr) auto auto;
  }
}

/* Restore the compact daily-task note selected in the shop mockup. */
.town-view > .task-preview {
  width: 158px;
  min-height: 94px;
  right: max(10px, calc(var(--safe-right) + 8px));
  bottom: max(12px, calc(var(--safe-bottom) + 8px));
  padding: 10px 15px 9px 12px;
  border: 1px solid rgba(91, 72, 38, 0.24);
  border-radius: 5px 15px 7px 11px;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,.7), transparent 38%),
    repeating-linear-gradient(8deg, rgba(105,88,50,.025) 0 1px, transparent 1px 7px),
    linear-gradient(90deg, rgba(99,77,38,.07), transparent 8%, transparent 94%, rgba(91,70,34,.08)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 310px auto repeat;
  box-shadow:
    0 1px rgba(255,255,255,.82) inset,
    0 0 0 3px rgba(255,255,255,.18) inset,
    2px 4px 0 rgba(87,70,36,.05),
    0 10px 22px rgba(36,51,35,.23);
  transform: rotate(.35deg);
}

.town-view > .task-preview::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: auto;
  right: 14px;
  bottom: -18px;
  left: auto;
  width: 11px;
  height: 38px;
  border-radius: 0 0 2px 2px;
  background:
    linear-gradient(90deg, rgba(38,62,43,.22), transparent 34%, rgba(255,255,255,.18) 58%, rgba(34,57,41,.2)),
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / cover;
  box-shadow: 2px 3px 6px rgba(36,51,35,.16);
}

.town-view > .task-preview::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 14px;
  height: 14px;
  background: linear-gradient(225deg, rgba(218,201,151,.72) 0 47%, transparent 50%);
  filter: drop-shadow(-1px 1px 1px rgba(64,54,33,.08));
}

.town-view > .task-preview .section-heading {
  padding-right: 18px;
}

.town-view > .task-preview .task-preview-trigger {
  min-height: 54px;
}

.town-view > .task-preview .task-preview-title {
  font-size: .72rem;
  -webkit-line-clamp: 1;
}

.town-view > .task-preview .task-preview-copy {
  font-size: .6rem;
}

.town-view > .task-preview .task-preview-metric {
  padding: 2px 5px;
  background: rgba(119,145,112,.09);
}

/* Release B.7: a visible route home and quieter, more celestial star labels. */
.home-page.is-galaxy-chapter .memory-galaxy-back {
  position: absolute;
  z-index: 30;
  top: max(14px, calc(env(safe-area-inset-top) + 8px));
  left: max(14px, calc(env(safe-area-inset-left) + 10px));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(240, 220, 255, 0.24);
  border-radius: 22px 8px 18px 22px;
  color: rgba(255, 247, 225, 0.94);
  text-align: left;
  background:
    linear-gradient(145deg, rgba(65, 40, 80, 0.82), rgba(20, 28, 52, 0.88));
  box-shadow:
    0 9px 22px rgba(2, 1, 12, 0.34),
    inset 0 1px rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.memory-galaxy-back > span:first-child {
  display: grid;
  place-items: center;
  font: 400 1.18rem/1 Georgia, serif;
}

.memory-galaxy-back > span:last-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.memory-galaxy-back small {
  color: rgba(226, 202, 240, 0.58);
  font: 600 0.46rem/1.1 Georgia, serif;
  letter-spacing: 0.12em;
}

.memory-galaxy-back strong {
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

.home-page.is-galaxy-chapter .memory-galaxy .home-memory-card-head {
  padding-inline: 68px;
}

.home-page.is-galaxy-chapter .memory-galaxy .home-memory-card-head .feature-kicker {
  font-size: clamp(1.42rem, 7vw, 1.7rem);
}

/* Compact owned-building badge: map context only, never above open feature pages. */
.building-summary {
  min-width: 38px;
  min-height: 32px;
  display: inline-grid;
  grid-template-columns: 18px auto;
  place-items: center;
  gap: 2px;
  padding: 3px 7px 3px 4px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  color: #315c46;
  background: rgba(248, 246, 224, 0.78);
  box-shadow: 0 5px 14px rgba(36, 73, 52, 0.14);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.building-summary img {
  width: 21px;
  height: 21px;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(49, 76, 53, 0.18));
}

.building-summary span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.building-summary strong {
  min-width: 12px;
  font-size: 0.7rem;
  line-height: 1;
}

.app-surface:has(.building-layer:not([hidden])) .building-summary {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 380px) {
  .home-page.is-galaxy-chapter .memory-galaxy-back {
    top: max(10px, calc(env(safe-area-inset-top) + 6px));
    left: max(10px, calc(env(safe-area-inset-left) + 6px));
    width: 40px;
    height: 40px;
  }

  .home-page.is-galaxy-chapter .memory-galaxy .home-memory-card-head {
    padding-inline: 58px;
  }
}

.memory-galaxy-back:focus-visible {
  outline: 2px solid rgba(255, 232, 169, 0.92);
  outline-offset: 3px;
}

.memory-galaxy-stage {
  background:
    radial-gradient(ellipse at 49% 51%, rgba(210, 158, 227, 0.13), transparent 18%),
    radial-gradient(ellipse at 68% 40%, rgba(97, 133, 208, 0.1), transparent 34%),
    radial-gradient(ellipse at 27% 66%, rgba(209, 135, 181, 0.08), transparent 32%),
    linear-gradient(155deg, #070711, #0c1120 55%, #100a19);
}

.memory-star-list .memory-star.is-selected {
  padding: 4px 9px;
  border: 1px solid rgba(246, 226, 255, 0.18);
  border-radius: 999px;
  background: rgba(17, 11, 30, 0.42);
  box-shadow: 0 5px 16px rgba(3, 2, 12, 0.24);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

@media (prefers-reduced-motion: no-preference) {
  .memory-galaxy-back {
    animation: memory-back-arrive 420ms cubic-bezier(.2, .78, .2, 1) both;
  }
}

@keyframes memory-back-arrive {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* --------------------------------------------------------------------------
   Map action dock
   Closed skill cards are a small book icon; dice remains the primary action.
   This layer intentionally avoids backdrop-filter so the map can composite
   cheaply on lower-end phones.
   -------------------------------------------------------------------------- */

.map-panel .skill-card-mount {
  position: absolute;
  right: max(14px, calc(env(safe-area-inset-right) + 10px));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 34;
  width: auto;
  max-width: none;
  pointer-events: none;
}

.map-panel .skill-card-tray {
  position: relative;
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  pointer-events: auto;
}

.map-panel .skill-card-tray > summary {
  position: relative;
  display: grid;
  width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 252, 224, 0.88);
  border-radius: 18px;
  color: #fffbe5;
  background:
    linear-gradient(145deg, rgba(61, 91, 61, 0.96), rgba(31, 61, 47, 0.98));
  box-shadow:
    0 9px 20px rgba(25, 49, 35, 0.24),
    inset 0 1px rgba(255, 255, 255, 0.24);
  cursor: pointer;
  list-style: none;
}

.map-panel .skill-card-tray > summary::-webkit-details-marker {
  display: none;
}

.map-panel .skill-card-tray > summary::before {
  content: "";
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: url("../../assets/runtime/ui/skill-card-icon.png") center / cover no-repeat;
  box-shadow:
    0 3px 10px rgba(21, 40, 29, 0.28),
    inset 0 0 0 1px rgba(255, 252, 222, 0.64);
}

.map-panel .skill-card-tray > summary > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.map-panel .skill-card-tray > summary > strong {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border: 2px solid #fff8dc;
  border-radius: 999px;
  color: #294c3b;
  background: #f5d66f;
  font: 800 10px/1 ui-rounded, "Microsoft YaHei", sans-serif;
  box-shadow: 0 3px 8px rgba(25, 49, 35, 0.22);
}

.map-panel .skill-card-tray[open] {
  width: min(328px, calc(100vw - 28px));
  max-width: min(328px, calc(100vw - 28px));
  padding: 54px 12px 12px;
  border: 1px solid rgba(255, 251, 221, 0.9);
  border-radius: 24px;
  color: #294c3b;
  background: rgba(255, 252, 229, 0.97);
  box-shadow: 0 18px 44px rgba(25, 49, 35, 0.27);
  overflow: auto;
  max-height: min(62vh, 430px);
  overscroll-behavior: contain;
}

.map-panel .skill-card-tray[open] > summary {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 14px;
}

.map-panel .skill-card-tray[open] > summary::before {
  content: "×";
  width: auto;
  height: auto;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: 25px;
}

.map-panel .skill-card-tray[open] > summary > strong {
  display: none;
}

.map-panel .skill-card-hint {
  margin: -36px 52px 10px 2px;
  font-size: 12px;
  line-height: 1.45;
}

.map-panel .skill-card-hand {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.map-panel .skill-card-button,
.map-panel .skill-card-empty,
.map-panel .skill-effect-active,
.map-panel .skill-overflow {
  min-width: 0;
  border-radius: 15px;
}

.map-panel .skill-card-button {
  min-height: 76px;
  padding: 10px 12px;
}

.map-panel .skill-card-empty {
  padding: 12px;
}

/* The stage label exists for screen/state feedback, but is never allowed to
   leak into idle/armed/moving UI. */
.map-panel .dice-roll-stage {
  display: none !important;
}

.map-panel .dice-view-mount.is-dice-stage-active .dice-roll-stage {
  display: grid !important;
}

/* Reserve a separate action lane for the die. The skill book sits to its
   right, with enough room at 360/390/430 widths and all safe-area sizes. */
.map-panel .dice-view-mount {
  right: max(82px, calc(env(safe-area-inset-right) + 78px));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 33;
}

@media (max-width: 430px) {
  .map-panel .skill-card-mount {
    right: max(12px, calc(env(safe-area-inset-right) + 8px));
    bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px));
  }

  .map-panel .dice-view-mount {
    right: max(76px, calc(env(safe-area-inset-right) + 72px));
    bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px));
  }

  .map-panel .skill-card-tray[open] {
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(82px, calc(env(safe-area-inset-bottom) + 76px));
    width: min(316px, calc(100vw - 20px));
    max-width: min(316px, calc(100vw - 20px));
    max-height: min(56vh, 400px);
  }

  .map-panel .dice-fab-copy {
    display: none;
  }

  .map-panel .dice-fab {
    width: 56px;
    min-width: 56px;
    height: 56px;
    min-height: 56px;
    padding: 0;
    justify-content: center;
    border-radius: 18px;
  }

  .map-panel .dice-fab-visual {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }
}

@media (max-width: 370px) {
  .map-panel .skill-card-tray,
  .map-panel .skill-card-tray > summary {
    width: 52px;
    min-width: 52px;
  }

  .map-panel .skill-card-tray > summary {
    height: 52px;
    min-height: 52px;
    border-radius: 17px;
  }

  .map-panel .dice-view-mount {
    right: max(70px, calc(env(safe-area-inset-right) + 66px));
  }

  .map-panel .dice-fab {
    width: 52px;
    min-width: 52px;
    height: 52px;
    min-height: 52px;
    border-radius: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-panel .skill-card-tray,
  .map-panel .skill-card-tray > summary {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   Release B · Living Field Guide
   The map remains the world; the journal is a tactile, playable layer.
   -------------------------------------------------------------------------- */

.app-shell {
  background:
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / 520px auto repeat,
    #6f8061;
}

.phone-frame {
  max-width: 430px;
}

.app-surface {
  isolation: isolate;
  background: #a9c990;
  box-shadow:
    0 28px 70px rgba(30, 48, 37, 0.28),
    0 0 0 1px rgba(255, 249, 222, 0.3);
}

.hud-card {
  top: max(12px, calc(var(--safe-top) + 8px));
  right: 10px;
  left: 10px;
  align-items: center;
}

.player-chip,
.resource-cluster {
  border: 1px solid rgba(116, 91, 48, 0.16);
  border-radius: 8px 15px 7px 13px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.54), rgba(244, 234, 201, 0.22)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 360px auto repeat;
  box-shadow:
    0 8px 18px rgba(50, 62, 39, 0.2),
    inset 0 0 0 2px rgba(255, 255, 255, 0.2);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.player-chip {
  padding: 6px 10px 6px 6px;
  transform: rotate(-0.6deg);
}

.player-chip:hover {
  transform: translateY(-1px) rotate(-0.6deg);
}

.player-chip-avatar {
  width: 42px;
  height: 42px;
  border: 3px solid #f8efd3;
  box-shadow:
    0 0 0 1px rgba(67, 83, 55, 0.32),
    0 5px 12px rgba(42, 59, 39, 0.2);
}

.player-chip-copy strong {
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.resource-cluster {
  gap: 3px;
  padding: 5px 6px;
  transform: rotate(0.45deg);
}

.resource-pill,
.resource-pill-coin,
.resource-pill-dice {
  min-height: 34px;
  padding: 2px 5px;
  border: 0;
  border-radius: 4px 9px 5px 8px;
  background: rgba(255, 250, 229, 0.48);
  box-shadow: none;
}

.resource-icon {
  width: 23px;
  height: 23px;
}

.resource-label {
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  color: #4d553a;
}

.sync-indicator {
  display: none;
}

.building-entry-label,
.building-entry-progress,
.building-entry-status {
  border-color: rgba(105, 84, 48, 0.16);
  border-radius: 5px 11px 6px 9px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.32), rgba(241, 229, 191, 0.18)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 260px auto repeat;
  color: #39442f;
  box-shadow: 0 5px 12px rgba(42, 58, 38, 0.17);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  text-shadow: none;
}

.field-journal-launcher {
  --field-journal-dock-height: 188px;
  position: absolute;
  z-index: 24;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--field-journal-dock-height);
  overflow: hidden;
  pointer-events: none;
}

.field-journal-cover {
  width: 244px;
  height: 156px;
  position: absolute;
  right: -24px;
  bottom: -26px;
  border: 1px solid rgba(44, 61, 40, 0.6);
  border-radius: 24px 4px 0 0;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.12), transparent 38%, rgba(31, 53, 39, 0.22)),
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / 360px auto repeat;
  box-shadow:
    -14px -12px 30px rgba(34, 52, 36, 0.28),
    inset 5px 0 rgba(255, 255, 255, 0.08);
  transform: rotate(-1.8deg);
  /*
   * The cover is decorative. Keeping the empty cloth area click-through
   * preserves direct interaction with map buildings underneath it.
   */
  pointer-events: none;
}

.field-journal-cover::after {
  content: "";
  position: absolute;
  top: 11px;
  right: 11px;
  bottom: 18px;
  left: 14px;
  border: 1px solid rgba(248, 237, 196, 0.14);
  border-radius: 16px 3px 4px 4px;
  pointer-events: none;
}

.field-journal-botanical {
  width: 70px;
  height: 70px;
  position: absolute;
  right: 18px;
  top: 26px;
  object-fit: contain;
  opacity: 0.34;
  filter: sepia(0.35) saturate(0.65) drop-shadow(0 4px 8px rgba(30, 48, 37, 0.16));
  transform: rotate(13deg);
}

.field-journal-page {
  width: 184px;
  min-height: 112px;
  position: absolute;
  top: -24px;
  left: 15px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 18px 23px 16px 20px;
  border: 1px solid rgba(103, 82, 46, 0.2);
  border-radius: 5px 18px 8px 13px;
  color: #344530;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.48), rgba(242, 230, 191, 0.12)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 360px auto repeat;
  box-shadow:
    0 9px 20px rgba(41, 55, 36, 0.22),
    5px 6px 0 -2px rgba(236, 224, 187, 0.9),
    8px 9px 0 -4px rgba(216, 203, 164, 0.7);
  text-align: left;
  transform: rotate(2.4deg);
  transition: transform 260ms cubic-bezier(.2,.8,.2,1), box-shadow 260ms ease;
  pointer-events: auto;
}

.field-journal-page:hover,
.field-journal-page:focus-visible {
  transform: translateY(-7px) rotate(1.2deg);
  box-shadow:
    0 16px 28px rgba(41, 55, 36, 0.28),
    5px 6px 0 -2px rgba(236, 224, 187, 0.9),
    8px 9px 0 -4px rgba(216, 203, 164, 0.7);
}

.field-journal-page > span {
  color: rgba(52, 69, 48, 0.62);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.field-journal-page strong {
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  font-size: 1.22rem;
  letter-spacing: 0.12em;
}

.field-journal-page small {
  color: rgba(52, 69, 48, 0.7);
  font-size: 0.68rem;
}

.field-journal-ribbon {
  width: 17px;
  height: 94px;
  position: absolute;
  left: 132px;
  top: 78px;
  background: #8aa256;
  box-shadow: inset 2px 0 rgba(255, 255, 255, 0.18);
  transform: rotate(1.5deg);
}

.field-journal-tabs {
  position: absolute;
  top: 18px;
  right: -2px;
  display: grid;
  gap: 7px;
}

.field-journal-tabs span {
  min-width: 43px;
  padding: 6px 5px 6px 10px;
  border-radius: 5px 0 0 5px;
  background:
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 180px auto,
    #d9c78d;
  color: #405039;
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  font-size: 0.64rem;
  text-align: center;
  box-shadow: -4px 4px 9px rgba(39, 54, 37, 0.16);
}

.field-journal-tabs span:nth-child(2) { background-color: #aeba82; }
.field-journal-tabs span:nth-child(3) { background-color: #baa9b8; }

.field-bookmarks {
  position: absolute;
  left: max(12px, calc(var(--safe-left) + 8px));
  bottom: max(10px, calc(var(--safe-bottom) + 6px));
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.field-bookmark {
  min-width: 62px;
  min-height: 76px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 8px 7px;
  border: 1px solid rgba(74, 66, 42, 0.28);
  border-radius: 5px 12px 7px 9px;
  color: #3b4a35;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.5), transparent),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 220px auto repeat;
  box-shadow: 0 8px 18px rgba(36, 51, 35, 0.24);
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  font-size: 0.7rem;
  transform: rotate(-2deg);
}

.field-bookmark-skill {
  color: #f5f0d7;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.09), rgba(18, 38, 29, 0.22)),
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / 240px auto repeat;
  transform: translateY(3px) rotate(1.5deg);
}

.field-bookmark img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.field-bookmark:hover,
.field-bookmark:focus-visible {
  transform: translateY(-5px) rotate(0);
}

.map-panel .dice-view-mount {
  right: auto;
  /*
   * The die owns a separate action shelf above the journal. This prevents it
   * from covering the page button or either bookmark at narrow phone widths.
   */
  bottom: max(
    174px,
    calc(var(--safe-bottom) + 170px)
  );
  left: 50%;
  z-index: 25;
  transform: translateX(-50%);
}

.map-panel .dice-fab {
  width: 60px;
  min-width: 60px;
  height: 60px;
  min-height: 60px;
  position: relative;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(82, 70, 43, 0.28);
  border-radius: 7px 15px 8px 13px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(226, 214, 175, 0.44)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 220px auto repeat;
  box-shadow:
    0 9px 18px rgba(35, 50, 36, 0.24),
    inset 0 0 0 2px rgba(255, 255, 255, 0.24);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.map-panel .dice-fab-visual {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
}

.map-panel .dice-fab-canvas {
  width: 58px;
  height: 58px;
}

.map-panel .dice-fab-badge {
  min-width: 24px;
  min-height: 24px;
  position: absolute;
  z-index: 2;
  top: -9px;
  right: -9px;
  order: initial;
  border: 2px solid rgba(255, 250, 229, 0.9);
  box-shadow: 0 4px 9px rgba(42, 58, 39, 0.2);
}

.map-panel .dice-fab-copy {
  display: none;
}

.map-panel .skill-card-mount {
  display: block;
  right: max(10px, calc(var(--safe-right) + 8px));
  bottom: max(88px, calc(var(--safe-bottom) + 82px));
  z-index: 35;
}

.map-panel .skill-card-tray:not([open]) {
  visibility: hidden;
  pointer-events: none;
}

.map-panel .skill-card-tray[open] {
  visibility: visible;
}

.task-drawer[open] {
  display: grid;
  align-items: end;
  padding: 0;
}

.task-drawer:not([open]) {
  display: none;
}

.task-drawer::backdrop {
  background: linear-gradient(180deg, rgba(25, 46, 33, 0.04), rgba(25, 46, 33, 0.26));
  backdrop-filter: none;
}

.task-drawer-panel {
  width: min(calc(100% - 10px), 420px);
  height: min(62dvh, 560px);
  max-height: min(62dvh, 560px);
  margin: auto auto 0;
  border: 1px solid rgba(52, 68, 45, 0.45);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  background:
    linear-gradient(90deg, rgba(61, 77, 53, 0.14), transparent 8%, transparent 95%, rgba(61, 77, 53, 0.12)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 520px auto repeat;
  box-shadow:
    0 -18px 44px rgba(25, 44, 31, 0.3),
    inset 0 0 0 4px rgba(255,255,255,0.2);
  animation: field-journal-open 430ms cubic-bezier(.2,.82,.18,1) both;
}

.task-drawer-panel::before {
  width: 14px;
  border-radius: 28px 0 0 0;
  background:
    linear-gradient(90deg, rgba(28, 47, 34, 0.55), rgba(255,255,255,0.14)),
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / cover;
}

.task-drawer-panel::after {
  inset: 7px;
  border-radius: 22px 22px 0 0;
}

.task-drawer-header {
  min-height: 66px;
  padding: 13px 16px 9px 24px;
  background:
    linear-gradient(90deg, rgba(255, 252, 239, 0.86), rgba(255, 252, 239, 0.52)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 520px auto repeat;
}

.task-drawer-title {
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  letter-spacing: 0.12em;
}

.task-journal-tabs {
  padding: 7px 14px 0 22px;
  background: transparent;
}

.task-journal-summary {
  margin: 10px 14px 4px 22px;
  padding: 11px 13px;
  border-radius: 7px 14px 9px 12px;
  color: #3e4b35;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.48), rgba(238,226,187,0.12)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 420px auto repeat;
  box-shadow: 0 6px 14px rgba(55, 67, 45, 0.1);
  transform: none;
}

.task-summary-grid {
  display: none;
}

.task-drawer-scroll {
  padding: 9px 14px 18px 22px;
}

.task-drawer-panel .task-group-heading {
  margin-bottom: 7px;
}

.task-drawer-panel .task-group-heading p,
.task-drawer-panel .task-card-time {
  display: none;
}

.task-drawer-panel .task-card {
  min-height: 92px;
  gap: 8px;
  padding: 10px 11px;
  border-radius: 5px 15px 8px 12px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.48), rgba(241, 229, 191, 0.12)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 420px auto repeat;
  box-shadow: 0 7px 16px rgba(51, 65, 43, 0.11);
}

.task-drawer-panel .task-card-body {
  gap: 5px;
}

.task-drawer-panel .task-card-head,
.task-drawer-panel .task-card-meta {
  align-items: center;
  flex-direction: row;
}

.task-drawer-panel .task-card-desc {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.76rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

@keyframes field-journal-open {
  from { opacity: 0; transform: translateY(58%) rotate(1.5deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}

@media (max-width: 390px) {
  .player-chip-copy small,
  .resource-label {
    display: none;
  }

  .player-chip {
    padding-right: 7px;
  }

  .player-chip-copy strong {
    max-width: 84px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .resource-cluster {
    gap: 1px;
  }

  .resource-pill {
    padding-right: 4px;
    padding-left: 3px;
  }

  .field-journal-cover {
    right: -38px;
  }

  .field-journal-page {
    width: 176px;
  }

  .field-bookmark {
    min-width: 58px;
  }

  .map-panel .dice-view-mount {
    bottom: max(
      172px,
      calc(var(--safe-bottom) + 168px)
    );
  }
}

@media (max-height: 700px) {
  .field-journal-launcher {
    --field-journal-dock-height: 152px;
    height: 152px;
  }

  .field-journal-cover {
    bottom: -52px;
  }

  .field-bookmark {
    min-height: 66px;
  }

  .map-panel .dice-view-mount {
    bottom: max(
      136px,
      calc(var(--safe-bottom) + 132px)
    );
  }

  .task-drawer-panel {
    height: min(68dvh, 540px);
    max-height: min(68dvh, 540px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .field-journal-page,
  .field-bookmark,
  .task-drawer-panel {
    animation: none;
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   Release B.2 · one dock, two entries
   The duplicate "今日任务" page has been removed from the DOM. The bottom dock
   now contains only the task and skill-card bookmarks, while the die occupies
   the free center lane.
   -------------------------------------------------------------------------- */

.field-journal-launcher {
  --field-journal-dock-height: 96px;
  height: var(--field-journal-dock-height);
  overflow: visible;
}

.field-bookmarks {
  bottom: max(10px, calc(var(--safe-bottom) + 6px));
}

.map-panel .dice-view-mount {
  bottom: max(15px, calc(var(--safe-bottom) + 11px));
}

@media (max-width: 390px) {
  .map-panel .dice-view-mount {
    bottom: max(15px, calc(var(--safe-bottom) + 11px));
  }
}

@media (max-height: 700px) {
  .field-journal-launcher {
    --field-journal-dock-height: 88px;
    height: var(--field-journal-dock-height);
  }

  .map-panel .dice-view-mount {
    bottom: max(12px, calc(var(--safe-bottom) + 8px));
  }
}

/* Skill-card book sheet */
.map-panel .skill-card-mount {
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 36;
  width: auto;
  max-width: none;
  max-height: none;
  pointer-events: none;
}

.map-panel .skill-card-tray:not([open]) {
  visibility: hidden;
  pointer-events: none;
}

.map-panel .skill-card-tray[open] {
  position: fixed;
  right: max(10px, calc(var(--safe-right) + 8px));
  bottom: max(104px, calc(var(--safe-bottom) + 100px));
  left: max(10px, calc(var(--safe-left) + 8px));
  width: auto;
  min-width: 0;
  max-width: 410px;
  max-height: min(52dvh, 430px);
  margin: 0 auto;
  padding: 15px 15px 16px 23px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(88, 72, 41, 0.34);
  border-radius: 5px 18px 8px 15px;
  color: #314638;
  background:
    linear-gradient(90deg, rgba(73, 61, 36, 0.1), transparent 7%, transparent 95%, rgba(73, 61, 36, 0.06)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 520px auto repeat;
  box-shadow:
    0 20px 45px rgba(25, 43, 31, 0.28),
    inset 0 0 0 3px rgba(255, 255, 255, 0.23);
  visibility: visible;
  pointer-events: auto;
  overscroll-behavior: contain;
  animation: skill-book-rise 280ms cubic-bezier(.2, .82, .2, 1) both;
}

.map-panel .skill-card-tray[open]::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 10px;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(27, 48, 35, 0.46), rgba(255, 255, 255, 0.12)),
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / cover;
  box-shadow: 4px 0 12px rgba(43, 53, 35, 0.12);
}

.map-panel .skill-card-tray[open] > summary {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  border: 1px solid rgba(255, 250, 222, 0.3);
  border-radius: 5px 12px 6px 10px;
  color: #fff8e4;
  background:
    linear-gradient(145deg, rgba(92, 117, 82, 0.92), rgba(46, 73, 55, 0.98)),
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / cover;
  box-shadow: 0 6px 13px rgba(36, 57, 42, 0.2);
}

.map-panel .skill-card-tray[open] > summary::before {
  content: "×";
  width: auto;
  height: auto;
  border: 0;
  box-shadow: none;
  font: 400 25px/1 Georgia, serif;
}

.map-panel .skill-card-tray[open] > summary > strong {
  display: none;
}

.skill-card-book-head {
  min-height: 52px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 48px 10px 0;
  padding: 0 0 11px;
  border-bottom: 1px solid rgba(86, 72, 41, 0.2);
}

.skill-card-book-head p,
.skill-card-book-head h2 {
  margin: 0;
}

.skill-card-book-head p {
  color: #aa7e32;
  font: 700 0.58rem/1.2 Georgia, "Times New Roman", serif;
  letter-spacing: 0.14em;
}

.skill-card-book-head h2 {
  margin-top: 4px;
  font-family: "STKaiti", "KaiTi", "FangSong", "Songti SC", serif;
  font-size: 1.32rem;
  letter-spacing: 0.08em;
}

.skill-card-book-head > span {
  align-self: center;
  padding: 5px 8px;
  border: 1px solid rgba(91, 74, 42, 0.16);
  border-radius: 4px 9px 4px 9px;
  color: #536550;
  background: rgba(229, 220, 183, 0.48);
  font-size: 0.66rem;
  font-weight: 800;
  white-space: nowrap;
}

.map-panel .skill-card-hint {
  margin: 0 0 10px;
  color: rgba(49, 70, 56, 0.72);
  font-size: 0.72rem;
  line-height: 1.55;
}

.map-panel .skill-card-hand {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 0;
  overflow: visible;
}

.map-panel .skill-card-button,
.map-panel .skill-card-empty,
.map-panel .skill-effect-active,
.map-panel .skill-overflow {
  min-width: 0;
  border: 1px solid rgba(89, 74, 43, 0.2);
  border-radius: 5px 13px 7px 11px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.58), rgba(233, 221, 181, 0.36)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 420px auto repeat;
  box-shadow:
    2px 6px 14px rgba(62, 53, 32, 0.09),
    inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.map-panel .skill-card-button {
  min-height: 88px;
  padding: 11px 12px;
}

.map-panel .skill-card-button strong,
.map-panel .skill-card-empty strong {
  font-family: "STKaiti", "KaiTi", "FangSong", "Songti SC", serif;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.map-panel .skill-card-timing,
.map-panel .skill-card-ready,
.map-panel .skill-card-reason {
  border: 1px solid rgba(84, 73, 44, 0.12);
  border-radius: 3px 8px 3px 7px;
}

.map-panel .skill-card-empty {
  position: relative;
  padding: 14px 14px 13px;
  border-style: solid;
}

.map-panel .skill-card-empty::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 24px;
  width: 58px;
  height: 13px;
  background: rgba(215, 184, 100, 0.5);
  box-shadow: 0 2px 3px rgba(70, 55, 27, 0.08);
  transform: rotate(-2deg);
}

@keyframes skill-book-rise {
  from { opacity: 0; transform: translateY(24px) rotate(.4deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}

@media (max-width: 370px) {
  .map-panel .skill-card-tray[open] {
    right: 8px;
    left: 8px;
    padding-right: 13px;
    padding-left: 21px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-panel .skill-card-tray[open] {
    animation: none;
  }
}

/* Release B.3: skill cards / die / daily task each own a separate dock lane. */
.field-bookmark-skill img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(27, 43, 30, 0.3));
}

.town-view > .task-preview {
  width: 150px;
  min-height: 108px;
  position: absolute;
  right: max(10px, calc(var(--safe-right) + 8px));
  bottom: max(10px, calc(var(--safe-bottom) + 6px));
  z-index: 25;
  display: grid;
  gap: 3px;
  padding: 9px 10px 10px;
  overflow: hidden;
  border: 1px solid rgba(85, 71, 42, 0.25);
  border-radius: 7px 16px 9px 12px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.5), rgba(241,229,191,0.12)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 250px auto repeat;
  box-shadow: 0 8px 18px rgba(36, 51, 35, 0.24);
  transform: rotate(0.7deg);
}

.town-view > .task-preview .section-heading {
  min-height: 0;
  margin: 0;
  padding: 0 0 4px;
  border-bottom: 1px solid rgba(93, 77, 45, 0.2);
}

.town-view > .task-preview .section-heading span {
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  font-size: 0.84rem;
}

.town-view > .task-preview .section-heading small,
.town-view > .task-preview .task-preview-chevron,
.town-view > .task-preview .task-preview-metric:nth-child(n + 2) {
  display: none;
}

.town-view > .task-preview .task-preview-trigger {
  min-height: 66px;
  display: grid;
  gap: 4px;
  padding: 2px 0 0;
}

.town-view > .task-preview .task-preview-main {
  display: block;
}

.town-view > .task-preview .task-preview-title {
  display: -webkit-box;
  overflow: hidden;
  color: #39442f;
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  font-size: 0.75rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.town-view > .task-preview .task-preview-copy {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 2px;
  color: #68705c;
  font-size: 0.64rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.town-view > .task-preview .task-preview-metrics {
  display: block;
}

.town-view > .task-preview .task-preview-metric {
  min-height: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 5px 9px 5px 8px;
  background: rgba(143, 178, 155, 0.13);
}

.town-view > .task-preview .task-preview-metric-label {
  font-size: 0.6rem;
}

.town-view > .task-preview .task-preview-metric-value {
  font-size: 0.72rem;
}

@media (max-height: 700px) {
  .town-view > .task-preview {
    bottom: max(8px, calc(var(--safe-bottom) + 4px));
  }
}

/* Real ambient cloud artwork floats over the map without intercepting buildings. */
/* A newly acquired field card blooms out of the real daisy particle set. */
.skill-card-reveal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255,250,221,.28), transparent 47%);
}

.skill-card-reveal-card {
  width: min(58vw, 225px);
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 14px 14px 17px;
  border: 1px solid rgba(92, 75, 40, .32);
  border-radius: 11px 24px 13px 19px;
  color: #33432f;
  text-align: center;
  background:
    linear-gradient(145deg, rgba(255,255,255,.56), rgba(240,225,183,.18)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 330px auto;
  box-shadow: 0 22px 55px rgba(36, 49, 33, .34);
  animation: skill-card-bloom 2.15s cubic-bezier(.2,.82,.2,1) both;
}

.skill-card-reveal-card > img {
  width: 94px;
  height: 94px;
  justify-self: center;
  object-fit: contain;
  filter: drop-shadow(0 7px 9px rgba(55, 48, 31, .2));
}

.skill-card-reveal-card figcaption {
  display: grid;
  gap: 3px;
}

.skill-card-reveal-card small {
  color: #a17d2e;
  font-size: .66rem;
  letter-spacing: .16em;
}

.skill-card-reveal-card strong {
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  font-size: 1.2rem;
}

.skill-card-reveal-card span {
  color: #66705c;
  font-size: .72rem;
  line-height: 1.5;
}

.skill-card-reveal-burst {
  width: 256px;
  height: 256px;
  position: absolute;
  background: url("../../assets/runtime/ui/growth/growth-petal-bloom-burst-sheet.png") 0 center / 800% 100% no-repeat;
  animation: daisy-burst .72s steps(8) .2s both;
}

.skill-card-reveal-petal {
  --angle: calc(var(--petal-index) * 30deg);
  width: 42px;
  height: 42px;
  position: absolute;
  object-fit: contain;
  opacity: 0;
  animation: daisy-petal-flight 1.55s cubic-bezier(.18,.72,.2,1) calc(.24s + var(--petal-index) * 22ms) both;
}

@keyframes skill-card-bloom {
  0% { opacity: 0; transform: translateY(34px) scale(.68) rotate(-4deg); }
  22%, 78% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
  100% { opacity: 0; transform: translateY(-15px) scale(1.03); }
}

@keyframes daisy-burst {
  from { opacity: 0; background-position-x: 0; transform: scale(.55); }
  35% { opacity: 1; }
  to { opacity: 0; background-position-x: 100%; transform: scale(1.2); }
}

@keyframes daisy-petal-flight {
  0% { opacity: 0; transform: rotate(var(--angle)) translateY(0) scale(.35); }
  18% { opacity: .92; }
  100% { opacity: 0; transform: rotate(var(--angle)) translateY(-190px) rotate(150deg) scale(.8); }
}

/* Existing feature artwork becomes restrained chapter illustration, not wallpaper. */
.shop-page,
.home-page,
.ai-cottage-page {
  position: relative;
  isolation: isolate;
}

.shop-page::before,
.home-page::before,
.ai-cottage-page::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  right: 0;
  width: 72%;
  height: 42%;
  opacity: .14;
  background: var(--chapter-art) top right / cover no-repeat;
  mask-image: linear-gradient(145deg, #000, transparent 76%);
  -webkit-mask-image: linear-gradient(145deg, #000, transparent 76%);
  pointer-events: none;
}

.shop-page { --chapter-art: url("../../assets/runtime/ui/optimized/shop-greeting-background.webp"); }
.home-page { --chapter-art: url("../../assets/runtime/ui/optimized/home-cottage-background.webp"); }
.ai-cottage-page { --chapter-art: url("../../assets/runtime/ui/optimized/ai-cottage-background.webp"); }

@media (prefers-reduced-motion: reduce) {
  .map-cloud-band,
  .skill-card-reveal-card,
  .skill-card-reveal-burst,
  .skill-card-reveal-petal {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   Release B.4 · feature-layer focus and physical-book silhouettes
   -------------------------------------------------------------------------- */

/* Map controls belong to the map only. Any opened chapter or task book hides
   them so they cannot float over feature content or intercept touch gestures. */
body:has(.building-layer.is-active) .field-journal-launcher,
body:has(.building-layer.is-active) .dice-view-mount,
body:has(.building-layer.is-active) .town-view > .task-preview,
body:has(.task-drawer[open]) .field-journal-launcher,
body:has(.task-drawer[open]) .dice-view-mount,
body:has(.task-drawer[open]) .town-view > .task-preview {
  visibility: hidden;
  opacity: 0;
  pointer-events: none !important;
  transform: translateY(16px);
}

.field-journal-launcher,
.dice-view-mount,
.town-view > .task-preview {
  transition: opacity 180ms ease, transform 220ms ease, visibility 180ms;
}

/* Zenow Cottage owns one reliable vertical scroll container on mobile. */
.building-layer[data-building-layer="aiCottage"],
.building-layer[data-building-layer="aiCottage"] > [data-ai-mount] {
  height: 100%;
  min-height: 0;
  touch-action: pan-y !important;
}

.building-layer[data-building-layer="aiCottage"] > [data-ai-mount] {
  position: relative;
  overflow: hidden;
}

.building-layer[data-building-layer="aiCottage"] .ai-cottage-page {
  height: 100% !important;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: scroll !important;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(79, 99, 72, .34) transparent;
}

/* The connection state becomes a ruled book note instead of a floating web
   status pill. */
.ai-cottage-page .ai-mode-strip,
.ai-cottage-page .ai-mode-strip.is-ready {
  min-height: 58px;
  margin: -3px 2px 0;
  padding: 9px 11px 9px 14px;
  border: 0;
  border-left: 3px solid rgba(185, 138, 54, .62);
  border-bottom: 1px solid rgba(85, 72, 43, .2);
  border-radius: 0;
  background:
    repeating-linear-gradient(180deg, transparent 0 24px, rgba(84, 101, 86, .075) 25px);
  box-shadow: none;
}

.ai-cottage-page .ai-mode-strip .feature-kicker {
  font-size: .62rem;
}

.ai-cottage-page .ai-mode-strip strong {
  font-family: var(--guide-serif);
  font-size: .88rem;
}

.ai-cottage-page .ai-mode-strip > .ai-status-dot {
  width: 10px;
  height: 10px;
  overflow: hidden;
  border-radius: 50%;
  color: transparent;
  background: #6e9b64;
  box-shadow: 0 0 0 4px rgba(110, 155, 100, .13);
}

/* Compact map task page: visible oat paper, sage cloth spine and folded page
   corner. It stays tactile without colliding with the center die. */
.town-view > .task-preview {
  width: 154px;
  min-height: 112px;
  padding: 10px 11px 10px 18px;
  border-radius: 3px 16px 7px 4px;
  isolation: isolate;
  box-shadow:
    -4px 8px 18px rgba(36, 51, 35, .25),
    inset 2px 0 rgba(255, 255, 255, .34);
  transform: rotate(.45deg);
}

.town-view > .task-preview::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -1px;
  bottom: -1px;
  left: -1px;
  width: 10px;
  border-radius: 3px 0 0 4px;
  background:
    linear-gradient(90deg, rgba(34, 59, 43, .9), rgba(255,255,255,.12)),
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / cover;
  box-shadow: 3px 0 7px rgba(41, 50, 32, .12);
}

.town-view > .task-preview::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 24px;
  height: 24px;
  background: linear-gradient(225deg, rgba(221, 207, 164, .92) 0 48%, transparent 50%);
  filter: drop-shadow(-2px 2px 2px rgba(64, 54, 33, .08));
}

/* The task drawer reads as an opened journal page, not a rounded bottom sheet. */
.task-drawer-panel {
  width: min(calc(100% - 10px), 420px);
  border-color: rgba(55, 69, 45, .42);
  border-radius: 5px 23px 0 0;
  box-shadow:
    -8px -14px 36px rgba(25, 44, 31, .24),
    inset 4px 0 0 rgba(52, 76, 57, .13),
    inset 0 0 0 3px rgba(255,255,255,.17);
}

.task-drawer-panel::before {
  width: 16px;
  border-radius: 5px 0 0 0;
}

.task-drawer-panel::after {
  inset: 7px 7px 0 12px;
  border-radius: 3px 17px 0 0;
}

.task-drawer-header {
  min-height: 72px;
  padding: 12px 15px 10px 25px;
  border-radius: 0 20px 0 0;
  box-shadow: inset 0 -1px rgba(84, 72, 45, .08);
}

.task-drawer-close {
  width: 44px;
  min-width: 44px;
  height: 48px;
  border: 1px solid rgba(79, 70, 43, .22);
  border-radius: 3px 15px 5px 10px;
  color: #41513c;
  background:
    linear-gradient(145deg, rgba(255,255,255,.55), rgba(227,216,179,.3)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 180px auto;
  box-shadow: 3px 5px 10px rgba(53, 64, 43, .11);
  transform: rotate(-1.5deg);
}

.task-journal-tabs button {
  border-radius: 4px 13px 0 0;
}

/* Release C · concept-board fidelity: torn paper HUD and an open field journal. */
.hud-card {
  top: max(10px, calc(var(--safe-top) + 6px));
  right: 12px;
  left: 12px;
  gap: 12px;
  align-items: flex-start;
}

.hud-card .player-chip,
.hud-card .resource-cluster {
  min-height: 52px;
  border: 0;
  border-radius: 0;
  background:
    url("../../assets/runtime/ui/book/optimized/ui-book-page-frame-9slice.webp") center / 100% 100% no-repeat,
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 360px auto repeat;
  box-shadow:
    0 7px 15px rgba(42, 54, 34, .24),
    0 1px rgba(255, 255, 255, .5);
}

.hud-card .player-chip {
  flex: 1 1 48%;
  max-width: 194px;
  padding: 6px 17px 7px 7px;
  transform: rotate(-1.1deg);
}

.hud-card .player-chip-avatar {
  width: 45px;
  height: 45px;
  margin: -4px 2px -3px -2px;
  border-width: 3px;
  box-shadow:
    0 0 0 2px rgba(89, 104, 65, .42),
    0 4px 9px rgba(45, 55, 35, .2);
}

.hud-card .player-chip-copy {
  min-width: 0;
}

.hud-card .player-chip-copy strong {
  overflow: hidden;
  font-family: "STKaiti", "KaiTi", "FangSong", "Songti SC", serif;
  font-size: .92rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hud-card .player-chip-copy small {
  display: none;
}

.hud-card .resource-cluster {
  flex: 0 1 210px;
  gap: 0;
  padding: 7px 10px 8px;
  transform: rotate(.6deg);
}

.hud-card .resource-pill,
.hud-card .resource-pill-coin,
.hud-card .resource-pill-dice {
  min-width: 0;
  min-height: 37px;
  flex: 1 1 50%;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 0;
  background: transparent;
}

.hud-card .resource-pill + .resource-pill {
  border-left: 1px solid rgba(82, 73, 46, .18);
}

.hud-card .resource-icon {
  width: 25px;
  height: 25px;
}

.hud-card .resource-label {
  font-size: .67rem;
}

.hud-card .resource-pill strong {
  font: 700 1.06rem/1 Georgia, "Times New Roman", serif;
}

.town-view > .task-preview {
  right: 15px;
  bottom: max(96px, calc(var(--safe-bottom) + 90px));
  width: min(76vw, 326px);
  max-width: 326px;
  min-height: 326px;
  display: block;
  padding: 29px 25px 27px 36px;
  overflow: visible;
  border: 0;
  border-radius: 0 18px 20px 3px;
  background:
    url("../../assets/runtime/ui/book/optimized/ui-book-page-frame-9slice.webp") center / 100% 100% no-repeat,
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 430px auto repeat;
  box-shadow:
    -13px 14px 25px rgba(35, 46, 30, .31),
    -7px 7px 0 rgba(218, 203, 160, .75),
    -12px 11px 0 rgba(118, 119, 82, .76);
  transform: rotate(.2deg);
}

.town-view > .task-preview::before {
  top: 9px;
  bottom: 8px;
  left: 7px;
  width: 19px;
  border-radius: 5px 0 0 5px;
  background:
    url("../../assets/runtime/ui/book/optimized/ui-book-cover-sage-seamless.webp") center / cover;
  box-shadow:
    inset -5px 0 8px rgba(31, 47, 34, .28),
    5px 0 9px rgba(48, 54, 34, .13);
}

.town-view > .task-preview::after {
  display: none;
}

.town-view > .task-preview .task-preview-book-crest {
  display: none;
}

.town-view > .task-preview .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 35px;
  margin: 0 0 10px;
  padding: 0 3px 8px;
  border-bottom: 1px solid rgba(74, 73, 45, .25);
}

.town-view > .task-preview .section-heading span {
  color: #344a35;
  font-family: "STKaiti", "KaiTi", "FangSong", "Songti SC", serif;
  font-size: 1.12rem;
  letter-spacing: .12em;
}

.town-view > .task-preview .section-heading small {
  display: block;
  color: #8b805d;
  font: 600 .58rem/1 Georgia, serif;
  letter-spacing: .08em;
}

.town-view > .task-preview .task-preview-trigger {
  min-height: 0;
  display: block;
  padding: 0;
}

.town-view > .task-preview .task-preview-main,
.town-view > .task-preview .task-preview-metrics,
.town-view > .task-preview .task-preview-page-foot {
  display: none;
}

.task-preview-list {
  display: grid;
  gap: 8px;
}

.task-preview-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto 25px;
  align-items: center;
  gap: 8px;
  padding: 7px 7px 7px 6px;
  border: 1px solid rgba(92, 79, 44, .16);
  border-radius: 4px 9px 6px 4px;
  color: #344331;
  text-align: left;
  background:
    linear-gradient(150deg, rgba(255,255,255,.38), rgba(232,219,177,.16)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 310px auto repeat;
  box-shadow: 2px 3px 7px rgba(64, 57, 36, .09);
}

.task-preview-row > img {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(71, 79, 48, .22);
  border-radius: 3px 8px 4px 6px;
  object-fit: cover;
  filter: saturate(.88) sepia(.08);
}

.task-preview-row-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.task-preview-row-copy strong,
.task-preview-row-copy small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.task-preview-row-copy strong {
  font-family: "STKaiti", "KaiTi", "FangSong", "Songti SC", serif;
  font-size: .76rem;
  letter-spacing: .03em;
}

.task-preview-row-copy small {
  color: #706f5c;
  font-size: .57rem;
}

.task-preview-row-copy i {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(91, 99, 69, .18);
}

.task-preview-row-copy i b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #65845c;
}

.task-preview-row-progress {
  font: 700 .66rem/1 Georgia, serif;
}

.task-preview-row-enter {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #f8f1d5;
  background: #47704d;
  font: 700 1.08rem/1 Georgia, serif;
}

.task-preview-row.is-completed {
  opacity: .7;
}

.task-preview-row.is-completed .task-preview-row-enter {
  background: #879176;
}

.map-panel .dice-view-mount {
  bottom: max(30px, calc(var(--safe-bottom) + 26px));
  z-index: 29;
}

.field-bookmarks {
  z-index: 30;
}

@media (max-width: 380px), (max-height: 740px) {
  .hud-card {
    gap: 7px;
  }

  .hud-card .player-chip {
    max-width: 168px;
  }

  .town-view > .task-preview {
    right: 10px;
    bottom: max(90px, calc(var(--safe-bottom) + 84px));
    width: min(76vw, 292px);
    max-width: 292px;
    min-height: 278px;
    padding: 24px 18px 20px 31px;
  }

  .task-preview-row {
    min-height: 61px;
    grid-template-columns: 48px minmax(0, 1fr) auto 23px;
    gap: 6px;
    padding: 5px;
  }

  .task-preview-row > img {
    width: 48px;
    height: 48px;
  }
}

/* Full-screen dice stage. The 3D canvas leaves the transformed bottom dock,
   expands from its exact original center, lands, then returns on the same path. */
.dice-roll-stage {
  width: min(100vw, var(--phone-max-width));
  height: 100dvh;
  position: fixed;
  z-index: 92;
  inset: 0;
  display: none !important;
  place-items: center;
  margin: auto;
  overflow: hidden;
  pointer-events: none;
  isolation: isolate;
}

.dice-roll-stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  opacity: 0;
  background:
    radial-gradient(circle at center, rgba(255, 249, 218, .42), rgba(45, 68, 50, .2) 48%, rgba(28, 47, 36, .42));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: dice-stage-veil 240ms ease forwards;
}

.dice-roll-stage.is-active {
  display: grid !important;
}

.dice-view-mount.is-dice-stage-active .dice-fab {
  opacity: 0;
  pointer-events: none;
}

.dice-roll-stage .dice-fab-visual {
  width: 188px;
  height: 188px;
  flex-basis: 188px;
  transform-origin: center;
  animation: dice-stage-enter 330ms cubic-bezier(.18,.82,.22,1) both;
}

.dice-roll-stage .dice-fab-canvas {
  width: 224px;
  height: 224px;
}

.dice-roll-stage .dice-fab-cube {
  width: 132px;
  height: 132px;
  border-radius: 30px;
}

.dice-roll-stage.is-settling .dice-fab-visual {
  animation: dice-stage-exit 260ms cubic-bezier(.42,0,.72,.3) both;
}

@keyframes dice-stage-veil {
  to { opacity: 1; }
}

@keyframes dice-stage-enter {
  from {
    opacity: .72;
    transform: translate(var(--dice-origin-x), var(--dice-origin-y)) scale(.245);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes dice-stage-exit {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  to {
    opacity: .72;
    transform: translate(var(--dice-origin-x), var(--dice-origin-y)) scale(.245);
  }
}

/* Proper two-sided skill reveal: dedicated daisy card back first, then the
   skill face. The flower-language icon is no longer misused as a card back. */
.skill-card-reveal-card {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  perspective: 900px;
}

.skill-card-reveal-inner {
  width: 100%;
  min-height: 326px;
  position: relative;
  display: grid;
  transform-style: preserve-3d;
  animation: skill-card-face-reveal 1.45s cubic-bezier(.2,.78,.2,1) .2s both;
}

.skill-card-reveal-back,
.skill-card-reveal-front {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 13px 26px 14px 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 22px 55px rgba(36, 49, 33, .34);
}

.skill-card-reveal-back {
  object-fit: cover;
}

.skill-card-reveal-front {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px 14px 17px;
  border: 1px solid rgba(92, 75, 40, .32);
  text-align: center;
  background:
    linear-gradient(145deg, rgba(255,255,255,.56), rgba(240,225,183,.18)),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 330px auto;
  transform: rotateY(180deg);
}

.skill-card-reveal-front > img {
  width: 94px;
  height: 94px;
  justify-self: center;
  object-fit: contain;
}

@keyframes skill-card-face-reveal {
  0%, 34% { transform: rotateY(0deg) scale(.92); }
  72%, 100% { transform: rotateY(180deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .dice-roll-stage .dice-fab-visual,
  .dice-roll-stage.is-settling .dice-fab-visual,
  .skill-card-reveal-inner {
    animation: none;
  }

  .skill-card-reveal-inner {
    transform: rotateY(180deg);
  }
}

/* Release C.3 final cascade guard. */
.hud-card .player-chip,
.hud-card .resource-cluster {
  background: url("../../assets/runtime/ui/hud-torn-paper-v1.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 6px 7px rgba(42, 54, 34, .2));
  box-shadow: none;
}

.hud-card .resource-cluster {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 14px;
}

.hud-card .resource-cluster > .resource-pill {
  min-width: 0;
  min-height: 36px;
  display: grid;
  grid-template-columns: 21px max-content minmax(14px, 1fr);
  align-items: center;
  align-content: center;
  column-gap: 4px;
  padding: 0 7px;
  line-height: 1;
}

.hud-card .resource-cluster > .resource-pill .resource-icon {
  width: 21px;
  height: 21px;
}

.hud-card .resource-cluster > .resource-pill .resource-label {
  align-self: center;
  font-size: .62rem;
  line-height: 1;
  white-space: nowrap;
}

.hud-card .resource-cluster > .resource-pill strong {
  align-self: center;
  min-width: 0;
  font: 700 .98rem/1 Georgia, "Times New Roman", serif;
  text-align: right;
}

body .town-view > .task-preview {
  right: 12px;
  bottom: max(96px, calc(var(--safe-bottom) + 90px));
  width: min(56vw, 210px);
  max-width: 210px;
  min-height: 126px;
  padding: 15px 13px 12px 24px;
}

body .town-view > .task-preview::before {
  width: 14px;
}

body .town-view > .task-preview .task-preview-row {
  min-height: 54px;
  grid-template-columns: 42px minmax(0, 1fr) auto 21px;
  gap: 5px;
  padding: 5px 5px 5px 4px;
}

body .town-view > .task-preview .task-preview-row > img {
  width: 42px;
  height: 42px;
}

@media (max-width: 360px), (max-height: 700px) {
  .hud-card .resource-cluster {
    padding-inline: 10px;
  }

  .hud-card .resource-cluster > .resource-pill {
    grid-template-columns: 19px max-content minmax(12px, 1fr);
    column-gap: 3px;
    padding-inline: 4px;
  }

  body .town-view > .task-preview {
    right: 8px;
    bottom: max(88px, calc(var(--safe-bottom) + 82px));
    width: min(57vw, 196px);
    max-width: 196px;
    min-height: 116px;
    padding: 13px 10px 10px 22px;
  }

  body .town-view > .task-preview .task-preview-row {
    min-height: 49px;
    grid-template-columns: 38px minmax(0, 1fr) auto 20px;
    gap: 4px;
    padding: 4px;
  }

  body .town-view > .task-preview .task-preview-row > img {
    width: 38px;
    height: 38px;
  }
}
