/* 列阵 — 触屏 / 强制横屏 / 摇杆 / 竖屏提示 */

/* ============ 触屏 / 手机 ============ */
.touch-only { display: none; }

#game { touch-action: none; }

#deselect-btn {
  display: none;
  position: absolute;
  top: 70px;
  right: 14px;
  z-index: 11;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: rgba(13, 19, 16, 0.9);
  color: var(--gold-bright);
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 2px;
  pointer-events: auto;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
}

@media (pointer: coarse) {
  .touch-only { display: block; }
  .desktop-only { display: none !important; }
  #keyhints, #minimap-panel { display: none; }
  #deselect-btn { display: block; }
  #dock {
    width: calc(100% - 16px);
    min-width: 0;
    bottom: 8px;
    padding: 9px 12px;
    min-height: 92px;
  }
  .build-grid { grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 5px; }
  .build-card { min-height: 64px; padding: 5px 3px 5px; }
  .build-card .b-desc { display: block; font-size: 8px; line-height: 1.2; }
  .b-icon { width: 25px; height: 25px; font-size: 14px; }
  .b-name { font-size: 10px; }
  .rally-note { display: block; font-size: 8px; margin-top: 4px; padding-top: 4px; }
  .dock-empty { padding: 6px 4px; }
  .mini-btn, .produce-btn { min-height: 38px; }
  .produce-actions { min-width: 124px; }
  .produce-actions .produce-btn { min-width: 124px; }
  .controls-strip { display: none; }
  #topbar { height: 52px; padding: 0 12px; }
  .tb-left { min-width: 0; gap: 8px; }
  .tb-right { min-width: 0; gap: 14px; }
  .gold-line { font-size: 19px; }
  #timer { font-size: 19px; }
  #phase { font-size: 8px; letter-spacing: 3px; }
  .crest { width: 28px; height: 28px; font-size: 16px; }
  .tb-stat span { font-size: 16px; }
  .tb-stat small { font-size: 8px; letter-spacing: 1px; }
  #dock .panel-head { margin-bottom: 7px; padding-bottom: 6px; }
  .dock-empty { padding: 10px 6px; }
  .dock-title { font-size: 9px; letter-spacing: 4px; }
  .dock-hint { font-size: 11px; line-height: 1.7; }
  .unit-portrait { width: 56px; min-height: 62px; font-size: 26px; }
  .unit-name { font-size: 13px; }
  .econ-row { gap: 4px 10px; font-size: 9px; }
  .econ-row .mini-btn { padding: 4px 8px; }
  .upgrade-row { gap: 8px; }
  .upgrade-note { font-size: 8px; }
  .upgrade-btn { min-width: 130px; }
  .mobile-hint {
    margin-top: 10px;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--faint);
    text-align: center;
  }
}

@media (pointer: coarse) and (orientation: portrait) {
  .menu-content { padding: 12px 20px; }
  .title { font-size: 56px; }
  .tagline { letter-spacing: 4px; }
  #dock { width: calc(100vw - 10px); }
  .panel-head { flex-wrap: wrap; gap: 4px; }
  .produce-row { gap: 8px; }
  .produce-actions { min-width: 104px; }
  .produce-actions .produce-btn { min-width: 104px; padding: 8px 8px; font-size: 11px; }
}

@media (pointer: coarse) {
  .army-note { display: none; }
  .army-foot { margin-top: 6px; gap: 6px; }
  .army-chip { padding: 3px 7px 3px 5px; font-size: 10px; }
  .army-chip .chip-icon { width: 18px; height: 18px; font-size: 11px; }
  .unit-desc { display: block; font-size: 8px; line-height: 1.3; }
  .unit-portrait { width: 48px; min-height: 54px; font-size: 22px; }
  .unit-name { font-size: 12px; }
  .queue-row { margin-top: 5px; }
  .upgrade-row { margin-top: 5px; padding-top: 5px; }
}


/* 设集结点 / 手机建造时收起指令面板，给战场留空间 */
body.rally-mode #dock { display: none; }
body.rally-mode #deselect-btn { display: block; }
body.rally-mode::after {
  content: "点击地面设置集结点 · 点右上角取消";
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: rgba(13, 19, 16, 0.92);
  color: var(--gold-bright);
  font-size: 11px;
  letter-spacing: 1px;
  pointer-events: none;
  white-space: nowrap;
}

@media (pointer: coarse) {
  body.placing #dock { display: none; }
  #placement-bar { bottom: 16px; }
}

