:root {
  --bg: #0d0826;
  --panel: rgba(14, 9, 44, 0.66);
  --line: rgba(255, 255, 255, 0.2);
  --gold: #f6d67a;
  --cyan: #7fe4ff;
  --text: #f4f0ff;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

#flash { position: fixed; inset: 0; background: radial-gradient(circle at 50% 60%, #fff, rgba(255, 255, 255, 0.4) 60%, transparent); opacity: 0; pointer-events: none; z-index: 30; }
#flash.go { animation: flash 0.7s ease-out; }
#flash.bad { background: radial-gradient(circle at 50% 60%, rgba(255, 60, 80, 0.9), rgba(120, 0, 30, 0.35) 65%, transparent); animation: flash 0.6s ease-out; }
#flash.void { background: radial-gradient(circle at 50% 60%, rgba(154, 75, 255, 0.9), rgba(40, 0, 80, 0.4) 65%, transparent); animation: flash 0.6s ease-out; }
@keyframes flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#topbar { position: absolute; top: calc(10px + var(--safe-t)); left: 12px; right: 12px; display: flex; gap: 8px; align-items: center; }
.chip { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 5px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.chip .k { font-size: 10px; letter-spacing: 0.12em; opacity: 0.7; }
.chip b { font-size: 20px; font-variant-numeric: tabular-nums; }
.iconbtn { margin-left: auto; pointer-events: auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(6px); color: rgba(255, 255, 255, 0.85); }
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn .ic-off { display: none; }
.iconbtn.muted .ic-on { display: none; }
.iconbtn.muted .ic-off { display: block; }
.iconbtn.muted { color: rgba(255, 255, 255, 0.45); }

/* 手持ちのマナ（縦並び・各色5つまで） */
#pool { position: absolute; left: 10px; top: calc(62px + var(--safe-t)); display: flex; flex-direction: column; gap: 5px; padding: 8px 10px 8px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#pool { transition: opacity 0.2s; }
body.intro-on #pool { opacity: 0; } /* 次のカードを見せている間は隠す */
.prow { display: flex; align-items: center; gap: 7px; }
.picon { width: 30px; height: 30px; border-radius: 50%; background-size: cover; flex: none; }
.picon.pop { animation: pop 0.35s ease-out; }
.pdots { display: flex; gap: 3px; }
.pdots b { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); transition: background 0.15s, box-shadow 0.15s; }
.pdots b.on { background: var(--c); box-shadow: 0 0 8px 1px var(--c); }
.prow.max .picon { box-shadow: 0 0 10px 3px rgba(255, 240, 160, 0.9); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }

#castText { position: fixed; z-index: 26; pointer-events: none; top: calc(64px + var(--safe-t)); left: 0; right: 0; text-align: center; animation: castPop 1.9s ease-out forwards; }
.ct-main { font-size: clamp(34px, 10vw, 58px); font-weight: 900; letter-spacing: 0.08em; background: linear-gradient(#fff, var(--gold) 55%, #e59b2e); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 14px rgba(255, 220, 120, 0.9)) drop-shadow(0 3px 0 rgba(90, 40, 0, 0.8)); }
@keyframes castPop { 0% { opacity: 0; transform: scale(0.5); } 14% { opacity: 1; transform: scale(1.15); } 26% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px) scale(1.05); } }

#controls { position: absolute; left: 0; right: 0; bottom: calc(22px + var(--safe-b)); display: flex; justify-content: space-between; padding: 0 20px; }
.dir {
  pointer-events: auto; width: clamp(78px, 22vw, 108px); height: clamp(78px, 22vw, 108px); border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); background: radial-gradient(circle at 35% 30%, rgba(160, 200, 255, 0.5), rgba(40, 30, 110, 0.55));
  font-size: 34px; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px); touch-action: manipulation;
}
.dir:active, .dir.press { transform: scale(0.92); background: radial-gradient(circle at 35% 30%, rgba(200, 230, 255, 0.75), rgba(70, 60, 170, 0.7)); }

