/* [codex] 2026-10-24 收整小螢幕操作列，頭像與血條完整放進選取按鈕。 */
/* [codex] 2026-10-23 最終驗收修正：裝置像素、英雄狀態與難度曲線。 */
/* [codex] 2026-10-23 M5 主線出征鈕固定於直式導覽上方，地圖以原尺寸顯示。 */
/* [codex] 2026-10-23 直式戰場保留整數兩倍寬度與手機觸控空間。 */
/* [codex] 2026-10-23 建立獨立守城平台並替換顯示題材。 */
/* [claude code] 2026-10-18 主城部位格顯示強化等級與品階(v0.4.2) */
@font-face {
  font-family: system-display;
  src: local("Bahnschrift");
}
* {
  box-sizing: border-box;
}
html {
  background: #151918;
  color-scheme: dark;
}
body {
  margin: 0;
  color: #eeeade;
  font:
    14px/1.5 system-ui,
    "Microsoft JhengHei",
    sans-serif;
  background: #181c1b;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
button:focus-visible {
  outline: 2px solid #f6b36a;
  outline-offset: 4px;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  border: 0;
}
a {
  color: inherit;
}
svg.ico {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon-library {
  width: 0;
  height: 0;
  position: absolute;
}
p,
h1,
h2,
h3 {
  margin: 0;
}
small,
.eyebrow,
.mono {
  font-family: system-display, "Courier New", monospace;
  letter-spacing: 1.5px;
}
.muted {
  color: #8e9690;
}
.eyebrow {
  font-size: 10px;
  color: #9ca69d;
  text-transform: uppercase;
}
.boot {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.brand-mark {
  font-size: 32px;
  background: #d65e43;
  color: #f4eee2;
  width: 44px;
  height: 44px;
  display: grid;
  place-content: center;
  transform: skew(-7deg);
}
.shell {
  max-width: 1500px;
  margin: auto;
  padding: 0 40px;
}
.topbar {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #353b36;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}
.brand strong {
  font-family: system-display, sans-serif;
  font-size: 18px;
  letter-spacing: 3px;
  line-height: 1.15;
  display: block;
}
.brand span {
  font-size: 9px;
  letter-spacing: 4px;
  color: #8e9690;
}
.resource-bar {
  display: flex;
  gap: 27px;
}
.resource {
  display: flex;
  align-items: center;
  gap: 10px;
}
.resource .ico {
  width: 16px;
  height: 16px;
  color: #a5b39b;
}
.resource b {
  font:
    17px system-display,
    monospace;
}
.resource small {
  display: block;
  font-size: 9px;
  color: #899087;
  letter-spacing: 1px;
}
.top-actions {
  display: flex;
  gap: 16px;
  align-items: center;
}
.online {
  font-size: 10px;
  letter-spacing: 1px;
  color: #b0bba4;
}
.online:before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  background: #a6b58a;
  margin-right: 8px;
  border-radius: 50%;
}
.icon-button {
  background: none;
  border: 1px solid #3c443b;
  width: 34px;
  height: 34px;
  color: #b3b9ac;
}
.page-intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 36px 0 25px;
}
.page-intro h1 {
  font:
    italic 48px/0.95 system-display,
    Impact,
    sans-serif;
  letter-spacing: 1px;
  margin-top: 12px;
}
.page-intro h1 span {
  color: #b1b9a1;
}
.page-intro > p {
  font-size: 11px;
  color: #8e9690;
  max-width: 225px;
  text-align: right;
}
.workspace {
  display: grid;
  grid-template-columns: 230px minmax(290px, 1fr) 280px;
  gap: 32px;
  min-height: 500px;
}
.section-label {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #3a4239;
  padding: 0 0 14px;
  font-size: 10px;
  letter-spacing: 2px;
  color: #aeb7a6;
}
.section-label span {
  color: #5d685b;
}
.mission-thumb {
  height: 128px;
  position: relative;
  overflow: hidden;
  margin: 20px 0;
  background: #3c483b;
  background-image:
    linear-gradient(
      31deg,
      transparent 42%,
      #b7ae8960 42%,
      #b7ae8960 46%,
      transparent 46%
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 21px,
      #91a47718 22px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 21px,
      #91a47718 22px
    );
}
.mission-thumb:before,
.mission-thumb:after {
  content: "";
  position: absolute;
  border: 1px solid #91a47780;
  border-radius: 50%;
  width: 90px;
  height: 90px;
  top: 16px;
  left: 30px;
}
.mission-thumb:after {
  width: 30px;
  height: 30px;
  top: 46px;
  left: 60px;
}
.mission-thumb i {
  position: absolute;
  right: 15px;
  bottom: 12px;
  font: 24px system-display;
  color: #dcd8bf;
}
.mission-brief h2 {
  font-size: 23px;
  margin: 12px 0;
}
.mission-brief p {
  color: #9ca395;
  font-size: 12px;
  line-height: 1.9;
}
.mission-brief .reward-inline {
  display: flex;
  gap: 15px;
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px solid #353d33;
  color: #c7c5a5;
  font: 12px system-display;
}
.text-button {
  background: none;
  color: #bdc3b2;
  padding: 17px 0;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 15px;
}
.text-button .ico {
  width: 16px;
}
.castle-view {
  background: #202620;
  position: relative;
  overflow: hidden;
  min-height: 420px;
  border: 1px solid #394133;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 39px,
      #9aaf8210 40px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 39px,
      #9aaf8210 40px
    );
}
.castle-corner {
  position: absolute;
  top: 18px;
  left: 20px;
  font: 10px system-display;
  color: #8d9b83;
  letter-spacing: 2px;
}
.castle-corner.right {
  left: auto;
  right: 20px;
  text-align: right;
}
.castle-corner em {
  font-style: normal;
  display: block;
  font-size: 8px;
  letter-spacing: 1px;
  margin-top: 5px;
  color: #56654c;
}
.castle-grid {
  position: absolute;
  width: 310px;
  height: 310px;
  border: 1px solid #5b684430;
  border-radius: 50%;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.castle-grid:before {
  content: "";
  position: absolute;
  inset: 27px;
  border: 1px dashed #717d4550;
  border-radius: 50%;
}
.castle-grid:after {
  content: "";
  position: absolute;
  left: 50%;
  top: -28px;
  height: 360px;
  width: 1px;
  background: #81965830;
}
.lord-hero {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 90%;
  max-width: 360px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(6px 20px 8px #0009);
  z-index: 1;
}
.castle-bottom {
  position: absolute;
  bottom: 18px;
  left: 20px;
  right: 20px;
  border-top: 1px solid #56614d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
}
.castle-bottom strong {
  font: 20px system-display;
  letter-spacing: 2px;
}
.castle-bottom p {
  font-size: 10px;
  color: #9ca58f;
}
.status-pill {
  font: 9px system-display;
  letter-spacing: 1px;
  border: 1px solid #7d8a5f;
  padding: 4px 8px;
  color: #b6c390;
}
.gear-list {
  margin-top: 8px;
}
.gear-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 0;
  background: none;
  border-bottom: 1px solid #353d33;
  text-align: left;
}
.gear-row .slot-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #252c24;
  color: #c5ceac;
  border: 1px solid #404936;
}
.gear-row .gear-title {
  flex: 1;
}
.gear-row b {
  display: block;
  font-size: 12px;
  font-weight: 500;
}
.gear-row small {
  font-size: 8px;
  color: #899780;
  letter-spacing: 1px;
}
.gear-row .level {
  font: 17px system-display;
  color: #d2d2ba;
}
.gear-row .chevron {
  font-size: 20px;
  color: #737f65;
}
.gear-row:hover .slot-icon {
  border-color: #c5ceac;
}
.stats-bar {
  margin-top: 25px;
  border-top: 1px solid #3b4337;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding-top: 18px;
}
.stat small {
  font-size: 8px;
  color: #87917f;
  letter-spacing: 1px;
}
.stat b {
  display: block;
  font: 22px system-display;
}
.stat em {
  font-style: normal;
  color: #768369;
  font-size: 10px;
  margin-left: 3px;
}
.launch-row {
  display: grid;
  grid-template-columns: 230px 1fr 280px;
  gap: 32px;
  margin-top: 24px;
  align-items: center;
}
.launch-meta {
  color: #86917b;
  font-size: 10px;
  letter-spacing: 1px;
}
.launch-meta b {
  color: #bdc6ac;
  font-weight: 400;
  display: block;
  font-size: 12px;
  letter-spacing: 0;
}
.launch-button {
  background: #d65e43;
  color: #fff3de;
  padding: 18px 24px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 17px;
  letter-spacing: 3px;
  box-shadow: 0 4px 0 #973f2e;
}
.launch-button small {
  font-size: 9px;
  letter-spacing: 2px;
  display: block;
  margin-top: 3px;
  font-weight: 400;
  opacity: 0.7;
}
.launch-button:hover {
  background: #e76b4e;
}
.launch-tip {
  font-size: 10px;
  color: #909984;
  display: flex;
  gap: 12px;
  align-items: center;
}
.launch-tip .ico {
  color: #bdc6ac;
}
.navigation {
  display: flex;
  justify-content: center;
  gap: 55px;
  border-top: 1px solid #353d33;
  margin-top: 36px;
  padding: 20px 0 22px;
}
.nav-item {
  background: none;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #829079;
  font-size: 12px;
  position: relative;
}
.nav-item.active {
  color: #eeeade;
}
.nav-item.active:before {
  content: "";
  position: absolute;
  top: -21px;
  left: 0;
  right: 0;
  background: #d65e43;
  height: 2px;
}
.nav-item .ico {
  width: 18px;
  height: 18px;
}
.footer {
  display: flex;
  justify-content: space-between;
  color: #66715f;
  font: 9px system-display;
  letter-spacing: 1px;
  padding-bottom: 20px;
}
.panel {
  min-height: 520px;
}
.panel-heading {
  margin-bottom: 24px;
  display: flex;
  align-items: end;
  justify-content: space-between;
}
.panel-heading h2 {
  font-size: 25px;
}
.panel-heading p {
  color: #8d9883;
  font-size: 12px;
}
.stage-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
}
.stage-card {
  background: #242b23;
  border: 1px solid #3f4838;
  padding: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  position: relative;
}
.stage-card .stage-number {
  font: 52px system-display;
  color: #717e62;
}
.stage-card h3 {
  font-size: 17px;
  margin: 16px 0 5px;
}
.stage-card p {
  font-size: 10px;
  color: #96a086;
  flex: 1;
}
.stage-card .stars {
  color: #d7b778;
  font-size: 16px;
  letter-spacing: 5px;
  margin-top: 25px;
}
.stage-card.selected {
  border-color: #d65e43;
}
.stage-card.selected:before {
  content: "準備出擊";
  position: absolute;
  right: 12px;
  top: 12px;
  color: #e27a61;
  font-size: 9px;
}
.stage-card.locked {
  opacity: 0.5;
}
.chapter-next {
  margin-top: 22px;
  padding: 20px;
  border-top: 1px solid #37402f;
  font-size: 12px;
  color: #7f8b72;
  display: flex;
  justify-content: space-between;
}
.tech-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
.tech-column > h3 {
  font-size: 13px;
  color: #a5b392;
  padding-bottom: 14px;
  border-bottom: 1px solid #424f36;
}
.tech-card {
  border: 1px solid #3e4935;
  padding: 18px;
  margin-top: 15px;
  background: #22291f;
  display: flex;
  align-items: center;
  gap: 15px;
  text-align: left;
  width: 100%;
}
.tech-card > div {
  flex: 1;
}
.tech-card h3 {
  font-size: 14px;
}
.tech-card p {
  font-size: 11px;
  color: #91a080;
  margin-top: 4px;
}
.tech-card small {
  font-size: 8px;
  color: #717e62;
}
.tech-card .level {
  color: #cbd7b9;
  font: 20px system-display;
}
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.inventory-resource {
  border: 1px solid #404a36;
  padding: 30px;
  background: #22291f;
}
.inventory-resource b {
  display: block;
  font: 40px system-display;
  margin: 20px 0 8px;
}
.inventory-resource h3 {
  font-size: 13px;
}
.inventory-resource p {
  font-size: 11px;
  color: #859574;
  margin-top: 8px;
}
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0;
  border-bottom: 1px solid #39432f;
  gap: 20px;
}
.task-row h3 {
  font-size: 17px;
}
.task-row p {
  font-size: 12px;
  color: #8d9c7c;
  margin-top: 5px;
}
.small-button {
  padding: 10px 18px;
  background: #465038;
  font-size: 12px;
  color: #e4e9d9;
  white-space: nowrap;
}
.notice {
  padding: 17px 20px;
  border-left: 2px solid #c16c4e;
  background: #292c23;
  color: #a9b49a;
  font-size: 12px;
  margin: 24px 0;
  line-height: 1.8;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #090d0bbd;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  width: 440px;
  max-width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #526145 #252c23;
  background: #252c23;
  border: 1px solid #596347;
  padding: 30px;
  box-shadow: 0 25px 80px #0009;
}
.modal-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 25px;
}
.modal-title h2 {
  font-size: 23px;
  margin: 7px 0;
}
.modal-close {
  font-size: 24px;
  color: #9aa98b;
  background: none;
  padding: 0 0 10px 20px;
}
.modal-icon {
  width: 65px;
  height: 65px;
  border: 1px solid #71835d;
  display: grid;
  place-items: center;
  color: #d0dabd;
  margin: 0 auto 20px;
}
.modal-icon .ico {
  width: 34px;
  height: 34px;
}
.upgrade-value {
  display: flex;
  justify-content: space-around;
  text-align: center;
  align-items: center;
  padding: 15px 0;
  border-top: 1px solid #445038;
  border-bottom: 1px solid #445038;
}
.upgrade-value b {
  font: 37px system-display;
  display: block;
}
.upgrade-value span {
  font-size: 11px;
  color: #a0ad90;
}
.upgrade-value .new {
  color: #d1dca7;
}
.costs {
  display: flex;
  justify-content: space-between;
  padding: 20px 0;
  font-size: 12px;
  color: #9aa98a;
}
.modal .launch-button {
  width: 100%;
  justify-content: center;
  gap: 14px;
  font-size: 15px;
  padding: 15px;
}
.branch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.branch-button {
  min-width: 0;
  background: #303a28;
  border: 1px solid #506040;
  text-align: left;
  padding: 12px;
  font-size: 11px;
}
.branch-button strong {
  display: block;
  color: #d4dec4;
  margin-bottom: 5px;
}
.branch-button span {
  color: #8f9e7d;
}
.modal p.help {
  font-size: 11px;
  color: #8f9c7e;
  line-height: 1.8;
  margin-top: 17px;
}
.error-text {
  color: #e4967e;
  font-size: 12px;
  margin-top: 14px;
  min-height: 18px;
}
.result-stars {
  font-size: 40px;
  letter-spacing: 14px;
  text-align: center;
  color: #d4b97c;
  margin: 15px 0;
}
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.result-grid > div {
  border: 1px solid #48543c;
  padding: 14px;
  text-align: center;
}
.result-grid b {
  font: 25px system-display;
  display: block;
}
.result-grid small {
  font-size: 10px;
  color: #9caa8c;
}
#toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #e4e7d3;
  color: #242c20;
  font-size: 12px;
  padding: 12px 20px;
  max-width: 90%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
