/* Shared scene chrome follows the outdoor map's cream, sage and paper palette. */
.town-body .town {
  --map-cream: #faf3e5;
  --map-border: #d7c7ad;
  --map-ink: #302d24;
  --map-green: #405c43;
  --map-orange: #ed852c;
  --bar-h: 40px;
  --top: calc(12px + env(safe-area-inset-top));
  --hotbar-h: 72px;
  --base: max(24px, env(safe-area-inset-bottom));
}

.town-body .town-top {
  top: var(--top);
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 10;
  min-height: 0;
  box-sizing: border-box;
  padding: 0;
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--map-ink);
  pointer-events: none;
}

.town-body .town-brand {
  min-height: 52px;
  padding: 8px 14px;
  gap: 16px;
  border: 1px solid var(--map-border);
  border-radius: 20px;
  background: var(--map-cream);
  box-shadow: 0 3px 12px #273b2526;
  color: var(--map-ink);
}

.town-body .town-mark { font-size: 32px; }
.town-body .town-mark-lit { color: var(--map-orange); }
.town-body .town-brand-text {
  border-left: 1px solid var(--map-border);
  padding-left: 16px;
}
.town-body .town-brand-text strong { font-size: 19px; }
.town-body .town-brand-text small { display: none; }
.town-body .town-toolbar {
  align-items: center;
  gap: 10px;
  min-height: 52px;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--map-border);
  border-radius: 24px;
  background: var(--map-cream);
  box-shadow: 0 3px 12px #273b2526;
}
.town-body #btn-replies { order: -1; }
.town-body .town-tool {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--map-border);
  border-radius: 22px;
  background: transparent;
  color: var(--map-ink);
  box-shadow: none;
  font-size: 14px;
  font-weight: 600;
}
.town-body .town-tool:hover,
.town-body .town-tool[aria-expanded="true"] {
  background: #f6dfbc;
  color: var(--map-ink);
  border-color: #c9a477;
}
.town-body .town-profile {
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  border-left: 1px solid var(--map-border);
  border-right: 1px solid var(--map-border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.town-body .town-profile .town-tool { border: 0; border-radius: 20px; }
.town-body .town-profile .town-xp { display:none; }
.town-body .town-dot { background: #b6ab8b; }
.town-body .town-dot.is-on { background: var(--map-green); }
.town-body #account-portrait { display:block; width:30px; height:30px; border:1px solid #cab99d; border-radius:50%; padding:3px; background:#eee2ce; image-rendering:pixelated; }
.town-body #btn-account .town-dot { display:none; }
.town-body #town-location { position:absolute; z-index:8; display:flex; align-items:center; gap:8px; left:24px; bottom:28px; min-height:44px; padding:0 16px; border:1px solid var(--map-border); border-radius:22px; background:var(--map-cream); color:var(--map-ink); font-weight:600; box-shadow:0 3px 10px #273b251c; }
.town-body #town-location svg { width:19px; height:19px; }
.town-body .town-log {
  left:24px;
  right:auto;
  bottom:80px;
  width:max-content;
  max-width:min(320px,calc(100vw - 48px));
  justify-items:start;
}
.town-body .town-log p { max-width:100%; box-sizing:border-box; overflow-wrap:anywhere; }
.in-town:has(#town-place-card:not([hidden])) #town-prompt { display:none; }
.town-pass-progress { padding:12px 14px; border-radius:12px; background:#f4e9d5; color:#4b5940; }
.town-body .town-unread { background: var(--map-orange); border-color: var(--map-cream); }

.town-body .town-hotbar {
  z-index: 8;
  bottom: var(--base);
  gap: 0;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--map-cream);
  border: 1px solid var(--map-border);
  border-radius: 22px;
  box-shadow: 0 4px 14px #273b2529;
}
.town-body .town-slot {
  flex-direction: row;
  width: auto;
  min-width: 148px;
  height: 48px;
  gap: 10px;
  padding: 0 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--map-green);
}
.town-body .town-slot + .town-slot { border-left: 1px solid var(--map-border); }
.town-body .town-slot:hover,
.town-body .town-slot.is-campus:hover { background: #efe6d4; }
.town-body .town-slot.is-campus,
.town-body .town-slot.is-say { background: transparent; }
.town-body .town-slot span { font-size: 15px; color: var(--map-ink); }
.town-body #town-hotbar svg { width: 26px; height: 26px; flex: none; color: var(--map-green); }
.town-body .town-slot kbd { display: none; }
.town-body .town-slot canvas { margin: 0; }
.town-body .town-slot-door { margin: 0; border-color: var(--map-green); }

.town-body .town-mapcard { top: calc(76px + env(safe-area-inset-top)); }
.in-town .town-mapcard { left:max(12px, env(safe-area-inset-left)); right:auto; }
.in-town #corner-minimap { width:180px; height:120px; }
#corner-minimap, #town-minimap { touch-action:none; }
.town-body .town-corner-map,
.town-body .town-zoom button,
.town-body .town-prompt button,
.town-body .town-log p {
  border: 1px solid var(--map-border);
  background-color: var(--map-cream);
  color: var(--map-ink);
  box-shadow: 0 2px 8px #273b2520;
}
.town-body .town-panel {
  top: calc(76px + env(safe-area-inset-top));
  border: 1px solid var(--map-border);
  background: var(--map-cream);
  box-shadow: 0 6px 24px #273b2533;
}
.town-body .town :focus-visible { outline: 2px solid var(--map-green); outline-offset: 3px; }

/* Room controls keep their own row below the shared header. */
.town-body:not(.in-town) .town-mapcard {
  left: max(12px, env(safe-area-inset-left));
  right: auto;
  max-width: calc(100vw - 24px);
}
.town-body:not(.in-town) #corner-minimap { width:132px; height:88px; }
.town-body .town-leave {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--map-border);
  border-radius: 20px;
  background: var(--map-cream);
  color: var(--map-ink);
  box-shadow: 0 2px 8px #273b2520;
  font-size: 14px;
  font-weight: 600;
}
.town-body .town-leave:hover { background: #f6dfbc; border-color: #c9a477; }
.town-body:not(.in-town) #town-location {
  bottom: calc(var(--base) + var(--hotbar-h) + 16px);
  max-width: calc(100vw - 48px);
}
.town-body:not(.in-town) #town-location-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.town-body:not(.in-town) #town-location svg { flex: none; }
.town-body:not(.in-town) .town-log { bottom: calc(var(--base) + var(--hotbar-h) + 68px); }

/* JS positions the card below the selected door and clamps it to the viewport. */
.in-town #town-place-card {
  position: absolute;
  z-index: 7;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 24px;
  row-gap: 4px;
  box-sizing: border-box;
  width: max-content;
  min-width: 264px;
  max-width: calc(100% - 24px);
  padding: 16px 18px;
  transform: translateX(-50%);
  border: 1px solid var(--map-border);
  border-radius: 17px;
  background: var(--map-cream);
  color: var(--map-ink);
  box-shadow: 0 4px 16px #24361e33;
}
.in-town #town-place-card[hidden] { display: none !important; }
.in-town #town-place-card::after {
  content: "";
  position: absolute;
  top: -9px;
  left: calc(50% - 8px);
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
  border-left: 1px solid var(--map-border);
  border-top: 1px solid var(--map-border);
  background: var(--map-cream);
}
.in-town #town-place-title { grid-column:1; margin:0; font-size:21px; line-height:1.3; }
.in-town #town-place-presence {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--map-green);
  font-size: 13px;
  line-height: 1.5;
}
.in-town #town-place-presence .town-icon { width: 17px; height: 17px; }
.in-town #town-place-enter {
  grid-column: 2;
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: 14px;
  background: var(--map-orange);
  color: #fffdf6;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.in-town #town-place-enter:hover { background: #ce6819; }

