/* Region town maps — Gen I Kanto, Gen II Johto & Kanto, etc. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:        #D42B1E;
  --red-dark:   #8C1C12;
  --yellow:     #F2C12E;
  --black:      #0E0E14;
  --surface-1:  #14141C;
  --surface-2:  #1C1C28;
  --surface-3:  #242433;
  --border:     rgba(141, 50, 168, 0.10);
  --border-med: rgba(141, 50, 168, 0.16);
  --border-2:   rgba(141, 50, 168, 0.16);
  --text-1:     #F2ECFF;
  --text-2:     #A89BC4;
  --text-3:     #6B6284;
  --green:      #3EC46D;
  --font-pixel: 'Press Start 2P', monospace;
  --font-cond:  'Barlow Condensed', sans-serif;
  --font-body:  'Barlow', sans-serif;
}

html { scroll-behavior: smooth; }
body {
  background: var(--black);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding-top: 60px;
}

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  background: rgba(14,14,20,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 48px;
}
.wordmark {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--text-1);
  text-decoration: none;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.wordmark span { color: var(--red); }
.nav-links {
  list-style: none;
  display: flex;
  gap: 32px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  font-family: var(--font-cond);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text-1); }
.nav-open {
  font-family: var(--font-cond);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  background: var(--red);
  color: white;
  padding: 8px 22px;
  border: none;
  border-radius: 3px;
  flex-shrink: 0;
  transition: background 0.15s;
  box-shadow: 0 3px 0 var(--red-dark);
  cursor: pointer;
}
.nav-open:hover { background: #E03020; }

.list-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 28px 40px 24px;
}
.list-header-inner { max-width: 1280px; margin: 0 auto; }
.page-kicker {
  font-family: var(--font-cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
  display: block;
  margin-bottom: 6px;
}
.page-title {
  font-family: var(--font-cond);
  font-size: 36px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1;
}
.map-subtitle {
  margin-top: 10px;
  color: var(--text-2);
  font-size: 14px;
  max-width: 560px;
}

.map-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 40px 48px;
}

/* Game version bar — matches Pokédex detail-version-bar */
.map-main .detail-version-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-version-label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.detail-game-version {
  font-family: var(--font-body);
  font-size: 13px;
  min-width: 220px;
  max-width: min(100%, 520px);
  flex: 1 1 280px;
  background: var(--surface-3);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

.detail-game-version:focus {
  outline: none;
  border-color: var(--border-med);
}

.map-main .map-version-hint {
  flex: 1 1 100%;
  margin-top: 0;
  max-width: none;
  font-size: 12px;
  line-height: 1.4;
  color: var(--yellow);
}

.map-main .map-alola-bar {
  margin-bottom: 0;
  padding-bottom: 12px;
  border-bottom: none;
}

.map-main .map-alola-bar + .map-alola-bar {
  padding-top: 0;
}

.map-main .map-alola-bar:last-of-type {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-end;
  margin-bottom: 20px;
}
.map-control label {
  display: block;
  font-family: var(--font-cond);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 6px;
}
.map-control select {
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--border-2);
  padding: 8px 12px;
  min-width: 160px;
  cursor: pointer;
}
.map-control select:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

.map-pokemon-search {
  flex: 1 1 220px;
  min-width: 200px;
  max-width: 320px;
}
.map-search-wrap {
  position: relative;
}
.map-search-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--border-2);
  padding: 8px 32px 8px 12px;
  outline: none;
}
.map-search-input:focus {
  border-color: var(--red);
  outline: 2px solid var(--red);
  outline-offset: 1px;
}
.map-search-input::placeholder { color: var(--text-3); }
.map-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.map-search-clear:hover { color: var(--text-1); }
.map-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 2px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 120;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.map-search-dropdown.hidden { display: none; }
.map-search-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.map-search-option:hover,
.map-search-option:focus {
  background: var(--surface-3);
  outline: none;
}
.map-search-option img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.map-search-option-name { font-weight: 500; }
.map-search-empty {
  padding: 12px;
  font-size: 13px;
  color: var(--text-3);
}
.map-search-hint {
  padding-bottom: 8px;
}
.map-search-locations {
  list-style: none;
  margin: 0;
  padding: 0;
}
.map-search-locations li {
  border-bottom: 1px solid var(--border);
}
.map-search-locations li:last-child { border-bottom: none; }
.map-search-location-btn {
  display: block;
  width: 100%;
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.map-search-location-btn:hover,
.map-search-location-btn:focus {
  background: var(--surface-3);
  outline: none;
}

.map-control-edit { min-width: 200px; }
.map-control-label {
  display: block;
  font-family: var(--font-cond);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 6px;
}
.map-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.map-edit-btn {
  font-family: var(--font-cond);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border: 1px solid var(--border-2);
  background: var(--surface-3);
  color: var(--text-1);
  cursor: pointer;
}
.map-edit-btn:hover { border-color: var(--text-2); }
.map-edit-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.map-edit-btn-muted { color: var(--text-2); }
.map-edit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.map-edit-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-2);
  max-width: 320px;
  line-height: 1.4;
}