#toast.show {
  opacity: 1;
}
#battle {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #0b100e;
  display: flex;
  align-items: center;
  justify-content: center;
}
#battle[hidden],
#battle-overlay[hidden] {
  display: none;
}
.battle-frame {
  position: relative;
  aspect-ratio: 9/16;
  height: 100dvh;
  max-width: 100vw;
  max-height: 177.777vw;
  background: #283d2b;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
#battle-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#pause-button {
  position: absolute;
  right: 3.8%;
  top: 1.2%;
  width: 8%;
  height: 4.5%;
  background: #14271dc9;
  border: 1px solid #889a6b;
  font-size: 18px;
  color: #e2e7d3;
}
#virtual-stick {
  position: absolute;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border-radius: 50%;
  border: 2px solid rgba(122, 243, 255, 0.35);
  background: rgba(53, 230, 255, 0.06);
  pointer-events: none;
}
#virtual-stick[hidden] {
  display: none;
}
#virtual-stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: rgba(53, 230, 255, 0.35);
  border: 2px solid rgba(122, 243, 255, 0.8);
}
#skill-button {
  position: absolute;
  right: max(4.5%, env(safe-area-inset-right));
  bottom: max(3%, env(safe-area-inset-bottom));
  width: 20%;
  aspect-ratio: 1;
  min-width: 44px;
  border: 1px solid #e59665;
  border-radius: 50%;
  background: #bd5538e6;
  color: #eceddb;
  font-size: 35px;
  touch-action: none;
}
#skill-button span {
  display: block;
  line-height: 0.9;
}
#skill-button small {
  display: block;
  font-size: 8px;
  letter-spacing: 1px;
  margin-top: 5px;
}
#skill-button.unavailable {
  background: #30372c;
  border-color: #677357;
  color: #88947b;
}
#battle-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #101a14c9;
  padding: 25px;
  z-index: 2;
}
#battle-overlay > div {
  text-align: center;
  width: 100%;
}
#battle-overlay h2 {
  font-size: 26px;
  margin: 15px 0;
}
#battle-overlay p {
  font-size: 12px;
  color: #abb69c;
  margin-bottom: 24px;
}
#battle-overlay button {
  display: block;
  width: 100%;
  padding: 15px;
  background: #d65e43;
  margin-top: 12px;
}
#battle-overlay button.secondary {
  background: #37452d;
}
.connection-error {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 30px;
}
.connection-error h1 {
  font-size: 28px;
  margin: 15px 0;
}
.connection-error p {
  color: #91a27f;
  margin-bottom: 20px;
}
/* All screens share the portrait layout, including desktop previews. */
:root {
  --portrait-width: 480px;
  --nav-height: 76px;
}
html {
  scrollbar-gutter: stable;
}
body {
  min-height: 100svh;
  -webkit-text-size-adjust: 100%;
}
button {
  min-height: 44px;
  touch-action: manipulation;
}
.shell {
  width: 100%;
  max-width: var(--portrait-width);
  min-height: 100svh;
  padding: env(safe-area-inset-top) max(18px, env(safe-area-inset-right))
    calc(var(--nav-height) + env(safe-area-inset-bottom) + 20px)
    max(18px, env(safe-area-inset-left));
  background: #181c1b;
  border-inline: 1px solid #353b3655;
}
.shell main,
.workspace > *,
.resource,
.gear-title,
.tech-card > div,
.panel-heading > *,
.task-row > *,
.stat,
.inventory-resource {
  min-width: 0;
}
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  height: auto;
  gap: 14px;
  padding: 16px 0;
}
.brand {
  gap: 10px;
}
.brand-mark {
  width: 36px;
  height: 38px;
  font-size: 28px;
}
.brand strong {
  font-size: 16px;
  letter-spacing: 3px;
}
.brand span {
  font-size: 9px;
  letter-spacing: 3px;
}
.top-actions {
  grid-column: 2;
  grid-row: 1;
  gap: 10px;
}
.online {
  font-size: 8px;
  letter-spacing: 0.5px;
}
.icon-button {
  width: 44px;
  height: 44px;
  font-size: 20px;
}
.resource-bar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.resource {
  gap: 7px;
}
.resource > div {
  min-width: 0;
}
.resource b {
  font-size: 17px;
  overflow-wrap: anywhere;
}
.resource small {
  font-size: 8px;
  letter-spacing: 0.6px;
}
.resource .ico {
  width: 15px;
  height: 15px;
}
.page-intro {
  padding: 24px 0 20px;
  display: block;
}
.page-intro h1 {
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.05;
  margin-top: 8px;
  overflow-wrap: anywhere;
}
.page-intro > p {
  max-width: none;
  text-align: left;
  margin-top: 10px;
  font-size: 11px;
}
.eyebrow {
  font-size: 9px;
}
.workspace {
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  min-height: 0;
}
.mission-brief {
  display: none;
}
.castle-view {
  height: clamp(250px, 38svh, 340px);
  min-height: 0;
}
.lord-hero {
  width: 280px;
  max-width: 80%;
  top: 44%;
}
.castle-grid {
  width: 260px;
  height: 260px;
  top: 44%;
}
.castle-grid:after {
  height: 300px;
}
.castle-bottom {
  bottom: 12px;
  padding-top: 9px;
  gap: 8px;
}
.castle-bottom strong {
  font-size: 19px;
}
.castle-bottom p {
  font-size: 10px;
}
.castle-corner {
  top: 12px;
  left: 14px;
  font-size: 9px;
}
.castle-corner.right {
  right: 14px;
}
.stats-bar {
  margin-top: 14px;
  padding-top: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.stat b {
  font-size: 23px;
}
.stat small {
  font-size: 9px;
  letter-spacing: 0.3px;
  overflow-wrap: anywhere;
}
.equipment .section-label {
  padding-bottom: 10px;
}
.gear-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
  margin-top: 0;
}
.gear-row {
  padding: 14px 0;
  min-height: 72px;
  gap: 8px;
}
.gear-row .slot-icon {
  width: 30px;
  height: 34px;
  flex: none;
}
.slot-icon .ico {
  width: 19px;
  height: 19px;
}
.gear-row b {
  font-size: 12px;
}
.gear-row small {
  display: block;
  font-size: 8px;
  letter-spacing: 0.3px;
  overflow-wrap: anywhere;
}
.gear-row .level {
  font-size: 17px;
}
.gear-row .chevron {
  display: none;
}
.launch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 22px;
}
.launch-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 9px;
}
.launch-meta b {
  font-size: 13px;
  text-align: right;
}
.launch-button {
  width: 100%;
  padding: 16px 20px;
  font-size: 17px;
  min-height: 60px;
}
.launch-tip {
  font-size: 11px;
  gap: 10px;
}
.launch-tip br {
  display: none;
}
.launch-tip .ico {
  width: 18px;
}
.navigation {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, var(--portrait-width));
  bottom: 0;
  z-index: 20;
  background: #181c1bf5;
  backdrop-filter: blur(10px);
  gap: 0;
  justify-content: space-around;
  margin: 0;
  padding: 8px max(8px, env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.nav-item {
  flex: 1;
  min-width: 0;
  min-height: 58px;
  font-size: 11px;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
  padding: 5px;
}
.nav-item.active:before {
  top: -9px;
  left: 10px;
  right: 10px;
}
.nav-item .ico {
  width: 21px;
  height: 21px;
}
.footer {
  margin-top: 24px;
  font-size: 8px;
  letter-spacing: 0.4px;
  padding-bottom: 0;
  gap: 10px;
  flex-wrap: wrap;
}
.panel {
  min-height: 0;
}
.panel-heading {
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 20px;
}
.panel-heading h2 {
  font-size: 22px;
}
.panel-heading p {
  font-size: 11px;
}
.stage-list {
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.stage-card {
  min-height: 108px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 56px;
  gap: 4px 12px;
  padding: 16px 12px;
  align-items: center;
}
.stage-card .stage-number {
  font-size: 32px;
  grid-column: 1;
  grid-row: 1 / 3;
}
.stage-card h3 {
  margin: 0;
  font-size: 15px;
  grid-column: 2;
  grid-row: 1;
}
.stage-card p {
  font-size: 11px;
  grid-column: 2;
  grid-row: 2;
  overflow-wrap: anywhere;
}
.stage-card .stars {
  margin: 0;
  font-size: 14px;
  letter-spacing: 1px;
  grid-column: 3;
  grid-row: 1 / 3;
}
.stage-card.selected:before {
  right: 12px;
  top: auto;
  bottom: 6px;
  font-size: 8px;
}
.chapter-next {
  font-size: 11px;
  padding: 16px 0;
  gap: 10px;
  flex-wrap: wrap;
}
.tech-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}
.tech-column > h3 {
  font-size: 13px;
}
.tech-card {
  padding: 16px;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: nowrap;
}
.tech-card .ico {
  width: 22px;
  height: 22px;
}
.tech-card h3 {
  font-size: 15px;
}
.tech-card p {
  font-size: 12px;
}
.tech-card .level {
  font-size: 21px;
  flex: none;
}
.tech-card small {
  font-size: 10px;
  letter-spacing: 0.2px;
}
.inventory-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.inventory-resource {
  padding: 18px 14px;
  overflow-wrap: anywhere;
}
.inventory-resource b {
  font-size: 30px;
}
.inventory-resource small {
  font-size: 9px;
  letter-spacing: 0.4px;
}
.inventory-resource p {
  font-size: 12px;
}
.task-row {
  gap: 12px;
  padding: 20px 0;
}
.task-row h3 {
  font-size: 15px;
}
.task-row p {
  font-size: 12px;
}
.task-row > .muted {
  font-size: 10px;
  flex: none;
}
.small-button {
  padding: 10px 12px;
  flex: none;
}
.notice {
  font-size: 12px;
  padding: 15px;
  margin: 20px 0;
}
body.modal-open {
  overflow: hidden;
}
.modal-backdrop {
  padding: max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}
.modal {
  width: 456px;
  --modal-pad: 22px;
  padding: var(--modal-pad);
  max-height: calc(
    100dvh - max(12px, env(safe-area-inset-top)) -
      max(12px, env(safe-area-inset-bottom))
  );
  overscroll-behavior: contain;
}
.modal-close {
  width: 44px;
  height: 44px;
  padding: 0;
  flex: none;
}
.modal-title {
  position: sticky;
  top: calc(-1 * var(--modal-pad));
  z-index: 1;
  background: #252c23;
  margin: calc(-1 * var(--modal-pad)) calc(-1 * var(--modal-pad)) 22px;
  padding: 14px var(--modal-pad) 10px;
  border-bottom: 1px solid #445038;
  gap: 10px;
}
.modal-title > div {
  min-width: 0;
}
.modal-title h2 {
  font-size: 23px;
  overflow-wrap: anywhere;
}
.modal .eyebrow {
  overflow-wrap: anywhere;
}
.modal p.help {
  font-size: 13px;
}
.costs {
  flex-wrap: wrap;
  gap: 8px;
}
.branch-row {
  grid-template-columns: minmax(0, 1fr);
}
.branch-button {
  font-size: 12px;
  min-height: 76px;
}
#toast {
  width: max-content;
  max-width: min(90%, 430px);
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 12px);
}
#battle {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.battle-frame {
  width: min(
    100%,
    var(--portrait-width),
    calc(
      (100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 9 / 16
    )
  );
  height: auto;
  max-height: none;
  max-width: 100%;
  flex: none;
}
#pause-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  top: 0;
  right: 0;
  background: #14271d77;
  font-size: 20px;
}
#battle-overlay {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
}
#battle-overlay > div {
  margin-block: auto;
}
#battle-overlay p {
  font-size: 13px;
}
#skill-button small {
  font-size: 10px;
  letter-spacing: 0;
}
@media (max-width: 350px) {
  .shell {
    padding-inline: max(12px, env(safe-area-inset-left))
      max(12px, env(safe-area-inset-right));
  }
  .online {
    display: none;
  }
  .gear-list {
    gap: 0 10px;
  }
  .gear-row .slot-icon {
    display: none;
  }
  .gear-row b {
    font-size: 13px;
  }
  .stat small {
    font-size: 8px;
  }
  .modal {
    --modal-pad: 18px;
  }
}
#orientation-hint {
  display: none;
}
@media (orientation: landscape) and (pointer: coarse) {
  #orientation-hint {
    display: grid;
    position: fixed;
    inset: 0;
    z-index: 90;
    place-items: center;
    overflow-y: auto;
    padding: 24px;
    background: #101a14f5;
    text-align: center;
  }
  #orientation-hint span {
    font-size: 48px;
    color: #e28c67;
  }
  #orientation-hint h2 {
    margin: 8px 0 12px;
    font-size: 22px;
  }
  #orientation-hint p {
    color: #a9b49a;
    font-size: 13px;
    line-height: 1.8;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* [codex] 2026-10-23 手機直式主城及底部導覽。 */
