/* ガチャクリッカー ─ 夜空で星を召喚するテーマ。画像アセットなし・CSSのみ */
:root {
  --bg0: #0b0d22;
  --bg1: #181b3d;
  --panel: #1c2044;
  --panel-2: #232858;
  --line: #32386e;
  --ink: #eceef8;
  --sub: #9aa0c4;
  --gold: #f6c453;
  --gold-deep: #d99a1f;
  --n: #97a0b4;
  --r: #58a6ff;
  --sr: #b478ff;
  --danger: #ff7a7a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1px 1px at 15% 25%, #ffffffcc 50%, transparent 51%),
    radial-gradient(1px 1px at 75% 12%, #ffffff88 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 45%, #ffe9b088 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 70%, #ffffff66 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 60%, #ffffff99 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 10% 90%, #ffe9b066 50%, transparent 51%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 60%, #10132c);
  background-attachment: fixed;
  min-height: 100vh;
}
main { max-width: 560px; margin: 0 auto; padding: 0 14px 60px; }
button { font-family: inherit; cursor: pointer; }

/* ---- ヘッダー ---- */
.top {
  max-width: 560px; margin: 0 auto; padding: 14px;
  display: flex; align-items: center; gap: 10px;
}
.logo { margin: 0; font-size: 20px; font-weight: 900; letter-spacing: .14em; }
.logo span { color: var(--gold); }
.account { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sub); }
.account button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
}

/* ---- リソースバー ---- */
.resources {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px;
  padding: 10px 0; background: linear-gradient(180deg, var(--bg0) 70%, transparent);
}
.res {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.res-label { font-size: 10px; color: var(--sub); letter-spacing: .08em; }
.res strong { font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.res-coin strong { color: var(--gold); font-size: 22px; }
.res small { font-size: 10px; color: var(--sub); }
.mini {
  margin-top: 2px; align-self: flex-start; font-size: 10px; padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--gold-deep); background: transparent; color: var(--gold);
}
.res-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- 採掘(シグネチャ: 星鉱石ボタン) ---- */
.mine { position: relative; text-align: center; padding: 26px 0 8px; }
.star-btn {
  width: 168px; height: 168px; border-radius: 50%;
  font-size: 64px; color: #4a3404; border: none;
  background: radial-gradient(circle at 34% 30%, #ffe9a8, var(--gold) 45%, var(--gold-deep) 78%, #8a5c0a);
  box-shadow: 0 0 42px #f6c45355, 0 0 120px #f6c45322, inset 0 -10px 24px #00000033;
  transition: transform .06s ease;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.star-btn:active { transform: scale(.92); }
.mine-hint { font-size: 12px; color: var(--sub); margin: 12px 0 0; }
.pop-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute; font-weight: 900; color: var(--gold); font-size: 15px;
  text-shadow: 0 1px 6px #00000088; animation: popUp .8s ease-out forwards;
}
@keyframes popUp {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-56px); }
}

