/*
 * ページ全体の土台（色・文字・配置・ボタン・開封画面）。
 * 袋は pack.css、ボックスと棚は box.css、カードは card.css、カードファイル（図鑑）は binder.css。
 *
 * トーン：夜の書店のコレクター棚。袋やカードと同じ藍の夜に、金と銀の箔をアクセントにする。
 * 他のアプリ（トップの青、book-battle の墨×朱×金、quest-maker のコーラル×ティール）とは混ぜない（CLAUDE.md 7章）。
 */

:root {
  --bp-bg: #0c1120; /* 夜の藍 */
  --bp-bg-2: #172042; /* 光の当たるところ */
  --bp-ink: #eef0f5;
  --bp-muted: #9aa3b8;
  --bp-line: rgba(201, 206, 214, 0.16);
  --bp-surface: rgba(255, 255, 255, 0.04);
  --bp-card: #f7f3ea; /* 紙（カードの内側と同じ） */
  --bp-accent: #e2496a; /* NEW の札 */
  --bp-gold-a: #fff1b8;
  --bp-gold-b: #d4a62a;
  --bp-gold-c: #8a6413;
  --bp-silver-a: #f2f4f7;
  --bp-silver-b: #9aa3b3;
  --font-mincho: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --rarity-n: #9a9482;
  --rarity-r: #3b7bd6;
  --rarity-sr: #9b4fd1;
  --rarity-ssr: #d9a520;
}

[hidden] { display: none !important; }

/* 画面には出さず、読み上げにだけ使う */
.bp-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

* { box-sizing: border-box; }

html {
  background: var(--bp-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, var(--bp-bg-2), transparent 70%),
    radial-gradient(ellipse 60% 40% at 85% 40%, rgba(80, 60, 140, 0.18), transparent 70%),
    var(--bp-bg);
  color: var(--bp-ink);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--bp-gold-a);
  outline-offset: 3px;
}

/* ---- 見出し ---- */
/* ヘッダー：背後に3〜5枚のカードを扇に並べ、中央にロゴ。地には夜空の光を薄く敷く */
.bp-header {
  position: relative;
  isolation: isolate;
  padding: 44px 16px 48px;
  text-align: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 55% at 50% 32%, rgba(240, 198, 80, 0.2), transparent 70%),
    radial-gradient(ellipse 90% 60% at 50% 110%, rgba(61, 107, 179, 0.28), transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 0%, rgba(120, 90, 180, 0.18), transparent 70%),
    radial-gradient(ellipse 50% 40% at 90% 0%, rgba(60, 130, 160, 0.16), transparent 70%),
    linear-gradient(180deg, #121a33 0%, #0d1328 60%, #0b0f20 100%);
}