html,body{margin:0;min-height:100%;background:#14101e;color:#f4f4f4;font-family:system-ui,sans-serif;overscroll-behavior:none}*{box-sizing:border-box}body{max-width:480px;margin:auto}button,a,input,select{font:inherit}button,a.btn{min-height:44px;touch-action:manipulation}button{cursor:pointer}img{image-rendering:pixelated;object-fit:contain}.art{width:32px;height:32px}.topbar{position:sticky;top:0;z-index:5;background:#242236;border-bottom:2px solid #4a4f64;padding:8px}.topbar>div{display:flex;justify-content:space-between;align-items:center;gap:4px}.topbar span{display:flex;align-items:center}.topbar .art{width:16px;height:16px}.topbar button{font-size:12px;padding:4px}.page{padding:12px 12px 90px;min-height:calc(100dvh - 110px);overflow-x:hidden}.bottom-nav{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:min(100%,480px);display:grid;grid-template-columns:repeat(5,1fr);z-index:10;background:#2b2a3d;padding-bottom:env(safe-area-inset-bottom)}.bottom-nav button{height:58px;border:0;background:transparent;color:#b5bccb;font-weight:700}.bottom-nav button[aria-pressed=true]{color:#ffd94a;background:#3b3243}.castle-scene{text-align:center;position:relative;background:#13294b;border:3px solid #4a4f64;padding:10px;border-radius:12px;min-height:210px}.castle-art{width:144px;height:144px}.lord-art{position:absolute;width:64px;height:64px;left:calc(50% - 32px);top:108px}.castle-scene h1{font-size:23px;margin:0}.castle-scene p{margin:6px}.castle-stars{position:absolute;right:15px;top:12px;color:#ffd94a}.lord-slots{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin:10px 0}.slot{display:flex;flex-direction:column;align-items:center;gap:3px;background:#2b2a3d;border:2px solid #7a8093;border-radius:7px;color:inherit;padding:6px}.slot small{font-size:10px}.row3{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-bottom:8px}.coming{text-align:center;padding:24px 8px}.coming>img{width:96px;height:96px}.growth-tabs{display:flex;gap:5px}.growth-tabs button{flex:1;background:#2b2a3d;color:inherit;border:1px solid #7a8093}.modal{max-height:calc(100dvh - 32px);overflow-y:auto;max-width:456px}form{display:grid;gap:8px;margin-top:16px}form label{display:grid;gap:3px}input{min-height:44px;width:100%;color:#14101e}.system-icon{width:20px;height:20px}h1,h2,h3{overflow-wrap:anywhere}.btn.wide{width:100%}

/* [codex] 2026-10-23 直式小螢幕主按鈕與明確可按樣式。 */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;padding:9px 12px;background:#2b2a3d;border:2px solid #7a8093;border-radius:7px;color:#f4f4f4;text-decoration:none;font-weight:600}.btn.primary{background:#2f6b3a;border-color:#8ad05a;color:#f4f4f4}.topbar{height:auto;min-height:64px;display:block}.topbar button{background:#2b2a3d;border-radius:5px}.castle-scene{min-height:202px}.castle-art{width:120px;height:120px}.castle-scene h1{font-size:20px}.lord-art{top:86px}.lord-slots .art{width:24px;height:24px}.slot{min-height:75px}.castle.page{padding-bottom:75px}.row3 button{font-size:12px}.bottom-nav{height:58px}.bottom-nav button{padding:4px;font-size:14px}.coming{padding-top:16px}.coming .btn{margin-top:12px}

.castle-art{width:96px;height:96px}.lord-slots .art{width:32px;height:32px}.slot{padding:4px;gap:1px;min-height:75px}.slot b{font-size:12px;line-height:16px}.slot small{font-size:10px;line-height:12px}.castle-scene{min-height:180px}.lord-art{top:64px}
.castle-scene{min-height:160px}.castle-scene p{margin:2px}.castle.page{padding-top:8px}.castle .row3{margin-bottom:4px}

/* [codex] 2026-10-23 全直式一屏戰場，上下操作列固定，中間取最大整數倍。 */
[hidden]{display:none!important}.in-battle{overflow:hidden}.td-screen{position:fixed;inset:0 auto 0 50%;transform:translateX(-50%);width:min(100%,480px);height:100dvh;z-index:50;display:flex;flex-direction:column;background:#14101e;color:#f4f4f4;overflow:hidden}.td-top{display:flex;align-items:center;justify-content:space-between;gap:4px;flex:none;padding:4px 6px;border-bottom:2px solid #7a8093;background:#2b2a3d}.td-top b{font-size:12px;white-space:nowrap}.td-top .btn{padding:4px 8px;min-width:44px}.td-field{position:relative;display:flex;align-items:center;justify-content:center;flex:1;min-height:0;overflow:hidden;background:#1f3d2b;border-left:1px solid #3b2416;border-right:1px solid #3b2416}.td-field canvas{flex:none;touch-action:none;image-rendering:pixelated}.td-map-title{position:absolute;top:3px;left:5px;font-size:11px;background:#14101e;padding:2px 5px;pointer-events:none}.td-bottom{flex:none;padding:5px;background:#2b2a3d;border-top:2px solid #7a8093}.td-heroes{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;margin-bottom:4px}.td-hero{display:flex;gap:2px;min-width:0}.td-hero .btn{min-width:0;padding:3px;flex:1;display:flex;flex-direction:column;font-size:11px;line-height:13px;min-height:52px}.td-hero .btn[data-hero-skill]{flex:none;min-width:44px}.td-hero small{font-size:9px;letter-spacing:0;white-space:nowrap}.td-controls{display:grid;grid-template-columns:1fr 1.5fr 1fr;gap:4px}.td-controls .btn{font-size:12px;padding:4px}.td-hint{font-size:10px;text-align:center;line-height:14px;margin-top:4px}.td-menu{position:absolute;z-index:3;width:180px;min-height:180px;background:#2b2a3d;border:2px solid #ffd94a;border-radius:16px;box-shadow:0 4px 0 #14101e}.td-menu .btn{min-height:44px;font-size:11px;padding:3px}.radial{height:180px;background:#14101e}.radial button{position:absolute;width:56px;height:48px;display:flex;flex-direction:column;gap:0}.radial button:nth-child(1){top:2px;left:60px}.radial button:nth-child(2){top:64px;right:2px}.radial button:nth-child(3){bottom:2px;left:60px}.radial button:nth-child(4){top:64px;left:2px}.radial button.center{left:60px;top:64px;width:56px}.tower-actions{display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:7px}.tower-actions>b{grid-column:1/-1;text-align:center}.td-pause{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:12px;background:#14101eee;z-index:6}.td-pause h2{font-size:22px}.td-result-stars{font-size:36px;color:#ffd94a;text-align:center}.td-brief{padding:12px;display:grid;gap:14px;background:#2b2a3d;border:2px solid #7a8093;border-radius:12px}.td-brief h1{text-align:center}.brief-map{text-align:center}.brief-map .art{width:96px;height:96px}.td-hero .selected{border-color:#ffd94a}

/* [codex] 2026-10-23 M2 手機直式法術列、選關與觸控區。 */
.td-spells{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;margin-top:4px}.td-spells .btn{font-size:11px;padding:4px;min-height:44px}.td-controls [data-next]{display:flex;flex-direction:column;justify-content:center}.td-controls [data-next] small{font-size:9px;line-height:11px;white-space:normal}.td-chapter{padding:8px 0}.td-chapter h1{font-size:20px;margin:8px 0}.td-stage-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-bottom:12px}.td-stage-list .btn{display:flex;flex-direction:column;font-size:14px;min-height:60px}.td-stage-list small{font-size:10px}.td-stage-list .selected{border-color:#ffd94a}.td-trial{display:flex;gap:8px;align-items:center;min-height:44px;font-size:12px}.td-trial input{width:20px;height:20px}.tower-actions .btn small{display:block;font-size:9px;white-space:normal}.tower-actions>b{font-size:12px}.tower-actions>small{grid-column:1/-1}

/* [codex] 2026-10-23 M3 手機直式英雄、招募、隊伍與教學。 */
.hero-banner{background:#13294b;padding:12px;border:2px solid #3a92d8;border-radius:10px}.hero-banner h1{margin:0;font-size:22px}.hero-filters{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:10px 0}.hero-filters label,.team-slots label{display:grid;gap:4px;font-size:13px}.hero-filters select,.team-slots select{min-height:44px;width:100%;min-width:0;background:#2b2a3d;color:#f4f4f4;border:1px solid #7a8093;border-radius:5px}.hero-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.hero-card{background:#2b2a3d;color:#f4f4f4;border:2px solid #7a8093;border-radius:9px;display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 4px;min-width:0}.hero-card img,.recruit-result img{width:64px;height:64px}.hero-card strong{font-size:13px}.hero-card span,.hero-card small{font-size:11px}.rarity-SSR{border-color:#ffd94a;color:#ffd94a}.rarity-SR{border-color:#c06bd8}.hero-detail{text-align:center}.hero-detail>img{width:128px;height:128px}.hero-stats{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:10px;background:#2b2a3d}.hero-ability{text-align:left;border-block:1px solid #7a8093;padding:8px;margin:10px 0}.hero-ability h3{font-size:15px;margin:5px 0;color:#ffd94a}.hero-ability p{font-size:13px;line-height:1.7;color:#f4f4f4}.hero-detail .btn{margin-bottom:8px;flex-wrap:wrap}.hero-detail .chip{font-size:11px}.team-slots{display:grid;gap:10px;margin:12px 0}.team-slots span{min-height:44px;display:flex;align-items:center;color:#b5bccb}.recruit-tabs{display:flex;gap:5px;margin-bottom:10px}.recruit-tabs button{flex:1;padding:8px 3px;font-size:12px}.recruit-tabs [aria-pressed=true]{border-color:#ffd94a}.recruit-stage{text-align:center;background:#13294b;border:2px solid #7d3c98;padding:12px;border-radius:12px;margin-bottom:12px}.recruit-stage>img{width:128px;height:128px}.recruit-stage h1{font-size:22px;margin:4px}.recruit-stage p{font-size:12px;line-height:1.6}.recruit-stage progress{width:100%;accent-color:#ffd94a}.recruit-stage .row2{display:flex}.recruit-stage .row2>.btn{flex:1;flex-direction:column;font-size:14px}.recruit-stage .chip{font-size:11px}.recruit-portal{text-align:center;min-height:330px;display:flex;flex-direction:column;align-items:center;justify-content:center}.recruit-portal img{width:192px;height:192px}.recruit-portal.rarity-SSR{background:#3b2416}.recruit-portal.rarity-SR{background:#4a1f4f}.recruit-results{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;margin:10px 0}.recruit-result{min-height:148px;display:flex;flex-direction:column;align-items:center;gap:4px;border:2px solid #7a8093;background:#2b2a3d;padding:7px}.recruit-result strong{font-size:12px;text-align:center}.recruit-result small{font-size:10px;color:#f4f4f4}.recruit-covered{min-height:148px;font-size:35px;color:#ffd94a}.recruit-log article{display:flex;gap:10px;padding:8px;border-bottom:1px solid #4a4f64}.recruit-log img{width:32px;height:32px}.recruit-log small{display:block;font-size:10px}.blueprint{font-size:12px;max-height:120px;overflow:auto;padding-left:24px}.td-tutorial{position:absolute;z-index:2;top:23px;left:4px;right:4px;padding:6px;background:#13294b;border:2px solid #ffd94a;font-size:12px;pointer-events:none;text-align:center}.odds-page{max-width:480px}.odds-page table{width:100%;table-layout:fixed;border-collapse:collapse;font-size:11px}.odds-page td,.odds-page th{padding:7px 2px;border:1px solid #7a8093;overflow-wrap:anywhere}.odds-page p{font-size:13px;line-height:1.8}

/* [codex] 2026-10-23 M4 塔工坊與科技的直式卡片。 */
.tower-workshop,.tech-trees{display:grid;gap:12px;margin-top:12px}.tower-workshop-card,.tech-tree{background:#2b2a3d;border:2px solid #7a8093;border-radius:10px;padding:10px}.tower-workshop-heading{display:flex;gap:10px;align-items:center}.tower-workshop-heading>img{width:64px;height:96px}.tower-workshop-heading h2{margin:4px 0;font-size:20px}.tower-workshop-heading p{margin:4px 0}.tower-mods{display:grid;grid-template-columns:1fr 1fr;gap:7px;margin:10px 0}.tower-mods section{border:1px solid #4a4f64;border-radius:7px;padding:7px;min-width:0}.tower-mods h3{font-size:14px;color:#ffd94a;min-height:34px}.tower-mods p,.tower-mods small{font-size:11px;line-height:1.6}.tower-mods .btn,.tower-workshop-card>.btn{display:flex;flex-wrap:wrap;font-size:12px}.tower-mods .chip{font-size:10px}.tech-overview h1,.workshop-overview h1{font-size:22px}.tech-overview p,.workshop-overview p{font-size:13px;line-height:1.7}.tech-tree h2{font-size:18px;color:#ffd94a;margin-top:0}.tech-node{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center;border-top:1px solid #4a4f64;padding:8px 0}.tech-node small{display:block;font-size:11px;line-height:1.7;color:#b5bccb}.tech-mastery{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between}.tech-node .btn{min-width:60px;font-size:12px}.tower-workshop-card button:disabled,.tech-node button:disabled{opacity:.45}

/* [codex] 2026-10-23 可操作的養成提示紅點。 */
.growth-dot{display:inline-block;flex:none;width:7px;height:7px;background:#e5593c;border:1px solid #ffd8b8;margin-left:5px;vertical-align:middle}.growth-tabs button{position:relative;min-height:44px}

/* M5 六章地圖與直式固定出征鈕。 */
.m5-difficulty,.m5-chapters{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.m5-chapters img{width:16px;height:16px;image-rendering:pixelated;display:block;margin:auto}.m5-map{position:relative;display:grid;grid-template-columns:repeat(12,1fr);width:192px;aspect-ratio:12/17;margin:12px auto;image-rendering:pixelated}.m5-map i{background-size:100% 100%;aspect-ratio:1}.m5-spot{position:absolute;width:16.666%;height:11.764%;border:1px solid #ffd94a;background:#352d4180}.m5-castle{position:absolute;width:48px;transform:translate(-50%,-85%);image-rendering:pixelated}.m5-launch{position:sticky;bottom:-12px;padding:8px 0;background:#171522;z-index:3}.m5-reward{padding:8px;border:1px solid #51465f;margin:8px 0}.m5-reward .chips{flex-wrap:wrap}.campaign details summary{min-height:44px;padding:12px;cursor:pointer}select{min-height:44px;max-width:100%}

/* M5 首領資訊不遮住觸控。 */
.td-boss{position:absolute;top:26px;left:4px;right:4px;padding:3px;background:#171522dc;color:#ffd94a;font-size:11px;text-align:center;pointer-events:none;z-index:2}
.m5-launch{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(58px + env(safe-area-inset-bottom));width:min(calc(100% - 24px),456px);padding:6px 0;z-index:4}.page.campaign{padding-bottom:150px}

/* [codex] 2026-10-23 M6 直式模式與排行榜。 */
.m6-tabs{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px}.m6-tabs .btn{font-size:12px;padding:5px}.m6-dungeons{display:grid;grid-template-columns:1fr 1fr;gap:5px}.m6-panel{padding:12px;border:2px solid #7a8093;border-radius:10px;background:#2b2a3d;margin:10px 0}.m6-panel h2{font-size:21px}.m6-panel label{display:grid;gap:4px}.m6-panel select{width:100%}.m6-panel .chips{flex-wrap:wrap}.m6-tools{display:flex;gap:8px}.m6-launch{display:flex;gap:6px}.m6-launch .btn{flex:1}.page.modes{padding-bottom:150px}.m6-boss{height:112px;display:flex;align-items:center;justify-content:center}.m6-boss i{display:block;background-repeat:no-repeat;image-rendering:pixelated;transform:scale(2)}.m6-board article{display:grid;grid-template-columns:32px 1fr;gap:4px;padding:10px 4px;border-bottom:1px solid #51465f}.m6-board article strong{grid-column:2;font-size:12px}.m6-board .mine{background:#3b3243;color:#ffd94a}.m6-board~.chips{flex-wrap:wrap}

/* [codex] 2026-10-23 M7 手機商城與像素造型。 */
.shop-modal{padding-bottom:20px}.shop-wallet{display:flex;gap:12px;margin:10px 0}.shop-tabs{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px;position:sticky;top:-16px;background:#252936;padding:8px 0;z-index:2}.shop-tabs button{min-height:42px;padding:5px}.shop-tabs button[aria-pressed=true]{background:#446338;color:#fff}.shop-list{display:grid;gap:12px;margin-top:12px}.shop-card{border:2px solid #666c80;padding:12px;background:#252936}.shop-card h3{margin:0 0 8px}.shop-card small{display:block;margin-top:6px}.shop-card .btn{margin-top:8px}.skin-card{display:grid;grid-template-columns:64px minmax(0,1fr);gap:12px;align-items:center}.skin-card>img{width:64px;height:64px;object-fit:contain;image-rendering:pixelated}.shop-modal .chips{flex-wrap:wrap}.shop-card .chip{font-size:13px}.shop-modal .btn{max-width:100%}

.chest-odds p{overflow-wrap:anywhere}.chest-odds article{border-top:2px solid #4a4f64;padding:8px 0}.odds-page .page{max-width:480px;margin:auto}

/* [codex] 2026-10-23 M8 整數像素框與可讀的手機介面。 */
.page.modes{display:block;grid-template-columns:none}.m6-tabs,.m6-panel,.m6-tools{width:100%;min-width:0}.m6-tabs .btn{padding:4px 2px}.m6-dungeons .btn{min-width:0}.m6-panel p{line-height:1.6}
html{background:#14101e}body{background:#14101e}.page.castle{background-image:var(--pixel-ground);background-repeat:repeat}.castle-scene,.hero-banner,.recruit-stage,.m6-panel,.shop-card,.hero-card,.tower-workshop-card,.tech-tree{border:8px solid transparent;border-image:var(--pixel-panel) 8 fill stretch;border-radius:0;background:#2b2a3d}.btn{border:6px solid transparent;border-image:var(--pixel-button) 6 fill stretch;border-radius:0;image-rendering:pixelated}.btn.primary{border-image-source:var(--pixel-primary)}.modal{border:8px solid transparent;border-image:var(--pixel-panel) 8 fill stretch;border-radius:0;background:#2b2a3d;image-rendering:pixelated}.system-icon{width:16px;height:16px;flex:none;object-fit:contain;image-rendering:pixelated}.bottom-nav button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}.bottom-nav .system-icon{width:32px;height:32px}.bottom-nav span{font-size:11px;line-height:14px}.lord-animation{image-rendering:pixelated}.settings-options{display:grid;gap:14px;margin-top:18px}.settings-options label{display:flex;gap:10px;align-items:center}.settings-options input{width:24px;height:24px;min-height:24px}.settings-options select{max-width:190px;min-height:44px}.td-screen .btn{padding:3px}.shop-tabs{background:#2b2a3d}.shop-tabs button{background:#2b2a3d;border:2px solid #7a8093;color:#f4f4f4}.shop-tabs button[aria-pressed=true]{background:#2f6b3a}.hero-card{min-width:0}.modal .chips{flex-wrap:wrap}

/* [codex] 2026-10-23 M8 圖示使用原生十六點的一倍或兩倍，取消舊裝飾對圖片盒子的縮放。 */
img.art{width:32px!important;height:32px!important;flex-shrink:0}img.art.res{width:16px!important;height:16px!important;min-width:16px}img.art,img.system-icon{padding:0!important;border:0!important;border-radius:0!important;object-fit:contain}.page.castle>[data-tab="campaign"]{position:fixed;bottom:calc(58px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:min(calc(100% - 24px),456px);z-index:4}.page.castle{padding-bottom:130px}
/* [codex] 2026-10-23 M8 容器尺寸變動當下即選整數倍率，不等待 rAF 或 resize 派發。 */
.td-field{container-type:size}
.td-hero [data-hero]{position:relative;gap:2px;height:52px;overflow:hidden}.td-hero-portrait{position:relative;display:block;width:32px;height:32px;flex:none}.td-hero-portrait img{display:block;width:32px;height:32px;image-rendering:pixelated}.td-hero.dead img{filter:grayscale(1);opacity:.5}.td-hero-revive{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#fff;background:#14101e66;font-size:14px;font-weight:bold}.td-hero-health{display:block;flex:none;width:100%;height:6px;border:1px solid #14101e;background:#6c2c2c}.td-hero-health i{display:block;height:100%;background:#8ad05a}.td-hero [data-hero] small{display:none}
/* [codex] 2026-10-23 M8 像素圖不套模糊，資源圖示的 flex 尺寸也保持原生。 */
img{filter:none!important}.modal-backdrop{backdrop-filter:none}img.art.res{flex-basis:16px!important}

.td-hint{margin:0;line-height:12px}.td-controls [data-next]{height:44px;overflow:hidden;gap:0}.td-controls [data-next] small{display:block;max-height:22px;overflow:hidden}
.td-controls .btn{height:44px;min-height:44px;font-size:11px;line-height:12px;overflow:hidden}
@media(max-height:700px){.td-top{padding:0 6px;height:44px;min-height:44px;border-bottom:0}.td-top .btn{height:44px}.td-bottom{padding:1px;position:relative}.td-heroes{margin-bottom:2px}.td-hero .btn{height:44px;min-height:44px;padding:2px;gap:0}.td-hero [data-hero]{height:44px}.td-hero-health{height:4px}.td-spells{margin-top:2px}.td-hint{position:absolute;bottom:100%;left:0;right:0;background:#14101eaa;pointer-events:none}}

/* [codex] 2026-10-24 陣亡頭像覆蓋既有的全圖濾鏡重置。 */
.td-hero.dead img{filter:grayscale(1)!important}.td-hero [data-hero]{border-width:2px;border-image-width:2px}

/* [codex] 2026-10-24 位置與倍率均由繪圖層依裝置像素對齊。 */
.td-field canvas{position:absolute}
