/* Original AHQ paper-form character sheet (#578). */
@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,500;0,600;0,700;0,800;1,600&family=Big+Shoulders+Display:wght@700;800&display=swap");

.ahq-sheet-wrap {
  display: flex;
  justify-content: center;
  padding: 0 0 1.5rem;
}

.ahq-sheet {
  --ink: #141414;
  --paper: #f4f0e6;
  container-type: inline-size;
  container-name: ahq-sheet;
  position: relative;
  width: min(740px, 100%);
  max-width: 100%;
  min-width: 0;
  background: url("/images/heroes/tattered-paper.png") center / 100% 100% no-repeat;
  color: var(--ink);
  padding: 3.2rem 2.5rem 2.8rem 2.5rem;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 600;
}

.ahq-sheet .ink-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.ahq-sheet .ink-overlay path {
  fill: none;
  stroke: #1a1410;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.ahq-sheet .ink-overlay .ink-frame { stroke-width: 2.2; }
.ahq-sheet .ink-overlay .ink-oval { stroke-width: 2.05; }
.ahq-sheet .ink-overlay .ink-grid { stroke-width: 1.85; }
.ahq-sheet .ink-overlay .ink-btn { stroke-width: 1.5; }

.ahq-sheet .hero-location {
  position: absolute;
  top: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: none;
  text-align: center;
  white-space: normal;
  max-width: 94%;
  line-height: 1.2;
  pointer-events: none;
}

.ahq-sheet .hero-location.alive { color: #1b7a2a; }
.ahq-sheet .hero-location.dead { color: #b71c1c; }
.ahq-sheet .hero-location.ko { color: #9a4a12; }

.ahq-sheet * { box-sizing: border-box; }

.ahq-sheet .top-frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 210px) minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "left    portrait right"
    "name    portrait wounds";
  column-gap: 0.15rem;
  row-gap: 0.05rem;
  padding: 0.22rem 0.85rem 0.28rem;
  position: relative;
  margin-bottom: 0.28rem;
  align-items: stretch;
}

.ahq-sheet .heads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.22rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1;
  width: 100%;
  max-width: 146px;
  margin: 0 0 0.2rem;
  text-align: center;
}

.ahq-sheet .stat-col { grid-area: left; display: flex; flex-direction: column; }
.ahq-sheet .stat-col.right { grid-area: right; align-items: flex-end; }

.ahq-sheet .stat-block { display: block; width: 100%; max-width: 146px; min-width: 0; margin: 0 0 0.18rem; }

.ahq-sheet .stat-label {
  display: block;
  width: 100%;
  max-width: 146px;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.05;
  text-transform: uppercase;
  text-align: center;
  overflow-wrap: break-word;
}

.ahq-sheet .ovals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.22rem;
  width: 100%;
  max-width: 146px;
}

.ahq-sheet .oval {
  width: 100%;
  height: 34px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  font-size: 1.22rem;
  font-weight: 700;
  position: relative;
}

.ahq-sheet .hero-status {
  position: absolute;
  top: -1.35rem;
  left: 10%;
  right: auto;
  z-index: 4;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1;
  pointer-events: none;
  color: #1b7a2a;
}