/* ---- 召喚 ---- */
.gacha { padding: 18px 0 6px; }
.gacha-btns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 10px;
}
.pull-btn {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 8px;
  background: var(--panel-2); color: var(--ink);
  font-size: 15px; font-weight: 700; letter-spacing: .06em;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.pull-btn em { font-style: normal; font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; }
.pull-ten {
  border-color: var(--gold-deep);
  background: linear-gradient(160deg, #3a2f10, #2a2350);
  box-shadow: 0 0 18px #f6c45322;
}
.pull-btn:disabled { opacity: .45; cursor: default; }
.pity-note {
  width: fit-content; margin: 10px auto 0; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #141832cc; color: var(--sub); font-size: 11px; text-align: center;
}
.pity-note strong { color: var(--gold); font-variant-numeric: tabular-nums; }
.rates-note { font-size: 10px; color: var(--sub); text-align: center; margin: 10px 0 0; }

/* ---- タブ ---- */
.tabs { margin-top: 22px; }
.tab-nav { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: none; color: var(--sub); font-size: 13px; font-weight: 700;
  padding: 8px 12px; border-bottom: 2px solid transparent;
}
.tab.on { color: var(--ink); border-bottom-color: var(--gold); }
.tabpane { display: none; padding: 14px 0; }
.tabpane.on { display: block; }

/* ---- 図鑑 ---- */
.rarity-sec { margin-bottom: 16px; }
.rarity-head { font-size: 12px; font-weight: 900; letter-spacing: .18em; margin: 0 0 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.card {
  position: relative; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); padding: 10px 6px 8px; text-align: center; min-height: 96px;
}
.card .glyph {
  display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 6px;
  border-radius: 50%; font-size: 20px; font-weight: 900; color: #0b0d22;
}
.card .cname { font-size: 10px; line-height: 1.35; word-break: keep-all; overflow-wrap: anywhere; }
.card .cnt {
  position: absolute; top: -6px; right: -4px; font-size: 10px; font-weight: 900;
  background: var(--gold); color: #3a2a00; border-radius: 999px; padding: 1px 6px;
}
.card.unowned { opacity: .38; filter: grayscale(.6); }
.card[data-rarity="N"]   .glyph { background: var(--n); }
.card[data-rarity="R"]   .glyph { background: var(--r); }
.card[data-rarity="SR"]  .glyph { background: var(--sr); }
.card[data-rarity="SSR"] .glyph { background: linear-gradient(135deg, #ffe9a8, var(--gold), var(--gold-deep)); }
.card[data-rarity="SSR"] { border-color: var(--gold-deep); }
.rarity-head.h-N { color: var(--n); } .rarity-head.h-R { color: var(--r); }
.rarity-head.h-SR { color: var(--sr); } .rarity-head.h-SSR { color: var(--gold); }

/* ---- 履歴 ---- */
.hist-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.badge {
  font-size: 10px; font-weight: 900; padding: 2px 7px; border-radius: 6px; color: #0b0d22; min-width: 30px; text-align: center;
}
.badge.N { background: var(--n); } .badge.R { background: var(--r); }
.badge.SR { background: var(--sr); } .badge.SSR { background: var(--gold); }
.hist-row time { margin-left: auto; font-size: 10px; color: var(--sub); }
.hist-row .src-ex { font-size: 10px; color: var(--gold); }
.empty-note { font-size: 12px; color: var(--sub); text-align: center; padding: 24px 0; }
.empty-note button { border: none; background: none; color: var(--gold); text-decoration: underline; font-size: 12px; }

/* ---- モーダル ---- */
.modal {
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  color: var(--ink); padding: 20px; width: min(92vw, 480px);
}
.modal::backdrop { background: #05061599; backdrop-filter: blur(2px); }
.modal-title { margin: 0 0 6px; font-size: 16px; letter-spacing: .1em; }
.modal-sub { margin: 0 0 14px; font-size: 12px; color: var(--sub); }
.modal-sub strong { color: var(--gold); }
.modal-close {
  margin-top: 16px; width: 100%; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font-weight: 700;
}

/* ---- 召喚結果(シグネチャ演出: 舞い降りるカード) ---- */
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.rcard {
  position: relative; /* first-getの光彩(::after)の基準 */
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2);
  padding: 10px 4px; text-align: center; min-height: 92px;
  opacity: 0; animation: dropIn .5s ease-out forwards;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-26px) scale(.85); }
  60%  { opacity: 1; transform: translateY(3px) scale(1.02); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.rcard .glyph {
  display: grid; place-items: center; width: 40px; height: 40px; margin: 0 auto 6px;
  border-radius: 50%; font-size: 18px; font-weight: 900; color: #0b0d22;
}
.rcard .rname { font-size: 10px; line-height: 1.35; }
.rcard .new { font-size: 9px; color: var(--gold); font-weight: 900; letter-spacing: .1em; }
.rcard[data-rarity="N"]   .glyph { background: var(--n); }
.rcard[data-rarity="R"]   .glyph { background: var(--r); }
.rcard[data-rarity="SR"]  .glyph { background: var(--sr); }
.rcard[data-rarity="SR"]  { border-color: var(--sr); }
.rcard[data-rarity="SSR"] .glyph { background: linear-gradient(135deg, #ffe9a8, var(--gold), var(--gold-deep)); }
.rcard[data-rarity="SSR"] {
  border-color: var(--gold);
  box-shadow: 0 0 14px #f6c45366;
  animation: dropIn .5s ease-out forwards, ssrGlow 1.6s ease-in-out infinite alternate;
}
@keyframes ssrGlow {
  from { box-shadow: 0 0 10px #f6c45344; }
  to   { box-shadow: 0 0 26px #f6c453aa; }
}

/* ---- 交換所 / ログイン ---- */
.exchange-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.ex-row {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 13px;
}
.ex-row .own { margin-left: auto; font-size: 11px; color: var(--sub); }
.ex-row button {
  border: 1px solid var(--gold-deep); background: none; color: var(--gold);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700;
}
.ex-row button:disabled { opacity: .35; cursor: default; }
/* v2.5: 未所持を目立たせ、所持済みは控えめに(未所持が上にソートされる) */
.ex-row.ex-unowned { border-color: var(--gold-deep); background: #2a2440; }
.ex-row.ex-unowned .own { color: var(--gold); }
.ex-row.ex-owned { opacity: .6; }
.login-form { display: flex; gap: 8px; }
.login-form input {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg0); color: var(--ink); font-size: 14px;
}
.primary {
  border: none; border-radius: 10px; padding: 10px 14px; font-weight: 900;
  background: linear-gradient(135deg, #ffe9a8, var(--gold)); color: #3a2a00;
}
.login-msg { font-size: 12px; color: var(--gold); min-height: 1em; margin: 10px 0 0; overflow-wrap: anywhere; }
.login-msg a { color: var(--gold); }

/* ---- トースト ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 50;
  max-width: 88vw; z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- ボーナス / データ消去 ---- */
.bonus-modal { text-align: center; border-color: var(--gold-deep); box-shadow: 0 0 44px #f6c45333; }
.bonus-amount { font-size: 18px; font-weight: 900; margin: 8px 0 2px; }
.bonus-amount strong { color: var(--gold); font-size: 32px; font-variant-numeric: tabular-nums; }
.primary.big { width: 100%; padding: 13px; font-size: 15px; margin-top: 6px; }
.foot { text-align: center; padding: 34px 0 8px; }
.linklike { border: none; background: none; color: var(--sub); font-size: 11px; text-decoration: underline; }
.danger-title { color: var(--danger); }
.danger-strong { color: var(--danger); }
.danger-check { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--sub); margin: 2px 0 12px; cursor: pointer; }
.danger-btn {
  width: 100%; padding: 11px; border-radius: 10px;
  border: 1px solid var(--danger); background: #3a1620; color: var(--danger); font-weight: 900;
}
.danger-btn:disabled { opacity: .35; cursor: default; }

/* ---- 召喚演出(全画面レイヤー) ---- */
.fx-layer {
  position: fixed; inset: 0; z-index: 40; background: #05061a;
  display: grid; place-items: center; overflow: hidden; user-select: none;
  -webkit-user-select: none; -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.fx-layer[hidden] { display: none; }
#summonVideo { width: 100%; height: 100%; object-fit: cover; background: #000; pointer-events: none; }
.movie-skip-hint {
  position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 6px 12px; border-radius: 999px; border: 1px solid #ffffff44;
  background: #00000088; color: #ffffffcc; font-size: 11px; letter-spacing: .08em;
  pointer-events: none; animation: movieHintIn .2s ease-out;
}
.movie-skip-hint[hidden] { display: none; }
@keyframes movieHintIn { from { opacity: 0; transform: translateX(-50%) translateY(6px); } to { opacity: 1; transform: translateX(-50%); } }
.fx-skip {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px;
  border: 1px solid #ffffff55; background: #00000088; color: #fff;
  padding: 8px 14px; border-radius: 999px; font-size: 12px; z-index: 2;
}

/* 紹介背景: 画像が無いレア度はグラデーションで代用 */
.intro-grad { position: absolute; inset: 0; transition: background 1s; }
.intro-grad.g-N   { background: radial-gradient(circle at 50% 30%, #3a4152, #171b26 70%); }
.intro-grad.g-R   { background: radial-gradient(circle at 50% 30%, #16457e, #0a1430 70%); }
.intro-grad.g-SR  { background: radial-gradient(circle at 50% 30%, #55257e, #170a30 70%); }
.intro-grad.g-SSR { background: radial-gradient(circle at 50% 30%, #7e5c16, #201405 68%),
                                radial-gradient(1.5px 1.5px at 20% 20%, #ffe9a8 50%, transparent 51%); }
.intro-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.intro-art {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  height: min(76vh, 900px); max-width: 92vw; object-fit: contain;
  filter: drop-shadow(0 6px 30px #000000aa);
  transition: filter .5s ease, transform .5s ease;
}
.intro-art.silhouette { filter: brightness(0) contrast(1.1) drop-shadow(0 0 24px #00000088); transform: translateX(-50%) scale(.97); }
.intro-art.reveal-flash { animation: revealFlash .5s ease-out; }
@keyframes revealFlash {
  0% { filter: brightness(4) saturate(0); }
  100% { filter: brightness(1); }
}

.intro-caption[hidden] { display: none; }  /* display:flexが[hidden]に勝ってしまう対策 */
.intro-caption {
  position: absolute; left: 0; right: 0; bottom: max(12vh, 90px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: captionIn .55s ease-out; pointer-events: none;
}
@keyframes captionIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.intro-rarity {
  font-size: 13px; font-weight: 900; letter-spacing: .5em; padding-left: .5em;
  color: #fff; text-shadow: 0 0 12px #000;
}
.intro-rarity.N { color: var(--n); } .intro-rarity.R { color: var(--r); }
.intro-rarity.SR { color: var(--sr); }
.intro-rarity.SSR { color: var(--gold); text-shadow: 0 0 18px #f6c453aa; }
.intro-name {
  font-size: clamp(22px, 6vw, 34px); font-weight: 900; letter-spacing: .12em;
  color: #fff; text-shadow: 0 2px 18px #000, 0 0 34px #00000088;
}
.intro-new { font-size: 12px; font-weight: 900; color: var(--gold); letter-spacing: .2em; min-height: 1em; }
.intro-counter {
  position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px;
  font-size: 12px; color: #ffffffaa; font-variant-numeric: tabular-nums;
}
.intro-tap {
  position: absolute; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  font-size: 11px; color: #ffffff88; letter-spacing: .2em; animation: tapPulse 1.6s ease-in-out infinite;
}
@keyframes tapPulse { 0%,100% { opacity: .4; } 50% { opacity: 1; } }

/* SSR演出: 金の粒子 */
.fx-layer.ssr-fx::before, .fx-layer.ssr-fx::after {
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(2px 2px at 20% 30%, #ffe9a8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 70% 20%, #f6c453 50%, transparent 51%),
    radial-gradient(2px 2px at 40% 70%, #ffe9a8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 85% 60%, #f6c453 50%, transparent 51%),
    radial-gradient(2px 2px at 10% 80%, #ffe9a8 50%, transparent 51%);
  animation: floatUp 7s linear infinite; pointer-events: none;
}
.fx-layer.ssr-fx::after { animation-duration: 11s; animation-delay: -4s; transform: scale(1.4); opacity: .6; }
@keyframes floatUp { from { transform: translateY(6%); } to { transform: translateY(-6%); } }

/* ---- 図鑑カードの立ち絵と詳細モーダル ---- */
.card { cursor: pointer; }
.card.unowned { cursor: default; }
.card-art { width: 54px; height: 54px; object-fit: contain; display: block; margin: 0 auto 6px; }
.card.unowned .card-art { filter: brightness(0) opacity(.65); }
.char-modal { width: min(94vw, 520px); }
.char-head { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 8px; }
.char-head img { width: 96px; height: 130px; object-fit: contain; filter: drop-shadow(0 4px 12px #0008); }
.char-head-info .modal-title { margin: 4px 0; }
.char-head-info p { margin: 2px 0; font-size: 12px; color: var(--sub); }
.story-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.story-list details {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); padding: 8px 12px;
}
.story-list summary { font-size: 13px; font-weight: 700; cursor: pointer; }
.story-list details p { font-size: 13px; line-height: 1.8; color: var(--ink); white-space: pre-wrap; margin: 8px 0 2px; }
.story-locked {
  border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px;
  font-size: 12px; color: var(--sub);
}

/* ---- 提供割合 ---- */
.rates-body { max-height: 52vh; overflow-y: auto; font-size: 12px; }
.rates-rarity { margin: 10px 0 4px; font-weight: 900; letter-spacing: .1em; }
.rates-row { display: flex; justify-content: space-between; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.rates-row .pct { font-variant-numeric: tabular-nums; color: var(--sub); }
.rates-row.suspended { opacity: .45; }

/* ---- 図鑑: アコーディオンと所持スイッチ ---- */
details.rarity-sec > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  -webkit-tap-highlight-color: transparent;
}
details.rarity-sec > summary::-webkit-details-marker { display: none; }
details.rarity-sec > summary::before {
  content: "▸"; font-size: 12px; color: var(--sub); transition: transform .15s;
}
details.rarity-sec[open] > summary::before { transform: rotate(90deg); }
.switch-row {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sub);
  margin: 2px 0 10px; cursor: pointer; user-select: none; width: fit-content;
}
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 36px; height: 20px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); position: relative; transition: background .15s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--sub); transition: transform .15s, background .15s;
}
.switch-row input:checked + .switch { background: #3d3a1c; border-color: var(--gold); }
.switch-row input:checked + .switch::after { transform: translateX(16px); background: var(--gold); }

/* ---- 実績 ---- */
.ach-card {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  padding: 10px 12px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 4px;
}
.ach-card.done { border-color: #3a5a3a; }
.ach-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ach-title { font-size: 13px; font-weight: 800; }
.ach-desc { font-size: 12px; color: var(--sub); }
.ach-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.ach-reward { color: var(--gold); font-weight: 700; }
.ach-progress { flex: 1; height: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.ach-progress i { display: block; height: 100%; background: linear-gradient(90deg, #6b5cff, var(--gold)); }
.ach-progress-num { color: var(--sub); font-variant-numeric: tabular-nums; }
.ach-actions { display: flex; gap: 8px; margin-top: 2px; }
.ach-claim {
  border: none; border-radius: 999px; padding: 7px 16px; font-weight: 800; font-size: 12px;
  background: linear-gradient(135deg, var(--gold), #ffdf8e); color: #201405; cursor: pointer;
  animation: claimPulse 1.8s ease-in-out infinite;
}
@keyframes claimPulse { 0%,100% { box-shadow: 0 0 0 0 #f6c45355; } 50% { box-shadow: 0 0 0 7px transparent; } }
.ach-read {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px; font-size: 12px;
  background: var(--panel-2); color: var(--ink); cursor: pointer;
}
.story-queue-skip { margin-top: 12px; }
.hist-row .src-achievement { font-size: 10px; color: var(--gold); }
.ach-claimed-label { font-size: 11px; color: #7fbf8a; font-weight: 700; }
.story-read { font-size: 13px; line-height: 1.9; white-space: pre-wrap; max-height: 56vh; overflow-y: auto; }

/* ---- キャライコン(正方形・レア度枠) ---- */
.card-icon {
  width: 56px; height: 56px; object-fit: cover; display: block; margin: 0 auto 6px;
  border-radius: 10px; border: 2px solid var(--line); background: var(--panel-2);
}
.card-icon.rar-N   { border-color: var(--n); }
.card-icon.rar-R   { border-color: var(--r); }
.card-icon.rar-SR  { border-color: var(--sr); box-shadow: 0 0 6px #a06bff44; }
.card-icon.rar-SSR { border-color: var(--gold); box-shadow: 0 0 8px #f6c45366; }
.card.unowned .card-icon { filter: brightness(0) opacity(.65); border-color: var(--line); box-shadow: none; }

/* リザルト: 初入手キャラのハイライト */
/* 初入手ハイライト: 本体のanimation(dropIn=登場)を上書きしないよう、光彩は疑似要素で */
.rcard.first-get { outline: 2px solid var(--gold); }
.rcard.first-get::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  pointer-events: none; animation: firstGetGlow 1.6s ease-in-out infinite;
}
@keyframes firstGetGlow {
  0%, 100% { box-shadow: 0 0 10px #f6c45366, inset 0 0 14px #f6c45318; }
  50% { box-shadow: 0 0 20px #f6c453cc, inset 0 0 22px #f6c45330; }
}

/* ---- キャラ詳細: バストアップ+ギャラリー ---- */
.cm-bustup-wrap { display: grid; place-items: center; margin: -6px -6px 8px; }
.cm-bustup { max-height: 34vh; max-width: 100%; object-fit: contain; filter: drop-shadow(0 6px 18px #0009); }
.cm-info { text-align: center; margin-bottom: 6px; }
.cm-info .modal-title { margin: 6px 0 2px; }
.cm-info p { margin: 2px 0; font-size: 12px; color: var(--sub); }
.cm-gallery { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.cm-thumb-link { display: inline-flex; border: none; background: none; padding: 0; cursor: zoom-in; }
.cm-thumb {
  width: 56px; height: 56px; object-fit: cover; border-radius: 10px;
  border: 2px solid var(--line); cursor: pointer; background: var(--panel-2); padding: 0;
}
.cm-thumb:hover { border-color: var(--gold); }

/* 100連など多数プルの集計リザルト(アイコンなしで縦に伸びすぎない) */
.result-summary {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px 14px; font-size: 12px;
}
.rs-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 2px; border-bottom: 1px solid var(--line);
  opacity: 0; animation: dropIn .3s ease-out forwards;
}
.rs-row .badge { flex: none; font-size: 9px; padding: 1px 6px; }
.rs-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-count { font-variant-numeric: tabular-nums; color: var(--sub); }
.rs-row.first-get { outline: none; }
.rs-row .rs-new { color: var(--gold); font-weight: 900; font-size: 10px; }

/* ---- 100連ボタン ---- */
.pull-hundred {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #2b0f3a, #4a1259);
  border: 1px solid var(--gold);
}
.pull-hundred[hidden] { display: none; }

/* ---- タブバッジ(未受取実績) ---- */
.tab-badge {
  display: inline-grid; place-items: center; min-width: 17px; height: 17px;
  margin-left: 5px; padding: 0 4px; border-radius: 999px;
  background: #e5484d; color: #fff; font-size: 10px; font-weight: 900;
  vertical-align: 1px;
}
.tab-badge[hidden] { display: none; }
.switch-wrap { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }

/* ---- クイックナビ ---- */
.nav-toggle {
  flex: none;
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 17px; cursor: pointer;
}
.quick-nav {
  position: fixed; z-index: 31; display: flex; flex-direction: column; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; width: 210px;
}
.nav-head { font-size: 11px; color: var(--sub); letter-spacing: .2em; margin: 0 0 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 6px; text-align: left;
  border: none; background: none; color: var(--ink); font-size: 13px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.nav-btn:hover { background: var(--panel-2); }
.nav-sep { border-top: 1px solid var(--line); margin: 4px 0; }
.nav-user p { margin: 3px 0; font-size: 11px; color: var(--sub); }
.nav-user b { color: var(--ink); font-weight: 700; user-select: all; }
.nav-hint { font-size: 10px; }
.nav-warn { color: #f0a860; line-height: 1.6; }
@media (min-width: 1100px) {   /* PC: 右側に常時表示 */
  .nav-toggle { display: none; }
  .quick-nav { top: 70px; right: max(12px, calc(50vw - 560px)); }
}
@media (max-width: 1099.9px) { /* SP: ハンバーガーで開閉 */
  .quick-nav { top: 56px; right: 10px; box-shadow: 0 10px 30px #000a; }
  .quick-nav:not(.open) { display: none; }
}

/* ---- 世界観・遊びかたモーダル ---- */
.page-modal { width: min(94vw, 560px); }
.page-body { font-size: 13px; line-height: 1.9; max-height: 60vh; overflow-y: auto; }
.page-body img { max-width: 100%; border-radius: 10px; margin: 8px 0; }
.page-body h3 { font-size: 14px; margin: 12px 0 4px; color: var(--gold); }

.text-input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font-size: 14px; margin: 6px 0 10px;
}
.modal-actions { display: flex; gap: 8px; }

/* hidden属性はdisplay指定に必ず勝たせる(display:grid等がhiddenを打ち消す事故の根本対策) */
[hidden] { display: none !important; }

/* ---- ノベルプレイヤー ---- */
#novelLayer {
  position: fixed; inset: 0; z-index: 55; background: #000;
  display: grid; place-items: center;
}
#novelLayer[hidden] { display: none; }
.nv-stage {
  position: relative; overflow: hidden; background: #000;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.nv-fade { opacity: 0; transition: opacity .35s ease; }
.nv-fade.nv-shown { opacity: 1; }

.nv-bg, .nv-still { position: absolute; inset: 0; pointer-events: none; }
.nv-bg-img, .nv-still-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.nv-still { z-index: 3; }

.nv-chars { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.nv-slot {
  position: absolute; bottom: 4%; transform: translateX(-50%);
  height: 62%; transition: opacity .35s ease, filter .3s ease, left .5s ease;
}
.nv-slot.nv-dim { filter: brightness(.4) saturate(.7); } /* 話者以外の暗転(imgのfilter演出と干渉しない) */
.nv-chara-img {
  position: absolute; bottom: 0; left: 50%; translate: -50% 0;
  height: 100%; max-width: none; object-fit: contain;
} /* スロット枠(幅0)を基準に中央へ絶対配置 → 表情差分のクロスフェード中も重なる */

.nv-ui {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px;
  display: flex; gap: 6px; z-index: 5; transition: opacity .25s;
}
/* nv-join-skipはノベル操作列に置くため共通スタイルを使う。本文内のstory-queue-skipとは配置目的が異なる。 */
.nv-ui button {
  border: 1px solid #ffffff44; background: #000000aa; color: #fff;
  font-size: 11px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.nv-box {
  position: absolute; left: 3%; right: 3%; bottom: max(3%, env(safe-area-inset-bottom));
  z-index: 4; background: #0b0d24e6; border: 1px solid #565da877;
  border-radius: 14px; padding: 12px 16px 16px; transition: opacity .25s;
}
.nv-name {
  margin: 0 0 4px; font-size: 13px; font-weight: 900; color: var(--gold);
  letter-spacing: .08em;
}
.nv-text {
  margin: 0; font-size: 15px; line-height: 1.85; color: #f2f3ff;
  white-space: pre-wrap; height: calc(1.85em * 4); overflow: hidden; /* 4行でクリック待ち */
}
.nv-measure {
  position: absolute; inset: 12px 16px auto; visibility: hidden; pointer-events: none;
}
.nv-next {
  position: absolute; right: 14px; bottom: 8px; color: var(--gold); font-size: 12px;
  animation: nvNextBlink 1s ease-in-out infinite;
}
@keyframes nvNextBlink { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
.nv-ui-hidden .nv-box, .nv-ui-hidden .nv-ui { opacity: 0; pointer-events: none; }

.nv-overlay {
  position: absolute; inset: 0; z-index: 6; background: #000000d9;
  padding: 48px 16px 20px; overflow-y: auto; cursor: default;
}
.nv-overlay-title { font-size: 13px; font-weight: 900; color: var(--gold); letter-spacing: .1em; margin: 0 0 10px; }
.nv-overlay-hint { font-size: 11px; color: #ffffff77; text-align: center; margin-top: 14px; }
.nv-log-body { display: flex; flex-direction: column; gap: 10px; }
.nv-log-row b { display: block; font-size: 11px; color: var(--gold); margin-bottom: 2px; }
.nv-log-row p { margin: 0; font-size: 13px; line-height: 1.7; color: #e8e9f7; white-space: pre-wrap; }

.nv-skip-card { display: grid; align-content: center; justify-items: center; text-align: center; }
.nv-synopsis {
  font-size: 13px; line-height: 1.9; color: #e8e9f7; max-width: 340px;
  margin: 0 0 18px; white-space: pre-wrap;
}
.nv-skip-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.nv-open {
  display: inline-block; margin-top: 8px; border: 1px solid var(--gold);
  background: #2a2410; color: var(--gold); font-size: 12px; font-weight: 700;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.nv-open:hover { background: #3a3218; }

/* ---- アクセシビリティ ---- */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .pop, .rcard, .intro-caption { animation-duration: .01s !important; }
  .rcard[data-rarity="SSR"] { animation: dropIn .01s forwards; }
  .star-btn, .intro-art { transition: none; }
  .fx-layer.ssr-fx::before, .fx-layer.ssr-fx::after, .intro-tap, .ach-claim, .rcard.first-get::after, .nv-next { animation: none; }
}

/* ==== v3: ソシャゲ型レイアウト(ホームハブ+下部ナビ)。既存ルールへの上書きはこの節に集約 ==== */
html { background: #0b0d22; height: 100%; }
body {
  display: flex; flex-direction: column;
  max-width: 480px; margin: 0 auto; height: 100dvh; min-height: 0;
  overflow: hidden;
}
@media (min-width: 481px) {
  body { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ヘッダー: 通貨チップ常時表示(bodyがflex化したためwidth/marginも上書き) */
header.top { padding: 10px 12px; gap: 8px; width: 100%; max-width: none; margin: 0; }
.logo { font-size: 15px; letter-spacing: .1em; flex: none; }
.res-chips { margin-left: auto; display: flex; gap: 6px; min-width: 0; align-items: center; }
.chip {
  display: flex; align-items: baseline; gap: 4px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 12px; min-width: 0;
}
.chip-ico { font-size: 11px; color: var(--gold); }
.chip strong { font-size: 13px; }
.chip-coin strong { color: var(--gold); }
.chip small { color: var(--sub); font-size: 9px; overflow: hidden; text-overflow: ellipsis; }

/* 画面ハブ: 1画面ずつ表示、mainがスクロール領域 */
main#screens { flex: 1 1 0; min-height: 0; overflow-y: auto; max-width: none; margin: 0; padding: 0 12px 16px; width: 100%; }
.screen { display: none; }
.screen.on { display: block; }
#screen-home.on { display: flex; flex-direction: column; height: 100%; }
#screen-home { padding: 0; }
main#screens:has(#screen-home.on) { overflow: hidden; padding: 0; }

/* ホーム: 画面全体がタップ採掘。看板キャラ(所持最高レア)を表示 */
.home-stage { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; padding: 0; }
.home-tap {
  position: relative; flex: 1 1 0; min-height: 0; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.home-char {
  position: absolute; inset: 0; margin: auto;
  max-height: 96%; max-width: 92%; object-fit: contain; object-position: bottom;
  pointer-events: none; /* 立ち絵はタップで動かさない(動くのは波紋レイヤー) */
}
.star-btn.with-char { display: none; } /* 立ち絵があるときは✦を出さない(未所持時の中央大ボタンとしてだけ使う) */
.home-tap .star-btn { pointer-events: none; }
.home-stage .pop-layer { z-index: 2; }
.home-stage .mine-hint { flex: none; margin: 0; padding: 6px 0 10px; }

/* 召喚画面 */
.exchange-row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.screen-sub { font-size: 12px; color: var(--sub); letter-spacing: .18em; margin: 22px 0 8px; }

/* 下部ナビ(親指ゾーン) */
.bottom-nav {
  flex: none; display: flex; z-index: 6;
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bn-btn {
  flex: 1 1 0; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 9px; background: none; border: none;
  color: var(--sub); font-size: 10px; letter-spacing: .08em;
  -webkit-tap-highlight-color: transparent;
}
.bn-btn .bn-ico { font-size: 18px; line-height: 1; }
.bn-btn.on { color: var(--gold); }
.bn-btn.on::after {
  content: ""; position: absolute; top: 0; left: 25%; right: 25%;
  height: 2px; background: var(--gold); border-radius: 2px;
}
.bn-btn .tab-badge { position: absolute; top: 3px; left: calc(50% + 8px); }

/* メニュー(低頻度項目のみ)。全サイズでハンバーガー開閉に統一 */
.quick-nav { top: 54px; right: max(10px, calc(50vw - 230px)); box-shadow: 0 10px 30px #000a; }
.quick-nav:not(.open) { display: none; }
.nav-toggle { display: block; }
.quick-nav .account { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; }
.quick-nav .account span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* v3.1: 通貨チップのフル桁表示(タップ切替)と桁あふれ対策 */
.chip { cursor: default; }
.chip-coin { cursor: pointer; }
.chip strong { font-variant-numeric: tabular-nums; }
.chip-coin.long strong { font-size: 11px; }
.chip-coin.long small { display: none; } /* 桁が極端に多い時はレート表示を畳んで幅を確保 */

/* v3.1: ホームキャラ選択 */
.home-pick { left: 18px; bottom: 18px; }
.hp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 38vh; overflow-y: auto; padding: 2px; }
.hp-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 4px 6px; color: var(--ink); font-size: 10px; cursor: pointer;
}
.hp-card.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.hp-card .card-icon, .hp-card .glyph { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
.hp-card span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-variant-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px; }
.hp-variant {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; color: var(--sub); font-size: 10px; cursor: pointer; max-width: 96px;
}
.hp-variant.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); color: var(--ink); }
.hp-variant img { width: 72px; height: 96px; object-fit: cover; object-position: top; border-radius: 6px; }
.hp-variant span { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-place { display: block; margin: 10px auto 20px; }

/* v3.2: ストーリー連続再生の幕間バックドロップ。
   通常UI(〜31)より上、召喚演出(40)・ノベル(55)・dialogトップレイヤーより下。
   画像に差し替える場合はここに background-image を足すだけ(デザイナー調整可) */
.story-backdrop {
  position: fixed; inset: 0; z-index: 35;
  background:
    radial-gradient(1.5px 1.5px at 20% 30%, #ffffff88 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 18%, #ffffff66 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 45% 65%, #ffe9b066 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 80%, #ffffff55 50%, transparent 51%),
    linear-gradient(180deg, #05061a, #10132c 60%, #05061a);
}

/* v3.2: 召喚バナー。画像は assets/banners/summon.webp を置くだけで差し替わる(正方形推奨) */
.summon-banner {
  display: block; width: min(100%, 300px); aspect-ratio: 1 / 1; margin: 0 auto 14px;
  padding: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: var(--panel); cursor: pointer;
}
.summon-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-fallback {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--line); border-radius: 12px;
  color: var(--sub); font-size: 12px; letter-spacing: .18em;
}
.banner-fallback span[aria-hidden] { font-size: 28px; color: var(--gold); }
.banner-fallback[hidden] { display: none; }

/* v3.2: ホーム3層化(最奥=背景イラスト / 中間=波紋 / 前=立ち絵)。タップで動くのは波紋だけ */
.home-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0; pointer-events: none;
}
.home-ripples { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.home-char { z-index: 2; }
.home-tap .star-btn { z-index: 3; }
.home-stage .pop-layer { z-index: 4; }
.ripple {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; border: 2px solid #f6c453aa;
  box-shadow: 0 0 12px #f6c45344 inset;
  animation: rippleOut .55s ease-out forwards;
}
@keyframes rippleOut {
  from { opacity: .9; transform: scale(1); }
  to   { opacity: 0; transform: scale(9); }
}
@media (prefers-reduced-motion: reduce) {
  .ripple { animation-duration: .01s; }
}

/* v2.4: ホーム台詞バルーン。アイコンは✦の上、バルーンはその左に同じ高さで出る */
.home-icon-btn { /* フキダシ・キャラ変更で共用する丸アイコンボタン */
  position: absolute; z-index: 5;
  width: 46px; height: 46px; padding: 9px; border-radius: 50%;
  border: 1px solid var(--gold-deep); background: #141832d9; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.home-icon-btn img { width: 100%; height: 100%; display: block; }
.home-icon-btn:active { transform: scale(.92); }
.home-talk-btn { right: 18px; bottom: 18px; } /* 立ち絵表示時は✦が消えるのでその位置に */
.home-talk-balloon {
  /* 中央寄せはmargin autoで行い、transformはアニメーション専用に空けておく
     (基準transformとanimationが衝突すると上書き地雷を踏むため) */
  position: absolute; left: 0; right: 0; margin: 0 auto; bottom: 92px; z-index: 5;
  width: fit-content; max-width: min(80%, 320px); padding: 10px 14px;
  background: #f8f4ea; color: #2a2416; font-size: 13px; line-height: 1.7;
  border-radius: 14px; border: 1px solid #d8cfae;
  box-shadow: 0 4px 18px #00000055;
  transition: transform .25s ease, opacity .25s ease;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.home-talk-balloon::after { /* フキダシのしっぽ(上のキャラクターへ向ける)。上端基準なので行数が変わってもズレない */
  content: ""; position: absolute; right: 20px; top: -20px;
  border-style: solid; border-width: 21px 0px 0px 13px;
  border-color: transparent transparent transparent #f8f4ea;
}
.home-talk-balloon.pop { animation: balloonPop .18s ease-out; }
@keyframes balloonPop {
  from { opacity: 0; transform: translateY(6px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
.home-talk-balloon.out { opacity: 0; transform: translateX(-110%); }
#homeTalkText { display: block; white-space: pre-line; text-align: left; } /* 台詞テキストの\nで改行できる */
/* 台詞引き直し: フキダシごと短くフェードアウト(.12s)→差し替え→クラスが外れて通常速度(.25s)でフェードイン */
.home-talk-balloon.fading { opacity: 0; transition-duration: .12s; }
@media (prefers-reduced-motion: reduce) {
  .home-talk-balloon, .home-talk-balloon.pop { animation: none; transition: opacity .1s; }
}
