/* Loaded last on purpose: the top HUD is restyled by several older sheets,
   so these overrides must come after every other stylesheet. */

/* ==========================================================================
   2026-11-19 · 顶部资源栏 / 舰队活动条改用 11.19 素材包 06_顶部资源栏
   资源卡片素材（*_China，175×96）内部的灰卡位置各不相同，实测卡片带：
     metal 52–78%   crystal 59–85%   gas 61–88%   energy 67–93%   ruby 70–96%
   这里用 --plate-shift 把五张卡统一对到 61–87% 那条带子上，
   汉字压在卡内、数字紧贴卡片下沿，返回/设置与卡片带同一水平线。
   ========================================================================== */
:root {
  /* 2026-12-02：上移顶部资源栏，去掉原来额外 +16px 下压留白，并在全屏隐藏状态栏机型上收紧安全区冗余 */
  --hud-safe-top: max(4px, calc(env(safe-area-inset-top, 0px) - 10px));
  --hud-bar-content-height: 62px;
  --game-hud-offset: calc(var(--hud-bar-content-height) + var(--hud-safe-top));
}

.global-hud-resources {
  grid-template-columns: 40px repeat(5, minmax(0, 1fr)) 36px !important;
  column-gap: 4px !important;
  row-gap: 0 !important;
  align-items: start !important;
  height: var(--game-hud-offset) !important;
  min-height: var(--game-hud-offset) !important;
  padding: var(--hud-safe-top) 4px 0 !important;
  border: 0 !important;
  /* 底片用 06_顶部资源栏 的 Common_Img_Resources（1080×172 城市天际线） */
  background:
    linear-gradient(180deg, rgba(2, 9, 12, .30), rgba(1, 6, 8, .62) 62%, rgba(1, 6, 8, .82)),
    url("../../../assets/topbar/bar-bg.webp") center bottom / 100% 100% no-repeat !important;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .38) !important;
  overflow: visible !important;
}

/* 返回键：与资源卡片同一条水平带，图标居中 */
.global-hud-resources .hud-back-button {
  align-self: start !important;
  width: 40px !important;
  height: 44px !important;
  margin: 2px 0 0 !important;
  transform: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-rows: 30px 12px !important;
  place-items: center !important;
  gap: 1px !important;
  background: transparent !important;
  box-shadow: none !important;
}
.global-hud-resources .hud-back-button::before {
  width: 25px !important;
  height: 28px !important;
}
.global-hud-resources .hud-back-button span { display: none !important; }
.global-hud-resources .hud-back-button { grid-template-rows: 44px !important; }

/* 资源格：保持 44px 卡片带使五张图标字板精确对齐，整体上提 3px */
.global-hud-resources .resource-item {
  position: relative !important;
  display: block !important;
  min-width: 0 !important;
  height: 61px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  box-shadow: none !important;
  transform: none !important;
  overflow: visible !important;
}

.global-hud-resources .resource-item .res-plate {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: -3px !important;
  display: block !important;
  height: 44px !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-size: contain !important;
  transform: translateY(var(--plate-shift, 0px));
  pointer-events: none;
}
.global-hud-resources .resource-item[data-resource="metal"] .res-plate { background-image: url("../../../assets/topbar/metal.webp") !important; --plate-shift: 3.7px; --label-top: 28.1px; }
.global-hud-resources .resource-item[data-resource="crystal"] .res-plate { background-image: url("../../../assets/topbar/crystal.webp") !important; --plate-shift: 0.8px; --label-top: 31.0px; --label-left: 42%; --label-right: 3%; }
.global-hud-resources .resource-item[data-resource="gas"] .res-plate { background-image: url("../../../assets/topbar/gas.webp") !important; --plate-shift: 0px; --label-top: 31.8px; }
.global-hud-resources .resource-item[data-resource="solar"] .res-plate { background-image: url("../../../assets/topbar/energy.webp") !important; --plate-shift: -2.5px; --label-top: 34.3px; }
.global-hud-resources .resource-item[data-resource="gem"] .res-plate { background-image: url("../../../assets/topbar/gem.webp") !important; --plate-shift: -3.7px; --label-top: 35.5px; --label-left: 33%; --label-right: 22%; }

