/* ============================================================
   棲地地圖 — 2×2 大格,底圖切自 map.webp 四象限
   平板版:由 .hd-main grid 撐高(不再寫死像素高度)
   ============================================================ */

.hd-map {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  background: var(--hd-card);
  border: 1.5px solid var(--hd-line);
  border-radius: var(--hd-radius-xl);
  box-shadow: var(--hd-shadow);
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* tile:沿用 map.webp 同一張底圖,以 background-position 切四象限 */
.hd-tile {
  position: relative;
  border-radius: var(--hd-radius-lg);
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color .2s, transform .2s;
  background-image: url("../assets/map.webp");
  background-size: 200% 200%;
  background-repeat: no-repeat;
}
.hd-tile:hover { transform: scale(0.998); }
.hd-tile--active {
  border-color: var(--hd-ink);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6);
}

/* 四象限:map.webp 左上濕地、右上森林、左下都會、右下埤塘 */
.hd-tile--wetland { background-position:   0%   0%; }
.hd-tile--forest  { background-position: 100%   0%; }
.hd-tile--urban   { background-position:   0% 100%; }
.hd-tile--pond    { background-position: 100% 100%; }

/* 棲地名稱:貼齊右上角(只圓左下內側角) */
.hd-tile__name {
  position: absolute;
  top: 0; right: 0;
  padding: 4px 8px;
  background: rgba(245, 241, 232, .95);
  border-radius: 0 0 0 12px;
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--hd-ink);
  z-index: 3;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

/* 你的族群:N 徽章:貼齊左上角(只圓右下內側角) */
.hd-tile__badge {
  position: absolute;
  top: 0; left: 0;
  padding: 4px 8px;
  background: rgba(245, 241, 232, .96);
  color: var(--hd-ink);
  border-radius: 0 0 12px 0;
  font-family: var(--hd-font-sans);
  font-weight: 600;
  font-size: 20px;
  z-index: 3;
  display: inline-flex; align-items: center; gap: 9px;
  box-shadow: 2px 2px 6px rgba(0,0,0,.14);
  white-space: nowrap;
}
.hd-tile__badge::before {
  content: "";
  width: 13px; height: 13px;
  border-radius: 999px;
  background: var(--hd-self-color, var(--hd-species-blue));
  box-shadow: 0 0 0 2px rgba(255,255,255,.85);
}

/* 動物族群圓點 — seeded random 分布 */
.hd-tile__species-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
/* 2026-05-31 微調:所有 pin 都加白色實線外框讓顏色更鮮跳;self 額外加白虛線外圈分辨我/隊友 */
.hd-species-pin {
  position: absolute;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .35);
}
.hd-species-pin--other {
  /* 飽和度與 self 一致;只少了虛線外圈 */
}
.hd-species-pin--self {
  z-index: 2;   /* 壓在 other 之上,虛線框不被遮 */
}
.hd-species-pin--self::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px dashed rgba(255, 255, 255, .95);
  border-radius: 999px;
  animation: hd-pulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes hd-pulse {
  0%, 100% { opacity: .6; transform: scale(1); }
  50%      { opacity: 1;  transform: scale(1.08); }
}
