:root{
  --bg:#ffffff;
  --bg2:#f7fbff;

  --panel:#ffffff;
  --text:#0b1020;
  --muted:#42526e;

  --line:#cfe1ff;           /* 青っぽい線 */
  --lineStrong:#a9c8ff;     /* 少し濃い線 */
  --shadow: none;

  --r:16px;

  --accent:#0a60ff;
  --accent2:#1aa7ff;

  --gap:6px;
  --slotSize:72px;
  --slotMax:96px;
  --benchSize: var(--slotSize);

  --ring: rgba(10,96,255,.90);

  --chipBg:#f3f7ff;
  --chipBg2:#eef6ff;
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
}

header{
  background: #ffffff;              /* 透けない */
  border-bottom:1px solid var(--line);
}

.wrap{max-width:1100px;margin:0 auto;padding:12px 16px}
h1{margin:0;font-size:18px;font-weight:900;letter-spacing:.2px;color:var(--text)}

main{max-width:1100px;margin:0 auto;padding:10px 10px 60px}

button{
  height:36px;
  border-radius:12px;
  border:1px solid var(--line);
  background: #ffffff;              /* 透けない */
  color: var(--text);
  padding:0 12px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:8px;
}
button:active{transform: translateY(1px)}

.btnIcon{ width:18px;height:18px; display:inline-block; color: var(--text); }

.iconBtn{
  width:36px;
  padding:0;
  justify-content:center;
}

.arrowBtn{
  width:32px;height:32px;padding:0;border-radius:12px;
  font-size:16px;display:flex;align-items:center;justify-content:center;
}

.stickyWrap{
  position: sticky;
  top: 0;
  z-index: 30;
  margin-top: 0px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.panel{
  background: var(--panel);          /* 透けない */
  border:1px solid var(--line);
  border-radius: var(--r);
  position: relative;
  overflow: hidden;
}

#pyramidPanel{ padding-bottom: 25px; }
.pyramidBody{ padding: 0 6px 10px; }

.rankDate{
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: var(--muted);
  font-size: clamp(10px, 2.8vw, 12px);
  line-height: 1.2;
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
}
.rankDatePad{ height: 0px; }

.rankBar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;

  font-size: 12px;
  color: var(--muted);

  position: sticky;
  top: 0;
  z-index: 50;

  background: #ffffff;              /* 透けない */
  border-bottom: 1px solid var(--line);

  padding: 10px 8px 8px;
}

.rankBar strong{ color: var(--text); font-weight:900; }

.rankTitlePad{
  padding-left: .5em;
  display:flex;
  gap:10px;
  align-items:baseline;
  flex-wrap:wrap;
  min-width: 0;
}

#rankStats{
  color: var(--muted);
  font-size: clamp(10px, 2.8vw, 12px);
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
}

.pyramidTopGap{ height: 8px; }
.rows{display:flex; flex-direction:column; gap:5px;}
.row{display:flex; justify-content:center; gap: var(--gap); width:100%; flex-wrap:nowrap;}

.slotWrap{
  width: var(--slotSize);
  flex: 0 0 auto;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;                 /* 番号＋テキストで詰まらんように */
  position: relative;
}

.slot{
  width: var(--slotSize);
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  overflow: hidden;
  background: #ffffff;
  border: 2px solid rgba(10,35,90,.18);
  cursor:pointer;
  touch-action: manipulation;
  position: relative;
}
.slot img{width:100%;height:100%;object-fit:cover;display:block;border-radius:999px;}
.slot.empty{background: #fbfdff; border: 2px dashed rgba(10,96,255,.35);}


.slotInfo{
  width:100%;
  text-align:center;
  line-height:1.0;
  display:flex; flex-direction:column;
  gap:2px;
}
.slotInfo .line{
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: clamp(8px, 2.6vw, 10px);
  color: rgba(11,16,32,.92);
}

#benchPanel{
  padding: 0;
  overflow: hidden;
  border-radius: var(--r);
  background: #ffffff;
}

#benchPanel .bar{
  background: #ffffff;
  border-top-left-radius: var(--r);
  border-top-right-radius: var(--r);
  position: relative;   /* ← 追加 */
  z-index: 1;           /* ← 追加 */
}

.benchRow{
  display:flex;
  gap: var(--gap);
  overflow-x:auto;
  padding: 8px 6px 8px;
  -webkit-overflow-scrolling: touch;
  align-items:flex-start;
}

.benchItemWrap{
  width:var(--benchSize);
  flex:0 0 auto;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
}

.benchItem{
  width: var(--benchSize);
  aspect-ratio:1/1;
  border-radius:999px;
  overflow:hidden;
  background: #ffffff;
  border:2px solid rgba(10,35,90,.18);
  cursor:pointer;
  touch-action: manipulation;
  position: relative;
}
.benchItem img{width:100%;height:100%;object-fit:cover;display:block;}

