/* ============ neighbourhoodz — comic-sansy cartoon skin ============ */
:root {
  --paper: #fffdf5;
  --ink: #2b2b2b;
  --msn-blue-1: #7db9e8;
  --msn-blue-2: #2989d8;
  --msn-green: #7ac142;
  --wobble-border: 3px solid var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Comic Neue", "Comic Sans MS", "Chalkboard SE", cursive;
  color: var(--ink);
  overflow: hidden;
}

#map { position: absolute; inset: 0; background: #d6ebc9; }

/* cartoonify the base tiles */
.leaflet-tile-pane { filter: saturate(1.5) contrast(0.92) brightness(1.05); }

/* ============ windows (MSN chic) ============ */
.window {
  background: var(--paper);
  border: var(--wobble-border);
  border-radius: 14px 16px 14px 18px; /* slightly uneven = hand-drawn */
  box-shadow: 6px 6px 0 rgba(43, 43, 43, 0.25);
  overflow: hidden;
}

.titlebar {
  background: linear-gradient(180deg, var(--msn-blue-1), var(--msn-blue-2));
  color: #fff;
  font-weight: 700;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.25);
  cursor: default;
  user-select: none;
}
.titlebar.mini { font-size: 14px; padding: 5px 10px; }
.titlebar-icon { font-size: 18px; }
.win-btns { margin-left: auto; display: flex; gap: 6px; }
.win-btns i {
  font-style: normal; background: rgba(255,255,255,0.25); border: 1px solid rgba(255,255,255,0.6);
  border-radius: 5px; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; cursor: pointer;
}
.win-btns i:hover { background: rgba(255,255,255,0.5); }

.hidden { display: none !important; }

/* ============ buttons & inputs ============ */
.btn {
  font-family: inherit; font-weight: 700; font-size: 15px;
  background: var(--msn-green); color: #fff;
  border: 2px solid var(--ink); border-radius: 12px 10px 12px 10px;
  padding: 8px 16px; cursor: pointer;
  box-shadow: 3px 3px 0 rgba(43,43,43,0.3);
  transition: transform 0.08s;
}
.btn:hover { transform: translate(-1px, -1px) rotate(-1deg); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn.small { font-size: 13px; padding: 5px 10px; }
.btn.big { font-size: 20px; padding: 12px 30px; margin-top: 14px; }

input {
  font-family: inherit; font-size: 15px;
  border: 2px solid var(--ink); border-radius: 10px 8px 10px 8px;
  padding: 8px 10px; background: #fff; outline: none;
}
input:focus { box-shadow: 0 0 0 3px rgba(122,193,66,0.4); }

/* ============ onboarding ============ */
.overlay {
  position: absolute; inset: 0; z-index: 5000;
  background: repeating-linear-gradient(45deg, #bfe3f7 0 24px, #cdeafc 24px 48px);
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto; padding: 16px;
}
.onboard-window { width: 400px; max-width: 96vw; }
.onboard-body { padding: 14px 22px 20px; text-align: center; }
.onboard-body h1 {
  margin: 4px 0 0; font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 42px; letter-spacing: 1px; transform: rotate(-1.5deg);
  color: var(--msn-blue-2); text-shadow: 2px 2px 0 #fce38a;
}
.tagline { margin: 2px 0 16px; font-size: 14px; }
.field-label { display: block; text-align: left; font-size: 13px; font-weight: 700; margin: 12px 0 5px; }
.nick-row { display: flex; gap: 8px; }
.nick-row input { flex: 1; }

.easel { position: relative; width: 150px; height: 190px; margin: 0 auto; }
.easel canvas {
  position: absolute; inset: 0;
  border: 2px dashed #9db8a0; border-radius: 10px; background: transparent;
}
#guideCanvas { background: #fff; }
#drawCanvas { touch-action: none; cursor: crosshair; }

.easel-tools { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink);
  cursor: pointer; display: inline-block;
}
.swatch.selected { outline: 3px solid #fce38a; }
.fineprint { font-size: 11px; color: #777; margin-top: 12px; }

/* ============ avatar dock ============ */
#dock {
  position: absolute; left: 14px; bottom: 18px; z-index: 3000;
  background: var(--paper); border: var(--wobble-border);
  border-radius: 16px 14px 18px 14px; box-shadow: 5px 5px 0 rgba(43,43,43,0.25);
  padding: 10px 14px; text-align: center; width: 150px;
}
#dockAvatar { width: 75px; height: 95px; cursor: grab; user-select: none; -webkit-user-drag: none; touch-action: none; }
#dockAvatar:active { cursor: grabbing; }
.dock-nick { font-weight: 700; font-size: 14px; margin: 2px 0 6px; }
.dock-hint {
  position: absolute; bottom: 105%; left: 0; width: 190px; pointer-events: none;
  background: #fce38a; border: 2px solid var(--ink); border-radius: 12px;
  padding: 7px 10px; font-size: 13px; font-weight: 700;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg);} 50% { transform: translateY(-6px) rotate(1deg);} }