/* ============ 横屏摇杆操作 ============ */
#joystick {
  display: none;
  position: fixed;
  left: 14px;
  bottom: 140px;
  width: 106px;
  height: 106px;
  border-radius: 50%;
  border: 1px solid rgba(216, 184, 120, 0.32);
  background: radial-gradient(circle at 42% 38%, rgba(34, 45, 36, 0.82), rgba(9, 14, 11, 0.5));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 0 26px rgba(216, 184, 120, 0.06);
  pointer-events: auto;
  z-index: 12;
  touch-action: none;
  user-select: none;
}
#joystick.active { border-color: rgba(216, 184, 120, 0.75); }
#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 1px solid rgba(242, 217, 163, 0.62);
  background: radial-gradient(circle at 35% 30%, rgba(242, 217, 163, 0.48), rgba(118, 90, 42, 0.42));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: transform 0.09s ease-out;
  pointer-events: none;
}
#joystick.active #joystick-knob { transition: none; }
.joy-label {
  position: absolute;
  left: 50%;
  top: -16px;
  transform: translateX(-50%);
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--faint);
  white-space: nowrap;
  pointer-events: none;
}
#zoom-controls {
  display: none;
  position: fixed;
  left: 128px;
  bottom: 140px;
  z-index: 12;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
}
#zoom-controls button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(13, 19, 16, 0.9);
  color: var(--gold-bright);
  font-family: var(--font-ui);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
}
#zoom-controls button:active { background: rgba(216, 184, 120, 0.22); }

@media (pointer: coarse) {
  #joystick { display: block; }
  #zoom-controls { display: flex; }
}

/* 竖屏强制提示 */
#rotate-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(30, 42, 33, 0.9), rgba(4, 7, 5, 0.99) 70%);
  color: var(--text);
}
.rotate-glyph {
  font-size: 64px;
  line-height: 1;
  color: var(--gold);
  animation: rotateHint 2.6s ease-in-out infinite;
}
@keyframes rotateHint {
  0%, 28% { transform: rotate(0deg); }
  62%, 100% { transform: rotate(90deg); }
}
#rotate-screen h3 {
  font-family: var(--font-title);
  font-size: 24px;
  letter-spacing: 7px;
  color: var(--gold-bright);
}
#rotate-screen p { font-size: 11px; letter-spacing: 2px; color: var(--muted); }
body.portrait #rotate-screen { display: flex; }
body.allow-portrait #rotate-screen { display: none !important; }
#rotate-screen p { max-width: 86vw; line-height: 1.7; }
.rotate-debug {
  font-size: 9px !important;
  letter-spacing: 1px !important;
  color: var(--faint) !important;
  min-height: 12px;
}
.rotate-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.rotate-force { width: 250px; padding: 9px 16px; }
#rotate-continue { margin-top: 0; pointer-events: auto; }


/* 横屏手机：固定左下摇杆，指令面板收窄靠右 */
@media (pointer: coarse) {
  #joystick { left: 14px; bottom: 16px; }
  #zoom-controls { left: 128px; bottom: 16px; }
  #dock {
    left: auto;
    right: 8px;
    transform: none;
    width: min(460px, calc(100% - 240px));
    max-height: 60%;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .build-grid {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    touch-action: none;
    overscroll-behavior-x: contain;
  }
  .build-card {
    flex: 0 0 74px;
    min-width: 74px;
    min-height: 60px;
    touch-action: none;
  }
  .hq-stats { font-size: 9px; gap: 3px 10px; }
  .hq-actions { gap: 5px; }
  .hq-actions .mini-btn { flex: 1 1 0; padding: 5px 3px; font-size: 8px; }
  .hq-actions .upgrade-btn { flex: 1.5 1 0; }
  .army-foot { gap: 6px; }
}



/* ============ 强制横屏应用壳 ============ */
#app {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body.force-landscape #app {
  width: 100vh;
  height: 100vw;
  transform: translate(100vw, 0) rotate(90deg);
  transform-origin: top left;
}
body.force-landscape #rotate-screen { display: none !important; }

/* 触屏右侧快捷操作 */
@media (pointer: coarse) {
  #action-rail {
    display: grid;
    grid-template-columns: repeat(3, 46px);
    gap: 5px;
    position: absolute;
    right: 10px;
    bottom: 84px;
    z-index: 12;
    pointer-events: auto;
  }
  .rail-btn {
    width: 46px;
    height: 40px;
    border: 1px solid var(--line);
    background: rgba(13, 19, 16, 0.9);
    color: var(--gold-bright);
    font-family: var(--font-ui);
    font-size: 10px;
    letter-spacing: 1px;
    cursor: pointer;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
  }
  .rail-btn:active { background: rgba(216, 184, 120, 0.18); }
  body[data-dock-mode="building"] #action-rail { bottom: 190px; }
  body[data-dock-mode="none"] #action-rail { display: none; }

  body[data-dock-mode="units"] #dock {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: auto;
    min-width: 250px;
    max-width: 480px;
    max-height: 90px;
  }
  body[data-dock-mode="units"] .army-compact { padding: 2px 2px; }
  body[data-dock-mode="units"] .army-chips { flex-wrap: nowrap; }
  .army-compact .army-chip { flex: none; }

  body.show-minimap #minimap-panel {
    display: block;
    left: 10px;
    top: 64px;
    bottom: auto;
    width: 172px;
    z-index: 13;
  }
}