/* 金の細い罫線。中央に小さな菱形 */
/* 背景：カードの絵をぼかして薄く敷く。下に行くほど消える */
.bp-header::before {
  content: "";
  position: absolute;
  inset: -8% -10% 0;
  z-index: -2;
  background: url("../img/bg/fic1-tall.webp") center / cover no-repeat;
  filter: blur(14px) saturate(1.2);
  opacity: 0.42;
  mask-image: linear-gradient(180deg, #000 30%, transparent 96%);
  pointer-events: none;
}

.bp-header::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(420px, 80%);
  height: 1px;
  translate: -50% 0;
  background: linear-gradient(90deg, transparent, rgba(240, 198, 80, 0.7) 20%, #f6dc8a 50%, rgba(240, 198, 80, 0.7) 80%, transparent);
  z-index: -1;
}

.bp-hero-cards {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.bp-hero-card {
  position: absolute;
  top: 46%;
  left: 50%;
  width: clamp(64px, 14vw, 104px);
  aspect-ratio: 63 / 88;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.5), 0 0 0 1.5px rgba(246, 220, 138, 0.55);
  translate: -50% -50%;
  animation: bp-hero-float 6s ease-in-out infinite;
}

/* 扇の角度と位置。中央の2枚は後ろに、外側の3枚は手前に広がる */
.bp-hero-card.is-1 { --r: -20deg; translate: calc(-50% - min(40vw, 380px)) -40%; z-index: 1; }
.bp-hero-card.is-2 { --r: 20deg; translate: calc(-50% + min(40vw, 380px)) -40%; z-index: 1; }
.bp-hero-card.is-3 { --r: -10deg; translate: calc(-50% - min(22vw, 210px)) -58%; z-index: 2; }
.bp-hero-card.is-4 { --r: 10deg; translate: calc(-50% + min(22vw, 210px)) -58%; z-index: 2; }
.bp-hero-card.is-5 { --r: 0deg; translate: -50% -66%; z-index: 0; opacity: 0.8; }

.bp-hero-card.is-1, .bp-hero-card.is-2, .bp-hero-card.is-3, .bp-hero-card.is-4, .bp-hero-card.is-5 {
  rotate: var(--r);
}

.bp-hero-card.is-2 { animation-delay: -1.5s; }
.bp-hero-card.is-3 { animation-delay: -3s; }
.bp-hero-card.is-4 { animation-delay: -4.5s; }

/* ---- 開いた瞬間の演出 ----
 * 1. カードが下から1枚ずつ配られる（外側から内側へ）
 * 2. ロゴが広がった字間から締まりながら現れ、名札・説明・物語の一行が順に浮かぶ
 * 3. 背景に光の粒がゆっくり舞い上がる
 * 位置は translate / rotate で決めているので、配る動きは transform だけで行う（位置とぶつからない）
 */
.bp-hero-card {
  animation:
    bp-hero-deal 0.9s cubic-bezier(0.2, 1.25, 0.35, 1) both,
    bp-hero-float 6s ease-in-out 1.6s infinite;
}

.bp-hero-card.is-1 { animation-delay: 0.15s, 1.6s; }
.bp-hero-card.is-2 { animation-delay: 0.3s, 0.1s; }
.bp-hero-card.is-3 { animation-delay: 0.45s, -1.4s; }
.bp-hero-card.is-4 { animation-delay: 0.6s, -2.9s; }
.bp-hero-card.is-5 { animation-delay: 0.75s, -4.4s; }

@keyframes bp-hero-deal {
  from { transform: translateY(160px) scale(0.6); opacity: 0; }
  60% { opacity: 1; }
  to { transform: none; opacity: 1; }
}

.bp-kicker,
.bp-title,
.bp-subtitle,
.bp-hero-story,
.bp-total {
  animation: bp-rise 0.8s ease-out both;
}

.bp-kicker { animation-delay: 0.9s; }
.bp-title { animation: bp-title-in 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) 1s both; }
.bp-subtitle { animation-delay: 1.35s; }
.bp-hero-story { animation-delay: 1.6s; }
.bp-total { animation-delay: 1.85s; }

@keyframes bp-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes bp-title-in {
  from { opacity: 0; letter-spacing: 0.45em; }
  to { opacity: 1; letter-spacing: 0.14em; }
}

/* 物語の一行。明朝の小さな文字で、上下に金の点を添える */
.bp-hero-story {
  margin: -6px auto 18px;
  max-width: 22em;
  font-family: var(--font-mincho);
  font-size: 0.85rem;
  line-height: 1.8;
  letter-spacing: 0.06em;
  color: #e3cf96;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9);
}

.bp-hero-story::before,
.bp-hero-story::after {
  content: "✦";
  margin: 0 0.6em;
  font-size: 0.6em;
  vertical-align: middle;
  color: var(--bp-gold-a);
  opacity: 0.8;
}

/* ---- ヘッダーの細部 ----
 * 奥から：紙の質感 → 光の筋（ゆっくり回る）→ 光の粒 → カード → 紋章 → 文字。
 * 四隅に金の飾り、下端に本の背表紙が並ぶ棚。どれも飾りなので aria-hidden
 */

/* 紙の細かい質感 */
.bp-hero-grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.95  0 0 0 0 0.85  0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.07;
  mix-blend-mode: soft-light;
}

/* カードの後ろから差す光の筋。中心から放射状に、ゆっくり回る */
.bp-hero-rays {
  position: absolute;
  left: 50%;
  top: 30%;
  width: 900px;
  height: 900px;
  translate: -50% -50%;
  z-index: -1;
  pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(246, 220, 138, 0.16) 0deg 4deg, transparent 4deg 15deg);
  mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0.6) 22%, transparent 48%);
  opacity: 0;
  animation: bp-rays-in 2.4s ease-out 0.4s forwards, bp-rays-turn 80s linear infinite;
}