.ahq-sheet .hero-status.alive { color: #1b7a2a; }
.ahq-sheet .hero-status.dead { color: #b71c1c; }
.ahq-sheet .hero-status.ko { color: #9a4a12; }

.ahq-sheet .oval.has-mods {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.2rem;
  gap: 0.04rem;
}

.ahq-sheet .oval.has-mods .oval-value {
  flex: 0 1 auto;
  min-width: 0.7em;
  text-align: center;
  font-size: 1.15rem;
}

.ahq-sheet .mod-plus,
.ahq-sheet .mod-minus {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 1.15rem;
  padding: 0;
  border: none;
  background: transparent;
  color: #111;
  font-weight: 800;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  z-index: 2;
}

.ahq-sheet .mod-plus:disabled,
.ahq-sheet .mod-minus:disabled { opacity: .35; cursor: not-allowed; }

.ahq-sheet .portrait-wrap {
  grid-area: portrait;
  position: relative;
  width: 210px;
  justify-self: center;
  align-self: center;
  z-index: 3;
}

.ahq-sheet .portrait-btn {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.ahq-sheet .portrait-frame {
  width: 198px;
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  border: 2.5px solid #111;
  border-radius: 50% / 46%;
  overflow: hidden;
  background: #cfc8b8;
}

.ahq-sheet .portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 8%;
  display: block;
}

.ahq-sheet .emblem-btn {
  all: unset;
  position: absolute;
  right: -22px;
  bottom: -2px;
  z-index: 6;
  cursor: pointer;
  filter: drop-shadow(1px 2px 1.5px rgba(0,0,0,.4));
}

.ahq-sheet .emblem-face {
  display: block;
  width: 92px;
  height: 114px;
  background-color: transparent;
  background-image: var(--emblem-url);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  -webkit-mask-image: var(--emblem-url);
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-image: var(--emblem-url);
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.ahq-sheet .identity {
  grid-area: name;
  position: relative;
  min-height: 58px;
  padding: 0.4rem 0.6rem;
  border: none;
  z-index: 2;
  margin-right: -22px;
  width: calc(100% + 40px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.ahq-sheet .identity-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.2;
  white-space: normal;
}

.ahq-sheet #woundsSlot {
  grid-area: wounds;
  justify-self: end;
  align-self: end;
  width: 146px;
}
.ahq-sheet #woundsSlot .stat-block,
.ahq-sheet #woundsSlot .stat-label,
.ahq-sheet #woundsSlot .heads,
.ahq-sheet #woundsSlot .ovals {
  width: 146px;
  max-width: 146px;
}

.ahq-sheet .paper-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ahq-sheet .paper-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.28rem;
  font-size: 0.82rem;
  font-weight: 700;
  background: transparent;
}

.ahq-sheet .paper-table th,
.ahq-sheet .paper-table td {
  border: 2px solid transparent;
  padding: 0.12rem 0.22rem;
  text-align: center;
  vertical-align: middle;
}

.ahq-sheet .paper-table .stub {
  text-align: center;
  font-family: "Big Shoulders Display", "Barlow Condensed", sans-serif;
  font-weight: 800;
  letter-spacing: .01em;
  text-transform: uppercase;
  width: 5.4rem;
  font-size: 1.05rem;
  line-height: 0.92;
}

.ahq-sheet .inv-name { text-align: left !important; font-size: 0.95rem; font-weight: 700; }
.ahq-sheet .total-row td { font-family: "Big Shoulders Display", sans-serif; font-weight: 800; letter-spacing: .04em; font-size: 1.05rem; }

.ahq-sheet .chip-btn {
  border: none;
  border-radius: 0;
  background: transparent;
  color: #111;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 0.08rem 0.2rem;
  cursor: pointer;
  line-height: 1.15;
  font-family: inherit;
}

.ahq-sheet .chip-btn:disabled { opacity: .35; cursor: not-allowed; }

.ahq-sheet .equip-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  align-items: center;
  padding: 0.28rem 0.2rem 0.4rem;
}

.ahq-sheet .equip-item {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  flex-wrap: wrap;
}

.ahq-sheet .extras-table { table-layout: fixed; }
.ahq-sheet .extras-table td { text-align: left; font-weight: 700; }
.ahq-sheet .extras-table .k { display: block; font-size: 0.58rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; }
.ahq-sheet .extras-table .v { font-size: 0.95rem; }
.ahq-sheet .extras-table .money-cell { width: 16.5%; vertical-align: top; }
.ahq-sheet .extras-table .money-cell.narrow { width: 12.4%; }
.ahq-sheet .extras-table .money-cell.hench { width: auto; }

.ahq-sheet .hench-link {
  color: #1a3a7a;
  text-decoration: underline;
  font-weight: 800;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
}

.ahq-sheet .effects-row { margin-top: 0.15rem; }
.ahq-sheet .effects-list { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; }

.ahq-sheet-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.ahq-sheet-picker button {
  border: 2px solid #222;
  background: #d8d0c0;
  padding: 0;
  cursor: pointer;
}

.ahq-sheet-picker img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }

