.hwh {
  --hwh-ink: #f7e5b7;
  --hwh-muted: #d0b986;
  --hwh-gold: #f0c060;
  --hwh-shadow: rgba(9, 5, 2, .72);
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 2056 / 765;
  min-height: 300px;
  overflow: hidden;
  color: var(--hwh-ink);
  font-family: Georgia, "Times New Roman", serif;
  text-shadow: 0 2px 2px #160b05;
}

.hwh-tabletop {
  position: absolute;
  inset: 0;
  z-index: -3;
  background: #263d2f url('/wagon/home/tabletop.png') center / 100% 100% no-repeat;
  image-rendering: pixelated;
}

.hwh-warm-light {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(ellipse at 51% 32%, rgba(255, 210, 117, .08), transparent 45%);
}
.hwh[data-lighting="dawn"] .hwh-tabletop { filter: sepia(.06) brightness(.98); }
.hwh[data-lighting="dusk"] .hwh-tabletop { filter: sepia(.14) brightness(.84); }
.hwh[data-lighting="night"] .hwh-tabletop { filter: saturate(.78) brightness(.65) hue-rotate(5deg); }
.hwh[data-lighting="dusk"] .hwh-warm-light { background: radial-gradient(ellipse at 78% 26%, rgba(255, 167, 70, .21), transparent 45%); }
.hwh[data-lighting="night"] .hwh-warm-light { background: radial-gradient(ellipse at 78% 25%, rgba(255, 173, 76, .24), transparent 38%), rgba(5, 10, 13, .12); }

.hwh button { font: inherit; }
.hwh img { image-rendering: pixelated; }

.hwh-prop {
  position: absolute;
  z-index: 2;
  display: block;
  min-width: 0;
  padding: 0;
  color: var(--hwh-ink);
  border: 0;
  background: transparent;
  cursor: pointer;
}
.hwh-prop > img,
.hwh-prop-art,
.hwh-prop-art > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.hwh-prop > img,
.hwh-prop-art {
  transform-origin: 50% 72%;
  filter: drop-shadow(5px 8px 2px var(--hwh-shadow));
  transition: transform 150ms ease, filter 150ms ease;
}
.hwh-prop:hover > img,
.hwh-prop:focus-visible > img,
.hwh-prop:hover .hwh-prop-art,
.hwh-prop:focus-visible .hwh-prop-art {
  transform: translateY(-7px) scale(1.018);
  filter: drop-shadow(0 0 2px #ffe59a) drop-shadow(0 0 5px #b9792d) drop-shadow(8px 14px 3px var(--hwh-shadow));
}
.hwh-prop:active > img,
.hwh-prop:active .hwh-prop-art { transform: translateY(-2px) scale(1.008); }

.hwh-prop-copy {
  position: absolute;
  left: 50%;
  bottom: 9%;
  z-index: 6;
  display: flex;
  min-width: max-content;
  padding: 5px 10px 4px;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
  border: 1px solid rgba(210, 158, 79, .64);
  border-radius: 3px;
  background: rgba(28, 16, 8, .88);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .52);
  pointer-events: none;
}
.hwh-prop--book .hwh-prop-copy { bottom: 17%; }
.hwh-prop-copy strong { font-size: clamp(13px, 1.22vw, 19px); line-height: 1.05; letter-spacing: .025em; }
.hwh-prop-copy small { margin-top: 2px; color: var(--hwh-muted); font: 600 clamp(9px, .75vw, 12px)/1.15 system-ui, sans-serif; }