@keyframes bp-rays-in {
  to { opacity: 1; }
}

@keyframes bp-rays-turn {
  to { rotate: 360deg; }
}

/* タイトルの後ろの紋章：金の二重の輪と、時計の目盛りのような細い刻み */
.bp-hero-emblem {
  position: absolute;
  left: 50%;
  top: calc(26px + 44px);
  width: 210px;
  height: 210px;
  translate: -50% -50%;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle, rgba(240, 198, 80, 0.12) 0%, transparent 62%),
    repeating-conic-gradient(rgba(246, 220, 138, 0.35) 0deg 0.6deg, transparent 0.6deg 6deg);
  mask-image: radial-gradient(circle, transparent 0 58%, #000 59% 66%, transparent 67% 70%, #000 71% 72%, transparent 73%);
  -webkit-mask-image: radial-gradient(circle, transparent 0 58%, #000 59% 66%, transparent 67% 70%, #000 71% 72%, transparent 73%);
  opacity: 0;
  animation: bp-emblem-in 1.6s ease-out 1s forwards;
}

.bp-hero-emblem::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(246, 220, 138, 0.35), 0 0 0 9px rgba(246, 220, 138, 0.06);
}

@keyframes bp-emblem-in {
  from { opacity: 0; scale: 0.8; }
  to { opacity: 1; scale: 1; }
}

/* 四隅の金の飾り：本の表紙の角金具のような L 字 */
.bp-hero-frame {
  position: absolute;
  inset: 12px;
  z-index: 0;
  pointer-events: none;
  --c: rgba(240, 198, 80, 0.75);
  --l: 26px;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 1.5px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--l) 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 1.5px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 1.5px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) 1.5px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 1.5px var(--l) no-repeat;
}

/* 角の内側の小さな菱形 */
.bp-hero-frame::before,
.bp-hero-frame::after {
  content: "◆";
  position: absolute;
  top: 6px;
  font-size: 7px;
  color: var(--c);
}

.bp-hero-frame::before { left: 6px; }
.bp-hero-frame::after { right: 6px; }

