/* ===== コレクションページ（図鑑） ===== */
.detail-link {
  width: 100%;
}
.detail-link:focus-visible {
  outline-offset: 3px;
}
.book {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 16px 56px;
}

/* ----- 見出しと進み具合 ----- */
.book-head {
  margin-bottom: 24px;
}
.book-title {
  margin: 0;
  font-size: clamp(26px, 5.4vw, 40px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.03em;
}
.book-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 28px;
  margin-top: 14px;
}
.progress {
  min-width: 220px;
  flex: 0 1 280px;
}
.wallet--small {
  margin: 0 0 4px;
  padding: 4px 14px 4px 6px;
  border-width: 2px;
  box-shadow: 0 3px 0 var(--ink);
}
.wallet--small .wallet-coin {
  width: 28px;
  height: 28px;
  font-size: 12px;
}
.wallet--small .wallet-count {
  font-size: 22px;
}
.progress-count {
  margin: 0;
  font-weight: 800;
  line-height: 1;
}
.progress-owned {
  font-size: 44px;
  color: var(--red);
}
.progress-total {
  font-size: 18px;
}
.progress-bar {
  height: 14px;
  margin: 10px 0 6px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--ink);
  overflow: hidden;
}
.progress-bar > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--red);
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.progress-draws {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.status {
  margin: 0 0 12px;
  font-weight: 800;
}
.status:empty {
  display: none;
}
.status.is-error {
  color: var(--red-dark);
}

/* ----- 棚 ----- */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  overflow: hidden;
  box-shadow: 0 5px 0 var(--ink);
}
button.card {
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}
button.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 0 var(--ink);
}
button.card:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}

.card-stage {
  position: relative;
  aspect-ratio: 1;
  background: radial-gradient(
    circle at 50% 60%,
    color-mix(in srgb, var(--c, #ccc) 28%, #fff) 0 55%,
    color-mix(in srgb, var(--c, #ccc) 12%, #fff) 56%
  );
}
.card-stage img {
  position: absolute;
  inset: 4%;
  width: 92%;
  height: 92%;
  object-fit: contain;
}
.card-no {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.card-count {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--sun);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}
.card-body {
  padding: 12px 14px 14px;
  border-top: 3px solid var(--ink);
}
.card-name {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
}
.card-meta {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
}

.card.locked {
  border-color: #9aa7b6;
  box-shadow: 0 5px 0 #9aa7b6;
}
.card.locked .card-stage {
  background: #eef2f0;
}
.card.locked .card-stage img {
  filter: brightness(0);
  opacity: 0.14;
}
.card.locked .card-no {
  background: #9aa7b6;
}
.card.locked .card-body {
  border-top-color: #9aa7b6;
}
.card.locked .card-name {
  color: #8793a3;
  letter-spacing: 0.1em;
}

.shelf.is-loading .card {
  opacity: 0.5;
}

.empty {
  margin: 28px 0 0;
  text-align: center;
  font-weight: 800;
}
.empty p {
  margin: 0 0 12px;
}

/* ----- パネル（保存キー・復元） ----- */
.panel {
  margin-top: 36px;
  padding: 24px 22px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(33, 48, 71, 0.12);
}
.panel-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
}
.panel-text {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 14px;
}
.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.keycard-code--inline {
  max-width: 360px;
  align-items: flex-start;
  padding: 14px 18px;
}
.keycard-code--inline .keycard-body.is-masked {
  color: #9aa7b6;
  user-select: none;
  -webkit-user-select: none;
}

.restore-panel {
  margin-top: 18px;
}
.restore-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 800;
}
.restore-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.restore-input {
  flex: 1 1 260px;
  min-height: 48px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.restore-input::placeholder {
  color: #a9b3c0;
  letter-spacing: 0.04em;
}
.restore-input[aria-invalid="true"] {
  border-color: var(--red);
}
.restore-msg {
  min-height: 1.6em;
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 800;
}
.restore-msg.is-error {
  color: var(--red-dark);
}
.restore-msg.is-ok {
  color: #1f7a45;
}

@media (max-width: 420px) {
  .shelf {
    gap: 12px;
  }
  .card {
    border-radius: 18px;
  }
  .card-name {
    font-size: 15px;
  }
  .card-body {
    padding: 10px 12px 12px;
  }
}

/* ----- 詳細ダイアログ ----- */
.detail {
  width: min(92vw, 440px);
  max-height: 92vh;
  padding: 0 0 22px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  overflow: auto;
}
.detail::backdrop {
  background: rgba(22, 36, 58, 0.6);
}
.detail[open] {
  animation: detail-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes detail-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 40px;
  height: 40px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding-bottom: 0.2em;
}
.detail-figure {
  aspect-ratio: 1;
  background: radial-gradient(
    circle at 50% 60%,
    color-mix(in srgb, var(--c, #ccc) 30%, #fff) 0 55%,
    color-mix(in srgb, var(--c, #ccc) 12%, #fff) 56%
  );
  border-bottom: 3px solid var(--ink);
}
.detail-figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.detail-body {
  padding: 0 22px;
}
.detail-no {
  margin-top: 16px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}
.detail-name {
  margin-top: 0;
  margin-bottom: 2px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.3;
}
.detail-desc {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 15px;
}
.detail-desc {
  white-space: pre-line;
}
.detail-desc:empty {
  display: none;
}
.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 18px;
}
.detail-meta div {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--paper);
}
.detail-meta dt {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
}
.detail-meta dd {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  .detail[open] {
    animation: none;
  }
  .progress-bar > span {
    transition: none;
  }
  button.card {
    transition: none;
  }
}