.hwh-book-zone { position: absolute; inset: 6% auto 9% 37%; width: 26%; z-index: 4; }
.hwh-prop--book { inset: 0 15% 0 0; width: 85%; }
.hwh-prop--book > img { object-position: 50% 42%; }
.hwh-bookmarks {
  position: absolute;
  z-index: 8;
  top: 19%;
  right: 0;
  display: grid;
  gap: clamp(3px, .45vw, 7px);
}
.hwh .hwh-bookmark {
  width: clamp(54px, 5.4vw, 82px);
  min-height: clamp(24px, 2.1vw, 32px);
  padding: 3px 6px 3px 10px;
  color: #241408;
  font: 800 clamp(9px, .78vw, 12px)/1.1 system-ui, sans-serif;
  text-align: left;
  text-shadow: none;
  border: 1px solid #1b1008;
  border-radius: 1px 4px 4px 1px;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .42), inset 0 0 0 1px rgba(255, 255, 255, .2);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
  white-space: nowrap;
}
.hwh-bookmark:hover, .hwh-bookmark:focus-visible { transform: translateX(5px); filter: brightness(1.12); }
.hwh .hwh-bookmark--study {
  width: clamp(66px, 6.4vw, 98px);
  min-height: clamp(30px, 2.65vw, 40px);
  margin: 0 0 clamp(2px, .25vw, 4px) -7px;
  color: #2c1805;
  font-size: clamp(11px, .93vw, 14px);
  letter-spacing: .035em;
  background:
    linear-gradient(115deg, transparent 0 20%, rgba(255, 249, 190, .72) 30%, transparent 41%),
    linear-gradient(#f8d778, #c98b25 72%, #9a5d16);
  border-color: #55300b;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .48), inset 0 0 0 2px rgba(255, 244, 172, .5), 0 0 8px rgba(244, 184, 55, .42);
}
.hwh-bookmark--codex { background: #dbc698; }
.hwh-bookmark--shop { background: #b9644e; }
.hwh-bookmark--wagon { background: #8ba16c; }
.hwh-bookmark--alchemy { background: #8c84bb; }
.hwh .hwh-bookmark--wagon,
.hwh .hwh-bookmark--alchemy {
  padding-right: 3px;
  padding-left: 8px;
}

.hwh-prop--kit { left: 5%; top: 13%; width: 28%; height: 73%; }
.hwh-prop-art { position: relative; }
.hwh-prop--kit .hwh-prop-art > img { object-position: center; }
.hwh-prop--chest { left: 69%; top: 11%; width: 26%; height: 74%; }

.hwh-live-stock {
  position: absolute;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, .4vw, 7px);
  pointer-events: none;
}
.hwh-live-stock--potions {
  left: 20%;
  right: 12%;
  top: 63%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.hwh-live-stock--ingredients {
  left: 17%;
  right: 13%;
  top: 41%;
  bottom: 33%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}
.hwh-live-stock--potions .hwh-stock-item,
.hwh-live-stock--ingredients .hwh-stock-item { justify-self: center; }
.hwh-live-stock--potions .hwh-stock-message,
.hwh-live-stock--ingredients .hwh-stock-message { grid-column: 1 / -1; justify-self: center; }
.hwh-stock-item {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(25px, 2.55vw, 39px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(17, 11, 7, .62);
  box-shadow: inset 0 0 0 1px rgba(231, 185, 103, .3);
}
.hwh-stock-item img { width: 78%; height: 78%; object-fit: contain; }
.hwh-stock-item b {
  position: absolute;
  right: -3px;
  bottom: -2px;
  min-width: 16px;
  padding: 1px 3px;
  color: #fff1bd;
  font: 800 10px/1.2 ui-monospace, monospace;
  text-shadow: none;
  background: #24140c;
  border: 1px solid #c38a3e;
  border-radius: 8px;
}
.hwh-stock-message {
  padding: 3px 6px;
  color: #e9d4a2;
  font: 700 clamp(8px, .68vw, 11px)/1.15 system-ui, sans-serif;
  text-shadow: 0 1px #000;
  background: rgba(25, 14, 8, .76);
  border-radius: 3px;
}

.hwh-clinic-zone { position: absolute; z-index: 10; right: 3.4%; bottom: 3%; display: flex; align-items: flex-end; gap: 10px; }
.hwh-rank { position: absolute; right: 0; bottom: calc(100% + 7px); max-width: 190px; color: var(--hwh-muted); font: 700 10px/1.15 system-ui, sans-serif; letter-spacing: .07em; text-align: right; text-transform: uppercase; }
.hwh-clinic {
  display: grid;
  grid-template-columns: auto 1fr;
  min-width: clamp(175px, 18vw, 270px);
  padding: clamp(7px, .8vw, 12px) clamp(10px, 1.2vw, 18px);
  color: #fff0c1;
  text-align: left;
  border: 3px solid #2a170b;
  border-radius: 4px;
  background: linear-gradient(#885928, #4b2b13);
  box-shadow: inset 0 0 0 2px #ce9141, 0 6px 0 #241207, 0 10px 18px rgba(0, 0, 0, .5);
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease;
}
.hwh-clinic > span { grid-row: 1 / 3; align-self: center; margin-right: 9px; color: #ffd270; font-size: 20px; }
.hwh-clinic strong { font-size: clamp(14px, 1.35vw, 21px); }
.hwh-clinic small { color: var(--hwh-muted); font: 600 clamp(9px, .72vw, 11px)/1.1 system-ui, sans-serif; }
.hwh-clinic:hover, .hwh-clinic:focus-visible { transform: translateY(-3px); filter: brightness(1.1); }
.hwh-clinic.is-locked { color: #b9ac8e; filter: grayscale(.7) brightness(.74); cursor: not-allowed; box-shadow: inset 0 0 0 2px #726044, 0 4px 0 #1d120b; }

.hwh-compact-actions { display: none; }
.hwh button:focus-visible { outline: 3px solid #ffe28c; outline-offset: 4px; }

@media (max-width: 900px) {
  .hwh { min-height: 280px; }
  .hwh-book-zone { left: 36%; width: 27%; }
  .hwh-prop--kit { left: 4%; width: 29%; }
  .hwh-prop--chest { left: 69%; width: 27%; }
  .hwh-clinic-zone { right: 2%; bottom: 3%; align-items: center; }
  .hwh-rank { position: static; max-width: 76px; font-size: 9px; }
}

@media (max-width: 620px) {
  .hwh { aspect-ratio: auto; min-height: 310px; padding-bottom: 84px; }
  .hwh-tabletop { bottom: 76px; background-size: 100% 100%; }
  .hwh-warm-light { bottom: 76px; }
  .hwh-book-zone { inset: 5% auto 29% 35%; width: 30%; }
  .hwh-prop--kit { left: 3%; top: 6%; width: 31%; height: 59%; }
  .hwh-prop--chest { left: 68%; top: 7%; width: 30%; height: 57%; }
  .hwh-prop-copy, .hwh-bookmarks, .hwh-clinic-zone { display: none; }
  .hwh-live-stock--potions, .hwh-live-stock--ingredients { transform: scale(.78); }
  .hwh-stock-message { font-size: 7px; }
  .hwh-compact-actions {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }
  .hwh-compact-action {
    min-height: 48px;
    padding: 5px 3px;
    color: #f3dfae;
    font: 700 10px/1.1 system-ui, sans-serif;
    text-shadow: 0 1px #000;
    border: 2px solid #432714;
    border-radius: 4px;
    background: linear-gradient(#704a26, #392111);
    box-shadow: inset 0 0 0 1px #a77339;
  }
  .hwh-compact-action--clinic { color: #fff1c4; background: linear-gradient(#8b5928, #513017); }
  .hwh-compact-action:disabled { color: #9f947b; filter: grayscale(.7); }
}

/* In the compact desktop frame, leave the lower right clear for clinic
   entry and its existing rank label. Move each intact prop upward together
   with its stock and caption; keep the book caption clear of its bookmarks. */
@media (min-width: 861px) {
  .hwh-prop--kit { top: 3%; }
  .hwh-prop--chest { top: 1%; }
  .hwh-prop--book .hwh-prop-copy { left: 25%; }
}

@media (prefers-reduced-motion: reduce) {
  .hwh *, .hwh *::before, .hwh *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Bookmark proportions follow the actual book, not the window around it. */
.hwh-book-zone{container-type:inline-size}
.hwh-bookmarks{top:18%;bottom:30%;right:0;width:32%;grid-template-rows:1.1fr repeat(4,1fr);gap:2%}
.hwh .hwh-bookmark,.hwh .hwh-bookmark--study{width:100%;height:100%;min-height:0;margin:0;padding:1px 4px 1px 7px;font-size:clamp(8px,4cqw,11px);line-height:1;letter-spacing:0}
