:root {
  --ink: #2b2622;
  --paper: #f3e7cf;
  --paper-2: #e6d5b4;
  --brick: #b5523b;
  --brick-d: #7e3626;
  --slate: #4a5361;
  --edge: #2b2622;
  --sky: #a9c7d6;
  --font-px: 'Silkscreen', ui-monospace, monospace;
  --font-txt: 'VT323', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font-txt);
  font-size: 20px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#view {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; cursor: grab;
  image-rendering: pixelated;
}
#view.dragging { cursor: grabbing; }

/* Pixel "panel" look: hard 2px border + offset shadow */
.panel, .bar.top .title, .search, .controls button, .toast, .info, .about, .suggest {
  background: var(--paper);
  border: 3px solid var(--edge);
  box-shadow: 4px 4px 0 rgba(43, 38, 34, .55);
  border-radius: 0;
}

.bar.top {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px;
  display: flex; gap: 12px; align-items: flex-start; pointer-events: none;
}
.bar.top > * { pointer-events: auto; }
.title {
  margin: 0; padding: 6px 10px 5px;
  font-family: var(--font-px); font-weight: 400; font-size: 13px; line-height: 1.05;
  letter-spacing: .5px; color: var(--paper); background: var(--brick) !important;
}
.title span { font-size: 17px; }
.search { position: relative; display: flex; flex: 1; max-width: 380px; margin-left: auto; }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 6px 10px;
  font: inherit; font-size: 21px; color: var(--ink); outline: none;
}
.search input::placeholder { color: #8a7b66; }
.search button {
  border: 0; border-left: 3px solid var(--edge); background: var(--slate); color: var(--paper);
  font-family: var(--font-px); font-size: 13px; padding: 0 12px; cursor: pointer;
}
.suggest {
  position: absolute; top: calc(100% + 6px); left: -3px; right: -3px; margin: 0; padding: 0;
  list-style: none; max-height: 50vh; overflow: auto;
}
.suggest li { padding: 5px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.suggest li small { color: #8a7b66; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--paper-2); }

.controls {
  position: fixed; right: 16px; bottom: max(36px, calc(env(safe-area-inset-bottom) + 28px));
  display: flex; flex-direction: column; gap: 8px;
}
.controls button {
  width: 46px; height: 46px; font-size: 24px; line-height: 1; padding: 0; cursor: pointer;
  color: var(--ink); font-family: var(--font-txt);
}
.controls button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 rgba(43,38,34,.55); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--brick); outline-offset: 2px; }

.credit {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 3px 10px calc(3px + env(safe-area-inset-bottom));
  font-size: 17px; background: rgba(43, 38, 34, .78); color: var(--paper); text-align: center;
}
.credit a { color: #ffd9a8; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 64px;
  padding: 6px 12px; max-width: calc(100% - 32px); text-align: center;
}
.info {
  position: fixed; left: 16px; bottom: 40px; padding: 8px 12px; max-width: min(320px, calc(100% - 100px));
  line-height: 1.05;
}
.info b { font-family: var(--font-px); font-weight: 400; font-size: 14px; display: block; margin-bottom: 3px; }
.info small { color: #6f6352; }

#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label {
  position: absolute; transform: translate(-50%, -100%);
  font-family: var(--font-px); font-size: 11px; white-space: nowrap;
  color: var(--paper); background: var(--ink); padding: 2px 5px 1px;
  box-shadow: 2px 2px 0 rgba(0,0,0,.35);
}
.label::after {
  content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -4px;
  border: 4px solid transparent; border-top-color: var(--ink); border-bottom: 0;
}
.label.pin { background: var(--brick); }
.label.pin::after { border-top-color: var(--brick); }

.loading {
  position: fixed; inset: 0; display: grid; place-items: center; background: var(--sky);
  font-family: var(--font-px); font-size: 16px; transition: opacity .4s;
}
.loading.done { opacity: 0; pointer-events: none; }

.about { max-width: min(560px, calc(100% - 32px)); max-height: calc(100% - 48px); padding: 16px 20px; color: var(--ink); line-height: 1.1; }
.about::backdrop { background: rgba(43, 38, 34, .55); }
.about h2 { font-family: var(--font-px); font-weight: 400; font-size: 20px; margin: 0 0 8px; color: var(--brick-d); }
.about h3 { font-family: var(--font-px); font-weight: 400; font-size: 14px; margin: 14px 0 4px; }
.about p, .about ul { margin: 4px 0; }
.about ul { padding-left: 20px; }
.about a { color: var(--brick-d); }
.about .small { font-size: 18px; color: #6f6352; }
.about .close {
  margin-top: 12px; font-family: var(--font-px); font-size: 13px; padding: 6px 14px;
  background: var(--slate); color: var(--paper); border: 3px solid var(--edge); cursor: pointer;
}

@media (max-width: 560px) {
  html, body { font-size: 18px; }
  .bar.top { flex-direction: column; gap: 8px; }
  .search { max-width: none; width: 100%; margin-left: 0; }
  .title { font-size: 11px; } .title span { font-size: 14px; }
  .bar.top .title br { display: none; }
  .controls button { width: 42px; height: 42px; font-size: 22px; }
  .credit { font-size: 15px; }
}
