/* ガチャ画面の WebGL 演出（gacha.js / gacha-fx.js）。共通UIはクリーム、舞台だけ深いインク */

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 舞台の上の帯: レア度（常設）とスキップ */
.fx-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 48px; }
.fx-badge {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border);
  font: 800 1rem/1 var(--font-heading); font-variant-numeric: tabular-nums;
}
.fx-badge:empty { visibility: hidden; }
.fx-badge { white-space: nowrap; }
.fx-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
.fx-skip, .fx-sound {
  min-height: 48px; padding: 0 16px; border: 1px solid var(--color-border); border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-text); font: 700 0.9375rem/1 var(--font-body); cursor: pointer;
}
.fx-sound[aria-pressed="true"] { border-color: var(--color-teal); color: var(--color-teal); }
.fx-skip:focus-visible, .fx-sound:focus-visible { box-shadow: var(--focus-ring); }
/* 10連の盤面のあいだも、スキップと音は画面の上に固定する */
.fx-top:has(.fx-skip:not([hidden])) {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; margin-inline: -16px; padding: 8px 16px;
  background: var(--color-bg); border-bottom: 1px solid var(--color-border);
}

.fx-stage {
  position: relative; width: min(100%, 480px); margin-inline: auto; height: clamp(320px, 58dvh, 520px);
  overflow: hidden; border-radius: var(--radius-panel); background: var(--color-stage);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
/* 10連の房は、縦スクロールを優先する */
.fx-stage.is-ten { touch-action: pan-y; }
.fx-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: opacity .15s linear; }
.fx-stage.is-fading canvas { opacity: 0; }
.fx-stage .egg-hint { bottom: 16px; }

/* WebGL が使えない・動きを減らす設定のときの、静止した卵 */
.fx-static { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; cursor: pointer; }
.fx-static img { width: 100px; height: 132px; }
.fx-static.is-ten { grid-template-columns: repeat(5, 48px); gap: 12px; }
.fx-static.is-ten img { width: 48px; height: 64px; }

/* 10連の盤面（2列×5行。下の行は縦スクロールで見る） */
.fx-board { position: relative; display: grid; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-panel);
  background: var(--color-surface); border: 1px solid var(--color-border); }
.fx-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fx-cell {
  width: 100%; min-height: 96px; display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto auto;
  align-items: center; column-gap: 12px; padding: 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-bg); color: var(--color-text);
}
.fx-cell img { grid-row: 1 / 4; width: 48px; height: 64px; object-fit: contain; }
.fx-cell-no { font: 500 0.8125rem/1.4 var(--font-body); color: var(--color-muted); }
.fx-cell-star { font: 800 1.125rem/1.2 var(--font-heading); }
.fx-cell-note { font: 700 0.8125rem/1.4 var(--font-body); min-height: 1.4em; }
/* 枠の形でもレア度が分かるように: ★3 単線 / ★4 二重線 / ★5 太線 */
.fx-cell.r4 { border: 3px double var(--color-gold); }
.fx-cell.r5 { border: 2px solid var(--color-violet); box-shadow: inset 0 0 0 2px var(--color-surface), inset 0 0 0 4px var(--color-teal); }
.fx-cell.is-open { cursor: default; background: var(--color-surface); }
.fx-cell:focus-visible { box-shadow: var(--focus-ring); }
.fx-board-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.fx-board .ten-bar { padding-top: 0; }

/* 操作列 */
.fx-controls { display: grid; gap: var(--space-2); }
.fx-note { margin: 0; font-size: 0.8125rem; color: var(--color-muted); text-align: center; }
.fx-toggles { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2) var(--space-4); }
.fx-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 0.875rem; cursor: pointer; }
.fx-toggle input { width: 20px; height: 20px; accent-color: var(--color-primary); }
.fx-toggle:has(input:disabled) { color: var(--color-muted); cursor: default; }
#egg-result-title:focus { outline: none; }

/* ---------- 全画面の演出（豪華版） ---------- */
html.fx-locked, html.fx-locked body { overflow: hidden; }
.fx-overlay {
  position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-rows: auto 1fr; height: 100dvh;
  background: var(--color-stage); animation: fx-fade .24s linear both; transition: opacity .15s linear;
}
.fx-overlay.is-fading { opacity: 0; }
.fx-overlay-bar {
  display: grid; gap: 6px; min-height: 64px; z-index: 100;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 8px; background: var(--color-bg); border-bottom: 1px solid var(--color-border);
}
.fx-overlay-bar .fx-badge { justify-self: start; }
.fx-full { position: relative; overflow: hidden; margin-bottom: env(safe-area-inset-bottom, 0px); }
.fx-full canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.fx-full > * { pointer-events: none; }
.fx-full > .fx-result { pointer-events: auto; }
@keyframes fx-fade { from { opacity: 0; } to { opacity: 1; } }

