:root {
  --bg: #16121a;
  --panel: #221c28;
  --line: #3a3142;
  --text: #f3eef6;
  --sub: #b3a8bb;
  --accent: #ff4f8b;
  --accent-2: #ff8fb5;
  --ur: linear-gradient(135deg, #ffd86b, #ff6fa8 50%, #8f7bff);
  --ssr: #ffc94d;
  --sr: #b78cff;
  --r: #7f8a99;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}
[hidden] { display: none !important; }
a { color: var(--accent-2); }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; padding: 12px 22px;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  touch-action: manipulation;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--sub); border: 1px solid var(--line); }
.btn.big { font-size: 18px; padding: 16px 28px; min-width: 150px; }

/* ---- 年齢確認 ---- */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, #3a1630, var(--bg) 70%);
  z-index: 10;
}
.gate-box { max-width: 420px; text-align: center; display: grid; gap: 14px; }
.gate-mark {
  margin: 0 auto; width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  border: 3px solid var(--accent); color: var(--accent);
}
.gate h1 { margin: 0; font-size: 28px; }
.gate p:not(.gate-mark) { margin: 0; color: var(--sub); }

/* ---- 共通レイアウト ---- */
.app { max-width: 1000px; margin: 0 auto; padding: 0 16px 40px; }
.brand { display: flex; align-items: center; gap: 10px; position: relative; }
.pr summary {
  list-style: none; cursor: pointer; font-size: 11px; font-weight: 700; color: var(--bg); background: var(--sub);
  border-radius: 4px; padding: 1px 7px; user-select: none;
}
.pr summary::-webkit-details-marker { display: none; }
.pr[open] summary { background: var(--text); }
.pr p {
  position: absolute; z-index: 6; left: 0; top: calc(100% + 8px); width: min(340px, calc(100vw - 32px)); margin: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-size: 12px; color: var(--sub); box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0; flex-wrap: wrap; }
.logo { margin: 0; font-size: 24px; letter-spacing: .02em; }
.logo small { margin-left: 8px; font-size: 12px; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 5px; vertical-align: middle; }