/* ---------- カードのお披露目 ---------- */
#intro { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: radial-gradient(ellipse at center, rgba(10, 5, 40, 0.6), rgba(10, 5, 40, 0.88)); padding: 12px 8px; animation: fadeIn 0.35s ease-out; cursor: pointer; }
#introTag { font-size: clamp(11px, 3vw, 14px); letter-spacing: 0.4em; color: var(--cyan); text-shadow: 0 0 10px rgba(127, 228, 255, 0.7); }
#introMode { font-size: clamp(26px, 8vw, 44px); font-weight: 900; letter-spacing: 0.08em; color: var(--gold); text-shadow: 0 0 16px rgba(255, 210, 100, 0.7), 0 3px 0 rgba(60, 20, 0, 0.85); margin-bottom: 2px; }
#introMode.all { color: #ff8f7a; text-shadow: 0 0 18px rgba(255, 70, 50, 0.9), 0 3px 0 #4a0a10; animation: allDanger 0.22s steps(2) infinite; }
/* 「ぜんぶ唱えろ！！」はいかにも危険な感じで小刻みに震わせる */
@keyframes allDanger {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); }
  15% { transform: translate(-2px, 1px) rotate(-1.2deg) scale(1.03); }
  30% { transform: translate(2px, -1px) rotate(1deg) scale(1.06); }
  45% { transform: translate(-1px, -1px) rotate(-0.8deg) scale(1.02); }
  60% { transform: translate(2px, 1px) rotate(1.1deg) scale(1.07); }
  75% { transform: translate(-2px, 0) rotate(-1deg) scale(1.03); }
  90% { transform: translate(1px, -1px) rotate(0.6deg) scale(1.05); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

/* 2枚: 横に並べる ／ 3枚: 上に1枚、その下に2枚 */
#introCards { display: grid; justify-content: center; gap: 8px clamp(8px, 3vw, 24px); }
#introCards.n2 { grid-template-columns: repeat(2, auto); --cw: min(40vw, 27vh, 230px); }
#introCards.n3 { grid-template-columns: repeat(2, auto); --cw: min(38vw, 20vh, 230px); column-gap: clamp(20px, 8vw, 44px); }
/* 3枚のときは縦に長くなり「詠唱成功」の表示と被りやすいので、少し下にずらす */
#intro.n3 #introTag { margin-top: 44px; }
#introCards.n3 .bigcard:first-child { grid-column: 1 / span 2; justify-self: center; width: calc(var(--cw) * 0.82); }
.bigcard { margin: 0; width: var(--cw); animation: cardIn 0.6s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.bigcard:nth-child(2) { animation-delay: 0.1s; }
.bigcard:nth-child(3) { animation-delay: 0.2s; }
.bigcard img { width: 100%; aspect-ratio: 488 / 680; border-radius: 4.5% / 3.3%; display: block; box-shadow: 0 0 22px rgba(127, 228, 255, 0.5), 0 8px 22px rgba(0, 0, 0, 0.7); background: #222; }
#intro.all .bigcard img:not(.cost-row) { box-shadow: 0 0 22px rgba(255, 110, 80, 0.7), 0 8px 22px rgba(0, 0, 0, 0.7); }
.bigcard figcaption { display: none; } /* カード名の表示は非表示 */
.bigcard .cost-row { display: block; height: clamp(28px, 7.5vw, 40px); width: auto; aspect-ratio: auto; margin: 8px auto 0; border-radius: 0; box-shadow: none; background: none; }
#countdown { min-height: 1.1em; margin-top: 34px; font-size: clamp(54px, 15vw, 82px); font-weight: 900; color: #fff; text-shadow: 0 0 20px rgba(127, 228, 255, 0.9); }
#countdown.tick { animation: tick 0.9s ease-out; }
/* 2ターン目以降（どちらか／どれか／ぜんぶ）: 1ターン目と同じ、中央に大きく見せる（触れない） */
#intro.big { pointer-events: none; cursor: default; }
#intro.big.out { animation: fadeOut 0.4s ease-in forwards; }
#intro.big #countdown { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(40px) rotate(-6deg) scale(0.7); } to { opacity: 1; transform: none; } }
@keyframes tick { 0% { transform: scale(1.7); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(0.9); opacity: 0.6; } }

/* ---------- タイトル / リザルト ---------- */
.screen { position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; }
#title { justify-content: flex-start; padding-top: max(12vh, calc(28px + var(--safe-t))); gap: 0; background: linear-gradient(rgba(8, 4, 30, 0.1), rgba(8, 4, 30, 0.5) 55%, rgba(8, 4, 30, 0.75)); }
.logo { display: flex; flex-direction: column; align-items: center; gap: 12px; }
h1 { margin: 0; font-size: clamp(38px, 14vw, 92px); font-weight: 900; letter-spacing: 0.04em; line-height: 1.1; white-space: nowrap; color: #fff;
  text-shadow: 0 3px 0 #101b5e, 0 6px 0 #101b5e, 0 9px 0 #0c1548, 0 12px 18px rgba(12, 21, 72, 0.9);
  animation: softBlink 2.8s ease-in-out infinite; }
@keyframes softBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.tagline { margin: 0; font-size: clamp(15px, 4.2vw, 21px); font-weight: 700; text-shadow: 0 2px 8px #000; }
#startBtn { margin-top: clamp(46px, 13vh, 130px); }
.btn { pointer-events: auto; display: inline-block; min-width: 220px; padding: 14px 34px; border-radius: 999px; border: 2px solid #fff3c4; font-size: 20px; font-weight: 900; letter-spacing: 0.1em; color: #3a1d00; text-decoration: none; text-align: center; cursor: pointer;
  background: linear-gradient(#fff2b8, #f5b93c 55%, #e58a1c); box-shadow: 0 6px 0 #9a5410, 0 12px 24px rgba(0, 0, 0, 0.5); transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #9a5410, 0 6px 14px rgba(0, 0, 0, 0.5); }
.btn:disabled { opacity: 0.55; filter: grayscale(0.6); cursor: default; }
.btn.ghost { padding: 12px 30px; font-size: 17px; letter-spacing: 0.06em; color: #fff; border: 2px solid rgba(255, 255, 255, 0.55); background: rgba(20, 14, 60, 0.7); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px); }
.btn.ghost:active { box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45); }
.status { margin: 14px 0 0; min-height: 1.3em; font-size: 12px; color: #ffb0ba; }
.legal { position: absolute; left: 16px; right: 16px; bottom: max(14px, calc(10px + var(--safe-b))); margin: 0; font-size: 10.5px; line-height: 1.65; opacity: 0.75; text-shadow: 0 1px 4px #000; }

#result { background: radial-gradient(ellipse at center, rgba(20, 8, 40, 0.72), rgba(6, 2, 20, 0.92)); overflow-x: hidden; overflow-y: auto; overscroll-behavior: none; justify-content: safe center; animation: fadeIn 0.6s ease-out; touch-action: manipulation; }
#result h2 { margin: 0; font-size: clamp(30px, 9vw, 46px); font-weight: 900; letter-spacing: 0.1em; color: #ff8a9a; text-shadow: 0 0 18px rgba(255, 60, 90, 0.7), 0 3px 0 #4a0a1a; }
#result h2 + .score { margin-top: 6px; }
.score { position: relative; display: flex; align-items: baseline; gap: 10px; }
.score > span { font-size: clamp(64px, 20vw, 104px); font-weight: 900; line-height: 1; color: var(--gold); text-shadow: 0 0 22px rgba(255, 210, 100, 0.65), 0 4px 0 rgba(80, 40, 0, 0.9); }
.score small { font-size: clamp(14px, 4vw, 18px); opacity: 0.9; }

/* 唱えた呪文を横にずらーっと（スワイプ / ドラッグで動かせる。タップで拡大） */
#castBlock { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; margin-top: 2px; }
/* 見出しは左右に細い線を伸ばす（ボタンに見えないように枠は付けない） */
.cast-title { display: flex; align-items: center; gap: 12px; width: min(100%, 320px); font-size: 14px; font-weight: 800; letter-spacing: 0.2em; color: rgba(255, 255, 255, 0.9); text-shadow: 0 2px 6px #000; white-space: nowrap; }
.cast-title::before, .cast-title::after { content: ''; flex: 1 1 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6)); }
.cast-title::after { background: linear-gradient(90deg, rgba(255, 255, 255, 0.6), transparent); }
.cast-strip { display: flex; gap: 10px; width: calc(100% + 40px); max-width: 900px; padding: 6px 20px 10px; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; -webkit-overflow-scrolling: touch; scrollbar-width: none; cursor: grab; }
.cast-strip::-webkit-scrollbar { display: none; }
/* カードを押すと拡大できることを、小さく点滅して知らせる */
.cast-hint { margin-top: -4px; font-size: 15px; font-weight: 700; letter-spacing: 0.1em; color: rgba(255, 255, 255, 0.8); animation: softBlink 1.6s ease-in-out infinite; }
.cast-strip.dragging { cursor: grabbing; }
.cast-strip img { flex: none; height: var(--castH, clamp(140px, 32vh, 260px)); aspect-ratio: 488 / 680; border-radius: 4.5% / 3.3%; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6); background: #222; -webkit-user-drag: none; user-select: none; cursor: pointer; transition: transform 0.12s; }
.cast-strip img:active { transform: scale(0.96); }
.cast-strip::before, .cast-strip::after { content: ''; flex: 0 0 auto; margin: auto; } /* 少数のときは中央寄せ */

/* もう一度遊ぶ の下に 共有・ランキング（グレーで立体感あり）を横に並べ、2つ合わせて もう一度遊ぶ と同じ幅にする */
#retryBtn, #subBtns { width: 280px; max-width: 100%; }
#retryBtn { min-width: 0; padding-left: 0; padding-right: 0; }
#subBtns { display: flex; justify-content: center; gap: 10px; margin-top: 4px; }
/* 広告。中身の大きさに合わせて main.js が iframe の大きさを決める */
.ad-slot { width: 100%; max-width: 728px; }
.ad-slot:empty { display: none; }
.ad-slot iframe { display: block; width: 100%; border: 0; background: transparent; }
.xbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: 1 1 0; min-width: 0;
  padding: 12px 14px; font-size: 14px; letter-spacing: 0.03em; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: linear-gradient(#b9bcc4, #7d818a 55%, #585c64); border-color: #cdd0d6;
  box-shadow: 0 6px 0 #34363b, 0 12px 24px rgba(0, 0, 0, 0.5);
}
.xbtn:active { transform: translateY(4px); box-shadow: 0 2px 0 #34363b, 0 6px 14px rgba(0, 0, 0, 0.5); }
.xbtn .btn-icon { width: 17px; height: 17px; flex: none; }
.xbtn .x-logo { width: 15px; height: 15px; fill: currentColor; }

/* ---------- ランキング（結果画面の順位・名前） ---------- */
/* 「N位にランクイン」は光らせて強調する */
.rank-mine.in { font-size: 24px; font-weight: 900; letter-spacing: 0.06em; color: #fff6cf; animation: rankGlow 1.4s ease-in-out infinite; }
@keyframes rankGlow {
  0%, 100% { text-shadow: 0 0 6px rgba(255, 220, 120, 0.9), 0 0 16px rgba(255, 190, 60, 0.7), 0 2px 0 rgba(90, 40, 0, 0.9); }
  50% { text-shadow: 0 0 10px #fff, 0 0 26px rgba(255, 220, 120, 1), 0 0 44px rgba(255, 170, 40, 0.9), 0 2px 0 rgba(90, 40, 0, 0.9); }
}
/* 名前の入力欄は下線だけのシンプルな形。初期値（匿名◯◯）はプレースホルダーとしてグレーで出す */
.name-form { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 300px; }
.name-form input { flex: 1 1 auto; min-width: 0; padding: 8px 2px; border: none; border-bottom: 1.5px solid rgba(255, 255, 255, 0.55); border-radius: 0; background: transparent; color: #fff; font: inherit; font-size: 16px; font-weight: 700; }
.name-form input::placeholder { color: rgba(255, 255, 255, 0.4); }
.name-form input:focus { outline: none; border-bottom-color: #7fe4ff; }
.name-form button { flex: none; padding: 10px 16px; border: 1.5px solid rgba(255, 255, 255, 0.6); border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: #fff; font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.name-form button:disabled { opacity: 0.5; cursor: default; }
.name-form button { border-color: var(--gold); color: #3a1d00; background: var(--gold); } /* フラット */
/* 「回、呪文を唱えた」の上に付けるバッジ（押すとランキング画面）。ランクインなら金色で斜めに、ランク外なら控えめに */
/* 中央寄せを崩さないよう、行の右上に浮かせる */
.score .rank-badge { position: absolute; right: -8px; top: calc(clamp(64px, 20vw, 104px) * 0.14 - 5px); } /* 数字の上辺あたり */
.rank-badge { padding: 5px 12px; border: 1.5px solid rgba(255, 255, 255, 0.5); border-radius: 999px; background: rgba(20, 14, 60, 0.75); color: #7fe4ff; font: inherit; font-size: 12px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.rank-badge::after { content: ' ›'; }
/* ランクイン: 金色の線で囲むだけのシンプルなボタン。2つの文字を重ねておき（幅は長いほうで固定）、
   出るときはバンと押し付け、あとで「ランキングを見る」にふわっと切り替える（main.js で .swap を付ける） */
.rank-badge.in {
  display: inline-grid; padding: 4px 11px; border: 1px solid rgba(246, 214, 122, 0.7); background: rgba(10, 6, 30, 0.35);
  color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: 0.04em;
  animation: badgeBang 0.42s cubic-bezier(0.3, 0, 0.4, 1) both;
}
.rank-badge.in.swap { animation: badgeBang 0.42s cubic-bezier(0.3, 0, 0.4, 1) both, badgeSwell 1.6s ease-in-out; }
.rank-badge.in > span { grid-area: 1 / 1; text-align: center; transition: opacity 0.9s ease, filter 0.9s ease, transform 0.9s ease; }
.rank-badge.in > .b { opacity: 0; filter: blur(5px); transform: scale(0.94); }
.rank-badge.in.swap > .a { opacity: 0; filter: blur(5px); transform: scale(1.06); }
.rank-badge.in.swap > .b { opacity: 1; filter: none; transform: none; }
/* バン: 衝撃の輪が広がって消える */
.rank-badge.in::after { content: ''; position: absolute; inset: -1px; border: 1px solid var(--gold); border-radius: inherit; pointer-events: none; animation: bangRing 0.6s 0.22s ease-out both; }
.rank-badge:active { transform: scale(0.96); }
@keyframes badgeBang {
  0% { transform: scale(2.6); opacity: 0; }
  50% { transform: scale(0.9); opacity: 1; }
  72% { transform: scale(1.05); }
  100% { transform: none; opacity: 1; }
}
@keyframes bangRing { from { opacity: 0.9; transform: scale(1); } to { opacity: 0; transform: scale(1.35, 1.9); } }
/* フォーン: 切り替わるときに、ふわっと光が満ちて引く */
@keyframes badgeSwell {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 210, 100, 0); background-color: rgba(10, 6, 30, 0.35); }
  45% { box-shadow: 0 0 20px rgba(255, 210, 100, 0.55), inset 0 0 14px rgba(255, 210, 100, 0.35); }
}
.name-status { font-size: 13px; color: #ff9aa8; }
.name-status:empty { display: none; }
#rankMore { flex: none; padding: 10px 22px; border: 1.5px solid var(--gold); border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: var(--gold); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }

/* ---------- ランキング画面 ---------- */
#ranking { z-index: 27; justify-content: flex-start; padding-top: max(28px, calc(16px + var(--safe-t))); background: rgba(6, 2, 20, 0.98); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn 0.25s ease-out; }
#ranking h2 { margin: 0; font-size: 30px; font-weight: 900; letter-spacing: 0.15em; color: var(--gold); text-shadow: 0 0 14px rgba(255, 210, 100, 0.6); }
.rank-mine { font-size: 15px; font-weight: 800; color: #7fe4ff; }
.rank-mine:empty { display: none; }
.rank-hint { margin-top: -8px; font-size: 14px; font-weight: 800; color: #fff; }
.rank-table { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 440px; }
.rank-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1.5px solid rgba(255, 255, 255, 0.35); font-size: 10px; font-weight: 800; letter-spacing: 0; color: rgba(255, 255, 255, 0.7); }
.rank-head .s, .rank-head .m { color: rgba(255, 255, 255, 0.7); }
.rank-list { position: relative; flex: 1 1 auto; width: 100%; margin: 0; padding: 0; overflow-y: auto; list-style: none; -webkit-overflow-scrolling: touch; }
.rank-list li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); font-size: 13px; font-weight: 700; }
/* 自分の行は光らせる */
.rank-list li.mine { background: rgba(127, 228, 255, 0.16); border-radius: 10px; animation: mineGlow 1.4s ease-in-out infinite; }
@keyframes mineGlow {
  0%, 100% { box-shadow: inset 0 0 0 1.5px rgba(127, 228, 255, 0.55), 0 0 8px rgba(127, 228, 255, 0.35); }
  50% { box-shadow: inset 0 0 0 1.5px rgba(200, 245, 255, 0.95), 0 0 18px rgba(127, 228, 255, 0.8); }
}
.rank-list .edit-btn { flex: none; padding: 3px 10px; border: none; border-radius: 999px; background: var(--gold); color: #3a1d00; font: inherit; font-size: 11px; font-weight: 900; cursor: pointer; } /* フラット */
.rank-list .edit-btn:active { transform: scale(0.94); }
.rank-list li.edit { flex-direction: column; gap: 4px; padding: 8px 12px 12px; }
.rank-list li.edit .name-form { max-width: none; }
.rank-head .r, .rank-list .r { flex: none; width: 46px; text-align: right; white-space: nowrap; }
.rank-list .r { color: rgba(255, 255, 255, 0.65); }
.rank-list li.top .r { color: var(--gold); }
.rank-head .n { flex: 1 1 auto; text-align: left; }
.rank-head .s, .rank-list .s, .rank-head .m, .rank-list .m { flex: none; width: 50px; text-align: right; }
.rank-head span { white-space: nowrap; }
.rank-list .m { font-variant-numeric: tabular-nums; color: #7fe4ff; }
.rank-list .n { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.rank-list .s { font-variant-numeric: tabular-nums; color: var(--gold); }
.rank-status { font-size: 14px; color: rgba(255, 255, 255, 0.7); }
#rankClose { flex: none; margin-bottom: max(8px, var(--safe-b)); }
/* 幅の狭い画面では数字の列を詰めて、名前を見えるようにする */
@media (max-width: 360px) {
  .rank-head, .rank-list li { gap: 5px; padding-left: 6px; padding-right: 6px; }
  .rank-list li { font-size: 12px; }
  .rank-head { font-size: 9px; }
  .rank-head .r, .rank-list .r { width: 40px; }
  .rank-head .s, .rank-list .s, .rank-head .m, .rank-list .m { width: 46px; }
  .rank-list .edit-btn { padding: 3px 7px; }
}

/* ---------- 拡大表示 ---------- */
#zoom { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 20px; background: rgba(4, 2, 16, 0.88); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn 0.2s ease-out; cursor: pointer; }
#zoom img { max-width: min(86vw, 420px); max-height: 60vh; width: auto; height: auto; aspect-ratio: 488 / 680; border-radius: 4.5% / 3.3%; box-shadow: 0 0 40px rgba(127, 228, 255, 0.45), 0 14px 40px rgba(0, 0, 0, 0.8); animation: zoomIn 0.25s cubic-bezier(0.2, 1.2, 0.4, 1); }
@keyframes zoomIn { from { transform: scale(0.75); opacity: 0; } to { transform: none; opacity: 1; } }
.zoom-btns { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.zoom-btns .btn { min-width: 250px; }
.zoom-btns .btn.mercari { margin-top: 6px; min-width: 250px; padding: 12px 14px; font-size: 14px; letter-spacing: 0.03em; color: #fff; background: #AD1537; border-color: #fff3c4; /* 枠は「閉じる」と同じ */ box-shadow: 0 6px 0 #7a0e26, 0 12px 24px rgba(0, 0, 0, 0.5); }
.zoom-btns .btn.mercari:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a0e26, 0 6px 14px rgba(0, 0, 0, 0.5); }

/* 背の低い画面では、すき間を詰めて唱えた呪文のカードを大きく残す */
@media (max-height: 680px) { #result { gap: 8px; } .zoom-btns .btn.mercari { margin-top: 0; } } /* メルカリと閉じるの間隔は、もう一度遊ぶと共有の間隔に合わせる */
@media (max-height: 560px) {
  #pool { gap: 2px; padding: 5px 7px; top: calc(54px + var(--safe-t)); }
  .picon { width: 22px; height: 22px; }
  .pdots b { width: 7px; height: 7px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  #title { padding-top: 6vh; }
  #startBtn { margin-top: 18px; }
  #intro { gap: 3px; }
  #introCards.n3 { grid-template-columns: repeat(3, auto); --cw: min(20vw, 30vh, 150px); }
  #introCards.n3 .bigcard:first-child { grid-column: auto; grid-row: auto; order: 2; width: var(--cw); }
  #introCards.n3 .bigcard:nth-child(2) { order: 1; }
  #introCards.n3 .bigcard:nth-child(3) { order: 3; }
  #introCards.n2 { --cw: min(24vw, 32vh, 150px); }
  .screen { gap: 8px; }
  .score > span { font-size: 52px; }
  #zoom img { max-height: 52vh; }
  #zoom { gap: 10px; }
}

.cost i.gen { display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #f2efec, #a8a29c); border: 2px solid #6d6862; color: #222; font-style: normal; font-weight: 900; font-size: 12px; line-height: 1; }
