.guide-section {
  scroll-margin-top: 5rem;
}

.guide-section h3 {
  margin: 1.25rem 0 .45rem;
}

.guide-section p,
.guide-section li,
.guide-section dd {
  line-height: 1.65;
}

.guide-section ol,
.guide-section ul {
  padding-inline-start: 1.5rem;
}

.guide-section li + li {
  margin-top: .3rem;
}

.guide-facts {
  margin: .5rem 0;
}

.guide-facts > div {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) 3fr;
  gap: .25rem .85rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--line, #d9dfdf);
}

.guide-facts dt {
  font-weight: 700;
}

.guide-facts dd {
  margin: 0;
  min-width: 0;
}

.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .75rem;
  margin-block: .5rem 1rem;
}

.guide-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.guide-subsection {
  border-block-start: 1px solid var(--line);
  margin-block-start: 1rem;
}

.guide-subsection h4 {
  margin: 1rem 0 .45rem;
}

.guide-toc {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: .25rem 1.25rem;
  margin-block: .5rem 0;
}

.guide-toc a {
  display: flex;
  align-items: center;
  min-height: 44px;
}

:where(.guide-section):target > :is(h2, h3) {
  text-decoration: underline;
  text-underline-offset: .2em;
}

.guide-scroll {
  max-width: 100%;
  overflow: auto;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  line-height: 1.55;
}

.guide-table caption {
  padding: .5rem 0;
  text-align: left;
  font-weight: 700;
}

.guide-table th,
.guide-table td {
  padding: .45rem .55rem;
  border: 1px solid var(--line, #d9dfdf);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.guide-table thead th {
  background: var(--line-soft, #eef4ef);
}

.ability-table thead th:last-child {
  white-space: nowrap;
}

.ability-field-label {
  display: none;
}

.card-position-heading {
  white-space: nowrap;
}

.guide-table[data-card-list] th[scope="row"] {
  font-weight: inherit;
}

.guide-table small,
.card-caption {
  display: block;
}

.card-name {
  font-weight: 700;
}

.card-stat {
  display: inline-block;
  margin-inline-end: .6rem;
}

.guide-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .65rem;
  margin-block: .5rem 1rem;
}

.guide-fields label {
  display: grid;
  gap: .2rem;
  flex: 1 1 8rem;
  min-width: 0;
}

.guide-fields label.search-field {
  flex-basis: 13rem;
}

.guide-fields input,
.guide-fields select,
.guide-button {
  min-height: 44px;
  max-width: 100%;
  border: 1px solid var(--line, #778780);
  border-radius: 8px;
  padding: .35rem .55rem;
  background: var(--panel, #fff);
  color: inherit;
  font: inherit;
}

.guide-button {
  cursor: pointer;
}

.guide-fields input,
.guide-fields select {
  width: 100%;
  min-width: 0;
}

.guide-button:disabled {
  opacity: .55;
  cursor: default;
}

.guide-button:focus-visible,
.guide-fields input:focus-visible,
.guide-fields select:focus-visible,
.guide-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-choice {
  display: inline-flex;
  white-space: nowrap;
  min-height: 44px;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
}

.card-choice input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.card-detail summary {
  min-height: 44px;
  padding: .45rem 0;
  cursor: pointer;
  color: var(--accent);
}

.card-detail dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: .5rem 1rem;
  margin: 0;
}

.card-detail dt {
  font-weight: 700;
}

.card-detail dd {
  margin: 0;
}

@media (min-width: 900px) {
  .guide-table[data-card-list] thead th:nth-last-child(-n+2) {
    white-space: nowrap;
  }
}

.guide-results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: .65rem 0;
}

.guide-results-bar p {
  margin: 0;
}

.guide-compare {
  table-layout: fixed;
}

.guide-compare thead th:first-child {
  width: 25%;
}

.guide-compare th,
.guide-compare td {
  white-space: pre-line;
}

.guide-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.guide-table .required-count {
  font-weight: 700;
}

.material-costs {
  min-width: 32rem;
}

.material-costs td {
  white-space: nowrap;
}

.material-costs th:first-child {
  position: sticky;
  inset-inline-start: 0;
}

.material-costs tbody th {
  background: var(--panel, #fff);
}

.material-totals input {
  width: 7ch;
  max-width: 100%;
  min-height: 44px;
  border: 1px solid var(--line, #778780);
  border-radius: 6px;
  text-align: right;
  font: inherit;
}

.material-totals input[aria-invalid="true"] {
  outline: 2px solid #9d2121;
  outline-offset: 1px;
}

.guide-section [hidden] {
  display: none !important;
}

@media (max-width: 600px) {
  .guide-section {
    scroll-margin-top: 4rem;
  }

  .guide-facts > div {
    grid-template-columns: 1fr;
  }

  .guide-table th,
  .guide-table td {
    padding: .35rem .4rem;
  }

  .card-detail dl {
    display: block;
  }

  .card-detail dt:not(:first-child) {
    margin-block-start: .7rem;
  }

  .ability-table,
  .ability-table :is(caption, tbody) {
    display: block;
  }

  .ability-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .ability-table tbody tr {
    display: grid;
    gap: 0.3rem;
    margin-bottom: 0.6rem;
    padding: 0.65rem;
    border: 1px solid var(--line, #d9dfdf);
    border-radius: 0.5rem;
  }

  .ability-table tbody :is(th, td) {
    padding: 0;
    border: 0;
  }

  .ability-field-label {
    display: block;
    font-size: 0.85em;
    font-weight: 700;
  }

  .ability-table td:last-child .ability-field-label {
    display: inline;
    margin-inline-end: 0.5rem;
  }

  .guide-compare thead th:first-child {
    width: max(31%, 6.25rem);
  }

  .guide-compare :is(th, td) {
    padding-inline: .35rem;
  }

  .guide-compare tbody th {
    font-size: .9rem;
    word-break: keep-all;
  }

  .title-table {
    font-size: .9rem;
  }

  .title-table :is(th, td) {
    padding-inline: .3rem;
  }

  .title-table :is(th[scope="col"], td) {
    white-space: nowrap;
  }

  .title-table th[scope="row"] {
    min-width: 6em;
  }

  .guide-table[data-card-list],
  .guide-table[data-card-list] tbody,
  .guide-table[data-card-list] tr,
  .guide-table[data-card-list] th,
  .guide-table[data-card-list] td {
    display: block;
  }

  .guide-table[data-card-list] caption {
    display: block;
  }

  .guide-table[data-card-list] thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .guide-table[data-card-list] tbody {
    border: 1px solid var(--line, #d9dfdf);
    border-radius: 8px;
    margin-block-end: .5rem;
  }

  .guide-table[data-card-list] .card-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name spirits" "series select" "stats stats";
    gap: 0 .5rem;
    align-items: start;
  }

  .guide-table[data-card-list] th,
  .guide-table[data-card-list] td {
    border: 0;
    min-width: 0;
  }

  .card-name-cell { grid-area: name; }
  .card-series-cell { grid-area: series; }
  .card-spirits-cell { grid-area: spirits; text-align: right; }
  .card-stats-cell { grid-area: stats; }
  .card-choice-cell { grid-area: select; text-align: right; }
  .card-spirits-cell::before {
    content: "最大スピリッツ";
    display: block;
    font-size: .75rem;
  }

  .guide-table[data-card-list] .card-detail-cell {
    border-top: 1px solid var(--line, #d9dfdf);
  }
}