.dummy-note { background: #3b2a12; color: #ffd38a; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.pull { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 24px 0 8px; }
.rates { text-align: center; color: var(--sub); font-size: 12px; margin: 0 0 20px; }
.share-row { text-align: center; margin: 24px 0; }

/* ---- カード ---- */
.result { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
@media (max-width: 420px) { .result { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

.card {
  background: var(--panel); border-radius: 12px; overflow: hidden;
  border: 2px solid var(--line); display: flex; flex-direction: column;
  animation: pop .45s cubic-bezier(.2, .9, .3, 1.3) both;
}
.card.r-SR { border-color: var(--sr); }
.card.r-SSR { border-color: var(--ssr); box-shadow: 0 0 16px rgba(255, 201, 77, .35); }
.card.r-UR { border: 2px solid transparent; background: linear-gradient(var(--panel), var(--panel)) padding-box, var(--ur) border-box; box-shadow: 0 0 24px rgba(255, 111, 168, .5); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.9) rotateY(70deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .card { animation: none; } }

/* 漫画は商業=縦長・同人=横長とバラバラなので、切らずに全体を収める */
.pic { position: relative; aspect-ratio: 4 / 5; background: #0e0b11; overflow: hidden; }
.pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--sub); font-weight: 700; background: repeating-linear-gradient(45deg, #1c1721 0 10px, #241e2a 10px 20px); }
/* 人気ラベルは画像の左上（白ふち・影つき） */
.badge {
  position: absolute; top: 6px; left: 6px; text-align: center;
  font-size: 13px; font-weight: 900; line-height: 1.3; letter-spacing: .04em;
  padding: 1px 8px 2px; border-radius: 6px; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .55); background: #7c4dff; color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.r-SSR .badge { background: linear-gradient(180deg, #ffe08a, #f5a800); color: #3a2500; text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
.r-UR .badge { background: var(--ur); color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
/* NEW はカード本文の上の行に小さく */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.new { font-size: 10px; font-weight: 800; line-height: 1.5; border-radius: 4px; padding: 0 6px; }
.new { background: var(--accent); color: #fff; }

.body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.title { margin: 0; font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta, .rank { margin: 0; font-size: 11px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.go {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; text-decoration: none; font-size: 12px; font-weight: 700;
  border-radius: 8px; padding: 7px 8px; text-align: center; line-height: 1.35; word-break: keep-all;
}
/* リンクボタン＋小さなコピーボタン */
.go-row { margin-top: auto; display: flex; gap: 4px; }
.go-row .go { flex: 1; min-width: 0; margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; font-size: 11px; padding: 7px 4px; letter-spacing: -.02em; }
.copy {
  flex: none; width: 28px; display: grid; place-items: center; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--sub); padding: 0;
}
.copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.copy.done { color: #6be3a0; border-color: #6be3a0; }
/* 画面下のお知らせ */
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
  background: #f3eef6; color: #16121a; border-radius: 12px; padding: 10px 16px; box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { display: block; font-size: 14px; }
.toast span { display: block; font-size: 12px; color: #5a5060; margin-top: 2px; }
.go.off { background: var(--line); color: var(--sub); }

/* ---- 絞り込み ---- */
.filter { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 16px; }
.f-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 760px) { .f-grid { grid-template-columns: repeat(2, 1fr); } }
.f-field { position: relative; min-width: 0; }
.f-label { display: block; font-size: 11px; color: var(--sub); margin-bottom: 3px; }
.f-box { position: relative; }
.f-box input {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 30px 7px 10px; -webkit-appearance: none; appearance: none;
}
.f-box input::-webkit-search-cancel-button { display: none; }
.f-field.sel input { border-color: var(--accent); font-weight: 700; }
.f-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--sub); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.f-sug {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); max-height: 320px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
@media (max-width: 760px) { .f-field:nth-child(2n) .f-sug { left: auto; width: calc(200% + 10px); } .f-field:nth-child(2n+1) .f-sug { width: calc(200% + 10px); } }
.f-sug button { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; padding: 8px 10px; cursor: pointer; }
.f-sug button:hover, .f-sug button:focus { background: var(--line); outline: none; }
.f-sug small { color: var(--sub); flex: none; }
.f-sug p { margin: 0; padding: 10px; color: var(--sub); font-size: 13px; }
.f-count { margin: 10px 0 0; font-size: 13px; color: var(--sub); }
.f-count b { color: var(--text); }

/* ---- 引くときの演出 ---- */
.fx {
  --c: #ffffff;
  position: fixed; inset: 0; z-index: 20; overflow: hidden;
  background: rgba(10, 7, 12, .92); cursor: pointer;
}
.fx.fx-SR { --c: #b78cff; }
.fx.fx-SSR { --c: #ffc94d; }
.fx.fx-UR { --c: #ff6fa8; }
.fx-pack {
  position: absolute; inset: 0; margin: auto; width: 120px; height: 168px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(150deg, #ff4f8b, #9b2fff); box-shadow: 0 0 0 3px rgba(255, 255, 255, .15), 0 10px 40px rgba(0, 0, 0, .6);
  color: #fff; font-weight: 800; font-size: 28px; letter-spacing: .05em;
  animation: fx-shake .55s ease-in-out both;
}
.fx-flash {
  position: absolute; inset: 0; margin: auto; width: 40px; height: 40px; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, #fff 0%, var(--c) 35%, transparent 70%);
}
.fx-rays { position: absolute; left: 50%; top: 50%; width: 160vmax; height: 160vmax; margin: -80vmax 0 0 -80vmax; opacity: 0; }
.fx-skip { position: absolute; bottom: 24px; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .4); font-size: 12px; margin: 0; }

/* はじける */
.fx.burst .fx-pack { animation: fx-pop .35s ease-in forwards; }
.fx.burst .fx-flash { animation: fx-flash .5s ease-out forwards; }
.fx.fx-UR.burst .fx-flash { background: radial-gradient(circle, #fff 0%, #ffd86b 25%, #ff6fa8 45%, #8f7bff 60%, transparent 72%); }
.fx.fx-UR.burst .fx-rays, .fx.fx-SSR.burst .fx-rays {
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--c) 35%, transparent) 0 6deg, transparent 6deg 18deg);
  mask-image: radial-gradient(circle, #000 0%, transparent 60%); -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 60%);
  animation: fx-rays .9s ease-out forwards;
}

/* 「視差効果を減らす」の人向け: 動かさず、フェードと色の光だけ */
.fx.calm .fx-pack { animation: fx-in .25s ease-out both; }
.fx.calm.burst .fx-pack { animation: fx-out .3s ease-in forwards; }
.fx.calm .fx-flash, .fx.calm .fx-rays { display: none; }
.fx.calm::after {
  content: ''; position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 55%, transparent) 0%, transparent 65%);
}
.fx.calm.fx-UR::after { background: radial-gradient(circle, rgba(255, 216, 107, .6) 0%, rgba(255, 111, 168, .45) 30%, rgba(143, 123, 255, .3) 50%, transparent 68%); }
.fx.calm.burst::after { animation: fx-glow .5s ease-out forwards; }
@keyframes fx-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fx-out { to { opacity: 0; } }
@keyframes fx-glow { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }

@keyframes fx-shake {
  0% { transform: translateY(30px) scale(.7); opacity: 0; }
  25% { transform: none; opacity: 1; }
  40% { transform: rotate(-7deg); } 55% { transform: rotate(7deg); }
  70% { transform: rotate(-4deg); } 85% { transform: rotate(3deg); } 100% { transform: none; }
}
@keyframes fx-pop { to { transform: scale(1.5); opacity: 0; filter: brightness(2); } }
@keyframes fx-flash { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(40); } }
@keyframes fx-rays { 0% { opacity: 0; transform: rotate(0); } 30% { opacity: 1; } 100% { opacity: 0; transform: rotate(40deg); } }

.btn:disabled { opacity: .5; cursor: wait; }
.card.r-N { border-color: var(--line); }
/* モード切り替え */
.modes { display: flex; justify-content: center; margin: 20px auto 0; width: fit-content; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.modes button { background: none; border: 0; color: var(--sub); font: inherit; font-size: 14px; font-weight: 700; padding: 7px 18px; border-radius: 999px; cursor: pointer; }
.modes button.on { background: var(--accent); color: #fff; }


footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--sub); font-size: 12px; }
footer p { margin: 4px 0; }
