/* WE 王國｜GM 紙娃娃登入與展示修正版 */
.kingdom-gm-dialog {
  width: min(1280px, calc(100vw - 32px));
  max-width: 1280px;
  height: auto;
  max-height: calc(100dvh - 32px);
  border-radius: 14px;
}

.kingdom-gm-shell {
  max-height: calc(100dvh - 32px);
  padding: 18px 20px 14px;
  overflow-x: hidden;
  overflow-y: auto;
}

.kingdom-gm-head {
  position: sticky;
  top: -18px;
  z-index: 30;
  margin: -18px -20px 0;
  padding: 14px 20px 12px;
  background: linear-gradient(180deg, rgba(5, 6, 10, .99), rgba(7, 7, 12, .96));
  backdrop-filter: blur(12px);
}

.kingdom-gm-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(410px, .95fr);
  gap: 18px;
  align-items: start;
}

.kingdom-gm-left-panel,
.kingdom-gm-equipment-panel {
  border-radius: 10px;
  overflow: hidden;
}

.kingdom-gm-stage {
  min-height: 540px;
  border-radius: 8px;
}

.kingdom-gm-character-stage {
  isolation: isolate;
}

.kingdom-gm-body-art {
  left: 55%;
  width: min(68%, 470px);
  height: 88%;
  bottom: 18px;
}

.kingdom-gm-dialog[data-gm-auth="pending"] [data-gm-save],
.kingdom-gm-dialog[data-gm-auth="pending"] [data-gm-loadout] {
  opacity: .5;
  cursor: wait;
}

.kingdom-gm-persist-status {
  min-height: 34px;
  border-radius: 7px;
  line-height: 1.5;
  font-size: 12px;
}

.kingdom-gm-flat-showcase[hidden] {
  display: none !important;
}

.kingdom-gm-flat-showcase {
  position: absolute;
  z-index: 8;
  top: 112px;
  right: 14px;
  width: min(176px, 29%);
  padding: 9px;
  border: 1px solid rgba(229, 195, 106, .48);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(10, 7, 17, .94), rgba(6, 7, 12, .9));
  box-shadow: 0 12px 30px rgba(0, 0, 0, .42), inset 0 0 20px rgba(125, 52, 178, .08);
  backdrop-filter: blur(8px);
}

.kingdom-gm-flat-showcase-title span,
.kingdom-gm-flat-showcase-title small {
  display: block;
}

.kingdom-gm-flat-showcase-title span {
  color: #f3d77d;
  font: 800 13px/1.2 Georgia, 'Noto Serif TC', serif;
  letter-spacing: .08em;
}

.kingdom-gm-flat-showcase-title small {
  margin-top: 4px;
  color: rgba(232, 220, 195, .62);
  font-size: 9px;
  line-height: 1.35;
}

.kingdom-gm-flat-showcase-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.kingdom-gm-flat-showcase-items figure {
  min-width: 0;
  margin: 0;
  padding: 5px;
  border: 1px solid rgba(214, 176, 80, .25);
  border-radius: 7px;
  background: radial-gradient(circle, rgba(96, 38, 139, .3), rgba(8, 8, 13, .92) 72%);
}

.kingdom-gm-flat-showcase-items figure:nth-child(4) {
  grid-column: span 2;
}

.kingdom-gm-flat-showcase-items img {
  display: block;
  width: 100%;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(167, 82, 223, .25));
}