/* ============ 移动端视觉精修 ============ */
@media (pointer: coarse) {
  #deselect-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    top: 58px;
    right: 12px;
    font-size: 0;
    line-height: 1;
    border-radius: 2px;
    background: rgba(9, 14, 11, 0.82);
    border-color: rgba(201, 168, 106, 0.26);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  }
  #deselect-btn::before {
    content: "×";
    display: block;
    font-family: var(--font-ui);
    font-size: 19px;
    color: var(--gold-bright);
  }

  .rail-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    height: 44px;
    border-color: rgba(201, 168, 106, 0.22);
    background:
      linear-gradient(180deg, rgba(255, 236, 200, 0.035), transparent 60%),
      rgba(11, 16, 12, 0.88);
    box-shadow: inset 0 1px 0 rgba(255, 236, 200, 0.05);
    transition: background 0.14s, border-color 0.14s;
  }
  .rail-btn i {
    font-style: normal;
    font-size: 15px;
    line-height: 1;
    color: var(--gold-bright);
    opacity: 0.95;
  }
  .rail-btn span {
    font-size: 9px;
    line-height: 1;
    letter-spacing: 1px;
    color: var(--muted);
  }
  .rail-btn:active {
    background: rgba(201, 168, 106, 0.16);
    border-color: rgba(201, 168, 106, 0.55);
  }
  body.show-minimap .rail-btn[data-rail="map"] {
    background: rgba(201, 168, 106, 0.16);
    border-color: rgba(201, 168, 106, 0.55);
  }

  body[data-dock-mode="units"] #dock {
    border-color: rgba(201, 168, 106, 0.3);
  }
  .army-compact .army-chip {
    padding: 4px 8px 4px 6px;
    font-size: 10px;
  }
  .army-compact .chip-icon { width: 20px; height: 20px; font-size: 12px; }
}

/* ============ 审计落地：触屏尺寸 ============ */
@media (pointer: coarse) {
  #deselect-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    top: 58px;
    right: 12px;
  }
  #dock {
    width: min(400px, calc(100% - 250px));
    max-height: 56%;
    padding: 8px 12px;
  }
  body[data-dock-mode="units"] #dock {
    width: max-content;
    min-width: 0;
    max-width: 480px;
    padding: 5px 10px;
    min-height: 0;
  }
  #action-rail {
    gap: 1px;
    padding: 1px;
    background: rgba(10, 12, 9, 0.82);
    border: 1px solid rgba(212, 175, 110, 0.32);
    box-shadow: inset 0 1px 0 rgba(255, 236, 196, 0.08);
  }
  .rail-btn {
    border: 0;
    box-shadow: none;
    background: rgba(13, 16, 12, 0.86);
  }
  .rail-btn:active { background: rgba(201, 168, 106, 0.2); }
  .panel-sub { font-size: 11px; }
  .q-label, .upgrade-note, .mm-foot { font-size: 10px; }
  .b-name { font-size: 11px; }
  .b-cost { font-size: 11px; }
  .build-card { min-height: 62px; }
  #minimap-panel { width: 148px; }
  #minimap { width: 130px; height: 130px; }
}

/* ============ 审计落地：右栏常驻 / 取消条件显示 / 建造分页 ============ */
@media (pointer: coarse) {
  #action-rail {
    top: 56px;
    bottom: auto;
    right: 10px;
  }
  body[data-dock-mode="building"] #action-rail,
  body[data-dock-mode="units"] #action-rail,
  body[data-dock-mode="none"] #action-rail {
    top: 56px;
    bottom: auto;
    display: grid;
  }
  #deselect-btn { display: none; }
  body.placing #deselect-btn,
  body.rally-mode #deselect-btn {
    display: block;
    top: 56px;
    right: 168px;
  }
  body[data-dock-mode="building"] .build-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    overflow: visible;
  }
  body[data-dock-mode="building"] .build-card {
    width: auto;
    min-width: 0;
    flex: none;
    min-height: 58px;
    padding: 5px 2px;
  }
  .build-tab { height: 34px; }
}

@media (pointer: coarse) {
  /* 双指缩放已覆盖；删掉与摇杆相邻的重复 +/- */
  #zoom-controls { display: none; }
}