@media (max-width: 900px) {
  .town-body .town-toolbar { gap: 6px; }
  .town-body .town-tool { padding: 0 10px; }
  .town-body .town-brand { gap: 10px; }
  .town-body .town-brand-text { padding-left: 10px; }
  .town-body .town-brand-text strong { font-size: 16px; }
  .town-body .town-slot { min-width: 110px; padding: 0 14px; }
}

@media (max-width: 640px) {
  .in-town #corner-minimap { display:none; }
  .town-body .town { --base: max(12px, env(safe-area-inset-bottom)); --hotbar-h: 68px; }
  .town-body .town-top { top:calc(8px + env(safe-area-inset-top)); left:max(8px, env(safe-area-inset-left)); right:max(8px, env(safe-area-inset-right)); gap:6px; }
  .town-body .town-brand { min-height:50px; padding:6px 10px; }
  .town-body .town-mark { font-size: 26px; }
  .town-body .town-brand-text { display: none; }
  .town-body .town-toolbar { min-height:50px; gap:3px; padding:4px 6px; }
  .town-body .town-tool { min-width: 36px; min-height: 40px; padding: 0 8px; }
  .town-body .town-tool-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .town-body .town-profile { min-height: 40px; padding: 0 3px; }
  .town-body #btn-lang { font-size: 12px; }
  .town-body .town-hotbar { width: max-content; max-width: calc(100vw - 20px); padding: 8px; border-radius: 18px; }
  .town-body .town-slot { flex-direction: column; min-width: 66px; height: 48px; padding: 0 6px; gap: 3px; }
  .town-body .town-slot span { font-size: 12px; }
  .town-body .town-mapcard,
  .town-body .town-panel { top: calc(70px + env(safe-area-inset-top)); }
  .town-body #town-location { left:12px; bottom:92px; min-height:36px; max-width:calc(100vw - 24px); padding:0 12px; font-size:12px; }
  .town-body .town-log { left:12px; bottom:136px; max-width:calc(100vw - 24px); }
  .town-body:not(.in-town) #town-location { bottom:92px; max-width:calc(100vw - 24px); }
  .town-body:not(.in-town) .town-log { bottom:136px; }
  /* Entry/station prompts sit above, never across, the location button. */
  .town-body:is(.in-library, .in-town) #town-prompt {
    left:12px;
    right:12px;
    bottom:136px;
    transform:none;
    width:max-content;
    max-width:calc(100vw - 24px);
  }
  .town-body:is(.in-library, .in-town) #prompt-btn { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
  .town-body:is(.in-library, .in-town):has(#town-prompt:not([hidden])) .town-log { bottom:192px; }
  .in-town #town-place-card { min-width: 220px; padding: 12px 14px; column-gap: 16px; }
  .in-town #town-place-title { font-size: 17px; }
}