/* 下端の棚：本の背表紙のシルエットが並び、その上に金の罫線（::after） */
.bp-hero-shelf {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  height: 34px;
  z-index: -1;
  pointer-events: none;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='60' viewBox='0 0 600 60'><rect x='0' y='30' width='8' height='30' fill='%2325335c'/><rect x='0' y='36' width='8' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='9' y='17' width='15' height='43' fill='%235b4520'/><rect x='9' y='50' width='15' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='25' y='30' width='13' height='30' fill='%2340242c'/><rect x='39' y='17' width='11' height='43' fill='%231d4446'/><rect x='39' y='23' width='11' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='51' y='30' width='9' height='30' fill='%232c2a3a'/><rect x='61' y='17' width='16' height='43' fill='%234a3123'/><rect x='61' y='50' width='16' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='78' y='30' width='14' height='30' fill='%2333294d'/><rect x='78' y='36' width='14' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='93' y='17' width='12' height='43' fill='%2325335c'/><rect x='106' y='30' width='10' height='30' fill='%235b4520'/><rect x='117' y='17' width='8' height='43' fill='%2340242c'/><rect x='117' y='23' width='8' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='117' y='50' width='8' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='126' y='30' width='15' height='30' fill='%231d4446'/><rect x='142' y='17' width='13' height='43' fill='%232c2a3a'/><rect x='156' y='30' width='11' height='30' fill='%234a3123'/><rect x='156' y='36' width='11' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='168' y='17' width='9' height='43' fill='%2333294d'/><rect x='168' y='50' width='9' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='178' y='30' width='16' height='30' fill='%2325335c'/><rect x='195' y='17' width='14' height='43' fill='%235b4520'/><rect x='195' y='23' width='14' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='210' y='30' width='12' height='30' fill='%2340242c'/><rect x='223' y='17' width='10' height='43' fill='%231d4446'/><rect x='223' y='50' width='10' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='234' y='30' width='8' height='30' fill='%232c2a3a'/><rect x='234' y='36' width='8' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='243' y='17' width='15' height='43' fill='%234a3123'/><rect x='259' y='30' width='13' height='30' fill='%2333294d'/><rect x='273' y='17' width='11' height='43' fill='%2325335c'/><rect x='273' y='23' width='11' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='273' y='50' width='11' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='285' y='30' width='9' height='30' fill='%235b4520'/><rect x='295' y='17' width='16' height='43' fill='%2340242c'/><rect x='312' y='30' width='14' height='30' fill='%231d4446'/><rect x='312' y='36' width='14' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='327' y='17' width='12' height='43' fill='%232c2a3a'/><rect x='327' y='50' width='12' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='340' y='30' width='10' height='30' fill='%234a3123'/><rect x='351' y='17' width='8' height='43' fill='%2333294d'/><rect x='351' y='23' width='8' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='360' y='30' width='15' height='30' fill='%2325335c'/><rect x='376' y='17' width='13' height='43' fill='%235b4520'/><rect x='376' y='50' width='13' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='390' y='30' width='11' height='30' fill='%2340242c'/><rect x='390' y='36' width='11' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='402' y='17' width='9' height='43' fill='%231d4446'/><rect x='412' y='30' width='16' height='30' fill='%232c2a3a'/><rect x='429' y='17' width='14' height='43' fill='%234a3123'/><rect x='429' y='23' width='14' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='429' y='50' width='14' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='444' y='30' width='12' height='30' fill='%2333294d'/><rect x='457' y='17' width='10' height='43' fill='%2325335c'/><rect x='468' y='30' width='8' height='30' fill='%235b4520'/><rect x='468' y='36' width='8' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='477' y='17' width='15' height='43' fill='%2340242c'/><rect x='477' y='50' width='15' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='493' y='30' width='13' height='30' fill='%231d4446'/><rect x='507' y='17' width='11' height='43' fill='%232c2a3a'/><rect x='507' y='23' width='11' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='519' y='30' width='9' height='30' fill='%234a3123'/><rect x='529' y='17' width='16' height='43' fill='%2333294d'/><rect x='529' y='50' width='16' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='546' y='30' width='14' height='30' fill='%2325335c'/><rect x='546' y='36' width='14' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='561' y='17' width='12' height='43' fill='%235b4520'/><rect x='574' y='30' width='10' height='30' fill='%2340242c'/><rect x='585' y='17' width='8' height='43' fill='%231d4446'/><rect x='585' y='23' width='8' height='2' fill='%23c9a24a' opacity='0.55'/><rect x='585' y='50' width='8' height='1.5' fill='%23c9a24a' opacity='0.45'/><rect x='594' y='30' width='15' height='30' fill='%232c2a3a'/></svg>") left bottom / auto 100% repeat-x;
  opacity: 0.55;
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

/* 光の粒：小さな点を何層か散らし、ゆっくり上へ流す */
.bp-hero-dust {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 30%, rgba(255, 238, 190, 0.9), transparent 70%),
    radial-gradient(1.2px 1.2px at 38% 72%, rgba(255, 238, 190, 0.7), transparent 70%),
    radial-gradient(2px 2px at 64% 18%, rgba(255, 226, 150, 0.85), transparent 70%),
    radial-gradient(1.3px 1.3px at 82% 56%, rgba(210, 225, 255, 0.75), transparent 70%),
    radial-gradient(1.8px 1.8px at 26% 88%, rgba(255, 238, 190, 0.6), transparent 70%),
    radial-gradient(1.1px 1.1px at 92% 10%, rgba(210, 225, 255, 0.7), transparent 70%);
  background-size: 220px 260px;
  opacity: 0;
  animation: bp-dust-in 2s ease-out 1.2s forwards, bp-dust-drift 24s linear infinite;
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}

@keyframes bp-dust-in {
  to { opacity: 0.75; }
}

@keyframes bp-dust-drift {
  from { background-position: 0 0; }
  to { background-position: 0 -260px; }
}

