.pf-dialog {
  width: min(700px, calc(100vw - 26px));
  max-height: min(88svh, 800px);
  color: #f1e7d2;
  background: #1b211e;
  border: 1px solid #a48755;
  padding: 0;
  overflow: auto;
  scrollbar-color: #786a4e #212621;
}
/* The title bar (and its ×) stays pinned while the window scrolls, so a long
   page can be closed from wherever the player has scrolled to. */
.pf-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #1b211e;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 23px 15px;
  border-bottom: 1px solid #806c474f;
}
.pf-head h2 {
  margin: 0;
  font: 700 27px var(--serif, serif);
  letter-spacing: 0.08em;
  color: #f2e0b8;
}
.pf-head p,
.pf-help {
  font-size: 13px;
  line-height: 1.55;
  color: #c8c4b6;
  margin: 8px 0 0;
}
.pf-close {
  font: 24px/1 sans-serif;
  color: #d5c7a7;
  background: transparent;
  border: 0;
  padding: 0 3px 5px 11px;
}
.pf-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 12px 22px;
  border-bottom: 1px solid #806c473f;
  background: #191d1b;
}
.pf-tab,
.pf-btn {
  color: #e5d8bb;
  background: #2a302a;
  border: 1px solid #88794f8c;
  padding: 6px 11px;
  font-size: 13px;
  line-height: 1.4;
}
.pf-tab {
  color: #d4cbb5;
  background: transparent;
  padding: 5px 9px;
  border-color: transparent;
}
.pf-tab[aria-pressed="true"],
.pf-btn.pf-gold {
  color: #262012;
  background: #cfb17a;
  border-color: #e3c894;
}
.pf-btn:hover:not(:disabled),
.pf-tab:hover {
  border-color: #e8c77e;
}
.pf-btn:disabled {
  cursor: default;
  opacity: 0.45;
}
.pf-danger {
  color: #f0beab;
  border-color: #8b5749;
}
.pf-wide {
  width: 100%;
  margin-top: 16px;
}
.pf-panel {
  padding: 14px 23px 22px;
}
.pf-panel h3 {
  font-size: 15px;
  letter-spacing: 0.06em;
  margin: 15px 0 4px;
  color: #e4c48e;
}
.pf-panel > .pf-btn {
  margin: 8px 8px 0 0;
}
.pf-panel > .pf-skill {
  text-align: left;
  flex-wrap: nowrap;
  min-height: 50px;
  padding: 10px 12px;
}
.pf-skill[aria-pressed="true"] {
  background: #383b2a;
  border: 1px solid #caaa70;
}
.pf-skill > span:last-child:not(.pf-info) {
  flex: none;
  color: #efd38f;
  font-size: 12px;
}
.pf-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #8d794b42;
  padding: 11px 0;
}
.pf-info {
  flex: 1;
  min-width: 0;
}
.pf-info strong {
  display: block;
  font-size: 14px;
  color: #f2e4c8;
  overflow-wrap: anywhere;
}
.pf-info small {
  display: block;
  font-size: 12px;
  line-height: 1.55;
  margin-top: 3px;
  color: #bcbcaf;
}
.pf-icon {
  width: 31px;
  height: 31px;
  object-fit: contain;
  image-rendering: pixelated;
}
.pf-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pf-actions select {
  padding: 4px;
  color: #e5d8bb;
  background: #1b1f1b;
  border: 1px solid #82754f;
  font: inherit;
  font-size: 13px;
}
.pf-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #d5cdbb;
  cursor: pointer;
}
.pf-qty {
  width: 52px;
  padding: 4px;
  color: #e5d8bb;
  background: #1b1f1b;
  border: 1px solid #88794f8c;
  font: inherit;
  font-size: 16px; /* smaller makes iOS zoom the page on focus */
  text-align: center;
}
.pf-notice {
  padding: 8px 22px;
  color: #e9d29f;
  font-size: 13px;
  background: #353425;
}
.pf-panel .pf-notice {
  margin: 12px 0 0;
}
.pf-portrait {
  width: 84px;
  height: 84px;
  image-rendering: pixelated;
}
.pf-pet-portrait {
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  background: radial-gradient(ellipse at 50% 72%, #474936 0%, transparent 75%);
}
.pf-pet-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.pf-pet-portrait .pf-egg-badge {
  position: absolute;
  right: -1px;
  bottom: 0;
  width: 22px;
  height: 16px;
  border-radius: 5px;
  background: #242921;
}
.pf-tree-balance {
  color: #edd49f;
}
.pf-branches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 12px 0;
}
.pf-branch h3 {
  margin: 0 0 8px;
  font: 600 17px var(--serif);
}
.pf-tree-path {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pf-tree-node {
  position: relative;
  padding: 9px 12px;
  border: 1px solid #605b46;
  background: #222824;
}
.pf-tree-node[data-learned="true"] {
  border-color: #a89460;
  background: #2b3026;
}
.pf-tree-node + .pf-tree-node {
  margin-top: 12px;
}
.pf-tree-node + .pf-tree-node::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 27px;
  height: 12px;
  border-left: 1px solid #ae955f;
}
.pf-tree-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pf-tree-title small {
  margin-left: auto;
  white-space: nowrap;
  color: #d9c393;
}
.pf-tree-icon {
  flex: none;
  width: 32px;
  height: 32px;
  background: #171b17 url("assets/sprites/tree-icons.png") no-repeat;
  image-rendering: pixelated;
}
.pf-tree-node p {
  font-size: 12px;
  line-height: 1.5;
  color: #d3d1bf;
  margin: 6px 0;
}
.pf-tree-node p small {
  display: block;
  font-size: inherit;
  color: #c6b487;
}
.pf-skill:disabled {
  opacity: 0.82;
}
.pf-tree-node .pf-btn:disabled {
  opacity: 1;
  background: transparent;
  border-color: transparent;
  color: #b9b6a7;
}
.pf-row > .pf-portrait {
  width: 52px;
  height: 52px;
  background: radial-gradient(ellipse at 50% 72%, #474936 0%, transparent 70%);
}
.pf-create {
  display: grid;
  grid-template-columns: 122px 1fr;
  gap: 18px;
}
.pf-create-head {width:66px;height:66px;image-rendering:pixelated;background:#292822;border:1px solid #6a604a}
.pf-look > .pf-portrait { max-width:100%; width: 122px; height: 136px; object-fit: contain; }
.pf-look {
  min-width:0;grid-template-columns:minmax(0,1fr);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
}
.pf-fields {
  display: grid;
  gap: 8px;
}
.pf-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #d5cdbb;
}
.pf-label > span {
  flex: 0 0 68px;
}
.pf-label input,
.pf-label select {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 1px solid #82754f;
  background: #141b18;
  color: #f2e9d7;
  font: inherit;
  padding: 6px 8px;
}
.pf-statgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 10px 0;
}
.pf-stat {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 5px;
  align-items: center;
  background: #272d26;
  border: 1px solid #806c4740;
  padding: 8px;
  font-size: 13px;
}
.pf-stat b {
  grid-column: 1/2;
}
.pf-stat small {
  grid-column: 2/-1;
  color: #bfb9a9;
  align-self: center;
  text-align: right;
}
.pf-stat strong {
  text-align: center;
}
.pf-stat .pf-btn {
  padding: 2px 5px;
}
@media (max-width: 520px) {
  .pf-branches {
    grid-template-columns: 1fr;
  }
  .pf-panel,
  .pf-head {
    padding-left: 13px;
    padding-right: 13px;
  }
  .pf-tabs {
    gap: 2px;
    padding: 6px 9px;
  }
  .pf-tab {
    padding: 4px 7px;
  }
  .pf-row {
    flex-wrap: wrap;
    gap: 7px;
  }
  .pf-actions {
    max-width: 58%;
  }
  .pf-btn {
    padding: 5px 7px;
  }
  .pf-statgrid {
    grid-template-columns: repeat(2, 1fr);
  }
  .pf-create {
    grid-template-columns: minmax(78px, 30%) minmax(0, 1fr);
    gap: 9px;
  }
}