/* 汉字写在素材右侧延伸出来的灰色卡片里 */
.global-hud-resources .resource-item .res-plate small {
  position: absolute !important;
  left: var(--label-left, 30%) !important;
  right: var(--label-right, 6%) !important;
  top: var(--label-top, 31.8px) !important;
  display: grid !important;
  place-items: center !important;
  height: 11px !important;
  transform: translateY(-50%) !important;
  color: #e3f4fa !important;
  font-family: var(--font-body, "Microsoft YaHei", sans-serif) !important;
  font-size: 9px !important;
  font-weight: 800 !important;
  line-height: 11px !important;
  letter-spacing: .04em !important;
  text-align: center !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .95) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  pointer-events: none;
}
.global-hud-resources .resource-item.energy-shortage .res-plate small { color: #ff6b74 !important; }

.global-hud-resources .resource-item strong {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: 41px !important;
  display: block !important;
  height: 23px !important;
  padding: 0 !important;
  color: #f4feff !important;
  font-family: var(--font-data, "Bahnschrift Condensed", sans-serif) !important;
  font-size: 20px !important;
  font-weight: 900 !important;
  line-height: 23px !important;
  -webkit-text-stroke: .6px currentColor;
  letter-spacing: -.02em !important;
  text-align: center !important;
  transform: translateX(-4px);
  font-variant-numeric: tabular-nums !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .92) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.global-hud-resources .resource-item[data-resource="solar"] strong,
.global-hud-resources .resource-item[data-resource="gem"] strong {
  top: 41px !important;
  height: 23px !important;
  font-size: 19px !important;
  font-weight: 500 !important;
  line-height: 23px !important;
  letter-spacing: .01em !important;
  -webkit-text-stroke: 0 !important;
}
.global-hud-resources .resource-item.resource-over-cap strong { color: #ff4f57 !important; }
.global-hud-resources .resource-item.energy-shortage strong { color: #ff6b74 !important; }

/* 上限报警感叹号：贴着卡片右上角 */
.global-hud-resources .resource-alert {
  position: absolute !important;
  right: 0 !important;
  top: 0 !important;
  z-index: 3 !important;
  display: grid !important;
  width: 11px !important;
  height: 11px !important;
  place-items: center !important;
  border-radius: 50% !important;
  background: #ff2f3d !important;
  color: #fff !important;
  font: 900 8px/1 Arial, sans-serif !important;
  box-shadow: 0 0 6px rgba(255, 47, 61, .8) !important;
}
.global-hud-resources .resource-alert[hidden] { display: none !important; }

/* 宝石卡片素材自带金色 +，这层只做点击热区 */
.global-hud-resources .gem-recharge-plus {
  position: absolute !important;
  left: 47% !important;
  top: 30px !important;
  z-index: 3 !important;
  display: grid !important;
  width: 18px !important;
  height: 18px !important;
  place-items: center !important;
  transform: translate(-50%, -50%) !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: transparent !important;
  font-size: 0 !important;
  box-shadow: none !important;
  pointer-events: auto;
  transition: box-shadow .15s ease, background .15s ease;
}
.global-hud-resources .gem-recharge-plus:hover,
.global-hud-resources .gem-recharge-plus:focus-visible {
  background: radial-gradient(circle, rgba(255, 205, 90, .32), transparent 68%) !important;
  box-shadow: 0 0 10px rgba(255, 198, 74, .55) !important;
}

/* 设置键：同一水平带、垂直居中；默认灰、展开/悬停亮 */
.global-hud-resources .add-resource {
  align-self: start !important;
  width: 36px !important;
  height: 30px !important;
  margin: 4px 0 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: url("../../../assets/topbar/menu.webp") center / contain no-repeat !important;
  box-shadow: none !important;
  opacity: .9;
  filter: none;
  transition: filter .16s ease;
}
.global-hud-resources .add-resource .settings-slashes { display: none !important; }
.global-hud-resources .add-resource::before,
.global-hud-resources .add-resource::after { display: none !important; content: none !important; }
.global-hud-resources .add-resource:hover,
.global-hud-resources .add-resource:focus-visible,
.global-hud-resources .add-resource[aria-expanded="true"],
.global-hud-resources .add-resource.is-active {
  background-image: url("../../../assets/topbar/menu-active.webp") !important;
  filter: drop-shadow(0 0 6px rgba(90, 240, 255, .55));
}

/* ---------- 舰队活动条 ---------- */
/* styles.css 里这两处用的是 3 类名 + !important，这里补到同等或更高优先级。 */
body .fleet-tabs .fleet-activity-side .fleet-expand-chevron,
body .fleet-activity-side .fleet-expand-chevron,
body .fleet-expand-chevron {
  display: block !important;
  width: 20px !important;
  height: 13px !important;
  margin-left: 5px !important;
  border: 0 !important;
  background: url("../../../assets/topbar/fleet-down.webp") center / contain no-repeat !important;
  transform: none !important;
  opacity: .95 !important;
  transition: transform .18s ease;
}
body .fleet-tabs .fleet-activity-side[aria-expanded="true"] .fleet-expand-chevron,
body .fleet-activity-side[aria-expanded="true"] .fleet-expand-chevron {
  transform: rotate(180deg) !important;
}

/* 警报图标画在 ::before 上（原实现就是如此），这里只换图、去掉 45° 旋转 */
body .fleet-tabs .fleet-warning-side .fleet-warning,
body .fleet-tabs .fleet-warning {
  color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}
body .fleet-tabs .fleet-warning i,
body .fleet-tabs .fleet-warning-side i {
  display: none !important;
  font-size: 0 !important;
}
body .fleet-tabs .fleet-warning-side::before,
body .fleet-tabs .fleet-warning::before {
  width: 26px !important;
  height: 26px !important;
  border: 0 !important;
  background: url("../../../assets/topbar/notice-grey.webp") center / contain no-repeat !important;
  box-shadow: none !important;
  transform: translate(-50%, -50%) !important;
  animation: none !important;
  opacity: 1 !important;
  content: "" !important;
}
body .fleet-tabs .fleet-warning-side.is-alert::before,
body .fleet-tabs .fleet-warning.is-alert::before {
  background-image: url("../../../assets/topbar/notice-alert.webp") !important;
  animation: fleetWarningBlink .9s steps(2, end) infinite !important;
}

/* 警报列保持原来的高度与分隔线，只把图示换掉 */
body .fleet-tabs > .fleet-warning-side {
  height: 88px !important;
  min-height: 88px !important;
  max-height: 88px !important;
}

/* 2026-11-21 mobile legibility pass: the five columns used to leave ~56px
   for "29,999" at 20px/900 with a .6px stroke, so iOS/Android clipped it to
   "29,...". Wider columns, lighter numerals and per-length sizes keep every
   value readable without ellipsis. */
.global-hud-resources {
  grid-template-columns: 36px repeat(5, minmax(0, 1fr)) 32px !important;
  column-gap: 6px !important;
  padding: var(--hud-safe-top) 4px 0 !important;
}
.global-hud-resources .hud-back-button { width: 36px !important; }
.global-hud-resources .hud-back-button::before { width: 23px !important; height: 26px !important; }
.global-hud-resources .add-resource { width: 32px !important; }

.global-hud-resources .resource-item strong {
  top: 38px !important;
  height: 22px !important;
  padding: 0 2px !important;
  /* Android 没有 Bahnschrift，旧栈会落到 monospace，六位数字就会撑破
     56px 的格子并出现 "29,..." 省略号。优先使用系统窄体，再退到正文字体。 */
  font-family: "Roboto Condensed", "Arial Narrow", "sans-serif-condensed", var(--font-body) !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  line-height: 22px !important;
  letter-spacing: 0 !important;
  -webkit-text-stroke: 0 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .92) !important;
  transform: none !important;
  color: #effcff !important;
}
.global-hud-resources .resource-item[data-resource="solar"] strong,
.global-hud-resources .resource-item[data-resource="gem"] strong {
  top: 38px !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  -webkit-text-stroke: 0 !important;
}
.global-hud-resources .resource-item strong[data-hud-size="long"] {
  font-size: 15px !important;
  letter-spacing: -.01em !important;
}
.global-hud-resources .resource-item strong[data-hud-size="xlong"] {
  font-size: 13px !important;
  letter-spacing: -.015em !important;
}

@media (max-width: 380px) {
  :root {
    --hud-bar-content-height: 54px;
  }
  .global-hud-resources {
    grid-template-columns: 32px repeat(5, minmax(0, 1fr)) 28px !important;
    column-gap: 5px !important;
    height: var(--game-hud-offset) !important;
    min-height: var(--game-hud-offset) !important;
  }
  .global-hud-resources .resource-item { height: 50px !important; }
  .global-hud-resources .resource-item .res-plate { top: -2px !important; height: 40px !important; }
  .global-hud-resources .resource-item .res-plate small { top: 26px !important; height: 11px !important; line-height: 11px !important; font-size: 8px !important; }
  .global-hud-resources .resource-item strong { top: 29px !important; height: 21px !important; line-height: 21px !important; font-size: 16px !important; transform: none !important; }
  .global-hud-resources .resource-item strong[data-hud-size="long"] { font-size: 14px !important; }
  .global-hud-resources .resource-item strong[data-hud-size="xlong"] { font-size: 12px !important; }
  .global-hud-resources .hud-back-button { width: 32px !important; height: 40px !important; margin-top: 1px !important; }
  .global-hud-resources .hud-back-button::before { width: 21px !important; height: 24px !important; }
  .global-hud-resources .add-resource { width: 28px !important; height: 26px !important; margin-top: 4px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .fleet-warning.is-alert { animation: none !important; }
  .fleet-expand-chevron { transition: none !important; }
}

/* ==========================================================================
   2026-11-21 Android scroll performance
   A blurred layer inside the scrolling command page is re-rasterised on every
   scroll frame by the Android WebView compositor (the fleet bar is 362×78 with
   a 6px blur). These fills are already opaque enough, so the blur only cost
   frames. Keep the same tint without backdrop-filter.
   ========================================================================== */
body[data-active-screen="command"] .fleet-tabs {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .07) 0%, rgba(255, 255, 255, .025) 38%, rgba(0, 0, 0, .04) 64%, rgba(0, 0, 0, .16) 100%),
    linear-gradient(180deg, rgba(48, 51, 47, .78) 0%, rgba(42, 45, 41, .76) 58%, rgba(37, 40, 36, .76) 100%) !important;
}
.command-screen .hex-action,
.command-screen .production-message,
.command-screen .dispatch-message,
.command-screen .defense-message,
.ucraft-chat-toggle {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
.command-screen .planet-showcase::before {
  /* The radial gradient is already soft; blur+screen blending made the whole
     showcase a live filter layer while the page scrolled. */
  filter: none !important;
  mix-blend-mode: normal !important;
  opacity: .42 !important;
}
.command-screen {
  -webkit-overflow-scrolling: touch;
}
