.window { display: grid; justify-items: center; }
.window .village-view { cursor: pointer; }
.window__visit { position: relative; z-index: 1; margin-top: -16px; }
.window__visit.has-news::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cherry);
  border: 2px solid var(--night);
}

.overlay[data-kind="village"] .overlay__body { max-width: 1100px; }

.visit {
  background: var(--night);
  color: var(--parchment);
  border-color: var(--ink-soft);
  gap: 10px;
  padding-block: 12px;
}
.visit__head { display: flex; align-items: flex-start; gap: 12px; }
.visit__titles { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; }
.visit h2 { color: var(--candle); font-size: 1.4rem; }
.visit .hint-text { color: var(--mist); }
.visit .icon-button { background: var(--night-light); color: var(--parchment); border-color: var(--mist); }

.visit__map {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  overflow: auto;
  overscroll-behavior: contain;
  border: 6px solid var(--ink-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #121530 0%, var(--night) 70%, var(--night-light) 100%);
  scrollbar-color: var(--ink-soft) var(--night);
}
.visit__scene { position: relative; margin-inline: auto; }
.visit__canvas, .visit__canvas canvas { display: block; width: 100%; height: 100%; }
.visit__canvas canvas.village { max-width: none; border-radius: 0; box-shadow: none; cursor: default; }
.visit__doors { position: absolute; inset: 0; }

.door {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
}
.visit:not([data-pointer-still-where-it-clicked]) .door:hover { box-shadow: inset 0 0 0 2px rgba(255, 233, 168, 0.55); background: rgba(255, 233, 168, 0.06); }
.door:focus-visible { outline: 3px solid var(--candle); outline-offset: 1px; background: rgba(255, 233, 168, 0.08); }
.door__name {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  translate: -50% 0;
  padding: 2px 10px 3px;
  border-radius: var(--radius);
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-title);
  font-size: 18px;
  white-space: nowrap;
  box-shadow: 0 2px 0 var(--ink-soft), 0 4px 12px var(--shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--visit-door-name-appears) ease;
  z-index: 2;
}
.visit:not([data-pointer-still-where-it-clicked]) .door:hover .door__name, .door:focus-visible .door__name { opacity: 1; }
.door__news {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% -70%;
  width: 18px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--parchment);
  opacity: 0;
  pointer-events: none;
}
.door__news::before {
  content: "";
  position: absolute;
  inset: 4px 3px auto;
  height: 2px;
  background: radial-gradient(circle, var(--ink) 0 1px, transparent 1.5px) 0 0 / 4px 2px repeat-x;
}
.door__news::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 3px;
  border: 3px solid transparent;
  border-top-color: var(--ink);
}
.door.has-news .door__news { opacity: 0.92; animation: news-bobs var(--visit-news-bubble-bob-cycle) ease-in-out infinite; }
.visit:not([data-pointer-still-where-it-clicked]) .door:hover .door__news, .door:focus-visible .door__news { opacity: 0; }
@keyframes news-bobs {
  50% { translate: -50% -95%; }
}

.visit__talk:empty { display: none; }
.visit__talk {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--parchment);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}
.visit__talk .scene { min-height: 0; }
@media (min-width: 900px) {
  .visit__talk:has(.visit__grimoire) { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
}
.scene--narration .bubble__text { font-style: italic; color: var(--ink-soft); }
.scene:has(.scene__aside) { grid-template-columns: auto minmax(0, 1fr) auto; }
.scene__aside { margin: 0; animation: character-steps-in var(--return-character-steps-in) ease-out both; }
.scene__sign {
  position: relative;
  display: flex;
  gap: 2px;
  margin-top: 10px;
  padding: 4px 8px 6px;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: linear-gradient(180deg, #b07a45 0%, #8a5a34 100%);
  box-shadow: inset 0 2px 0 rgba(255, 233, 168, 0.25), 0 3px 0 var(--ink);
}
.scene__sign::before,
.scene__sign::after {
  content: "";
  position: absolute;
  bottom: 100%;
  width: 3px;
  height: 10px;
  background: var(--ink);
}
.scene__sign::before { left: 14px; }
.scene__sign::after { right: 14px; }
.sign-rune {
  min-width: 30px;
  padding: 0 1px;
  border: 0;
  border-radius: 4px;
  background: none;
  font-family: var(--font-runes);
  font-size: 2rem;
  line-height: 1.2;
  text-align: center;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 233, 168, 0.35);
}
button.sign-rune { cursor: pointer; transition: background-color 0.15s, text-shadow 0.15s; }
button.sign-rune:hover { background: rgba(255, 233, 168, 0.18); text-shadow: 0 0 6px rgba(255, 233, 168, 0.75); }
button.sign-rune:focus-visible { outline: 3px solid var(--candle); outline-offset: 1px; background: rgba(255, 233, 168, 0.18); }
.sign-rune--blank { min-width: 14px; }
.visit__doorstep { display: grid; gap: 10px; align-content: start; }
.visit__sign-pencil .pencil { margin-top: 4px; }
.visit__sign-pencil .hint-text { color: var(--ink-soft); }
.scene__window {
  width: 132px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 4px 0 var(--ink);
}

.visit__grimoire { display: grid; justify-items: center; gap: 6px; }
.villager__note--unvisited { color: var(--ink-soft); opacity: 0.75; }
.visit__grows { font-family: var(--font-title); color: var(--ink-soft); }
.visit__book { width: min(100%, 420px); }
.visit__book .book { animation: book-opens var(--return-book-opens) ease-out both; }
.visit__book .book__cover { --book-height: 190px; padding: 8px 10px 14px; }
.visit__book .book__page { padding: 12px 16px 22px; }
.visit__book .villager__meta + .villager__meta { display: none; }
.visit__book :is(.villager__keepsake, .villager__gift) { display: none; }

@media (max-width: 520px) {
  .visit { padding-inline: 10px; }
  .visit h2 { font-size: 1.15rem; }
  .visit__talk { padding: 10px; }
  .scene:has(.scene__aside) { grid-template-columns: auto minmax(0, 1fr); }
  .scene__aside { grid-column: 2; justify-self: start; }
  .scene__window { width: 104px; }
  .scene__sign { padding-inline: 4px; gap: 1px; }
  .sign-rune { min-width: 24px; font-size: 1.4rem; }
  .scene:has(.scene__sign) { grid-template-columns: auto auto; justify-content: center; }
  .scene:has(.scene__sign) .scene__aside { grid-column: 2; grid-row: 1; align-self: center; }
  .scene:has(.scene__sign) .bubble { grid-column: 1 / -1; grid-row: 2; margin-top: 0; }
  .scene:has(.scene__sign) .bubble::before,
  .scene:has(.scene__sign) .bubble::after { display: none; }
  .visit__sign-pencil .pencil { gap: 4px; }
  .visit__sign-pencil .pencil input { width: 1.7em; }
  .visit__book .book__cover { --book-height: 190px; }
}