/* セクションは、画面に入ったときに下からふわっと出す（app.js の setupReveal） */
.bp-reveal-ready .bp-main > .bp-section {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bp-reveal-ready .bp-main > .bp-section.is-revealed {
  opacity: 1;
  transform: none;
}

/* 棚の箱は、セクションが出たあとに1つずつ並ぶ */
.bp-reveal-ready .bp-section.is-revealed .bp-box-tile {
  animation: bp-rise 0.7s ease-out both;
}

.bp-reveal-ready .bp-section.is-revealed .bp-box-tile:nth-child(2) { animation-delay: 0.12s; }
.bp-reveal-ready .bp-section.is-revealed .bp-box-tile:nth-child(3) { animation-delay: 0.24s; }

@keyframes bp-hero-float {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -6px; }
}

.bp-hero-text {
  position: relative;
  z-index: 1;
  padding-top: 26px;
}

/* 小さな見出し（英字の名札） */
.bp-kicker {
  margin: 0 0 6px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9);
  font-family: var(--font-ui, sans-serif);
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--bp-gold-a);
  opacity: 0.85;
}

/* 袋と同じ、金属の箔押しのロゴ */
.bp-title {
  margin: 0;
  font-family: var(--font-mincho);
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.2;
  background: linear-gradient(180deg, #fff 0%, #d6dbe3 45%, #8f98a8 55%, #e9ecf1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5));
}

/* ロゴの箔押し。光の筋が一度ゆっくり走る */
.bp-title {
  position: relative;
}

.bp-title::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 40%, rgba(255, 255, 255, 0.85) 50%, transparent 60%);
  background-size: 250% 100%;
  background-position: 120% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: bp-title-sheen 5.5s ease-in-out 2.2s infinite;
  pointer-events: none;
}

@keyframes bp-title-sheen {
  0%, 60% { background-position: 120% 0; }
  100% { background-position: -20% 0; }
}

.bp-subtitle {
  margin: 6px 0 18px;
  color: #ece6d4;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.6);
}

.bp-total {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 0.85rem;
  color: var(--bp-muted);
}

.bp-total strong {
  color: var(--bp-ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

/* 集まり具合の細い帯 */
.bp-meter {
  position: relative;
  display: block;
  width: 140px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bp-meter > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--p, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--bp-gold-b), var(--bp-gold-a));
  transition: width 0.4s ease;
}

/* ---- 配置 ---- */
.bp-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.bp-section {
  margin-top: 36px;
}

.bp-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bp-line);
}

.bp-section-title {
  margin: 0;
  font-family: var(--font-mincho);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.bp-section-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--bp-muted);
}

/* ---- ボタン ---- */
/* 主の操作：金の箔のボタン */
.bp-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 12px 26px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--bp-gold-a), var(--bp-gold-b) 60%, #b98a22);
  color: #2a1c03;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 6px 18px rgba(212, 166, 42, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bp-open-btn:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 24px rgba(212, 166, 42, 0.4);
}

.bp-open-btn:active {
  transform: translateY(1px);
}

.bp-open-btn:disabled {
  background: rgba(255, 255, 255, 0.12);
  color: var(--bp-muted);
  box-shadow: none;
  cursor: not-allowed;
}

/* 副の操作：銀の縁のボタン */
.bp-open-btn-box {
  background: rgba(255, 255, 255, 0.06);
  color: var(--bp-ink);
  box-shadow: inset 0 0 0 1px rgba(214, 219, 227, 0.55);
}

.bp-open-btn-box:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

/* ---- 足もと ---- */
.bp-footer {
  margin-top: 48px;
  text-align: center;
}

.bp-reset-btn {
  border: none;
  background: none;
  color: var(--bp-muted);
  font-size: 0.8rem;
  text-decoration: underline;
}

/* ---- 開封画面 ---- */
.bp-opening {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 40%, rgba(40, 52, 96, 0.6), transparent 70%),
    rgba(5, 7, 14, 0.94);
  display: flex;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden; /* 背後の光の筋（.bp-deck-rays）は画面より広いので、横へは出さずに切る */
  z-index: 10;
}