.map-stage.map-edit-mode {
  outline: 2px dashed var(--yellow);
  outline-offset: 4px;
  user-select: none;
  touch-action: none;
}
.map-edit-mode .map-pin-wrap {
  z-index: 5;
  touch-action: none;
}
.map-edit-mode .map-pin {
  cursor: grab;
  width: 16px;
  height: 16px;
  touch-action: none;
}
.map-edit-mode .map-pin-wrap:hover .map-pin {
  transform: none;
  background: var(--red);
}
.map-edit-mode .map-pin-wrap.kind-city:hover .map-pin { background: #5A8EE8; }
.map-edit-mode .map-pin-wrap.kind-cave:hover .map-pin { background: #A89028; }
.map-edit-mode .map-pin-wrap.kind-building:hover .map-pin { background: #8830A0; }
.map-edit-mode .map-pin-wrap.dragging {
  z-index: 10;
}
.map-edit-mode .map-pin-wrap.dragging .map-pin {
  cursor: grabbing;
  background: var(--yellow);
  transform: scale(1.35);
}
.map-edit-mode .map-pin-wrap.locked {
  opacity: 1;
  pointer-events: auto;
}
.map-edit-mode .map-pin::after {
  content: attr(data-pin-label);
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 4px;
  font-family: var(--font-cond);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  pointer-events: none;
}

.panel-pin-coords {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}
.panel-pin-coords code {
  font-family: ui-monospace, monospace;
  color: var(--yellow);
  font-size: 12px;
}

.map-layout {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 340px);
  gap: 24px;
  align-items: start;
}

.map-stage-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 4px;
  overflow: visible;
}

.map-stage {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  line-height: 0;
  container-type: inline-size;
  overflow: visible;
}

body.map-wide .map-stage {
  max-width: 960px;
}

.map-subtitle-links {
  margin-top: 8px;
  font-size: 14px;
}

.map-subtitle-links a {
  color: var(--red);
  font-weight: 600;
  text-decoration: none;
}

.map-subtitle-links a:hover {
  text-decoration: underline;
}

.map-stage img {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Town maps that are JPEG/vector art — smooth downscaling, never upscale past native px */
body.map-photo .map-stage {
  max-width: min(675px, 100%);
}

body.map-photo.map-photo-compact .map-stage {
  max-width: min(363px, 100%);
}

body.map-photo .map-stage img {
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
}

.map-pin-wrap {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}
.map-pin-wrap .map-pin {
  pointer-events: auto;
}
.map-pin {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--red);
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.5);
  transition: transform 0.12s, background 0.12s, opacity 0.12s;
}
.map-pin-wrap:hover {
  z-index: 3;
}
.map-pin-wrap:hover .map-pin:not(.map-pin-sprite-replace) {
  transform: scale(1.25);
  background: var(--yellow);
}
.map-pin-wrap:hover .map-pin.map-pin-sprite-replace {
  transform: scale(1.1);
}
.map-pin.active:not(.map-pin-sprite-replace) {
  background: var(--yellow);
  width: 16px;
  height: 16px;
}
.map-pin-wrap:has(.map-pin.active) {
  z-index: 4;
}
.map-pin-wrap.kind-city .map-pin:not(.map-pin-sprite-replace) { background: #5A8EE8; }
.map-pin-wrap.kind-cave .map-pin:not(.map-pin-sprite-replace) { background: #A89028; }
.map-pin-wrap.kind-building .map-pin:not(.map-pin-sprite-replace) { background: #8830A0; }
.map-pin-wrap.kind-island .map-pin:not(.map-pin-sprite-replace) {
  width: 22px;
  height: 22px;
  background: #E8A83A;
  border: 2px solid #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.map-pin-wrap.kind-island:hover .map-pin:not(.map-pin-sprite-replace) { background: #F2C12E; }
.map-pin-wrap.kind-island .map-pin.active:not(.map-pin-sprite-replace) { background: #F2C12E; }
.map-island-open-link {
  color: var(--yellow);
  font-weight: 700;
  text-decoration: none;
}
.map-island-open-link:hover { text-decoration: underline; }
.map-pin-wrap.locked .map-pin {
  opacity: 0.35;
  pointer-events: none;
}
.map-pin-wrap.locked:has(.map-pin.active) .map-pin { opacity: 0.5; }
.map-pin-wrap.search-dimmed:not(.locked) {
  opacity: 0.28;
}
.map-pin-wrap.search-dimmed:not(.locked):hover {
  opacity: 0.55;
}
.map-pin-wrap.search-match {
  z-index: 5;
}
.map-pin-wrap.search-match:hover {
  z-index: 6;
}
.map-pin-wrap.search-match:hover .map-pin:not(.map-pin-sprite-replace) {
  background: var(--yellow);
}
/* Sprite search: transparent hit target, small dot + sprite layered on top. */
.map-pin.map-pin-sprite-replace {
  width: 14px;
  height: 14px;
  padding: 18px;
  margin: -18px;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.map-pin-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--red);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.map-pin-wrap.kind-city .map-pin-dot { background: #5A8EE8; }
.map-pin-wrap.kind-cave .map-pin-dot { background: #A89028; }
.map-pin-wrap.kind-building .map-pin-dot { background: #8830A0; }
.map-pin-wrap.kind-island .map-pin-dot {
  width: 22px;
  height: 22px;
  background: #E8A83A;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.map-pin.map-pin-sprite-replace.active .map-pin-dot {
  width: 16px;
  height: 16px;
  background: var(--yellow);
}
.map-pin-wrap.kind-island .map-pin.map-pin-sprite-replace.active .map-pin-dot {
  width: 22px;
  height: 22px;
  background: #F2C12E;
}
.map-pin-wrap.search-match:hover .map-pin.map-pin-sprite-replace .map-pin-dot {
  background: var(--yellow);
}
.map-pin-wrap.kind-island.search-match:hover .map-pin.map-pin-sprite-replace .map-pin-dot {
  background: #F2C12E;
}
.map-pin-sprite {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
  display: block;
  width: 14.4cqi;
  height: 14.4cqi;
  min-width: 58px;
  min-height: 58px;
  max-width: 101px;
  max-height: 101px;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  background: transparent;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.65));
}
.map-pin-wrap.kind-island .map-pin-sprite {
  width: 16.8cqi;
  height: 16.8cqi;
  min-width: 67px;
  min-height: 67px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
}
.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.map-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #fff;
  display: inline-block;
}

.map-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.map-panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.map-panel-title {
  font-family: var(--font-cond);
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.map-panel-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}
.map-panel-body {
  flex: 1;
  overflow-y: auto;
  max-height: 520px;
  padding: 12px 0;
}
.map-panel-empty {
  padding: 32px 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

.area-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--border);
}
.area-tab {
  font-family: var(--font-cond);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
}
.area-tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.encounter-method-section {
  border-bottom: 1px solid var(--border);
}
.encounter-method-section:last-child {
  border-bottom: none;
}
.encounter-method-heading {
  margin: 0;
  padding: 10px 18px 6px;
  font-family: var(--font-cond);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.encounter-method-table .encounter-row:last-child {
  border-bottom: none;
}

.encounter-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
}
.encounter-row:hover { background: var(--surface-3); }
.encounter-row img {
  width: 36px;
  height: 36px;
  margin-top: 2px;
  image-rendering: pixelated;
}
.encounter-info {
  min-width: 0;
}
.encounter-name-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.encounter-name {
  font-weight: 600;
  font-size: 14px;
}
.encounter-total-chance {
  font-family: var(--font-cond);
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0;
}
.encounter-variants {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.encounter-variant {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.encounter-detail {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.35;
}
.encounter-chance {
  font-family: var(--font-cond);
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  text-align: right;
  flex-shrink: 0;
}
.encounter-none {
  padding: 16px 18px;
  color: var(--text-3);
  font-size: 13px;
}

.map-loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-2);
}
.map-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-2);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 40px;
  margin-top: 24px;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.footer-note { font-size: 12px; color: var(--text-3); }
.footer-links { display: flex; gap: 20px; }
.footer-links a {
  font-family: var(--font-cond);
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-panel { min-height: 240px; }
  .nav-inner, .list-header, .map-main, .site-footer { padding-left: 20px; padding-right: 20px; }
}


/* === Portal nav additions === */
.nav-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.nav-back {
  font-family: var(--font-pixel); font-size: 6px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-3); text-decoration: none;
  display: flex; align-items: center; gap: 6px; flex-shrink: 0; transition: color 0.15s;
}
.nav-back:hover { color: var(--red); }
.nav-divider { width: 1px; height: 16px; background: var(--border); flex-shrink: 0; }
.nav-tag {
  font-family: var(--font-pixel); font-size: 6px; letter-spacing: 1px;
  color: var(--red); background: rgba(141, 50, 168, 0.1);
  border: 1px solid rgba(141, 50, 168, 0.2); padding: 4px 9px; border-radius: 2px; flex-shrink: 0;
}
.nav-inner { gap: 28px !important; }
@media (max-width: 640px) {
  .nav-inner { gap: 16px !important; }
  .nav-tag { display: none; }
}