/* The switch to the other set of tabs sits at the end, set apart. */
.pf-tab-other {
  margin-left: auto;
  color: #cdb777;
  border-style: dashed;
}
/* 技能樹 by magic level (2026-11-14) */
.pf-layer {
  margin: 10px 0;
  border: 1px solid #4d4a3a;
  background: #1d221e;
}
.pf-layer > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 9px 12px;
  cursor: pointer;
  font: 600 16px var(--serif);
  color: #edd49f;
}
.pf-layer > summary small {
  font: 12px var(--sans, sans-serif);
  color: #c6b487;
}
.pf-layer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  padding: 0 10px 10px;
}
.pf-layer-grid .pf-tree-node + .pf-tree-node {
  margin-top: 0;
}
.pf-layer-grid .pf-tree-node + .pf-tree-node::before {
  display: none;
}

/* 批次連衝: target, quick picks and the one button, above the item rows. */
.pf-batch {
  display: grid;
  gap: 7px;
  margin: 0 0 10px;
  padding: 9px 11px;
  background: #20251f;
  border: 1px solid #88794f66;
}
.pf-batch-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.pf-batch-label {
  min-width: 42px;
  color: #cfc4a8;
  font-size: 13px;
}
.pf-btn.pf-chip {
  padding: 4px 9px;
}
.pf-batch-go .pf-btn {
  padding: 7px 14px;
  font-size: 14px;
}
.pf-batch-go small {
  flex: 1 1 220px;
  color: #bdb39b;
  font-size: 12px;
  line-height: 1.5;
}
.pf-pick {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: #c9a85a;
  cursor: pointer;
}