/* ghost avatar that follows pointer while dragging */
#dragGhost {
  position: fixed; z-index: 9000; pointer-events: none;
  width: 70px; opacity: 0.85; transform: translate(-50%, -50%) rotate(4deg);
  filter: drop-shadow(3px 4px 2px rgba(0,0,0,0.3));
}

.ghost-btn { background: #eee; color: #555; padding: 4px 8px; margin-left: 4px; }

/* ============ neighbourhood labels & markers ============ */
.hood-label {
  background: none; border: none; box-shadow: none;
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 15px; font-weight: 700; color: #4a4a4a;
  text-shadow: 1px 1px 0 #fff, -1px 1px 0 #fff, 1px -1px 0 #fff, -1px -1px 0 #fff;
  text-align: center; white-space: nowrap;
}
.hood-label .pop { color: var(--msn-blue-2); font-size: 13px; }

.avatar-marker { background: none; border: none; }
.avatar-marker .fig { position: relative; text-align: center; }
.avatar-marker img {
  width: 52px; height: 66px;
  filter: drop-shadow(2px 3px 1px rgba(0,0,0,0.25));
}
.avatar-marker.me img { animation: bob 2s ease-in-out infinite; }
.avatar-marker .who {
  font-size: 12px; font-weight: 700; background: #fff; border: 2px solid var(--ink);
  border-radius: 8px; padding: 0 5px; display: inline-block; white-space: nowrap;
}
.avatar-marker .bubble {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-30%);
  background: #fff; border: 2px solid var(--ink); border-radius: 12px;
  padding: 4px 9px; font-size: 12px; white-space: nowrap; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis;
}
.avatar-marker .bubble::after {
  content: ""; position: absolute; top: 100%; left: 22px;
  border: 6px solid transparent; border-top-color: var(--ink);
}

/* ============ hood card ============ */
#hoodCard { position: absolute; z-index: 3500; width: 250px; top: 80px; right: 16px; }
.hood-card-body { padding: 12px 14px; }
.hood-count-line { font-size: 14px; margin-bottom: 8px; }
.hood-links { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.hood-links a { font-size: 13px; color: var(--msn-blue-2); font-weight: 700; }

/* ============ chat window ============ */
#chatWindow {
  position: absolute; right: 16px; bottom: 16px; z-index: 4000;
  width: 440px; max-width: 94vw; height: 340px;
  display: flex; flex-direction: column;
}
#chatWindow.minimized { height: auto; }
#chatWindow.minimized .chat-inner { display: none; }
#chatWindow.shake { animation: shake 0.5s linear; }
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  10% { transform: translate(-8px,-4px) rotate(-1deg); } 20% { transform: translate(7px,5px) rotate(1deg); }
  30% { transform: translate(-6px,3px); } 40% { transform: translate(8px,-5px) rotate(1deg); }
  50% { transform: translate(-7px,-3px) rotate(-1deg); } 60% { transform: translate(5px,6px); }
  70% { transform: translate(-8px,2px) rotate(-1deg); } 80% { transform: translate(6px,-4px); }
  90% { transform: translate(-4px,4px); }
}

