/*! © 2026 烏蜃工房 | 愛すべき隣人たち | 無断転載・改変再配布禁止 */
:root {
  --ink: #303344;
  --muted: #636778;
  --paper: #fffdf7;
  --line: #e2e1da;
  --accent: #ed9879;
  --tint: #fff0e8;
  --stamp: #b8433a;
  --card-radius: 6% / 4%;
  --bounce-speed: 240ms;
  --bar-speed: 750ms;
  --glow-speed: 2200ms;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, sans-serif;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #383c72; outline-offset: 5px; }

/* ヘッダー */
.site-header {
  padding: 40px 20px 30px;
  text-align: center;
  background: linear-gradient(135deg, #fff0da, #f4edff 60%, #eaf3ff);
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin-bottom: 4px; font-size: .85rem; letter-spacing: .12em; font-weight: 700; }
h1 { margin: 4px 0 6px; font-size: clamp(1.75rem, 4.6vw, 2.8rem); font-weight: 800; letter-spacing: .06em; line-height: 1.3; }
.site-subtitle { margin: 0 0 10px; font-size: .95rem; color: var(--muted); letter-spacing: .08em; }
h2, h3, p { margin-top: 0; }
.site-header p:last-child { margin-bottom: 0; color: var(--muted); font-size: .9rem; }
main { max-width: 1160px; margin: auto; padding: 32px 24px 48px; }

/* 収集率 */
.collection-panel { margin-bottom: 28px; padding: 16px 20px; border: 2px solid var(--line); border-radius: 20px; background: white; }
.collection-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 10px; }
#collection-text { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.reset-button { min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); font-size: .85rem; }
.collection-progress { height: 14px; overflow: hidden; border: 1px solid #ddd8ed; border-radius: 999px; background: #f1eff8; }
.collection-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #b69bd6, #7daedc); transition: width var(--bar-speed) ease-out; }
.collection-panel.complete { border-color: #b69bd6; animation: collection-glow var(--glow-speed) ease-in-out infinite alternate; }
@keyframes collection-glow { to { box-shadow: 0 0 14px #b69bd680; } }
.storage-warning { margin: 8px 0 0; color: var(--muted); font-size: .75rem; }
/* 分類ごとの収集率。左の色が分類を表す */
.category-progress { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.category-progress-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 10px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--paper);
  font-size: .8rem;
  line-height: 1.6;
}
.category-progress-count { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.category-progress-done { margin-right: 6px; padding: 0 6px; border: 1px solid var(--stamp); border-radius: 4px; color: var(--stamp); font-size: .7rem; }
.category-progress-name { min-width: 0; white-space: nowrap; }
.category-progress-item.is-complete .category-progress-count { color: var(--stamp); }

/* 一覧の見出し・分類タブ・検索 */
.section-heading { display: flex; gap: 16px; align-items: baseline; justify-content: space-between; }
.section-heading h2 { font-size: 1.25rem; }
#list-count { color: var(--muted); font-size: .85rem; }
.category-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.category-tab {
  flex: 0 0 auto;
  white-space: nowrap;
  border: 2px solid var(--accent);
  background: white;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
}
.category-tab[aria-pressed="true"] { background: var(--tint); box-shadow: 0 3px 0 var(--accent); }
.list-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 28px; }
.search-control { flex: 1 1 280px; min-width: 0; }
.sort-control { flex: 0 1 220px; min-width: 0; }
.filter-control { flex: 0 1 180px; min-width: 0; }
.control-label { display: block; margin-bottom: 6px; font-size: .85rem; font-weight: 700; }
.search-field { position: relative; }
#character-search, #character-sort, #encounter-filter {
  display: block;
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
}
#character-search { padding-right: 48px; }
#character-search::placeholder { color: var(--muted); }
#character-sort, #encounter-filter { cursor: pointer; }
#character-search:focus-visible, #character-sort:focus-visible, #encounter-filter:focus-visible { outline: 3px solid #383c72; outline-offset: 3px; }
/* 消すボタンは入力欄の中に置き、文字があるときだけ表示する */
#clear-search {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  width: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
}
#clear-search:hover { color: var(--ink); }
#clear-search:focus-visible { outline-offset: -3px; }
#character-search:placeholder-shown + #clear-search { visibility: hidden; }
.no-result { padding: 28px 20px; border: 1px solid var(--line); border-radius: 20px; background: white; color: var(--muted); text-align: center; }

/* カード:カード画像そのものを主役にする */
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 24px; }
.character-card {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: none;
  text-align: left;
}
.card-art { position: relative; display: block; transition: transform var(--bounce-speed); }
.character-card .portrait { border-radius: var(--card-radius); box-shadow: 0 4px 0 var(--accent); transition: box-shadow var(--bounce-speed); }
@media (hover: hover) {
  .character-card:hover .card-art { transform: translateY(-6px) rotate(-1deg); }
  .character-card:hover .portrait { box-shadow: 0 4px 0 var(--accent), 0 16px 18px -10px #30334459; }
}
.character-card:active .card-art { transform: translateY(-3px) scale(1.02); }
.character-card.rare .portrait { animation: rare-glow var(--glow-speed) ease-in-out infinite alternate; }
@keyframes rare-glow { to { box-shadow: 0 4px 0 var(--accent), 0 0 18px var(--accent); } }
/* 遭遇済みは、カードに押した判子として見せる */
.encounter-stamp {
  position: absolute;
  right: 6%;
  bottom: 27%;
  z-index: 1;
  padding: 1px 10px;
  border: 3px double var(--stamp);
  border-radius: 8px;
  background: #fffdf7eb;
  color: var(--stamp);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .1em;
  line-height: 1.6;
  transform: rotate(-10deg);
  pointer-events: none;
}
.portrait {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--tint);
}
.portrait-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 300ms ease; }
.portrait-image.is-loaded { opacity: 1; }
.silhouette { width: 72%; height: auto; color: var(--accent); }
.card-name { display: block; margin-top: 12px; font-weight: 800; font-size: 1.05rem; line-height: 1.45; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; color: var(--muted); font-size: .8rem; }
.card-number { font-variant-numeric: tabular-nums; }
.rarity { display: inline-block; color: #886207; letter-spacing: .08em; }
.card-meta .rarity { font-size: .9rem; }

/* 詳細 */
.detail-view { max-width: 900px; margin: auto; }
.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 36px;
  align-items: center;
  padding: 28px;
  border: 2px solid var(--accent);
  border-radius: 24px;
  background: var(--tint);
}
.detail-art .portrait { border-radius: var(--card-radius); box-shadow: 0 6px 0 var(--accent); background: #ffffff90; }
.detail-number { display: block; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.detail-hero h2 { margin: 2px 0 6px; font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 800; letter-spacing: .04em; line-height: 1.3; }
/* 見出しは読み上げ位置の移動用なので、見た目の枠は出さない */
#detail-title:focus, #list-title:focus { outline: none; }
.detail-alias { margin-bottom: 10px; }
.detail-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 22px; }
.detail-tags .rarity { font-size: 1.15rem; }
.category-badge { display: inline-block; padding: 3px 12px; border: 1px solid var(--accent); border-radius: 999px; background: white; font-size: .8rem; }
.encounter-button {
  min-height: 48px;
  padding: 10px 28px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: white;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--accent);
  transition: transform 120ms, box-shadow 120ms;
}
.encounter-button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent); }
.encounter-button[aria-pressed="true"] { border-color: var(--stamp); color: var(--stamp); box-shadow: 0 4px 0 var(--stamp); }
.encounter-button[aria-pressed="true"]:active { box-shadow: 0 1px 0 var(--stamp); }
.detail-navigation { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; }
.detail-nav-button {
  min-width: 88px;
  min-height: 48px;
  padding: 10px 16px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--tint);
  font-weight: 700;
}
.detail-nav-button:disabled { opacity: .45; cursor: not-allowed; border-color: var(--line); background: #f0f1f5; }
.detail-position { min-width: 64px; margin: 0; text-align: center; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.route-notice { padding: 14px 18px; border: 1px solid var(--accent); border-radius: 14px; background: var(--tint); }
.share-controls { margin-top: 28px; text-align: center; }
.copy-button { min-height: 48px; padding: 10px 24px; border: 2px solid var(--accent); border-radius: 999px; background: var(--tint); font-weight: 700; }
.copy-button:disabled { opacity: .6; cursor: wait; }
.copy-status { min-height: 1.8em; margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.manual-copy { max-width: 600px; margin: 12px auto 0; text-align: left; }
.manual-copy label { display: block; margin-bottom: 6px; font-size: .85rem; }
.manual-copy textarea { width: 100%; min-height: 170px; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: white; color: var(--ink); font: inherit; font-size: 1rem; resize: vertical; }
.manual-copy textarea:focus-visible { outline: 3px solid #383c72; outline-offset: 3px; }
.panel { margin-top: 20px; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: white; }
.panel h3 { margin-bottom: 16px; font-size: 1.1rem; }
.info-list { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.info-list dt { font-size: .85rem; font-weight: 700; color: var(--muted); }
.info-list dd { margin: 0; }
.stats-layout { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 24px; }
.radar { width: 100%; height: auto; }
.radar-grid { fill: none; stroke: #d9dce5; stroke-width: 1; }
.radar-area { fill: var(--accent); fill-opacity: .28; stroke: var(--accent); stroke-width: 2; }
.radar text { fill: var(--ink); font-size: 11px; text-anchor: middle; }
.chart-note { font-size: .75rem; color: var(--muted); text-align: center; margin: 0; }
.stat-row + .stat-row { margin-top: 12px; }
.stat-label { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; margin-bottom: 4px; }
.stat-label strong { font-variant-numeric: tabular-nums; }
.stat-track { height: 13px; border-radius: 999px; background: #f0f1f5; overflow: hidden; border: 1px solid #e1e3ea; }
.stat-fill { height: 100%; border-radius: inherit; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform var(--bar-speed) ease-out; }
.bars-ready .stat-fill { transform: scaleX(1); }
.passive { padding: 14px 16px; background: var(--tint); border-radius: 12px; margin-bottom: 12px; }
.passive h4 { margin: 0 0 4px; }
.passive p { margin: 0; font-size: .9rem; }
.special { margin-top: 18px; border: 2px solid var(--accent); border-radius: 16px; overflow: hidden; }
.special-title { padding: 16px 22px; background: linear-gradient(115deg, var(--accent) 0%, var(--tint) 85%); }
.special-title small { font-weight: 800; }
.special-title h4 { margin: 0; font-size: 1.3rem; }
.special .info-list { padding: 18px; }
.trait-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.trait-grid .panel { padding: 20px; }
.trait-grid h3 { margin-bottom: 8px; }
.trait-grid p, .panel > p { margin-bottom: 0; }
.good-point { border-color: var(--accent); background: var(--tint); }
.back-button { display: block; margin: 28px auto 0; padding: 12px 30px; border: 2px solid var(--ink); border-radius: 999px; background: white; font-weight: 700; box-shadow: 0 4px 0 var(--ink); }
.back-button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.site-footer { padding: 24px; text-align: center; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.site-footer p { margin: 4px 0; }

@media (max-width: 1000px) { .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* スマホ:最初の画面からカードが見えるよう、上部を詰める */
@media (max-width: 720px) {
  .site-header { padding: 22px 16px 18px; }
  .site-subtitle { margin-bottom: 6px; }
  .site-header p:last-child { font-size: .85rem; }
  main { padding: 20px 16px 36px; }
  .collection-panel { margin-bottom: 20px; padding: 10px 14px 14px; border-radius: 16px; }
  .collection-heading { margin-bottom: 6px; }
  .reset-button { padding: 6px 12px; font-size: .8rem; }
  .section-heading h2 { margin-bottom: 10px; font-size: 1.15rem; }
  /* 分類タブは1段に並べ、横にスクロールして選ぶ */
  .category-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -16px 14px;
    padding: 2px 16px 8px;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .category-tabs::-webkit-scrollbar { display: none; }
  .category-tab { padding: 7px 14px; font-size: .8rem; }
  /* 検索は1行、並べ替えと遭遇記録は2つ並べる */
  .list-controls { gap: 10px; margin-bottom: 20px; }
  .search-control { flex: 1 1 100%; }
  .sort-control, .filter-control { flex: 1 1 0; }
  .category-progress { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
  .category-progress-item { padding: 2px 8px; font-size: .75rem; }
  /* スマホでは「達成」の札を省き、数字の色で伝える(読み上げでは「達成」を残す) */
  .category-progress-done { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .control-label { margin-bottom: 4px; font-size: .8rem; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 14px; }
  .card-name { margin-top: 10px; font-size: .95rem; }
  .encounter-stamp { font-size: .72rem; padding: 0 8px; }
  .detail-hero { grid-template-columns: 1fr; padding: 22px 18px; gap: 18px; text-align: center; }
  .detail-art { width: min(240px, 72%); margin: auto; }
  .detail-tags { justify-content: center; margin-bottom: 18px; }
  .stats-layout, .trait-grid { grid-template-columns: 1fr; }
  .radar { max-width: 360px; display: block; margin: auto; }
  .panel { padding: 20px; }
  .trait-grid { gap: 0; }
  .info-list { grid-template-columns: 80px minmax(0, 1fr); gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .stat-fill { transform: scaleX(1); }
}

/* 公開情報は既存フッターの末尾に控えめに表示します。 */
.site-footer .publication-meta { font-size: 0.75rem; color: #796e66; margin: 0.4rem 0; }
.publication-link { font: inherit; color: inherit; border: 0; background: transparent; padding: 0.35rem; cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em; }
.publication-dialog { width: min(34rem, calc(100% - 2rem)); max-height: 80vh; max-height: 80dvh; padding: 0; border: 1px solid #e4d7c7; border-radius: 1rem; background: #fffaf2; color: #493b32; box-shadow: 0 1rem 3rem #0003; overflow: auto; }
.publication-dialog::backdrop { background: #30271e77; }
.publication-panel { padding: clamp(1rem, 4vw, 1.75rem); }
.publication-panel h2 { margin-top: 0; font-size: 1.2rem; }
.publication-content { overflow-wrap: anywhere; line-height: 1.8; font-size: 0.9rem; }
#publication-close { display: block; margin: 1rem 0 0 auto; padding: 0.5rem 1rem; font: inherit; color: inherit; background: #fff; border: 1px solid #cdbba8; border-radius: 0.5rem; cursor: pointer; }