.benchAdd{
  display:flex;
  align-items:center;
  justify-content:center;
  background: #fbfdff;
  border: none; 
}
.benchAdd svg{ width:22px;height:22px; opacity:.95; color: var(--accent); }

.benchInfo{
  width:100%;
  text-align:center;
  line-height:1.05;
  display:flex;
  flex-direction:column;
  gap:2px;
}
.benchInfo .line{
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: clamp(8px, 2.6vw, 10px);
  color: rgba(11,16,32,.92);
}

.benchCollapsed .benchRow{ display:none; }
.benchCollapsed{ padding-bottom:8px; }

.bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;

  font-size:12px;
  color: var(--muted);

  padding: 10px 8px 8px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  margin: 0;
}

.bar strong{
  color:var(--text);
  font-weight:900;
}

.benchTitlePad{
  padding-left: .5em;
}


.belowBenchControls{
  margin-top: 10px;
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background: var(--chipBg);
  color: var(--text);
  font-size: 12px;
  user-select:none;
  white-space:nowrap;
}
.chip input{ accent-color: var(--accent); }

.displayRow{
  margin-top: 10px;
  display:flex;
}

.displayBtn{
  width:100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #ffffff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.displayBtn .label{
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.displayBtn .right{
  display:inline-flex;
  align-items:center;
  gap:10px;
  color: var(--muted);
  white-space: nowrap;
}

.displayBtn .picked{
  color: var(--text);
  font-weight: 900;
  max-width: 55vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.optionsPanel{
  margin-top: 6px;                 /* 余白詰め */
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px;
  box-shadow: var(--shadow);
}

.sortTitle{
  font-size:12px;
  color:var(--muted);
  margin: 0 0 8px;
}

.sortBox{display:flex;gap:10px;flex-wrap:wrap;align-items:center;}

select{
  height:36px;
  border-radius:12px;
  border:1px solid var(--line);
  background: #ffffff;
  color:var(--text);
  padding:0 12px;
  outline:none;
}

.gridSection{margin-top:12px}
.grid{display:grid;gap:10px;grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));}
@media (max-width:1100px){ .grid{ grid-template-columns: repeat(4, 1fr); } }
@media (max-width:360px){ .grid{ grid-template-columns: repeat(3, 1fr); } }

.loadError{
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px;
  border: 1px solid #ffc9c9;
  background: #fff5f5;
  border-radius: 12px;
  color: #9f1f1f;
  font-size: 13px;
}

.card{
  position:relative;
  background: #ffffff;
  border:1px solid var(--line);
  border-radius:16px;
  overflow:hidden;
  cursor:pointer;
  user-select:none;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.card:hover{transform: translateY(-2px)}
.thumb{
  aspect-ratio: 1 / 1;
  width:100%;
  background: #f4f9ff;
  display:block;
  object-fit: cover;
}
.meta{padding:8px 8px 10px}
.name{font-size:10px;font-weight:800;line-height:1.2;margin:0 0 4px;color:var(--text)}
.sub{font-size:10px;color:var(--muted);margin:0}

.idx{
  position:absolute;
  top:6px; left:6px;
  height:14px;
  padding:0 5px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  font-size:9px;
  font-weight:900;
  color: var(--accent);
  background: #ffffff;
  border:1px solid var(--lineStrong);
}

.card.selected,
.card.activeRing{
  box-shadow: 0 0 0 2px var(--ring);
}

.slot.activeRing,
.benchItem.activeRing{
  box-shadow: 0 0 0 2px var(--ring);
}

.modalOverlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modalOverlay.isOpen{ display:flex; }

.modal{
  width: min(640px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.modalHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.modalHeader .title{
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
  margin: 0;
}

.modalBody{
  padding: 10px 12px 12px;
  max-height: min(60vh, 520px);
  overflow: auto;
}

.modalToggles{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.chipToggle{
  display:inline-flex; align-items:center; gap:6px;
  padding:6px 10px; border-radius:999px;
  border:1px solid var(--line);
  background: var(--chipBg2);
  color: var(--text);
  font-size:12px; user-select:none; white-space:nowrap;
}
.chipToggle input{ accent-color: var(--accent); }
.chipToggle input:disabled{ opacity:.5; }

.modalFooter{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.btnGhost{
  background: #ffffff;
}

.headerWrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-links {
  position: relative;
  flex: 0 0 auto;
}

.link-toggle {
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}

.link-toggle svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.link-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(300px, calc(100vw - 32px));
  background: #ffffff;
  border: 1px solid #dbe6f5;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  z-index: 9999;
}

.link-menu a {
  display: block;
  padding: 12px 14px;
  color: #1f3b64;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  background: #ffffff;
  border-bottom: 1px solid #eef4fb;
}

.link-menu a:last-child {
  border-bottom: none;
}

.link-menu a:hover {
  background: #f4f8ff;
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .headerWrap {
    gap: 10px;
  }

  .headerWrap h1 {
    font-size: 16px;
  }

  .link-menu {
    width: min(280px, calc(100vw - 24px));
  }
}