/* 案内役（人物は加工しない。等比のまま枠に収める） */
.fx-chara { position: absolute; z-index: 20; object-fit: contain; transform-origin: 50% 100%; }
.fx-finger {
  position: absolute; z-index: 21; background: #FFF8EE; filter: drop-shadow(0 0 6px #F6D58A);
  clip-path: polygon(50% 0, 58% 42%, 86% 50%, 58% 58%, 50% 100%, 42% 58%, 14% 50%, 42% 42%);
}
.fx-frame { position: absolute; z-index: 19; }
.fx-frame i { position: absolute; display: block; border-radius: 2px; transform: scale(var(--grow, 1)); }
.fx-frame i:nth-child(1) { left: 8%; top: -10px; width: 72px; height: 2px; background: #C52F60; transform-origin: 0 50%; }
.fx-frame i:nth-child(2) { right: -10px; top: 12%; width: 2px; height: 72px; background: #B77916; transform-origin: 50% 0; }
.fx-frame i:nth-child(3) { right: 8%; bottom: 18%; width: 72px; height: 2px; background: #16796F; transform-origin: 100% 50%; }
.fx-frame i:nth-child(4) { left: -10px; bottom: 30%; width: 2px; height: 72px; background: #7152B8; transform-origin: 50% 100%; }

/* 巨大な確定文字: 塗りクリーム、内縁インク3px、外縁 金（★4）/紫（★5）6px。跳ね返り・回転・色相の循環なし */
.fx-big { position: absolute; z-index: 30; display: grid; justify-items: center; gap: 2px; white-space: nowrap; }
.fx-big-label { display: none; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--color-surface);
  color: var(--color-text); font: 700 0.8125rem/1.4 var(--font-body); }
.fx-big.is-ten .fx-big-label { display: block; }
.fx-big-word { position: relative; display: grid; font: 800 clamp(40px, 14vw, 88px)/1.15 var(--font-heading); letter-spacing: .02em; }
.fx-big[data-stars="5"] .fx-big-word { font-size: clamp(44px, 16vw, 104px); }
.fx-big-word b { grid-area: 1 / 1; font: inherit; }
.fx-big-word .w1 { -webkit-text-stroke: 18px #B77916; color: #B77916; text-shadow: 0 4px 0 #292635; }
.fx-big-word .w2 { -webkit-text-stroke: 6px #292635; color: #292635; }
.fx-big-word .w3 { color: #FFF8EE; }
.fx-big[data-stars="5"] .w1 { -webkit-text-stroke-color: #7152B8; color: #7152B8; }
/* ★4: 金の二重下線 / ★5: 外側四隅の4色の短い帯 */
.fx-big[data-stars="4"] .fx-big-word::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: -10px; height: 10px;
  border-top: 3px solid #B77916; border-bottom: 3px solid #B77916; }
.fx-big[data-stars="5"] .fx-big-word::before, .fx-big[data-stars="5"] .fx-big-word::after {
  content: ""; position: absolute; top: -12px; width: 24px; height: 4px; border-radius: 2px; }
.fx-big[data-stars="5"] .fx-big-word::before { left: -16px; background: #C52F60; box-shadow: 0 calc(1em + 20px) 0 #16796F; }
.fx-big[data-stars="5"] .fx-big-word::after { right: -16px; background: #B77916; box-shadow: 0 calc(1em + 20px) 0 #7152B8; }

/* 台詞（全文を一度に出す） */
.fx-line {
  position: absolute; z-index: 30; margin: 0; max-width: min(320px, calc(100% - 32px)); padding: 12px;
  border-radius: 12px; background: var(--color-bg); color: var(--color-text); font: 500 18px/1.5 var(--font-body); text-align: center;
}
.fx-chip3 {
  position: absolute; z-index: 30; padding: 2px 14px; border-radius: var(--radius-pill); background: var(--color-surface);
  color: var(--color-text); font: 800 32px/1.3 var(--font-heading);
}

/* 結果の案内（栞の小さな静止画。作品画像には重ねない） */
.fx-guide { display: flex; align-items: flex-end; gap: var(--space-2); }
.fx-guide img { width: 80px; height: 120px; object-fit: contain; flex: none; }
.fx-guide-line { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--color-bg);
  border: 1px solid var(--color-border); font-size: 0.9375rem; display: grid; }
.fx-guide-name { font: 700 0.75rem/1.4 var(--font-body); color: var(--color-primary); }

/* 1回の結果: 全画面のまま、開いた卵の位置（舞台の中央）に作品画像を置く。光の演出は画像に重ねない */
.fx-result { position: absolute; inset: 0; z-index: 40; overflow-y: auto; overscroll-behavior: contain; }
.fx-result-inner {
  display: grid; gap: var(--space-3); width: min(100% - 32px, 440px); margin: 0 auto;
  padding-block: 16px calc(24px + env(safe-area-inset-bottom, 0px));
}
.fx-result-inner > #fx-result-badge { justify-self: center; }
.fx-result-media .media { border-radius: 0; animation: fx-fade .3s linear both; }
.fx-result-inner h2 { color: #FFF8EE; font-size: 1.0625rem; line-height: 1.5; }
.fx-result-inner h2:focus { outline: none; }
.fx-result-inner .cta-note, .fx-result-inner .text-link { color: #E6DFD3; }
.fx-result-inner .text-link { justify-self: center; }
.fx-result-inner .button.is-sub { background: var(--color-surface); }
.fx-result-inner .fx-guide-line { background: var(--color-bg); }

/* 10連: 開いたマスは作品画像と★数・タイトル */
.fx-cell.is-open { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 8px; min-height: 0; color: var(--color-text); text-decoration: none; }
.fx-cell.is-open .media { border-radius: 0; }
.fx-cell.is-open .media img { grid-row: auto; width: 100%; height: 100%; object-fit: contain; }
.fx-cell.is-open .card-meta { display: flex; align-items: center; gap: 6px; }
.fx-cell.is-open .card-title { font-size: 0.8125rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fx-board-actions { display: grid; gap: var(--space-2); }