.ahq-scroll-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .58);
}

.ahq-scroll {
  --ink: #141414;
  --roll-top: 19%;
  --roll-bottom: 14%;
  --paper-side: 13%;
  position: relative;
  width: min(820px, 94vw);
  aspect-ratio: 947 / 585;
  height: auto;
  min-height: 0;
  box-sizing: border-box;
  background: url("/images/heroes/parchment-scroll.png") center / 100% 100% no-repeat;
  color: var(--ink);
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 600;
  padding: var(--roll-top) var(--paper-side) var(--roll-bottom);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

.ahq-scroll-copy {
  max-width: 100%;
}

.ahq-scroll h2 {
  margin: 0 0 0.5rem;
  font-family: "Big Shoulders Display", "Barlow Condensed", sans-serif;
  font-weight: 800;
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.1;
}

.ahq-scroll p {
  margin: 0;
  font-size: clamp(0.98rem, 1.7vw, 1.12rem);
  line-height: 1.4;
  font-weight: 700;
}

.ahq-scroll-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 0;
  padding-top: 0;
  padding-right: 0;
}

.ahq-scroll .ahq-scroll-claim {
  min-width: 0;
  padding: 0 !important;
  color: #1a1410 !important;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-transform: none;
}

.ahq-scroll-close {
  position: absolute;
  right: 5.1%;
  bottom: calc(3.2% + 85.8px);
  width: 78px;
  height: 78px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}

.ahq-scroll-close img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* iPad portrait (~768) and any sheet under 740px: keep the paper form, tighten. */
@media (max-width: 768px) {
  .ahq-sheet {
    padding: 2.1rem 1.05rem 2rem;
  }
  .ahq-sheet .top-frame {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 168px) minmax(0, 1fr);
    column-gap: 0.35rem;
    padding: 0.2rem 0.2rem 0.2rem;
  }
  .ahq-sheet .portrait-wrap { width: 168px; }
  .ahq-sheet .portrait-frame { width: 156px; }
  .ahq-sheet .emblem-face { width: 72px; height: 90px; }
  .ahq-sheet .emblem-btn { right: -10px; }
  .ahq-sheet .identity {
    margin-right: 0;
    width: 100%;
    min-width: 0;
  }
  .ahq-sheet .stat-label { font-size: 0.78rem; letter-spacing: .015em; }
  .ahq-sheet .paper-table { font-size: 0.72rem; }
  .ahq-sheet .paper-table th,
  .ahq-sheet .paper-table td { padding: 0.1rem 0.12rem; }
  .ahq-sheet .paper-table .stub { width: 4.6rem; font-size: 0.92rem; }
  .ahq-sheet-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container ahq-sheet (max-width: 739px) {
  .top-frame {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 168px) minmax(0, 1fr);
    column-gap: 0.35rem;
    padding: 0.2rem 0.2rem 0.2rem;
  }
  .portrait-wrap { width: 168px; }
  .portrait-frame { width: 156px; }
  .identity {
    margin-right: 0;
    width: 100%;
    min-width: 0;
  }
  .stat-label { font-size: 0.78rem; letter-spacing: .015em; }
  .paper-table { font-size: 0.72rem; }
}

