/* 地產大亨戰況 — 楓之谷 UI 框架 + 地圖（邏輯不動） */

body {
  background-color: #8fd3f0;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.7) 0%, transparent 26%),
    linear-gradient(180deg, #8fd3f0 0%, #ccecf9 42%, #e8f6e0 100%);
  color: #4a3422;
}

.page {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 36px;
}

.site-header + .page {
  padding-top: 4px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 10px;
}

.top .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top .logo {
  width: 48px;
  height: 48px;
  border: 2px solid #c9a56a;
  border-radius: 10px;
  overflow: hidden;
  background: #fff9ed;
  box-shadow: 0 2px 8px rgba(90, 61, 40, 0.15);
}

.top .logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.top .brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #5a3d28;
}

.top .brand p {
  margin: 3px 0 0;
  color: #8a735c;
  font-size: 12px;
}

.dc {
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid #5865f2;
  border-bottom-width: 3px;
  color: #fff;
  background: linear-gradient(180deg, #7289da 0%, #5865f2 100%);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 0 #4752c4;
}

.dc:hover {
  filter: brightness(1.05);
}

.page .hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 18px 22px;
  margin-bottom: 14px;
  grid-template-columns: unset;
  border: 3px solid #c9a56a;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff9ed 0%, #f7edd5 100%);
  box-shadow: 0 8px 20px rgba(90, 61, 40, 0.16);
}

.page .hero h2 {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 38px);
  font-weight: 800;
  color: #5a3d28;
  line-height: 1.15;
  text-shadow: 1px 1px 0 #fff;
}

.page .hero p {
  margin: 10px 0 0;
  max-width: 680px;
  color: #8a735c;
  line-height: 1.7;
  font-size: 14px;
}

.estate-meta {
  margin: 8px 0 0;
  color: #7a5235;
  font-size: 13px;
  font-weight: 700;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 280px;
}

.leg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 2px solid #ddb878;
  border-radius: 8px;
  background: #fff8ea;
  color: #7a5235;
  font-size: 12px;
  font-weight: 700;
}

.leg i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  border: 1px solid rgba(90, 61, 40, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.legend .leg:first-child i {
  background: #ffb020;
  border-color: #7a4f08;
  box-shadow: 0 0 0 1px #7a4f08, 0 0 8px rgba(255, 176, 32, 0.75);
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.card {
  border: 3px solid #c9a56a;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff9ed 0%, #f7edd5 100%);
  box-shadow: 0 8px 20px rgba(90, 61, 40, 0.16);
}

.mapCard {
  padding: 12px;
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 10px;
  padding: 6px;
  border: 2px solid #ddb878;
  border-radius: 10px;
  background: #fff8ea;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  height: 32px;
  padding: 0 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #7a5235;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.tab:hover {
  background: #fff3dc;
  border-color: #f0c878;
}

.tab.active {
  color: #fff;
  background: linear-gradient(180deg, #7ec956 0%, #5aad38 52%, #458f2a 100%);
  border: 2px solid #3d7a28;
  border-bottom-width: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 2px 0 #2d5f1e;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
}

.tab i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: block;
  background: var(--c);
}

.map {
  position: relative;
  border: 3px solid #8b6914;
  border-radius: 10px;
  overflow: hidden;
  background: #ccecf9;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.map-stage {
  position: relative;
  width: 100%;
  line-height: 0;
}

.map img,
.map picture {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  vertical-align: top;
}

.map img {
  user-select: none;
  -webkit-user-drag: none;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.pins {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.pin {
  pointer-events: auto;
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 0;
  height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
  --lvl: #c4a055;
  --owner: #5a8f4a;
  --city: #e8882a;
}

.pin::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--owner);
  opacity: 0.25;
  transition: width 0.15s ease, height 0.15s ease, background 0.35s ease, box-shadow 0.35s ease, opacity 0.35s ease;
}

.pin i {
  position: absolute;
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--lvl);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transition: width 0.15s ease, height 0.15s ease, background 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.pin.owned {
  z-index: 4;
}

.pin.owned::before {
  /* 光暈範圍縮小、模糊半徑降低，避免地段密集時光點互相吃在一起 */
  width: calc(20px + var(--lvl-ring, 0px) * 0.6);
  height: calc(20px + var(--lvl-ring, 0px) * 0.6);
  opacity: 0.7;
  background: var(--lvl);
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.92) 0%,
    var(--lvl) 36%,
    color-mix(in srgb, var(--lvl) 72%, var(--owner)) 100%
  );
  box-shadow:
    0 0 6px color-mix(in srgb, var(--lvl) 88%, white),
    0 0 12px color-mix(in srgb, var(--lvl) 55%, transparent);
  animation: estate-owned-halo 1.8s ease-in-out infinite;
}