.chat-inner { display: flex; flex: 1; min-height: 0; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#messages { flex: 1; overflow-y: auto; padding: 10px 12px; font-size: 14px; background: #fff; }
#messages .msg { margin-bottom: 6px; word-wrap: break-word; }
#messages .msg .nick { font-weight: 700; color: var(--msn-blue-2); }
#messages .msg.mine .nick { color: #18a558; }
#messages .msg.system { color: #999; font-size: 12.5px; font-style: italic; }
#messages .msg .time { color: #bbb; font-size: 11px; margin-left: 5px; }

.chat-compose {
  display: flex; gap: 6px; padding: 8px; border-top: 2px dashed #ccc; background: var(--paper);
}
.chat-compose input { flex: 1; min-width: 0; }

.chat-roster {
  width: 110px; border-left: 2px dashed #ccc; background: #f4fbee;
  overflow-y: auto; padding: 6px;
}
.roster-title { font-size: 11px; font-weight: 700; color: #777; text-transform: uppercase; margin-bottom: 4px; }
.roster-item { text-align: center; margin-bottom: 8px; cursor: pointer; }
.roster-item img { width: 34px; height: 43px; }
.roster-item .rn { font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-item .rs { font-size: 10px; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ status popup ============ */
#statusPopup { position: absolute; z-index: 4500; left: 14px; bottom: 190px; width: 270px; }
.status-body { padding: 12px; display: flex; gap: 6px; }
.status-body input { flex: 1; min-width: 0; }

/* ============ places carousel ============ */
.places-carousel { border: 2px dashed #bbb; border-radius: 12px; padding: 8px; margin-bottom: 10px; text-align: center; background: #fff; }
.carousel-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.place-title { flex: 1; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#placeArt { width: 140px; height: 105px; object-fit: contain; background: #fff; border: 2px solid var(--ink); border-radius: 8px; }
.place-who { font-size: 12px; margin: 6px 0; min-height: 16px; }
.place-who img { width: 20px; height: 25px; vertical-align: middle; }
.no-places { font-size: 13px; color: #888; margin-bottom: 10px; text-align: center; }
.hood-card-btns { display: flex; gap: 6px; }
.hood-card-btns .btn { flex: 1; font-size: 13px; padding: 7px 6px; }

/* ============ spot builder ============ */
.builder-window { width: 460px; max-width: 96vw; }
.builder-body { padding: 12px 18px 18px; text-align: center; }
.builder-blurb { font-size: 13px; margin: 4px 0 10px; }
.builder-row { display: flex; gap: 10px; align-items: flex-start; justify-content: center; }
#paintCanvas { border: 2px solid var(--ink); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; }
.paint-tools { display: flex; flex-direction: column; gap: 6px; width: 100px; }
.paint-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.pswatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink); cursor: pointer; }
.pswatch.selected { outline: 3px solid #fce38a; }
.ptool.selected { background: var(--msn-blue-2); }
.builder-meta { display: flex; gap: 8px; margin-top: 12px; }
.builder-meta input { flex: 1; min-width: 0; }
select {
  font-family: inherit; font-size: 14px; border: 2px solid var(--ink);
  border-radius: 10px 8px 10px 8px; padding: 8px; background: #fff;
}

#placeBanner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 4600;
  background: #fce38a; border: 3px solid var(--ink); border-radius: 14px;
  padding: 10px 18px; font-size: 15px; font-weight: 700;
  animation: bob 1.6s ease-in-out infinite;
}

/* place markers on the map */
.place-marker { background: none; border: none; }
.place-marker .pm { text-align: center; }
.place-marker img {
  width: 58px; height: 44px; object-fit: contain; background: rgba(255,255,255,0.85);
  border: 2px solid var(--ink); border-radius: 8px;
  filter: drop-shadow(2px 3px 1px rgba(0,0,0,0.2));
}
.place-marker .pn {
  font-size: 11px; font-weight: 700; background: #fff; border: 2px solid var(--ink);
  border-radius: 8px; padding: 0 4px; display: inline-block; white-space: nowrap;
}
.place-marker .pc { font-size: 11px; color: var(--msn-blue-2); font-weight: 700; }

/* zoomed-out presence dots */
.avatar-dot { background: none; border: none; }
.avatar-dot .dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--msn-green);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.25);
}
.avatar-dot.virtual .dot { background: var(--msn-blue-2); }
.avatar-dot.me .dot { outline: 3px solid #fce38a; }

/* UFO for virtual visitors — saucer on top, tractor beam pulling the lil guy up */
.avatar-marker .ufo { font-size: 30px; line-height: 1; display: block; position: relative; z-index: 2; }
.avatar-marker.virtual img { width: 40px; height: 50px; position: relative; z-index: 1; }
.avatar-marker.virtual .fig { animation: hover-ufo 3s ease-in-out infinite; }
.avatar-marker.virtual .beam {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  width: 54px; height: 58px; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,240,140,0.9), rgba(255,240,140,0.05));
  clip-path: polygon(36% 0, 64% 0, 100% 100%, 0 100%);
}
@keyframes hover-ufo { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ============ mod panel ============ */
#modPanel { position: absolute; z-index: 4800; top: 70px; left: 14px; width: 300px; max-height: 70vh; display: flex; flex-direction: column; }
.mod-list { overflow-y: auto; padding: 10px; }
.mod-item { border-bottom: 2px dashed #ddd; padding: 8px 0; text-align: center; }
.mod-item img { width: 130px; height: 98px; object-fit: contain; border: 2px solid var(--ink); border-radius: 8px; background: #fff; }
.mod-item .mi-name { font-weight: 700; font-size: 14px; }
.mod-item .mi-meta { font-size: 12px; color: #888; margin-bottom: 5px; }
.mod-item .btn { margin: 0 3px; }
.mod-empty { font-size: 13px; color: #888; text-align: center; padding: 10px; }

/* ============ DM windows ============ */
.dm-window {
  position: absolute; z-index: 4200; width: 300px; height: 240px;
  display: flex; flex-direction: column; bottom: 30px; left: 200px;
}
.dm-window .dm-messages { flex: 1; overflow-y: auto; background: #fff; padding: 8px 10px; font-size: 13.5px; }
.dm-window .chat-compose { padding: 6px; }
.dm-window .titlebar { background: linear-gradient(180deg, #f7a8c4, #d84f8b); }

/* ============ corkboard ============ */
#boardBtn { position: absolute; top: 14px; right: 16px; z-index: 3200; }

#board {
  position: absolute; z-index: 4300; top: 60px; right: 16px;
  width: 420px; max-width: 95vw; height: min(520px, 76vh);
  display: flex; flex-direction: column;
  background:
    radial-gradient(circle at 20% 30%, rgba(160,110,60,0.16) 0 3px, transparent 4px),
    radial-gradient(circle at 70% 60%, rgba(160,110,60,0.13) 0 2px, transparent 3px),
    #d9a86b;
}
.board-filters {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 10px; background: rgba(255,253,245,0.85); border-bottom: 2px dashed #b58449;
}
.chip {
  font-size: 12.5px; font-weight: 700; cursor: pointer;
  background: #fff; border: 2px solid var(--ink); border-radius: 20px; padding: 3px 9px;
}
.chip.selected { background: var(--msn-blue-2); color: #fff; }
#boardHood { margin-left: auto; font-size: 12.5px; padding: 4px 6px; max-width: 140px; }

.board-posts { flex: 1; overflow-y: auto; padding: 12px; }
.postit {
  position: relative;
  border: 2px solid var(--ink); border-radius: 3px 14px 6px 12px;
  padding: 10px 12px 8px; margin-bottom: 12px;
  box-shadow: 3px 4px 0 rgba(60,30,0,0.25);
  font-size: 14px;
}
.postit:nth-child(odd) { transform: rotate(-1.2deg); }
.postit:nth-child(even) { transform: rotate(1deg); }
.postit::before {
  content: "📌"; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  font-size: 16px;
}
.postit.need { background: #fff3b0; }
.postit.buy { background: #c9e9f6; }
.postit.sell { background: #d9f2c4; }
.postit.meetup { background: #ffd6e0; }
.postit .p-meta { font-size: 11.5px; color: #666; margin-top: 6px; }
.postit .p-meta b { color: var(--msn-blue-2); }
.postit .p-when { font-size: 12.5px; font-weight: 700; margin-top: 3px; }
.postit .p-actions { position: absolute; top: 4px; right: 7px; font-size: 12px; }
.postit .p-actions span { cursor: pointer; margin-left: 6px; }
.board-empty { text-align: center; color: #7a5426; font-weight: 700; padding: 30px 10px; }

.board-compose {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px;
  background: rgba(255,253,245,0.9); border-top: 2px dashed #b58449;
}
.board-compose select { font-size: 12.5px; padding: 5px; }
.board-compose input { flex: 1; min-width: 120px; font-size: 13.5px; }

.hood-board-peek { margin-bottom: 10px; }
.hood-board-peek .peek-line { font-size: 12.5px; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hood-board-peek .peek-open { font-size: 13px; font-weight: 700; color: var(--msn-blue-2); cursor: pointer; }

/* mobile */
@media (max-width: 640px) {
  #chatWindow { width: 96vw; height: 46vh; right: 2vw; bottom: 2vw; }
  .chat-roster { width: 84px; }
  #hoodCard { width: 220px; top: 66px; right: 8px; }
}
