.base-view {
  --base-tabs-top: 76px;
  --squad-grid-top: 138px;
}

.base-mode-tabs {
  position: absolute;
  z-index: 12;
  top: var(--base-tabs-top);
  left: 50%;
  display: grid;
  grid-template-columns: repeat(2, minmax(94px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(244, 252, 239, 0.82);
  box-shadow: 0 7px 18px rgba(25, 65, 69, 0.22);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
}

.base-mode-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  color: #516d74;
  background: transparent;
  font-size: 10px;
  font-weight: 950;
  cursor: pointer;
}

.base-mode-tabs button.is-active {
  color: #fffdf0;
  background: linear-gradient(135deg, #e97961, #d69a52);
  box-shadow: 0 4px 9px rgba(113, 71, 46, 0.25), inset 0 1px rgba(255, 255, 255, 0.6);
}

.base-mode-tabs span {
  font-size: 15px;
}

.construction-view,
.squad-view {
  position: absolute;
  z-index: 4;
  inset: 0;
}

/* 编队页依次使用顶部情报、模式切换与棋盘安全区，禁止浮层互相覆盖。 */
.squad-view .guide-bubble {
  top: 7px;
  min-height: 57px;
}

.squad-view .unit-grid {
  top: var(--squad-grid-top);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  min-height: 0;
}

.squad-view .unit-slot {
  min-height: 0;
  aspect-ratio: auto;
  overflow: hidden;
}

/* 士兵立绘是卡片主体；状态和等级只占四角，不再套用遮挡形象的大圆盘。 */
.squad-view .unit-grid .unit-token {
  position: absolute;
  inset: 2px 4px 1px;
  box-sizing: border-box;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: radial-gradient(ellipse at 50% 88%, color-mix(in srgb, var(--unit-accent) 30%, transparent) 0 26%, transparent 64%);
  box-shadow: none;
}

.squad-view .unit-grid .board-unit-art {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
}

.squad-view .unit-grid .unit-level {
  right: 3px;
  bottom: 3px;
  min-width: 29px;
  height: 17px;
  padding: 0 4px;
  border-width: 1px;
  border-radius: 6px 3px 6px 3px;
  font-size: 9px;
  line-height: 1;
}

.squad-view .unit-grid .unit-stars {
  top: 4px;
  right: 4px;
  gap: 0;
  max-width: 34px;
  overflow: hidden;
  font-size: 7px;
  line-height: 1;
  letter-spacing: -1px;
  white-space: nowrap;
}

.squad-view .unit-grid .formation-state {
  top: 3px;
  left: 3px;
  min-height: 16px;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px 3px 6px 3px;
  font-size: 8px;
  line-height: 14px;
}

.squad-view .unit-slot.is-reserve .unit-token {
  transform: scale(0.94);
}

.squad-view .unit-tier-3 .unit-token::before,
.squad-view .unit-tier-4 .unit-token::before {
  inset: 8% 10% 4%;
  border-width: 1px;
  border-radius: 45% 55% 48% 52%;
}

.squad-view .unit-grid .tutorial-merge-mark {
  top: 21px;
  right: 3px;
  width: 16px;
  height: 16px;
  font-size: 9px;
}

.squad-view .selection-actions {
  right: 18px;
  bottom: 3px;
  left: 18px;
}

.squad-view .selection-actions button {
  min-height: 32px;
  padding: 0 12px;
}

.squad-view:has(.selection-actions:not([hidden])) .merge-tip {
  visibility: hidden;
}

.base-view:has(.squad-view:not([hidden]) .guide-bubble:not([hidden])) > .base-status,
.base-view:has(.squad-view:not([hidden]) .guide-bubble:not([hidden])) > .enemy-intel {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.construction-view::before {
  position: absolute;
  z-index: 0;
  inset: 92px 0 0;
  content: "";
  background: radial-gradient(ellipse at 50% 49%, rgba(255, 251, 198, 0.17), transparent 58%);
  pointer-events: none;
}

.construction-routes {
  position: absolute;
  z-index: 1;
  top: 106px;
  right: 0;
  bottom: 25px;
  left: 0;
  width: 100%;
  height: calc(100% - 131px);
  overflow: visible;
  pointer-events: none;
}

.construction-routes path {
  fill: none;
  stroke: rgba(255, 247, 201, 0.7);
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-dasharray: 1.5 2.3;
  filter: drop-shadow(0 1px 1px rgba(45, 85, 77, 0.5));
  vector-effect: non-scaling-stroke;
}

.construction-routes .route-energy {
  stroke: rgba(104, 235, 225, 0.58);
  stroke-width: 0.7;
  stroke-dasharray: 0.8 3.1;
  animation: route-flow 7s linear infinite;
}

.building-plots {
  position: absolute;
  z-index: 2;
  top: 106px;
  right: 0;
  bottom: 25px;
  left: 0;
}

.building-plot {
  position: absolute;
  width: 31%;
  height: 28%;
  min-width: 88px;
  min-height: 88px;
  padding: 0;
  overflow: visible;
  border: 0;
  color: #294a59;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  isolation: isolate;
  transform: translate(-50%, -50%);
  transform-origin: 50% 72%;
  touch-action: manipulation;
}

/* 点位以底图石台的接地中心为准；top 预留了建筑透明画布下方约 23.5% 的接地偏移。 */
.building-plot:nth-child(1) { z-index: 5; top: 18%; left: 50%; width: 34%; height: 32%; }
.building-plot:nth-child(2) { z-index: 6; top: 32%; left: 24%; }
.building-plot:nth-child(3) { z-index: 6; top: 32%; left: 77%; }
.building-plot:nth-child(4) { z-index: 7; top: 56%; left: 29%; width: 33%; height: 30%; }
.building-plot:nth-child(5) { z-index: 7; top: 56%; left: 76%; width: 33%; height: 30%; }
.building-plot:nth-child(6) { z-index: 8; top: 61%; left: 52%; width: 34%; height: 31%; }

.building-plot::before {
  position: absolute;
  z-index: -1;
  width: 78%;
  height: 31%;
  right: 11%;
  bottom: 11%;
  content: "";
  border: 1px solid rgba(234, 255, 247, 0.68);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(225, 246, 221, 0.48), color-mix(in srgb, var(--building-accent, #67baa7) 14%, rgba(63, 118, 96, 0.42)) 60%, rgba(34, 84, 69, 0.18) 64%, transparent 70%);
  box-shadow: inset 0 2px rgba(255, 255, 255, 0.42), 0 5px 9px rgba(28, 72, 63, 0.19);
  transform: rotate(-3deg);
}

/* 已有石台只补接触光影，避免再盖一层椭圆地基；第 5 格是独立扩建位，保留完整基座。 */
.building-plot:nth-child(-n + 4):not(.is-empty)::before,
.building-plot:nth-child(6):not(.is-empty)::before {
  border-color: transparent;
  background: radial-gradient(ellipse, rgba(42, 88, 70, 0.2), rgba(31, 76, 65, 0.09) 54%, transparent 70%);
  box-shadow: none;
}

.building-plot:not(.is-empty)::after {
  position: absolute;
  z-index: 1;
  right: 22%;
  bottom: 17%;
  width: 56%;
  height: 12%;
  content: "";
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(22, 55, 55, 0.4), rgba(29, 73, 65, 0.16) 54%, transparent 74%);
  filter: blur(3px);
  transform: rotate(-3deg);
  pointer-events: none;
}

.building-plot:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.building-plot.is-selected::before {
  border: 2px solid #fff5a6;
  box-shadow: 0 0 0 4px rgba(255, 222, 103, 0.25), 0 0 18px rgba(255, 241, 158, 0.85);
}

.building-plot.is-empty {
  display: grid;
  place-content: center;
  gap: 2px;
  color: rgba(42, 80, 79, 0.7);
  background: transparent;
}

.building-plot.is-empty::before {
  width: 70%;
  height: 28%;
  right: 15%;
  bottom: 19%;
  border-style: dashed;
  background: radial-gradient(ellipse, rgba(214, 246, 207, 0.45), rgba(75, 135, 107, 0.24) 62%, transparent 67%);
  opacity: 0.9;
}

.plot-plus {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 12px auto 0;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  color: white;
  background: rgba(45, 109, 101, 0.62);
  box-shadow: 0 4px 10px rgba(26, 74, 70, 0.25), inset 0 0 0 3px rgba(193, 247, 219, 0.18);
  font-size: 24px;
}

.building-plot.is-empty b {
  padding: 2px 6px;
  border-radius: 99px;
  color: white;
  background: rgba(31, 76, 73, 0.68);
  box-shadow: 0 2px 5px rgba(32, 61, 59, 0.17);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.building-plot.is-move-target::before {
  border: 2px solid #fff29a;
  background: radial-gradient(ellipse, rgba(255, 247, 161, 0.65), rgba(82, 211, 184, 0.34) 60%, transparent 68%);
  animation: move-target-pulse 1s ease-in-out infinite;
}

.building-plot.is-move-source .building-art {
  filter: drop-shadow(0 0 9px #fff39b) drop-shadow(0 7px 4px rgba(36, 59, 58, 0.3));
}

.building-art {
  position: absolute;
  z-index: 2;
  width: 108%;
  height: 100%;
  top: -12%;
  left: -4%;
  object-fit: contain;
  filter:
    saturate(0.86)
    contrast(0.93)
    brightness(1.04)
    drop-shadow(0 8px 5px rgba(30, 64, 60, 0.31));
  transform-origin: 50% 82%;
  pointer-events: none;
  animation: building-idle 3.6s ease-in-out infinite;
}

.building-plot:nth-child(even) .building-art {
  animation-delay: -1.4s;
}

.building-label {
  position: absolute;
  z-index: 4;
  width: max-content;
  max-width: 112%;
  right: auto;
  bottom: 0;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 21px;
  padding: 3px 4px 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 10px 3px 10px 3px;
  color: white;
  background: rgba(29, 61, 70, 0.78);
  box-shadow: 0 3px 8px rgba(31, 57, 58, 0.2);
  backdrop-filter: blur(7px);
  transform: translateX(-50%);
}

.building-label b {
  overflow: hidden;
  font-size: 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.building-label em {
  flex: none;
  padding: 3px 5px;
  border-radius: 99px;
  color: white;
  background: var(--building-accent, #5cae9c);
  font-size: 7px;
  font-style: normal;
  font-weight: 950;
}

.building-upgrade-mark {
  position: absolute;
  z-index: 5;
  top: 1%;
  right: 4%;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid white;
  border-radius: 50%;
  color: #5b492c;
  background: #ffe27c;
  box-shadow: 0 3px 8px rgba(87, 65, 31, 0.22);
  font-size: 12px;
  font-style: normal;
  font-weight: 950;
  animation: building-ready 1.8s ease-in-out infinite;
}

.construction-hint {
  position: absolute;
  right: 6px;
  bottom: 5px;
  left: 6px;
  margin: 0;
  color: white;
  font-size: 7px;
  font-weight: 850;
  text-align: center;
  text-shadow: 0 1px 5px #244e53;
}

.cancel-building-move {
  position: absolute;
  z-index: 23;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px 0 11px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 15px 5px 15px 5px;
  color: white;
  background: linear-gradient(145deg, rgba(48, 91, 98, 0.96), rgba(31, 65, 77, 0.96));
  box-shadow: 0 5px 0 rgba(27, 57, 64, 0.82), 0 10px 20px rgba(27, 57, 64, 0.28);
  font-size: 10px;
  cursor: pointer;
}

.cancel-building-move span {
  font-size: 20px;
  line-height: 1;
}

.construction-panel {
  position: absolute;
  z-index: 24;
  right: 8px;
  bottom: 7px;
  left: 8px;
  max-height: 50%;
  padding: 14px 11px 11px;
  overflow: auto;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 23px 8px 23px 8px;
  color: #2b4559;
  background: linear-gradient(155deg, rgba(255, 254, 241, 0.98), rgba(222, 242, 230, 0.97));
  box-shadow: 0 -8px 30px rgba(18, 51, 58, 0.31);
  backdrop-filter: blur(15px);
  animation: construction-panel-in 0.22s ease-out both;
}

.construction-panel-close {
  position: absolute;
  z-index: 2;
  top: 4px;
  right: 4px;
  width: 44px;
  height: 44px;
  border: 0;
  color: #698082;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
}

.construction-detail-head {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding-right: 30px;
}

.construction-detail-head img {
  width: 82px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(44, 61, 60, 0.25));
}

.construction-detail-head small,
.construction-option small {
  color: #71878a;
  font-size: 7px;
  font-weight: 750;
  line-height: 1.35;
}

.construction-detail-head h3 {
  margin: 2px 0 3px;
  font-size: 14px;
}

.construction-effect-stack {
  display: grid;
  gap: 5px;
  margin: 9px 0;
}

.construction-effect-stack span {
  padding: 7px 9px;
  border: 1px solid rgba(80, 134, 123, 0.2);
  border-radius: 9px 3px 9px 3px;
  color: #43696a;
  background: rgba(179, 229, 200, 0.35);
  font-size: 8px;
  font-weight: 900;
}

.construction-effect-stack .is-next {
  color: #835a2f;
  background: rgba(255, 220, 133, 0.43);
}

.building-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
}

.building-actions:has(.building-action:only-child) {
  grid-template-columns: 1fr;
}

.building-move-action {
  min-width: 92px;
  min-height: 47px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 14px 5px 14px 5px;
  color: #335d68;
  background: linear-gradient(145deg, #d8f4e7, #aee0d7);
  box-shadow: 0 5px 0 #7eaaa4, 0 8px 13px rgba(47, 81, 80, 0.16);
  font-size: 9px;
  font-weight: 950;
  cursor: pointer;
}

.building-action {
  width: 100%;
  min-height: 47px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 14px 5px 14px 5px;
  color: white;
  background: linear-gradient(135deg, #ec8b5e, #d49b4f);
  box-shadow: 0 5px 0 #a36e3e, 0 9px 15px rgba(83, 58, 36, 0.19);
  font-size: 11px;
  font-weight: 950;
  cursor: pointer;
}

.building-action:disabled {
  color: #79858a;
  background: #d4dcda;
  box-shadow: 0 4px 0 #a7b1af;
  cursor: default;
}

.construction-options-title {
  margin: 0 36px 8px 3px;
  font-size: 13px;
}

.construction-options {
  display: grid;
  gap: 7px;
}

.construction-option {
  position: relative;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 74px;
  padding: 5px 7px 5px 4px;
  border: 1px solid color-mix(in srgb, var(--building-accent) 45%, white);
  border-radius: 14px 5px 14px 5px;
  color: #294759;
  background: rgba(255, 255, 250, 0.74);
  cursor: pointer;
}

.construction-option img {
  width: 64px;
  height: 62px;
  object-fit: contain;
}

.construction-option span {
  display: grid;
  min-width: 0;
  gap: 2px;
  text-align: left;
}

.construction-option b {
  font-size: 10px;
}

.construction-option em {
  color: var(--building-accent);
  font-size: 7px;
  font-style: normal;
  font-weight: 950;
}

.construction-option strong {
  padding: 5px 7px;
  border-radius: 99px;
  color: #5d4a2e;
  background: #ffe185;
  font-size: 9px;
}

.construction-option:disabled {
  filter: grayscale(0.6);
  opacity: 0.56;
  cursor: default;
}

@keyframes building-idle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.015); }
}

@keyframes building-ready {
  0%, 100% { transform: scale(1); box-shadow: 0 3px 8px rgba(87, 65, 31, 0.22); }
  50% { transform: scale(1.1); box-shadow: 0 0 13px rgba(255, 225, 112, 0.92); }
}

@keyframes construction-panel-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes route-flow {
  to { stroke-dashoffset: -24; }
}

@keyframes move-target-pulse {
  0%, 100% { opacity: 0.72; transform: scale(0.94) rotate(-3deg); }
  50% { opacity: 1; transform: scale(1.08) rotate(-3deg); }
}

@media (max-width: 430px) {
  .building-plots { top: 106px; right: 0; left: 0; }
  .building-art { width: 108%; left: -4%; }
  .construction-panel { right: 5px; bottom: 5px; left: 5px; }
}

@media (max-height: 700px) {
  .base-view {
    --base-tabs-top: 64px;
    --squad-grid-top: 122px;
  }
  .squad-view .guide-bubble { top: 5px; min-height: 52px; }
  .building-plots { top: 102px; right: 0; bottom: 24px; left: 0; }
  .construction-routes { top: 102px; bottom: 24px; height: calc(100% - 126px); }
  .building-plot { min-height: 66px; }
  .building-label { min-height: 21px; }
  .building-art { height: 100%; }
  .construction-panel { max-height: 66%; }
}

@media (prefers-reduced-motion: reduce) {
  .building-art,
  .building-upgrade-mark,
  .building-plot.is-move-target::before,
  .construction-routes .route-energy,
  .construction-panel {
    animation: none !important;
  }
}