.pin.owned i {
  width: calc(14px + var(--lvl-core, 0px) * 0.6);
  height: calc(14px + var(--lvl-core, 0px) * 0.6);
  border: 2px solid #fff8dc;
  background: var(--lvl);
  box-shadow:
    0 0 5px var(--lvl),
    0 0 4px rgba(255, 255, 255, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 2px 4px rgba(0, 0, 0, 0.45);
  animation: estate-owned-core 1.8s ease-in-out infinite;
}

.pin.owned:hover::before,
.pin.owned.active::before {
  width: 44px;
  height: 44px;
}

.pin.owned:hover i,
.pin.owned.active i {
  width: 24px;
  height: 24px;
}

@keyframes estate-owned-halo {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.68;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.14);
    opacity: 0.92;
  }
}

@keyframes estate-owned-core {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.18);
  }
}

.pin.unowned::before {
  width: 30px;
  height: 30px;
  background: radial-gradient(circle, #ffe082 0%, #ffb020 55%, #d4880a 100%);
  opacity: 0.62;
}

.pin.unowned i {
  width: 16px;
  height: 16px;
  background: linear-gradient(180deg, #ffe082 0%, #ffb020 52%, #e8930a 100%);
  border: 2px solid #7a4f08;
  box-shadow:
    0 0 10px rgba(255, 176, 32, 0.9),
    0 0 3px rgba(255, 255, 255, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 2px 4px rgba(0, 0, 0, 0.45);
}

.pin:hover::before,
.pin.active::before {
  width: 34px;
  height: 34px;
}

.pin:hover i,
.pin.active i {
  width: 18px;
  height: 18px;
}

.pin.dim {
  opacity: 0.22;
  pointer-events: none;
}

.pin.focus {
  opacity: 1;
  z-index: 6;
}

.pin.owned.focus::before {
  width: calc(44px + var(--lvl-ring, 0px));
  height: calc(44px + var(--lvl-ring, 0px));
  opacity: 1;
  box-shadow:
    0 0 20px color-mix(in srgb, var(--lvl) 92%, white),
    0 0 40px color-mix(in srgb, var(--lvl) 65%, transparent);
}

.pin.owned.focus i {
  width: 26px;
  height: 26px;
}

/* 名牌：扁平羊皮紙小旗，全部地段一律常駐顯示，字刻意壓小避免太搶眼 */
.ownerTag {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--owner);
  background: #fff8ea;
  color: #3a2a1a;
  font-size: 9px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(74, 52, 34, 0.4);
  pointer-events: none;
  display: none;
  z-index: 3;
}

.ownerTag::after {
  /* 小三角箭頭指向地段，取代原本的發光圈 */
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--owner);
}

.pin.owned .ownerTag {
  display: block;
}

.pin.owned:hover .ownerTag,
.pin.owned.active .ownerTag,
.pin.owned.focus .ownerTag {
  border-width: 1.5px;
  font-size: 10px;
}

.side {
  padding: 14px;
  position: sticky;
  top: 76px;
}

.sideHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px dashed #ddb878;
}

.side h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #5a3d28;
}