.kingdom-gm-flat-showcase-items figcaption {
  margin-top: 3px;
  overflow: hidden;
  color: #d8c28a;
  font-size: 8px;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kingdom-gm-stage.uses-flat-equipment-preview .kingdom-gm-body-art {
  left: 50%;
  width: min(63%, 430px);
}

.kingdom-gm-stage.uses-flat-equipment-preview .kingdom-gm-stage-caption {
  max-width: 54%;
}

.kingdom-gm-equipment-panel {
  position: sticky;
  top: 74px;
}

.kingdom-gm-slot {
  grid-template-columns: 132px minmax(0, 1fr) 106px;
}

.kingdom-gm-slot-copy {
  min-width: 0;
}

.kingdom-gm-slot-copy small {
  display: block;
  margin-top: 3px;
  color: rgba(230, 218, 191, .45);
  font-size: 9px;
}

.kingdom-gm-weapon-card {
  min-height: 180px;
  grid-template-columns: 150px minmax(0, 1fr);
  padding-right: 76px;
}

.kingdom-gm-weapon-art {
  height: 150px;
}

.kingdom-gm-weapon-art img {
  width: 132px;
  height: 142px;
}

@media (max-width: 1100px) {
  .kingdom-gm-dialog {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
  }

  .kingdom-gm-shell {
    max-height: calc(100dvh - 18px);
    padding: 14px;
  }

  .kingdom-gm-head {
    top: -14px;
    margin: -14px -14px 0;
    padding: 12px 14px 10px;
  }

  .kingdom-gm-grid {
    grid-template-columns: 1fr;
  }

  .kingdom-gm-equipment-panel {
    position: static;
  }

  .kingdom-gm-stage {
    min-height: 500px;
  }

  .kingdom-gm-body-art,
  .kingdom-gm-stage.uses-flat-equipment-preview .kingdom-gm-body-art {
    left: 54%;
    width: min(72%, 420px);
    height: 82%;
  }
}

@media (max-width: 680px) {
  .kingdom-gm-dialog {
    width: calc(100vw - 4px);
    max-width: none;
    max-height: calc(100dvh - 4px);
    border-radius: 9px;
  }

  .kingdom-gm-shell {
    max-height: calc(100dvh - 4px);
    padding: 8px 7px 12px;
  }

  .kingdom-gm-shell::before {
    inset: 3px;
  }

  .kingdom-gm-head {
    top: -8px;
    min-height: 54px;
    margin: -8px -7px 0;
    padding: 8px 8px 7px;
    gap: 8px;
  }

  .kingdom-gm-head-title {
    gap: 7px;
    min-width: 0;
    white-space: normal;
  }

  .kingdom-gm-head-title span {
    font-size: 14px;
    line-height: 1.1;
  }

  .kingdom-gm-head-title i {
    height: 20px;
  }

  .kingdom-gm-head-title strong {
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: .04em;
  }

  .kingdom-gm-head-tools {
    flex: 0 0 auto;
    gap: 6px;
  }

  .kingdom-gm-head-tools > img {
    width: 34px;
    height: 34px;
    margin: 0;
  }

  .kingdom-gm-head-tools > span,
  .kingdom-gm-help {
    display: none;
  }

  .kingdom-gm-close {
    width: 38px;
    height: 38px;
    font-size: 26px;
  }

  .kingdom-gm-grid {
    gap: 10px;
    padding-top: 10px;
  }

  .kingdom-gm-left-panel {
    padding: 10px 9px 9px;
  }

  .kingdom-gm-section-title {
    font-size: 15px;
  }

  .kingdom-gm-tabs,
  .kingdom-gm-loadout-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
  }

  .kingdom-gm-tab {
    min-width: 0;
    min-height: 40px;
    padding: 6px 4px;
    font-size: 12px;
    letter-spacing: .02em;
  }

  .kingdom-gm-loadout-options button {
    min-width: 0;
    min-height: 46px;
    padding-inline: 4px;
    font-size: 11px;
  }

  /* 手機版把「上傳頭像」與角色舞台拆成上下兩塊，避免覆蓋角色。 */
  .kingdom-gm-stage {
    display: block;
    min-height: 0;
    overflow: visible;
    border-radius: 8px;
    background: rgba(5, 6, 10, .9);
  }

  .kingdom-gm-avatar-column {
    position: relative;
    z-index: 12;
    width: auto;
    margin: 0;
    padding: 9px 10px;
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 10px;
    align-items: center;
    border: 0;
    border-bottom: 1px solid rgba(225, 188, 86, .3);
    background: linear-gradient(90deg, rgba(24, 11, 33, .96), rgba(7, 8, 13, .94));
    text-align: left;
    box-shadow: none;
  }

  .kingdom-gm-portrait-ring {
    grid-row: 1 / 3;
    width: 62px;
    height: 62px;
    margin: 0;
  }

  .kingdom-gm-portrait-ring > button {
    width: 24px;
    height: 24px;
    font-size: 17px;
  }

  .kingdom-gm-avatar-button {
    grid-column: 2;
    width: min(180px, 100%);
    padding: 7px 10px;
    font-size: 12px;
  }

  .kingdom-gm-avatar-column p {
    grid-column: 2;
    margin: 4px 0 0;
    font-size: 9px;
    line-height: 1.35;
  }

  .kingdom-gm-avatar-column p br {
    display: none;
  }

  .kingdom-gm-character-stage {
    position: relative;
    inset: auto;
    min-height: 390px;
    overflow: hidden;
    border-radius: 0 0 8px 8px;
    background-position: center 58%;
  }

  .kingdom-gm-body-art,
  .kingdom-gm-stage.uses-flat-equipment-preview .kingdom-gm-body-art {
    left: 50%;
    width: min(70%, 285px);
    height: 72%;
    bottom: 70px;
    object-fit: contain;
    object-position: center bottom;
  }

  .kingdom-gm-layer-effect {
    width: min(82%, 330px) !important;
    height: 34% !important;
    bottom: 48px !important;
    opacity: .58 !important;
  }

  .kingdom-gm-layer-back {
    top: 19% !important;
    width: min(70%, 300px) !important;
    height: 48% !important;
  }

  .kingdom-gm-layer-body {
    top: 22% !important;
    width: min(44%, 185px) !important;
    height: 40% !important;
  }

  .kingdom-gm-layer-head {
    top: 12% !important;
    width: min(19%, 82px) !important;
    height: 14% !important;
  }

  .kingdom-gm-layer-weapon {
    bottom: 54px !important;
    width: min(48%, 205px) !important;
    height: 48% !important;
  }

  .kingdom-gm-stage-crest {
    width: 48px;
    height: 48px;
    top: 9px;
    right: 8px;
  }

  .kingdom-gm-stage-caption,
  .kingdom-gm-stage.uses-flat-equipment-preview .kingdom-gm-stage-caption {
    left: 9px;
    right: 9px;
    bottom: 8px;
    min-width: 0;
    max-width: none;
    padding: 7px 9px;
    background: linear-gradient(90deg, rgba(24, 8, 33, .94), rgba(11, 8, 17, .86));
    backdrop-filter: blur(5px);
  }

  .kingdom-gm-stage-caption span {
    font-size: 9px;
  }

  .kingdom-gm-stage-caption strong {
    font-size: 16px;
    line-height: 1.15;
  }

  .kingdom-gm-title-art {
    max-width: min(190px, 68%) !important;
    max-height: 34px !important;
    margin-top: 4px;
  }

  /* 秩序／守護的非對位素材改成舞台下緣縮圖列，不再壓住角色。 */
  .kingdom-gm-flat-showcase {
    top: auto;
    right: 7px;
    bottom: 63px;
    left: 7px;
    width: auto;
    padding: 5px 6px;
    background: rgba(8, 7, 13, .9);
  }

  .kingdom-gm-flat-showcase-title span {
    font-size: 10px;
  }

  .kingdom-gm-flat-showcase-title small {
    display: none;
  }

  .kingdom-gm-flat-showcase-items {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    margin-top: 4px;
  }

  .kingdom-gm-flat-showcase-items figure {
    padding: 2px;
  }

  .kingdom-gm-flat-showcase-items figure:nth-child(4) {
    grid-column: auto;
  }

  .kingdom-gm-flat-showcase-items img {
    height: 29px;
  }

  .kingdom-gm-flat-showcase-items figcaption {
    display: none;
  }

  .kingdom-gm-stage-actions {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 7px;
  }

  .kingdom-gm-main-action {
    width: 100%;
    min-height: 43px;
    padding: 7px 8px;
    font-size: 13px;
  }

  .kingdom-gm-equipment-panel {
    padding-inline: 7px;
  }

  .kingdom-gm-slot {
    grid-template-columns: 72px minmax(0, 1fr) 58px;
    min-height: 48px;
  }

  .kingdom-gm-slot-label {
    padding: 0 5px;
    font-size: 10px;
  }

  .kingdom-gm-slot-value {
    padding: 4px 5px;
  }

  .kingdom-gm-slot-copy strong {
    font-size: 10px;
  }

  .kingdom-gm-slot-copy small {
    display: none;
  }

  .kingdom-gm-slot-thumb {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
  }

  .kingdom-gm-slot-action {
    min-width: 52px;
    padding-inline: 3px;
    font-size: 8px;
  }

  .kingdom-gm-weapon-card {
    grid-template-columns: 76px minmax(0, 1fr);
    min-height: 124px;
    padding: 8px 38px 8px 7px;
  }

  .kingdom-gm-weapon-art {
    height: 102px;
  }

  .kingdom-gm-weapon-art img {
    width: 72px;
    height: 96px;
  }

  .kingdom-gm-weapon-copy h4 {
    font-size: 15px;
  }

  .kingdom-gm-footer-note {
    padding-inline: 5px;
    font-size: 9px;
    line-height: 1.45;
  }
}

@media (max-width: 390px) {
  .kingdom-gm-head-title span,
  .kingdom-gm-head-title i {
    display: none;
  }

  .kingdom-gm-head-title strong {
    font-size: 17px;
  }

  .kingdom-gm-head-tools > img {
    width: 30px;
    height: 30px;
  }

  .kingdom-gm-close {
    width: 35px;
    height: 35px;
  }

  .kingdom-gm-tab {
    font-size: 11px;
  }

  .kingdom-gm-character-stage {
    min-height: 355px;
  }

  .kingdom-gm-body-art,
  .kingdom-gm-stage.uses-flat-equipment-preview .kingdom-gm-body-art {
    width: min(72%, 255px);
    height: 70%;
    bottom: 66px;
  }
}