/* align-items: center だと、中身が画面より高いとき上端が切れて戻れない。margin: auto で寄せる */
.bp-opening-inner {
  /* 上から並べる。物語（下に出る）で高さが変わっても、上にあるカードの位置が動かないように。
     PC（下のmedia指定）では、中央に寄せる */
  margin: 0 auto;
  width: 100%;
  max-width: 720px;
  text-align: center;
  color: #fff;
}

.bp-opening-progress {
  margin: 0 0 4px;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: #f3e3c7;
}

.bp-opening-hint {
  margin: 0 0 12px;
  font-size: 0.95rem;
  min-height: 3em; /* 2行ぶん。文が変わって改行しても、カードの位置が動かない */
}

/* 1パック分の結果。スマホは3枚＋2枚（2段目は中央）、広い画面は5枚を横1列。
   開封の舞台（.bp-stage）は中央寄せの縦並びなので、幅を指定しないと中身の幅まで縮んで1列になる */
.bp-opening-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

/* 1枚ずつ、上にレアリティの小さな札。押すと拡大表示で詳しく見られる */
.bp-result-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: calc((100% - 20px) / 3);
  max-width: 180px;
  border-radius: 10px;
  cursor: zoom-in;
  transition: transform 0.15s ease-out;
}

.bp-result-card:hover {
  transform: translateY(-4px);
}

.bp-result-card:focus-visible {
  outline: 2px solid var(--bp-gold-a, #f0c650);
  outline-offset: 4px;
}

@media (min-width: 640px) {
  .bp-result-card {
    width: calc((100% - 40px) / 5);
  }
}

.bp-summary-cards .bp-pocket[data-card-id] {
  cursor: zoom-in;
}

.bp-summary-note {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--bp-muted);
}

.bp-opening-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.bp-sub-btn {
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: transparent;
  color: #fff;
}

.bp-sub-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 箱を開けた結果のまとめ */
.bp-summary {
  width: 100%;
  text-align: left;
}

.bp-summary-lead {
  margin: 0 0 8px;
  text-align: center;
}

.bp-summary-counts {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.bp-summary-counts li {
  min-width: 60px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--rarity-n);
  text-align: center;
}

.bp-summary-counts li.is-r { border-color: var(--rarity-r); }
.bp-summary-counts li.is-sr { border-color: var(--rarity-sr); }
.bp-summary-counts li.is-ssr { border-color: var(--rarity-ssr); }

.bp-summary-counts span {
  display: block;
  font-size: 0.75rem;
}

.bp-summary-title {
  font-size: 0.95rem;
  margin: 0 0 8px;
}

.bp-summary-empty {
  margin: 0;
  font-size: 0.85rem;
}

/* 箱の結果の「新しく手に入れたカード」。スマホでも3列、広い画面は幅に合わせて増やす */
.bp-summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (min-width: 640px) {
  .bp-summary-cards {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
}

/* 物語（全カードのフレーバーテキスト）。開封で表に返ったときと、拡大表示で、カードの下（PC では右横）に出す。
   本のページのように明朝で、行間を広く。数文の短い文章なので、行頭は字下げしない（下げると読みにくい）。上に細い金の線を引き、ゆっくり浮かび上がらせる（余韻のため） */
.bp-story {
  width: min(100%, 26em);
  margin: 16px auto 0;
  padding: 14px 4px 0;
  border-top: 1px solid rgba(231, 191, 85, 0.4);
  color: #e9e4d6;
  font-family: var(--font-mincho);
  font-size: 0.95rem;
  line-height: 2;
  letter-spacing: 0.04em;
  text-align: left;
  animation: bp-story-in 1.2s ease-out both;
}

/* N・R はひと場面だけの短い物語。少し小さく、色も控えめにして、SR・SSR の物語と差をつける */
.bp-story.is-n,
.bp-story.is-r {
  color: #cfc9ba;
  font-size: 0.88rem;
  border-top-color: rgba(214, 219, 227, 0.25);
}

.bp-story.is-ssr {
  color: #f6ecd0;
  border-top-color: rgba(240, 198, 80, 0.75);
  text-shadow: 0 0 18px rgba(240, 190, 80, 0.25);
}

/* 拡大表示では、長い物語でも閉じるボタンが押せるように、高さを抑えてスクロール */
.bp-zoom .bp-story {
  margin-top: 0;
  max-height: 32vh;
  overflow-y: auto;
}

@keyframes bp-story-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bp-story { animation: none; }
}