/* Phone: stack, hide portrait and emblem, keep status. */
@media (max-width: 600px) {
  .ahq-sheet {
    padding: 1.6rem 0.7rem 1.5rem;
  }
  .ahq-sheet .top-frame {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "status status"
      "left right"
      "wounds wounds"
      "name name";
    column-gap: 0.55rem;
    row-gap: 0.45rem;
  }
  .ahq-sheet .portrait-wrap {
    grid-area: status;
    width: auto;
    justify-self: stretch;
  }
  .ahq-sheet .portrait-btn,
  .ahq-sheet .emblem-btn { display: none !important; }
  .ahq-sheet .hero-status {
    position: static;
    display: block;
    text-align: center;
    top: auto;
    left: auto;
    font-size: 1.05rem;
  }
  .ahq-sheet .hero-location {
    position: static;
    transform: none;
    left: auto;
    top: auto;
    max-width: 100%;
    margin: 0 0 0.45rem;
    font-size: 0.8rem;
  }
  .ahq-sheet .stat-col,
  .ahq-sheet .stat-col.right {
    align-items: stretch;
  }
  .ahq-sheet .stat-col .stat-block,
  .ahq-sheet .stat-col .stat-label,
  .ahq-sheet .stat-col .heads,
  .ahq-sheet .stat-col .ovals {
    max-width: none;
    width: 100%;
  }
  .ahq-sheet #woundsSlot { justify-self: center; }
  .ahq-sheet .extras-table { table-layout: auto; }
  .ahq-sheet .extras-table .money-cell,
  .ahq-sheet .extras-table .money-cell.narrow {
    width: auto;
  }
}

@container ahq-sheet (max-width: 600px) {
  .portrait-btn,
  .emblem-btn { display: none !important; }
  .hero-status {
    position: static;
    display: block;
    text-align: center;
  }
  .top-frame {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "status status"
      "left right"
      "wounds wounds"
      "name name";
  }
  .portrait-wrap {
    grid-area: status;
    width: auto;
  }
}

.ahq-sheet[data-layout="phone"] {
  padding: 1.6rem 0.7rem 1.5rem;
}
.ahq-sheet[data-layout="phone"] .top-frame {
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "status status"
    "left right"
    "wounds wounds"
    "name name";
  column-gap: 0.55rem;
  row-gap: 0.45rem;
}
.ahq-sheet[data-layout="phone"] .portrait-wrap {
  grid-area: status;
  width: auto;
  justify-self: stretch;
}
.ahq-sheet[data-layout="phone"] .portrait-btn,
.ahq-sheet[data-layout="phone"] .emblem-btn { display: none !important; }
.ahq-sheet[data-layout="phone"] .hero-status {
  position: static;
  display: block;
  text-align: center;
  top: auto;
  left: auto;
  font-size: 1.05rem;
}
.ahq-sheet[data-layout="phone"] .hero-location {
  position: static;
  transform: none;
  left: auto;
  top: auto;
  max-width: 100%;
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
}
.ahq-sheet[data-layout="phone"] .stat-col,
.ahq-sheet[data-layout="phone"] .stat-col.right { align-items: stretch; }
.ahq-sheet[data-layout="phone"] .stat-col .stat-block,
.ahq-sheet[data-layout="phone"] .stat-col .stat-label,
.ahq-sheet[data-layout="phone"] .stat-col .heads,
.ahq-sheet[data-layout="phone"] .stat-col .ovals {
  max-width: none;
  width: 100%;
}
.ahq-sheet[data-layout="phone"] #woundsSlot {
  justify-self: center;
  width: 100%;
}
.ahq-sheet[data-layout="phone"] #woundsSlot .stat-block {
  width: min(100%, 11.5rem);
  max-width: 11.5rem;
  margin: 0 auto;
}
.ahq-sheet[data-layout="phone"] #woundsSlot .stat-label,
.ahq-sheet[data-layout="phone"] #woundsSlot .heads,
.ahq-sheet[data-layout="phone"] #woundsSlot .ovals {
  width: 100%;
  max-width: none;
}
.ahq-sheet[data-layout="phone"] .extras-table { table-layout: auto; }
.ahq-sheet[data-layout="phone"] .extras-table .money-cell,
.ahq-sheet[data-layout="phone"] .extras-table .money-cell.narrow { width: auto; }

@media (max-width: 600px) {
  .ahq-sheet #woundsSlot {
    justify-self: center;
    width: 100%;
  }
  .ahq-sheet #woundsSlot .stat-block {
    width: min(100%, 11.5rem);
    max-width: 11.5rem;
    margin: 0 auto;
  }
  .ahq-sheet #woundsSlot .stat-label,
  .ahq-sheet #woundsSlot .heads,
  .ahq-sheet #woundsSlot .ovals {
    width: 100%;
    max-width: none;
    text-align: center;
  }
}