.reset {
  border: 2px solid #c9a56a;
  background: #fff8ea;
  color: #7a5235;
  border-radius: 8px;
  height: 28px;
  padding: 0 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.reset:hover {
  background: #fff3dc;
}

.rank {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.rankBtn {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 26px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  text-align: left;
  border: 2px dashed #c9a56a;
  border-radius: 6px;
  background: linear-gradient(180deg, #fffdf8 0%, #faf0d8 100%);
  color: #4a3422;
  padding: 8px 10px;
  cursor: pointer;
}

.rankBtn:hover,
.rankBtn.active {
  border-style: solid;
  border-color: var(--owner);
  background: color-mix(in srgb, var(--owner) 10%, #fffdf8);
}

/* 排名徽章改成領地旗幟/盾牌剪影，取代制式的圓角數字徽章 */
.rnkBanner {
  width: 30px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #efe0c0;
  color: #7a5235;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
  clip-path: polygon(0 0, 100% 0, 100% 68%, 50% 100%, 0 68%);
  border: 1px solid #c9a56a;
  padding-bottom: 4px;
}

.rnkBanner.top1 {
  background: linear-gradient(180deg, #ffe566 0%, #ffb020 100%);
  color: #5c3d00;
  border-color: #a66f08;
  box-shadow: 0 0 8px rgba(255, 176, 32, 0.55);
}

.rnkBanner.top2 {
  background: linear-gradient(180deg, #f0f0f5 0%, #b8bcc8 100%);
  color: #3a3f4d;
  border-color: #8a909e;
}

.rnkBanner.top3 {
  background: linear-gradient(180deg, #ffd0a0 0%, #c97830 100%);
  color: #4a2208;
  border-color: #9a5520;
}

/* 玩家標示改成小旗幟（領地旗），取代純色圓點頭像 */
.rflag {
  width: 22px;
  height: 28px;
  flex-shrink: 0;
  background: var(--owner);
  border: 2px solid #fff;
  clip-path: polygon(0 0, 100% 0, 100% 72%, 50% 100%, 0 72%);
  box-shadow: 0 1px 3px rgba(74, 52, 34, 0.35);
}

.rname {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: #5a3d28;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rbody {
  min-width: 0;
}

.rmeta {
  display: block;
  color: #8a735c;
  font-size: 11px;
  margin-top: 2px;
  line-height: 1.4;
}

.rscore {
  color: #c56a18;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  text-align: right;
}

.rscore small {
  margin-left: 1px;
  font-size: 11px;
  font-weight: 700;
  color: #8a735c;
}

.rankBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 2px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe566 0%, #ffb020 100%);
  color: #5c3d00;
  border: 1px solid #a66f08;
  font-size: 13px;
}

.empty {
  color: #8a735c;
  border: 2px dashed #ddb878;
  border-radius: 8px;
  padding: 12px;
  line-height: 1.65;
  font-size: 13px;
  background: #fffdf8;
}

.detail {
  border-top: 2px dashed #ddb878;
  padding-top: 10px;
}

.detail small {
  display: block;
  color: #8a735c;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
}

.detail h4 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 800;
  color: #5a3d28;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid #efe0c0;
  font-size: 13px;
}

.row span {
  color: #8a735c;
}

.row b {
  text-align: right;
  color: #5a3d28;
  font-weight: 700;
}

.fragSection {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 2px dashed #ddb878;
}

.fragRow span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fragIcon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
}

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffe082 0%, #ffb020 100%);
  color: #5c3d00;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid #a66f08;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.status.owned {
  background: #fff9ed;
  background: color-mix(in srgb, var(--owner) 25%, #fff9ed);
  color: #3d5c32;
  border-color: var(--owner);
}

/* ── 資源分布面板 ── */
.resDistr {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px dashed #ddb878;
}

.resDHead {
  font-size: 11px;
  font-weight: 700;
  color: #8a735c;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.resRow {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}

.resName {
  flex: 0 0 56px;
  font-size: 11px;
  color: #5a3d28;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resBar {
  flex: 1;
  height: 6px;
  background: #efe0c0;
  border-radius: 3px;
  overflow: hidden;
}

.resFill {
  height: 100%;
  background: linear-gradient(90deg, #7ec956, #5aad38);
  border-radius: 3px;
  transition: width 0.35s ease;
}

.resQty {
  flex: 0 0 44px;
  font-size: 11px;
  font-weight: 700;
  color: #c56a18;
  text-align: right;
  white-space: nowrap;
}

.resDistrEmpty {
  margin: 0;
  padding: 8px;
  font-size: 12px;
}

/* ── Tooltip 資源列 ── */
.tipFrag {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #ddb878;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tipFrag span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #5a3d28;
  justify-content: flex-start;
}

.tip {
  position: fixed;
  left: -9999px;
  top: -9999px;
  z-index: 50;
  min-width: 180px;
  max-width: 250px;
  border: 2px solid #c9a56a;
  border-radius: 10px;
  background: #fff9ed;
  padding: 10px 12px;
  box-shadow: 0 10px 24px rgba(90, 61, 40, 0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s ease;
}

.tip.show {
  opacity: 1;
}

.tip strong {
  display: block;
  color: #5a3d28;
  margin-bottom: 6px;
  font-size: 14px;
}

.tip div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #8a735c;
  font-size: 12px;
  line-height: 1.55;
}

.tip b {
  color: #5a3d28;
  font-weight: 700;
}

@media (max-width: 1120px) {
  .page .hero {
    display: block;
  }

  .legend {
    justify-content: flex-start;
    margin-top: 12px;
    min-width: 0;
  }

  .board {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
  }
}

@media (max-width: 680px) {
  .page {
    width: calc(100% - 16px);
    padding-bottom: 24px;
  }

  .page .hero {
    padding: 14px 16px;
  }

  .page .hero h2 {
    font-size: clamp(22px, 6vw, 28px);
  }

  .page .hero p {
    font-size: 13px;
  }

  .legend {
    gap: 4px;
  }

  .leg {
    height: 26px;
    padding: 0 8px;
    font-size: 11px;
  }

  .mapCard {
    padding: 8px;
    overflow: hidden;
  }

  .map {
    touch-action: pan-x pan-y;
  }

  .tabs {
    margin-bottom: 8px;
  }

  .tab {
    flex-shrink: 0;
    font-size: 12px;
    padding: 0 10px;
  }

  .side {
    padding: 12px;
  }

  .side h3 {
    font-size: 16px;
  }

  .rankBtn {
    grid-template-columns: 30px 22px minmax(0, 1fr) auto;
    gap: 6px;
    padding: 8px;
    min-height: 44px;
  }

  .rnkBanner {
    width: 26px;
    height: 30px;
    font-size: 12px;
  }

  .rflag {
    width: 18px;
    height: 24px;
  }

  .rname {
    font-size: 12px;
  }

  .rmeta {
    font-size: 10px;
  }

  .rscore {
    font-size: 14px;
  }

  .pin.owned .ownerTag {
    display: block;
    font-size: 8px;
    padding: 1px 5px;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 1px 2px rgba(74, 52, 34, 0.4);
  }

  /* 手機板：地圖渲染尺寸比桌面小很多，光暈再縮一輪、模糊半徑壓到最低，避免地段密集時整片糊成一坨 */
  .pin.owned::before {
    width: calc(13px + var(--lvl-ring, 0px) * 0.35);
    height: calc(13px + var(--lvl-ring, 0px) * 0.35);
    box-shadow:
      0 0 3px color-mix(in srgb, var(--lvl) 88%, white),
      0 0 5px color-mix(in srgb, var(--lvl) 55%, transparent);
    animation: estate-owned-halo-mobile 1.8s ease-in-out infinite;
  }

  .pin.owned i {
    width: calc(10px + var(--lvl-core, 0px) * 0.35);
    height: calc(10px + var(--lvl-core, 0px) * 0.35);
    box-shadow:
      0 0 2px var(--lvl),
      inset 0 1px 0 rgba(255, 255, 255, 0.65);
  }

  .pin.owned.focus::before {
    width: calc(24px + var(--lvl-ring, 0px) * 0.35);
    height: calc(24px + var(--lvl-ring, 0px) * 0.35);
  }

  @keyframes estate-owned-halo-mobile {
    0%, 100% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 0.68;
    }
    50% {
      transform: translate(-50%, -50%) scale(1.06);
      opacity: 0.85;
    }
  }
}

@media (max-width: 390px) {
  .page {
    width: calc(100% - 12px);
  }

  .rankBtn {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }

  .rankBtn .rflag {
    display: none;
  }

  .rmeta {
    white-space: normal;
  }
}

/* iOS / WebKit：減少地圖疊層合成 bug（半幅黑屏、破圖） */
@supports (-webkit-touch-callout: none) {
  .map {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  .pin.owned::before,
  .pin.owned i,
  .pin.owned .ownerTag {
    animation: none !important;
  }

  .pin.owned i {
    filter: none !important;
  }
}