/* PC：開封画面を広く使い、カードを大きく見せる（高さに合わせて伸ばす） */
@media (min-width: 900px) and (min-height: 640px) {
  .bp-opening {
    padding: 24px 32px;
  }

  /* 物語はカードの右横に出し、縦の高さをカードに回す。
     3列（左の余白・カードの幅・右の余白）にして、カードは常に中央、物語は右の列に置く */
  .bp-opening {
    --deck-w: clamp(240px, 46vh, 400px);
  }

  .bp-opening-inner {
    margin: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--deck-w) minmax(0, 1fr);
    max-width: 1280px;
  }

  .bp-opening-inner > * {
    grid-column: 1 / -1;
  }

  .bp-opening-inner > .bp-stage {
    grid-row: 3;
  }

  .bp-opening-inner > #opening-story {
    grid-row: 3;
    grid-column: 3;
    align-self: center;
    justify-self: start;
    width: auto;
    max-width: 30em;
    margin: 40px 0 0 48px;
  }

  .bp-opening-inner > .bp-opening-actions {
    grid-row: 4;
  }

  .bp-opening-hint {
    font-size: 1.05rem;
  }

  /* 基本の .bp-deck-stage（このファイルの後ろ）より強くするため、.bp-opening から指定する */
  .bp-opening .bp-deck-stage {
    width: var(--deck-w);
  }

  .bp-result-card {
    max-width: 230px;
  }

  .bp-summary-cards {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
  }

  .bp-opening .bp-story {
    font-size: 1.02rem;
  }
}

/* 開封の舞台 */
.bp-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 340px;
  width: 100%;
}

/* めくるカードの山 */
.bp-deck {
  width: 100%;
  display: flex;
  justify-content: center;
}

.bp-deck-stage {
  position: relative;
  width: min(72vw, 240px);
  aspect-ratio: 63 / 88;
}

.bp-deck-stage.is-emerge {
  animation: bp-emerge 0.6s ease-out both;
}

@keyframes bp-emerge {
  from { transform: translateY(40%) scale(0.9); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .bp-hero-card,
  .bp-title::after,
  .bp-kicker,
  .bp-title,
  .bp-subtitle,
  .bp-hero-story,
  .bp-total,
  .bp-hero-dust,
  .bp-hero-rays,
  .bp-hero-emblem {
    animation: none;
  }

  .bp-hero-rays,
  .bp-hero-emblem {
    opacity: 1;
  }

  .bp-hero-dust {
    opacity: 0.6;
  }

  .bp-open-btn,
  .bp-meter > span {
    transition: none;
  }
}

/* スマホ：カードは上の帯に並べ、ロゴと説明は帯の下に置く（重ならない） */
@media (max-width: 640px) {
  .bp-header {
    padding-top: 24px;
  }

  .bp-hero-cards {
    inset: 0 0 auto 0;
    height: 196px;
  }

  .bp-hero-text {
    padding-top: 168px;
  }

  .bp-hero-emblem {
    top: calc(168px + 46px);
    width: 180px;
    height: 180px;
  }

  .bp-hero-card.is-1 { translate: calc(-50% - min(40vw, 170px)) -30%; }
  .bp-hero-card.is-2 { translate: calc(-50% + min(40vw, 170px)) -30%; }
  .bp-hero-card.is-3 { translate: calc(-50% - min(22vw, 96px)) -38%; }
  .bp-hero-card.is-4 { translate: calc(-50% + min(22vw, 96px)) -38%; }
  .bp-hero-card.is-5 { translate: -50% -48%; }
}

/* PC：中央のカードはタイトルの真後ろに来て読みにくいので外し、内側の2枚を少し外へ広げる */
@media (min-width: 641px) {
  .bp-hero-card.is-5 {
    display: none;
  }

  .bp-hero-card.is-3 { translate: calc(-50% - min(25vw, 250px)) -58%; }
  .bp-hero-card.is-4 { translate: calc(-50% + min(25vw, 250px)) -58%; }
}
