/* ═══════════════════════════════════════════════════════════════
   屍術師将棋 — Necromancer Shogi
   深黒紫の闇 / 毒光緑(自軍) / 血赤(敵軍) / 魔紫(屍・魔術) / 骨白(文字)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg-deep: #07040d;
  --bg: #0e0918;
  --panel: #161028;
  --panel-2: #1d1533;
  --line: #2e2348;
  --line-lit: #4a3a74;

  --bone: #eae1cd;
  --bone-dim: #a99f8a;
  --ink: #0a0612;

  --venom: #9fe86c;
  --venom-deep: #5da23a;
  --venom-glow: rgba(140, 235, 90, 0.55);

  --blood: #e0475f;
  --blood-deep: #8e2036;
  --blood-glow: rgba(224, 71, 95, 0.55);

  --soul: #b18cff;
  --soul-deep: #6b4fc0;
  --soul-glow: rgba(157, 123, 255, 0.5);

  --gold: #d8b25a;
  --gold-deep: #8a6b25;

  --f-display: 'Shippori Mincho B1', 'Hiragino Mincho ProN', serif;
  --f-body: 'Zen Kaku Gothic New', 'Hiragino Kaku Gothic ProN', sans-serif;
  --f-num: 'Cinzel', serif;

  --cell: min(24vw, 104px);
}

* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  /* touch-action は継承されないため全要素に指定（ダブルタップズーム＝画面ズレの元凶を殺す） */
  touch-action: manipulation;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

/* PWA/スタンドアロンでダブルタップ時にビューポートがずれるのを防ぐ:
   body を固定し、スクロールは #app 内に閉じ込める */
body {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
}

#app {
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

body {
  background:
    radial-gradient(120vw 70vh at 50% -10%, #1b0f33 0%, transparent 60%),
    radial-gradient(90vw 60vh at 85% 110%, #14202c00 0%, #0d1b1466 45%, transparent 75%),
    radial-gradient(70vw 50vh at 8% 100%, #240c2455 0%, transparent 70%),
    var(--bg-deep);
  color: var(--bone);
  font-family: var(--f-body);
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ── 環境演出 ─────────────────────────────── */

.veil {
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background:
    radial-gradient(140% 100% at 50% 45%, transparent 55%, rgba(2, 0, 8, 0.55) 100%);
  mix-blend-mode: multiply;
}

.souls { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.souls i {
  position: absolute;
  width: 5px; height: 5px; border-radius: 50%;
  background: radial-gradient(circle, rgba(177, 140, 255, 0.9), rgba(177, 140, 255, 0));
  filter: blur(0.5px);
  animation: soul-rise 14s linear infinite;
  opacity: 0;
}
.souls i:nth-child(1)  { left: 8%;  animation-delay: 0s;    animation-duration: 15s; }
.souls i:nth-child(2)  { left: 21%; animation-delay: 3.2s;  animation-duration: 12s; width: 3px; height: 3px; }
.souls i:nth-child(3)  { left: 33%; animation-delay: 7.5s;  animation-duration: 17s; }
.souls i:nth-child(4)  { left: 44%; animation-delay: 1.4s;  animation-duration: 13s; width: 7px; height: 7px; }
.souls i:nth-child(5)  { left: 56%; animation-delay: 9s;    animation-duration: 16s; width: 3px; height: 3px; }
.souls i:nth-child(6)  { left: 65%; animation-delay: 5s;    animation-duration: 12.5s; }
.souls i:nth-child(7)  { left: 74%; animation-delay: 11s;   animation-duration: 18s; }
.souls i:nth-child(8)  { left: 84%; animation-delay: 2.2s;  animation-duration: 14s; width: 6px; height: 6px; }
.souls i:nth-child(9)  { left: 92%; animation-delay: 6.6s;  animation-duration: 13.5s; width: 3px; height: 3px; }
.souls i:nth-child(10) { left: 50%; animation-delay: 12.8s; animation-duration: 15.5s; }

@keyframes soul-rise {
  0%   { transform: translateY(104vh) translateX(0); opacity: 0; }
  8%   { opacity: 0.9; }
  60%  { opacity: 0.5; }
  100% { transform: translateY(-6vh) translateX(4vw); opacity: 0; }
}

/* ── 画面共通 ─────────────────────────────── */

#app { position: relative; z-index: 10; min-height: 100dvh; }

.screen {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.screen.hidden, .hidden { display: none !important; }

/* ── ボタン ─────────────────────────────── */

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }

.btn-rune, .btn-ghost {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: min(78vw, 300px);
  padding: 13px 18px 12px;
  border: 1px solid var(--line-lit);
  border-radius: 4px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 0 0 1px #000, 0 6px 18px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(234, 225, 205, 0.07);
  transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.btn-rune::before, .btn-rune::after {
  content: '◆';
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 8px; color: var(--soul-deep);
  transition: color 0.25s;
}
.btn-rune::before { left: 10px; }
.btn-rune::after { right: 10px; }
.btn-rune:hover, .btn-rune:active {
  border-color: var(--soul);
  box-shadow: 0 0 0 1px #000, 0 0 22px var(--soul-glow), inset 0 1px 0 rgba(234, 225, 205, 0.07);
  transform: translateY(-1px);
}
.btn-rune:hover::before, .btn-rune:hover::after { color: var(--soul); }
.btn-ghost { background: transparent; border-color: var(--line); opacity: 0.85; }
.btn-ghost:hover { border-color: var(--bone-dim); opacity: 1; }
button:disabled { opacity: 0.35; pointer-events: none; }

.btn-main { font-family: var(--f-display); font-weight: 700; font-size: 17px; letter-spacing: 0.14em; }
.btn-sub { font-size: 10.5px; color: var(--bone-dim); letter-spacing: 0.08em; }

/* ── タイトル画面 ─────────────────────────── */

.title-box { text-align: center; display: flex; flex-direction: column; align-items: center; }

.title-crest { width: 92px; height: 92px; margin-bottom: 4px; color: var(--soul); filter: drop-shadow(0 0 18px var(--soul-glow)); animation: crest-breathe 5s ease-in-out infinite; }
.title-crest svg { width: 100%; height: 100%; }
.title-crest .bone { fill: currentColor; }
.title-crest .pit { fill: var(--bg-deep); }
.title-crest .crown { fill: var(--gold); }
@keyframes crest-breathe {
  0%, 100% { filter: drop-shadow(0 0 12px var(--soul-glow)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 26px var(--soul-glow)); transform: scale(1.03); }
}

.title-eyebrow { font-family: var(--f-num); font-size: 11px; letter-spacing: 0.5em; color: var(--bone-dim); margin: 8px 0 2px; }

.game-title {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(52px, 17vw, 84px);
  line-height: 1.05;
  letter-spacing: 0.06em;
  background: linear-gradient(178deg, #f4ecd8 20%, #b9a877 45%, #eae1cd 60%, #6f6350 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(177, 140, 255, 0.25);
  margin-bottom: 10px;
}
.title-sep { display: block; font-size: 0.62em; letter-spacing: 0.5em; margin-top: 2px; padding-left: 0.5em; }

.title-tag { font-size: 12.5px; color: var(--bone-dim); letter-spacing: 0.22em; margin-bottom: 34px; }

.menu { display: flex; flex-direction: column; gap: 14px; }

/* ── オンライン受付 ────────────────────────── */

.online-box { width: min(88vw, 360px); display: flex; flex-direction: column; gap: 14px; }
.scr-title { font-family: var(--f-display); font-size: 30px; font-weight: 700; letter-spacing: 0.3em; text-align: center; color: var(--soul); text-shadow: 0 0 18px var(--soul-glow); }
.scr-desc { font-size: 12px; color: var(--bone-dim); text-align: center; line-height: 1.9; margin-bottom: 6px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 11px; letter-spacing: 0.2em; color: var(--bone-dim); }
.field input {
  font-family: var(--f-body); font-size: 16px; color: var(--bone);
  background: var(--panel); border: 1px solid var(--line-lit); border-radius: 4px;
  padding: 12px 14px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus { border-color: var(--soul); box-shadow: 0 0 14px var(--soul-glow); }
/* .deck-select は .app-select と共通スタイル（下部にまとめて定義） */
.modal .field { margin-bottom: 4px; }

.online-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6px; }

.join-status { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 16px; }
.summon-ring {
  width: 74px; height: 74px; border-radius: 50%;
  border: 2px solid transparent;
  background:
    conic-gradient(from 0deg, transparent 8%, var(--soul) 22%, transparent 40%) border-box;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: spin 1.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#join-status-text { font-size: 13px; letter-spacing: 0.15em; color: var(--soul); }

/* ── 対局画面 ─────────────────────────────── */

#screen-game {
  justify-content: flex-start;
  gap: 6px;
  padding-top: max(10px, env(safe-area-inset-top));
  max-width: 520px;
  margin: 0 auto;
}

/* HUD */
.hud { width: 100%; display: flex; align-items: center; gap: 10px; }
.hud-opp { justify-content: space-between; }
.hud-me { justify-content: space-between; align-items: flex-end; margin-top: auto; padding-bottom: max(4px, env(safe-area-inset-bottom)); }

.pl-badge { display: flex; align-items: center; gap: 7px; min-width: 0; }
.pl-face { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-lit); background: var(--panel); }
.pl-face svg { width: 20px; height: 20px; }
.pl-badge.enemy .pl-face { color: var(--blood); box-shadow: 0 0 10px rgba(224, 71, 95, 0.25); }
.pl-badge.me .pl-face { color: var(--venom); box-shadow: 0 0 10px rgba(140, 235, 90, 0.22); }
.pl-face .bone { fill: currentColor; } .pl-face .pit { fill: var(--ink); } .pl-face .crown { fill: var(--gold); }
.pl-name { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.pl-conn { font-size: 9px; color: var(--blood); }

.opp-hand { display: flex; gap: 3px; }
.opp-hand .mini-back { width: 20px; height: 28px; color: var(--soul-deep); }
.opp-hand svg { width: 100%; height: 100%; }

.pl-piles { display: flex; gap: 6px; }
/* 自分側だけ 山札(上)／捨札(下) の縦積みにして、手札に横幅を明け渡す */
.pl-piles.me { flex-direction: column; gap: 5px; }
.pile {
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px; color: var(--bone-dim); letter-spacing: 0.08em;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 3px 7px 3px 4px; background: rgba(22, 16, 40, 0.7);
}
.pile b { font-family: var(--f-num); font-size: 14px; color: var(--bone); }
.pile-meta { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
button.pile:hover { border-color: var(--soul-deep); }

/* 実カードのパイル表示 */
.pile-stack {
  position: relative;
  width: 25px; height: 34px; flex: none;
  border-radius: 3px;
}
.pile-stack::before, .pile-stack::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 3px;
  background: #191230;
  border: 1px solid var(--line);
  z-index: 0;
}
.pile-stack::before { transform: translate(2.5px, 2px); }
.pile-stack::after { transform: translate(1.2px, 1px); }
.pile.empty .pile-stack::before, .pile.empty .pile-stack::after { display: none; }
.pile.empty .pile-stack { border: 1px dashed var(--line); opacity: 0.55; }
.mini-card {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  width: 100%; height: 100%;
  border-radius: 3px;
  border: 1px solid var(--line-lit);
  background: linear-gradient(180deg, #241a44, #150f2a);
}
.mini-card.back { color: var(--soul-deep); }
.mini-card.back svg { width: 86%; height: 90%; }
.mini-card.face svg { width: 68%; height: 68%; filter: drop-shadow(0 0 4px currentColor); }
.mini-card.kind-move { color: var(--venom); }
.mini-card.kind-revive { color: var(--soul); }
.mini-card.kind-tutor { color: var(--gold); }
.pile.empty .mini-card { display: none; }

/* ターン表示 */
.turn-strip {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 2px 2px;
}
.strip-btn { font-size: 17px; color: var(--bone-dim); padding: 4px 9px; border: 1px solid var(--line); border-radius: 3px; }
.turn-label {
  flex: 1;
  text-align: center;
  font-family: var(--f-display); font-weight: 700;
  font-size: 15px; letter-spacing: 0.28em;
  padding: 5px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  color: var(--bone-dim);
  transition: color 0.3s, text-shadow 0.3s;
}
.turn-label.mine { color: var(--venom); text-shadow: 0 0 14px var(--venom-glow); border-color: rgba(140, 235, 90, 0.35); }
.turn-label.theirs { color: var(--blood); border-color: rgba(224, 71, 95, 0.3); }

.timer { position: relative; width: 40px; height: 40px; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer .t-bg { fill: none; stroke: var(--line); stroke-width: 3; }
.timer .t-fg { fill: none; stroke: var(--venom); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 97.4; transition: stroke-dashoffset 0.3s linear, stroke 0.3s; }
.timer.low .t-fg { stroke: var(--blood); }
.timer.low #timer-n { color: var(--blood); animation: timer-pulse 0.8s ease-in-out infinite; }
#timer-n { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-num); font-size: 13px; }
@keyframes timer-pulse { 50% { transform: scale(1.18); } }

/* ── 盤 ─────────────────────────────────── */

.board-frame {
  position: relative;
  padding: 10px;
  border: 1px solid var(--line-lit);
  border-radius: 6px;
  background:
    radial-gradient(140% 120% at 50% 0%, #221741 0%, #150e29 55%, #0e0919 100%);
  box-shadow:
    0 0 0 1px #000,
    0 14px 40px rgba(0, 0, 0, 0.6),
    inset 0 0 34px rgba(107, 79, 192, 0.14);
}
.board-frame::before, .board-frame::after {
  content: '✦';
  position: absolute; font-size: 10px; color: var(--soul-deep);
}
.board-frame::before { top: 3px; left: 8px; }
.board-frame::after { bottom: 3px; right: 8px; }

#board {
  position: relative;
  width: calc(var(--cell) * 3 + 8px);
  height: calc(var(--cell) * 4 + 12px);
}

.cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, var(--cell)); grid-template-rows: repeat(4, var(--cell)); gap: 4px; }

.cell {
  position: relative;
  border-radius: 4px;
  background:
    linear-gradient(158deg, rgba(234, 225, 205, 0.05), transparent 45%),
    linear-gradient(180deg, #1c1530, #151026);
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.cell.king-range { border-color: rgba(157, 123, 255, 0.34); box-shadow: inset 0 0 12px rgba(107, 79, 192, 0.2); }
.cell.king-range::after {
  content: '';
  position: absolute; inset: 4px;
  border: 1px dashed rgba(157, 123, 255, 0.18);
  border-radius: 3px;
  pointer-events: none;
}

/* 移動先ハイライト */
.cell .hl { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 4px; pointer-events: none; }
.cell.hl-move { border-color: var(--venom-deep); cursor: pointer; }
.cell.hl-move .hl::before {
  content: ''; width: 26%; height: 26%; border-radius: 50%;
  background: radial-gradient(circle, var(--venom-glow), transparent 70%);
  border: 2px solid var(--venom);
  animation: hl-pulse 1.2s ease-in-out infinite;
}
.cell.hl-swap { border-color: var(--soul); cursor: pointer; }
.cell.hl-swap .hl::before {
  content: '⇆'; font-size: calc(var(--cell) * 0.3); color: var(--soul);
  text-shadow: 0 0 12px var(--soul-glow);
  animation: hl-pulse 1.2s ease-in-out infinite;
}
.cell.hl-capture { border-color: var(--blood); cursor: pointer; box-shadow: inset 0 0 16px rgba(224, 71, 95, 0.3); }
.cell.hl-capture .hl::before {
  content: ''; width: 52%; height: 52%; border-radius: 50%;
  border: 2px solid var(--blood);
  outline: 1px solid rgba(224, 71, 95, 0.4); outline-offset: 4px;
  animation: hl-pulse 0.9s ease-in-out infinite;
}
@keyframes hl-pulse { 50% { transform: scale(1.14); opacity: 0.75; } }

/* 蘇生可能な屍 */
.cell.hl-revive { border-color: var(--soul); cursor: pointer; box-shadow: inset 0 0 18px rgba(157, 123, 255, 0.35); }

/* ── 駒 ─────────────────────────────────── */

.pieces { position: absolute; inset: 0; pointer-events: none; }

.piece {
  position: absolute;
  width: var(--cell); height: var(--cell);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  pointer-events: auto; cursor: pointer;
  transition: transform 0.38s cubic-bezier(0.22, 1.2, 0.36, 1);
  will-change: transform;
  z-index: 2;
}
.piece .p-disc {
  width: 62%; height: 62%;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 38% 30%, #241b40, #120d22 70%);
  border: 2px solid var(--line-lit);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.65), inset 0 1px 1px rgba(234, 225, 205, 0.1);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.piece svg { width: 68%; height: 68%; }
.piece .bone { fill: currentColor; }
.piece .pit { fill: var(--ink); }
.piece .crown { fill: var(--gold); }

.piece .p-name {
  font-size: calc(var(--cell) * 0.105);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--bone-dim);
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}

.piece.mine { color: var(--venom); }
.piece.mine .p-disc { border-color: rgba(140, 235, 90, 0.5); }
.piece.theirs { color: var(--blood); }
.piece.theirs .p-disc { border-color: rgba(224, 71, 95, 0.5); }
.piece.corpse { color: var(--soul); opacity: 0.92; }
.piece.corpse .p-disc {
  position: relative;
  border-style: dashed; border-color: var(--soul-deep);
  background: radial-gradient(circle at 50% 42%, #1c1433, #0e0a1c 75%);
}
.piece.corpse .p-name { color: var(--soul-deep); }
/* 正体の割れた屍: 倒れた眷属の姿を淡く見せ、死のしるしを重ねる */
.piece.corpse.known-corpse .p-disc svg { opacity: 0.66; filter: grayscale(0.4) brightness(0.9); }
.piece.corpse .corpse-mark {
  position: absolute; right: -9%; bottom: -9%;
  width: 44%; height: 44%;
  display: grid; place-items: center;
  color: #d0bdee;
  background: radial-gradient(circle at 40% 30%, #271c44, #0f0a1d 78%);
  border: 1px solid var(--soul-deep);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.65);
}
.piece.corpse .corpse-mark svg { width: 76%; height: 76%; filter: drop-shadow(0 0 4px rgba(157, 123, 255, 0.35)); }
/* お墓（埋葬屍）: 土色・掘り起こし前 */
.piece.corpse.buried { color: #b58f57; }
.piece.corpse.buried .p-disc {
  border-style: dashed; border-color: #6d5636;
  background: radial-gradient(circle at 50% 58%, #2b2214, #14100a 78%);
}
.piece.corpse.buried .p-name { color: #c0a06c; }
/* 掘り起こし演出: 土から立ち上がる */
.piece.digup { animation: dig-up 0.72s cubic-bezier(0.2, 0.7, 0.3, 1); z-index: 30; }
@keyframes dig-up {
  0%   { transform: var(--pos) translateY(34%) scale(0.55); filter: brightness(2.2); opacity: 0.15; }
  45%  { opacity: 1; }
  70%  { transform: var(--pos) translateY(-6%) scale(1.1); }
  100% { transform: var(--pos) translateY(0) scale(1); filter: none; opacity: 1; }
}

.piece.king .p-disc { width: 70%; height: 70%; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7), 0 0 16px rgba(216, 178, 90, 0.12), inset 0 1px 1px rgba(234, 225, 205, 0.12); }

.piece.promoted .p-name { color: var(--gold); }
.piece.promoted .p-disc { border-color: var(--gold-deep); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.65), 0 0 12px rgba(216, 178, 90, 0.28); }

.piece.selected { z-index: 5; }
.piece.selected .p-disc {
  border-color: var(--venom);
  box-shadow: 0 0 0 2px rgba(140, 235, 90, 0.35), 0 0 22px var(--venom-glow);
}
.piece.card-target .p-disc {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(216, 178, 90, 0.4), 0 0 18px rgba(216, 178, 90, 0.5);
  animation: hl-pulse 1.1s ease-in-out infinite;
}
.piece.buffed::after {
  content: '◈';
  position: absolute; top: 6%; right: 12%;
  font-size: calc(var(--cell) * 0.17);
  color: var(--gold);
  text-shadow: 0 0 8px rgba(216, 178, 90, 0.8);
}

/* 蘇生フリップ */
@keyframes reveal-flip {
  0% { transform: var(--pos) rotateY(90deg) scale(0.8); filter: brightness(2.4); }
  60% { transform: var(--pos) rotateY(0deg) scale(1.12); }
  100% { transform: var(--pos) rotateY(0deg) scale(1); filter: brightness(1); }
}
.piece.revealing { animation: reveal-flip 0.6s ease-out; }

@keyframes promote-flash {
  0% { filter: brightness(1); }
  35% { filter: brightness(2.6) drop-shadow(0 0 18px var(--gold)); }
  100% { filter: brightness(1); }
}
.piece.promoting { animation: promote-flash 0.8s ease-out; }

@keyframes capture-shake {
  0%, 100% { transform: var(--pos) translateX(0); }
  25% { transform: var(--pos) translateX(-4px); }
  75% { transform: var(--pos) translateX(4px); }
}
.piece.captured-anim { animation: capture-shake 0.35s ease-in-out; }

/* ── コンテキストバー・ログ ─────────────────── */

#context-bar {
  width: 100%;
  min-height: 34px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex-wrap: wrap;
}
#context-bar .ctx-hint { font-size: 12px; color: var(--gold); letter-spacing: 0.12em; text-shadow: 0 0 10px rgba(216, 178, 90, 0.35); }
#context-bar .ctx-btn {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.1em;
  padding: 7px 16px;
  border: 1px solid var(--line-lit); border-radius: 3px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
#context-bar .ctx-btn.primary { border-color: var(--soul); color: var(--soul); box-shadow: 0 0 12px rgba(157, 123, 255, 0.3); }
#context-bar .ctx-btn.venom { border-color: var(--venom-deep); color: var(--venom); }

#log {
  width: 100%;
  min-height: 30px; max-height: 44px;
  overflow: hidden;
  display: flex; flex-direction: column-reverse;
  font-size: 10.5px; line-height: 1.5;
  color: var(--bone-dim);
  padding: 0 4px;
}
#log .log-line b { color: var(--bone); }
#log .log-line.important { color: var(--gold); }

/* ── 手札 ─────────────────────────────────── */

#hand {
  flex: 1;
  min-width: 0; /* flexで縮めるために必須。無いと扇がフッターを画面外へ押し出す */
  display: flex; justify-content: center; align-items: flex-end;
  height: 128px;
  padding-bottom: 4px;
  overflow: visible;
}

.card {
  position: relative;
  width: 88px; height: 120px;
  border-radius: 6px;
  border: 1px solid var(--line-lit);
  background:
    linear-gradient(168deg, rgba(234, 225, 205, 0.07), transparent 40%),
    linear-gradient(180deg, #1e1636, #130d24);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 5px 5px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease;
  margin: 0 -7px;
  /* 扇（fan）: 底辺を軸に回転させ、全カードの上端（種別・名前）が必ず覗くようにする。
     --rot / --lift は枚数に応じて JS が各カードへ設定する（1〜6枚に対応）。 */
  transform-origin: 50% 138%;
  transform: rotate(var(--rot, 0deg)) translateY(var(--lift, 0px));
}
.card:hover, .card:active {
  transform: translateY(-16px) scale(1.06) !important;
  z-index: 40;
}
/* タップで最前面へ持ち上げたカード（重なりの中から選んだ1枚）。隣のカードの上端は隠さない */
.card.raised {
  transform: rotate(var(--rot, 0deg)) translateY(calc(var(--lift, 0px) - 16px)) scale(1.05);
  border-color: var(--card-hue, var(--soul));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.7), 0 0 18px var(--card-hue, var(--soul));
}
.card.unplayable { filter: grayscale(0.75) brightness(0.65); }

.card::before {
  content: '';
  position: absolute; inset: 2px;
  border: 1px solid rgba(234, 225, 205, 0.12);
  border-radius: 4px;
  pointer-events: none;
}
.card.kind-move { --card-hue: var(--venom); }
.card.kind-revive { --card-hue: var(--soul); }
.card.kind-tutor { --card-hue: var(--gold); }

.card .c-name {
  font-family: var(--f-display);
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--bone);
  padding: 1px 0 3px;
  width: 100%; text-align: center;
  border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden;
}
/* 長い名前は枠に収まらない時だけ、指定位置(<wbr>)で折り返す（例: アンデッド / 強化薬）。
   word-break: keep-all で語中の不自然な改行を防ぎ、短い名前は1行のまま。 */
.card .c-name.multi { white-space: normal; line-height: 1.12; font-size: 11px; letter-spacing: 0.02em; word-break: keep-all; overflow-wrap: break-word; }
.card .c-art { flex: 1; display: grid; place-items: center; color: var(--card-hue, var(--soul)); width: 100%; }
.card .c-art svg { width: 40px; height: 40px; filter: drop-shadow(0 0 7px currentColor); opacity: 0.95; }
.card .c-text {
  font-size: 8px; line-height: 1.35; color: var(--bone-dim);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 32px;
}
.card .c-kind {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  font-size: 8px; letter-spacing: 0.14em;
  color: var(--ink); background: var(--card-hue, var(--soul));
  border-radius: 2px; padding: 1px 6px;
  font-weight: 700;
}

/* ── モーダル ─────────────────────────────── */

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal-veil { position: absolute; inset: 0; background: rgba(4, 2, 10, 0.82); backdrop-filter: blur(3px); }
.modal-body {
  position: relative;
  width: min(90vw, 380px);
  max-height: 86dvh;
  overflow: auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-lit);
  border-radius: 6px;
  box-shadow: 0 0 0 1px #000, 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(107, 79, 192, 0.15);
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-title { font-family: var(--f-display); font-size: 19px; letter-spacing: 0.24em; text-align: center; color: var(--bone); }
.modal-desc { font-size: 11.5px; color: var(--bone-dim); text-align: center; line-height: 1.7; }
.modal-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.modal-actions.column { flex-direction: column; align-items: center; }
.modal-actions .btn-rune, .modal-actions .btn-ghost { width: auto; min-width: 128px; padding: 10px 20px; }

/* 汎用の選択ダイアログ（魔術リセット等） */
.choice-buttons { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.choice-buttons .btn-rune { width: auto; min-width: 200px; padding: 12px 22px; }

/* 変身薬の変身先選択: アイコン＋進める方向の矢印つき2×2カード */
.choice-buttons.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 12px 10px 10px; min-width: 118px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-lit); border-radius: 12px;
  color: var(--bone); cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.tf-btn:hover, .tf-btn:focus-visible {
  transform: translateY(-2px); border-color: var(--venom); outline: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 14px var(--venom-glow);
}
.tf-btn:active { transform: translateY(0); }
.tf-choice { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tf-disc { --tf-cell: 66px; position: relative; width: var(--tf-cell); height: var(--tf-cell);
  display: grid; place-items: center; color: var(--venom); }
/* コマと同じ円盤（緑＝自軍の眷属） */
.tf-disc::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 60%; height: 60%;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #241b40, #120d22 70%);
  border: 2px solid rgba(140, 235, 90, 0.5);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.55), inset 0 1px 1px rgba(234, 225, 205, 0.1);
}
.tf-disc svg { position: relative; width: 40%; height: 40%; }
.tf-disc .bone { fill: currentColor; }
.tf-disc .pit { fill: var(--ink); }
/* 進める方向の矢印（コマの .dir と同型・円盤サイズ基準） */
.tf-disc .dir {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--tf-cell) * 0.13); height: calc(var(--tf-cell) * 0.11);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  background: var(--venom); opacity: 0.9; pointer-events: none;
  transform: translate(-50%, -50%)
    translate(calc(var(--dx) * var(--tf-cell) * 0.42), calc(var(--dy) * var(--tf-cell) * 0.42))
    rotate(var(--ang));
}
.tf-disc .dir.far {
  opacity: 0.55; width: calc(var(--tf-cell) * 0.1);
  transform: translate(-50%, -50%)
    translate(calc(var(--dx) * var(--tf-cell) * 0.5), calc(var(--dy) * var(--tf-cell) * 0.5))
    rotate(var(--ang));
}
.tf-name { font-family: var(--f-display); font-weight: 700; font-size: 15px; color: var(--bone); }
.tf-hint { font-size: 10.5px; color: var(--bone-dim); letter-spacing: 0.01em; }

/* カード拡大 */
.card-zoom { align-items: center; }
.zoom-card {
  width: 220px;
  border-radius: 10px;
  border: 1px solid var(--line-lit);
  background:
    linear-gradient(168deg, rgba(234, 225, 205, 0.08), transparent 42%),
    linear-gradient(180deg, #221a3e, #140e26);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7);
  padding: 14px 14px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.zoom-card.kind-move { --card-hue: var(--venom); }
.zoom-card.kind-revive { --card-hue: var(--soul); }
.zoom-card.kind-tutor { --card-hue: var(--gold); }
.zoom-card.kind-special, .card.kind-special { --card-hue: var(--blood); }
.zoom-card .z-kind { font-size: 10px; letter-spacing: 0.2em; color: var(--card-hue); font-weight: 700; }
.zoom-card .z-name { font-family: var(--f-display); font-size: 24px; font-weight: 800; letter-spacing: 0.16em; text-align: center; line-height: 1.12; word-break: keep-all; overflow-wrap: break-word; }
.zoom-card .z-art { color: var(--card-hue); padding: 6px 0; }
.zoom-card .z-art svg { width: 84px; height: 84px; filter: drop-shadow(0 0 16px currentColor); }
.zoom-card .z-text { font-size: 13px; line-height: 1.8; color: var(--bone); }
.zoom-card .z-note { font-size: 10.5px; line-height: 1.6; color: var(--blood); border-top: 1px solid var(--line); padding-top: 8px; }
/* 予見: 引く順を選べる札 */
.foresee-card { position: relative; cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.foresee-card:hover { transform: translateY(-3px); }
.foresee-card.picked { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 14px 40px rgba(0, 0, 0, 0.7); }
.foresee-num {
  position: absolute; top: -10px; left: -10px; width: 26px; height: 26px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--gold); color: #140e26; font-weight: 800; font-size: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

/* 墓場の黒猫: 捨札回収モーダル */
.cat-subhead { font-size: 11px; letter-spacing: 0.1em; color: var(--bone-dim); margin: 10px 2px 4px; }
.cat-gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-card {
  position: relative; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1px solid var(--line-lit); border-radius: 8px;
  background: linear-gradient(180deg, #221a3e, #140e26); padding: 8px 4px 6px;
  transition: border-color 0.12s ease, transform 0.1s ease;
}
.cat-card:active { transform: scale(0.96); }
.cat-card .cc-art { color: var(--card-hue, var(--soul)); line-height: 0; }
.cat-card .cc-art svg { width: 28px; height: 28px; filter: drop-shadow(0 0 6px currentColor); }
.cat-card .cc-name { font-family: var(--f-display); font-size: 11px; font-weight: 700; text-align: center; line-height: 1.1; color: var(--bone); word-break: keep-all; overflow-wrap: break-word; }
.cat-card.kind-move { --card-hue: var(--venom); }
.cat-card.kind-revive { --card-hue: var(--soul); }
.cat-card.kind-tutor { --card-hue: var(--gold); }
.cat-card.kind-sorcery, .cat-card.kind-special { --card-hue: var(--blood); }
.cat-card.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.cat-card .cc-mark {
  position: absolute; top: -8px; right: -6px; z-index: 2;
  font-size: 10px; font-weight: 800; letter-spacing: 0.05em;
  color: #140e26; background: var(--gold); border-radius: 5px; padding: 1px 5px;
}
/* 黒猫の気配（駒の演出） */
.piece.catfx .p-disc { animation: cat-glimmer 0.9s ease-in-out; }
@keyframes cat-glimmer {
  0%, 100% { box-shadow: none; }
  40% { box-shadow: 0 0 14px 3px rgba(216, 178, 90, 0.7); filter: brightness(1.4); }
}

/* ピッカー */
.picker-list { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.pick-card {
  width: 96px;
  border: 1px solid var(--line-lit); border-radius: 5px;
  background: linear-gradient(180deg, #1e1636, #130d24);
  padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.pick-card.kind-move { --card-hue: var(--venom); }
.pick-card.kind-revive { --card-hue: var(--soul); }
.pick-card.kind-tutor { --card-hue: var(--gold); }
.pick-card .pk-name { font-family: var(--f-display); font-size: 12px; font-weight: 700; text-align: center; line-height: 1.1; }
.pick-card .pk-art { color: var(--card-hue); }
.pick-card .pk-art svg { width: 34px; height: 34px; }
.pick-card .pk-text { font-size: 8.5px; line-height: 1.4; color: var(--bone-dim); }
.pick-card.selected { border-color: var(--gold); box-shadow: 0 0 14px rgba(216, 178, 90, 0.4); transform: translateY(-3px); }
.pick-card { position: relative; }
.pick-card .pk-order {
  position: absolute; top: -8px; left: -8px;
  width: 22px; height: 22px;
  display: none; place-items: center;
  font-family: var(--f-num); font-size: 12px; font-weight: 700;
  color: var(--ink); background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(216, 178, 90, 0.6);
  z-index: 2;
}
.pick-card.selected .pk-order { display: grid; }
.pick-card.disabled { opacity: 0.35; pointer-events: none; }

/* 結果 */
.result-body { align-items: center; text-align: center; padding: 34px 20px 26px; }
.result-eyebrow { font-family: var(--f-num); font-size: 11px; letter-spacing: 0.5em; color: var(--bone-dim); }
.result-kanji {
  font-family: var(--f-display); font-weight: 800;
  font-size: clamp(76px, 22vw, 104px); line-height: 1.15; letter-spacing: 0.18em; padding-left: 0.18em;
  margin: 6px 0 4px; text-align: center; width: 100%;
}
.result-kanji.win { color: var(--venom); text-shadow: 0 0 34px var(--venom-glow); }
.result-kanji.lose { color: var(--blood); text-shadow: 0 0 34px var(--blood-glow); }
.result-kanji.draw { color: var(--soul); text-shadow: 0 0 34px var(--soul-glow); }
.result-reason { font-size: 12.5px; color: var(--bone-dim); margin-bottom: 16px; letter-spacing: 0.1em; }

/* ═══ 特殊勝利「蝙蝠の支配」演出 ═══════════════════════════════ */
/* 全画面オーバーレイ（盤の上・モーダルの下）: 血の月 + 羽ばたく群れ + 羽ばたきの闇 */
.bat-fx { position: fixed; inset: 0; z-index: 99; pointer-events: none; overflow: hidden; }

.bat-fx .bat-moon {
  position: absolute; left: 50%; top: 30%;
  width: min(70vw, 360px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%,
    #efe6ff 0%, #cbb0ff 26%, rgba(150,90,190,0.7) 50%, rgba(110,40,90,0.3) 72%, transparent 80%);
  box-shadow: 0 0 90px 30px rgba(150,95,210,0.4);
  filter: blur(0.5px); opacity: 0;
  animation: bat-moon-rise 2.4s cubic-bezier(0.18, 0.9, 0.24, 1) forwards;
}
.bat-fx.is-lose .bat-moon {
  background: radial-gradient(circle at 50% 45%,
    #ffe6e6 0%, #ff9aa8 26%, rgba(200,60,80,0.7) 50%, rgba(120,25,45,0.3) 72%, transparent 80%);
  box-shadow: 0 0 90px 30px rgba(210,60,80,0.4);
}
@keyframes bat-moon-rise {
  0%   { opacity: 0; transform: translate(-50%, -14%) scale(0.4); }
  34%  { opacity: 1; }
  100% { opacity: 0.72; transform: translate(-50%, -50%) scale(1); }
}

/* 巨大な翼が横切るような全画面の暗転パルス */
.bat-fx .bat-wingbeat {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 130% 84% at 50% 38%, transparent 28%, rgba(4,2,10,0.92) 100%);
  opacity: 0; animation: bat-wingbeat 1.45s ease-in-out 2;
}
@keyframes bat-wingbeat { 0%, 100% { opacity: 0; } 50% { opacity: 0.72; } }

/* 蝙蝠1羽: 外側=飛行(travel)、内側SVG=羽ばたき(flap) */
.bat-sprite {
  position: absolute; bottom: -8vh;
  width: clamp(26px, 6.4vw, 62px); aspect-ratio: 64 / 34; opacity: 0;
  animation-name: bat-fly; animation-timing-function: ease-in; animation-fill-mode: both;
  will-change: transform, opacity;
  filter: drop-shadow(0 0 7px rgba(160,110,240,0.65));
}
.bat-fx.is-lose .bat-sprite { filter: drop-shadow(0 0 7px rgba(224,71,95,0.6)); }
/* 闇に沈まないよう、月光を受けた霊的な紫のシルエットにする（魔紫の世界観に合わせる） */
.bat-sprite .bat-wings {
  display: block; width: 100%; height: 100%; fill: #8a6fca;
  transform-origin: 50% 46%;
  animation: bat-flap var(--flap, 0.22s) ease-in-out infinite;
}
.bat-fx.is-lose .bat-sprite .bat-wings { fill: #c06277; }
@keyframes bat-fly {
  0%   { opacity: 0; transform: translate3d(0, 8vh, 0) rotate(var(--r0, 0deg)) scale(var(--s, 1)); }
  10%  { opacity: var(--op, 0.8); }
  84%  { opacity: var(--op, 0.8); }
  100% { opacity: 0; transform: translate3d(var(--dx, 0), -94vh, 0) rotate(var(--r1, 0deg)) scale(var(--s, 1)); }
}
@keyframes bat-flap { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(0.4) scaleY(1.06); } }

/* 決着モーダルの専用意匠（月光の紋章タブロー） */
.result-body.bat-dominion { position: relative; overflow: hidden; }
.result-body.bat-dominion::before {
  content: ''; position: absolute; left: 50%; top: 30px;
  width: 260px; height: 260px; transform: translate(-50%, -32%);
  background: radial-gradient(circle, rgba(185,135,255,0.34), transparent 62%);
  pointer-events: none; z-index: 0; animation: bat-crest-glow 3.6s ease-in-out infinite;
}
@keyframes bat-crest-glow { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
.result-body.bat-dominion > * { position: relative; z-index: 1; }
.result-crest {
  width: 108px; height: 58px; margin: 2px auto -2px;
  animation: bat-crest-in 0.9s cubic-bezier(0.2, 1.1, 0.3, 1) both;
}
.result-crest svg { display: block; width: 100%; height: 100%; }
.result-crest .bat-wings { fill: #cbb0ff; filter: drop-shadow(0 0 12px rgba(180,130,255,0.85)); }
.result-body.bat-dominion.lose .result-crest .bat-wings { fill: #ff9aa8; filter: drop-shadow(0 0 12px rgba(224,71,95,0.85)); }
.result-crest .crest-flap { transform-origin: 50% 46%; animation: bat-crest-flap 2.6s ease-in-out infinite; }
@keyframes bat-crest-flap { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(0.86); } }
@keyframes bat-crest-in { 0% { opacity: 0; transform: translateY(8px) scale(0.7); } 100% { opacity: 1; transform: none; } }
.result-body.bat-dominion .result-eyebrow { color: var(--soul); }
.result-body.bat-dominion .result-kanji.win {
  color: #d9c2ff; text-shadow: 0 0 30px rgba(180,130,255,0.7), 0 0 62px rgba(120,40,120,0.4);
}
.result-body.bat-dominion .result-reason { color: #b79ce8; }

@media (prefers-reduced-motion: reduce) {
  .bat-fx .bat-wingbeat { animation: none; }
  .bat-sprite, .result-crest, .result-crest .crest-flap, .result-body.bat-dominion::before { animation: none; }
}

/* 特殊勝利の注釈チップ（ターンバー内・普段は控えめ／押すと解説） */
.strip-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; letter-spacing: 0.06em; line-height: 1;
  color: var(--soul);
  border: 1px solid var(--soul-deep);
  background: rgba(157, 123, 255, 0.1);
  border-radius: 999px; padding: 3px 9px 3px 7px; white-space: nowrap;
  animation: chip-breathe 2.8s ease-in-out infinite;
}
.strip-chip span { font-family: var(--f-body); font-weight: 700; }
.strip-chip .chip-bat { display: inline-flex; width: 15px; height: 12px; }
.strip-chip .chip-bat svg { width: 100%; height: 100%; }
@keyframes chip-breathe { 50% { box-shadow: 0 0 10px rgba(157, 123, 255, 0.5); border-color: var(--soul); } }
/* 睡眠中ステータス（効果が切れるまで常時表示） */
.strip-chip.sleep-chip {
  color: #8fb7ff; border-color: rgba(96, 140, 220, 0.6);
  background: rgba(70, 100, 180, 0.14); cursor: default;
}
@keyframes sleep-chip-breathe { 50% { box-shadow: 0 0 10px rgba(120, 160, 240, 0.5); border-color: #7fa0e0; } }
.strip-chip.sleep-chip { animation: sleep-chip-breathe 2.8s ease-in-out infinite; }

/* カード相互参照リンク（「睡眠薬」等） */
.card-link {
  display: inline; padding: 0 1px; margin: 0;
  font: inherit; color: var(--gold); background: none; border: none;
  border-bottom: 1px dashed currentColor; cursor: pointer;
}
.card-link:hover { filter: brightness(1.2); }

/* カード参照の吹き出し */
#card-popover {
  position: fixed; z-index: 4000; display: none;
  border: 1px solid var(--line-lit); border-radius: 10px;
  background: linear-gradient(180deg, #241b40, #150f27);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.75);
  padding: 10px 12px 12px; color: var(--bone);
}
#card-popover.show { display: block; }
#card-popover .cp-head { font-family: var(--f-display); font-weight: 800; font-size: 15px; letter-spacing: 0.08em; display: flex; align-items: baseline; gap: 8px; word-break: keep-all; overflow-wrap: break-word; }
#card-popover .cp-kind { font-size: 10px; letter-spacing: 0.2em; color: var(--gold); }
#card-popover .cp-text { margin-top: 6px; font-size: 12px; line-height: 1.7; }

/* カード一覧の特殊カード見出し */
.gallery-subhead {
  grid-column: 1 / -1; margin: 14px 2px 2px;
  font-size: 11px; letter-spacing: 0.12em; color: var(--blood);
  border-top: 1px solid var(--line); padding-top: 10px;
}

/* 睡眠薬を引いた瞬間の全画面演出（瞼が閉じる） */
#sleep-fx { position: fixed; inset: 0; z-index: 5000; pointer-events: none; opacity: 0; }
#sleep-fx.show { opacity: 1; }
#sleep-fx .sleep-fx-veil {
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 50%, transparent 30%, rgba(20, 26, 60, 0.55) 100%);
  opacity: 0;
}
#sleep-fx.show .sleep-fx-veil { animation: sleep-veil 2.6s ease-in-out forwards; }
@keyframes sleep-veil { 0% { opacity: 0; } 30% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
#sleep-fx .sleep-fx-lid {
  position: absolute; left: 0; right: 0; height: 55%;
  background: linear-gradient(180deg, #0a0c1c, #12162e);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}
#sleep-fx .sleep-fx-top { top: 0; transform: translateY(-100%); }
#sleep-fx .sleep-fx-bot { bottom: 0; transform: translateY(100%); }
#sleep-fx.show .sleep-fx-top { animation: sleep-lid-top 2.6s ease-in-out forwards; }
#sleep-fx.show .sleep-fx-bot { animation: sleep-lid-bot 2.6s ease-in-out forwards; }
@keyframes sleep-lid-top { 0%,10% { transform: translateY(-100%); } 40%,72% { transform: translateY(-10%); } 100% { transform: translateY(-100%); } }
@keyframes sleep-lid-bot { 0%,10% { transform: translateY(100%); } 40%,72% { transform: translateY(10%); } 100% { transform: translateY(100%); } }
#sleep-fx .sleep-fx-text {
  position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%);
  text-align: center; font-family: var(--f-display); font-size: 24px; letter-spacing: 0.3em;
  color: #a9c4ff; text-shadow: 0 0 20px rgba(120, 160, 240, 0.7); opacity: 0;
}
#sleep-fx.show .sleep-fx-text { animation: sleep-text 2.6s ease-in-out forwards; }
@keyframes sleep-text { 0%,20% { opacity: 0; } 45%,68% { opacity: 1; } 100% { opacity: 0; } }

/* 睡眠薬を引いた段階演出: ①札を引く ②強制発動 → その後 #sleep-fx へ引き継ぐ */
#sleep-draw {
  position: fixed; inset: 0; z-index: 5200; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(60% 60% at 50% 50%, rgba(20, 26, 60, 0.5), rgba(6, 8, 20, 0.82));
}
#sleep-draw.hidden { display: none; }
#sleep-draw .sd-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
#sleep-draw .sd-label {
  font-family: var(--f-display); font-size: 20px; letter-spacing: 0.14em;
  color: #a9c4ff; text-shadow: 0 0 18px rgba(120, 160, 240, 0.6); text-align: center;
}
#sleep-draw .zoom-card { width: 190px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.8), 0 0 34px rgba(120, 160, 240, 0.35); }
#sleep-draw .zoom-card .z-name { font-size: 21px; }
#sleep-draw .zoom-card .z-art svg { width: 64px; height: 64px; }
#sleep-draw .zoom-card .z-text { font-size: 11.5px; }
/* ①引く: 下からせり上がって出現 */
#sleep-draw.sd-draw .sd-wrap { animation: sd-draw-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes sd-draw-in { 0% { transform: translateY(46px) scale(0.9); opacity: 0; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
/* ②強制発動: 赤く脈打ち、揺れる */
#sleep-draw.sd-force .sd-label { color: var(--blood); text-shadow: 0 0 20px rgba(224, 71, 95, 0.7); }
#sleep-draw.sd-force .zoom-card { animation: sd-force 0.9s ease-in-out; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.8), 0 0 40px rgba(224, 71, 95, 0.6); }
@keyframes sd-force {
  0% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.08) rotate(-1.5deg); }
  50% { transform: scale(1.05) rotate(1.5deg); }
  70% { transform: scale(1.07) rotate(-1deg); }
  100% { transform: scale(1) rotate(0); }
}

/* ターン切り替わりの中央バナー */
#turn-banner {
  position: fixed; inset: 0; z-index: 5100; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
#turn-banner.hidden { display: none; }
#turn-banner .tb-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 54px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(12, 10, 26, 0.9), rgba(8, 6, 18, 0.82));
  border: 1px solid rgba(120, 100, 180, 0.28);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
#turn-banner .tb-text {
  font-family: var(--f-display); font-size: 34px; letter-spacing: 0.2em; font-weight: 700;
  color: var(--bone);
  white-space: nowrap; /* 「あなたのターン」の「ン」だけ改行されるのを防ぐ */
  margin-right: -0.2em; /* 末尾字間ぶんを相殺して中央に見せる */
}
#turn-banner .tb-sub { font-size: 13px; letter-spacing: 0.1em; color: var(--bone-dim); }
#turn-banner.mine .tb-text { color: var(--venom); text-shadow: 0 0 22px var(--venom-glow); }
#turn-banner.mine .tb-inner { border-color: rgba(140, 235, 90, 0.35); }
#turn-banner.theirs .tb-text { color: var(--soul); text-shadow: 0 0 22px var(--soul-glow); }
#turn-banner.theirs .tb-inner { border-color: rgba(157, 123, 255, 0.32); }
#turn-banner.asleep .tb-text { color: #a9c4ff; text-shadow: 0 0 22px rgba(120, 160, 240, 0.6); }
#turn-banner.show .tb-inner { animation: tb-pop 1.1s ease-in-out both; }
@keyframes tb-pop {
  0% { transform: scale(0.86) translateY(8px); opacity: 0; }
  16% { transform: scale(1) translateY(0); opacity: 1; }
  74% { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(1.02) translateY(-4px); opacity: 0; }
}

/* 死神のターン終了: 紫光の大斧が周囲8マス(3×3)をぐるりと薙ぎ払い、通過後に敵眷属がばたっと屍化する */
.reaper-sweep {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--cell) * 3); height: calc(var(--cell) * 3);
  transform: translate(-50%, -50%);
  pointer-events: none; z-index: 60;
  color: var(--soul); /* 死の紫光 */
  filter: drop-shadow(0 0 5px var(--soul-glow)) drop-shadow(0 0 15px rgba(157, 123, 255, 0.55));
}
.reaper-sweep svg { width: 100%; height: 100%; overflow: visible; }
.reaper-sweep .rs-blade { fill: currentColor; stroke: #efe6ff; stroke-width: 1; stroke-linejoin: round; }
.reaper-sweep .rs-haft { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; opacity: 0.9; }
/* 大斧が中心を軸にぐるりと一周（グルッと） */
.reaper-sweep .rs-axe { transform-origin: 50px 50px; animation: rs-orbit 0.95s cubic-bezier(0.4, 0, 0.25, 1) forwards; }
@keyframes rs-orbit {
  0%   { transform: rotate(-100deg) scale(0.35); opacity: 0; }
  14%  { transform: rotate(-42deg) scale(1); opacity: 1; }
  86%  { opacity: 1; }
  100% { transform: rotate(280deg) scale(1.08); opacity: 0; }
}
/* 刃を追う紫光の輪（一周ぶんが描かれていく） */
.reaper-sweep .rs-trail {
  fill: none; stroke: currentColor; stroke-width: 4.5; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  animation: rs-trail 0.95s linear forwards;
}
@keyframes rs-trail {
  0%   { stroke-dashoffset: 100; opacity: 0; }
  14%  { opacity: 0.6; }
  80%  { opacity: 0.55; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
/* 中心の脈動 */
.reaper-sweep .rs-core { fill: currentColor; transform-origin: 50px 50px; animation: rs-core 0.55s ease-out forwards; }
@keyframes rs-core {
  0%   { transform: scale(0.2); opacity: 0.85; }
  100% { transform: scale(1.8); opacity: 0; }
}
/* 締めの衝撃波（一周し終える頃に広がる） */
.reaper-sweep .rs-ring { fill: none; stroke: currentColor; stroke-width: 2; transform-origin: 50px 50px; opacity: 0; animation: rs-ring 0.6s ease-out 0.68s forwards; }
@keyframes rs-ring {
  0%   { transform: scale(0.55); opacity: 0.7; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* 被害眷属: 斧が回る間は生前の姿で立ち（不吉に震え）、通過後に「ばたっ」と倒れて屍化する */
.reaper-doomed { opacity: 0 !important; } /* 屍を一旦隠す（立像オーバーレイの下に） */
.reaper-ghost {
  position: absolute; width: var(--cell); height: var(--cell);
  display: flex; align-items: center; justify-content: center;
  transform: var(--pos); transform-origin: 50% 76%;
  pointer-events: none; z-index: 4; will-change: transform, opacity;
  animation: reaper-tremble 0.5s ease-in-out infinite;
}
.reaper-ghost.mine { color: var(--venom); }
.reaper-ghost.theirs { color: var(--blood); }
.reaper-ghost .p-disc {
  width: 62%; height: 62%; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 38% 30%, #241b40, #120d22 70%);
  border: 2px solid currentColor;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.65), 0 0 8px rgba(157, 123, 255, 0.25);
}
.reaper-ghost svg { width: 68%; height: 68%; }
.reaper-ghost .bone { fill: currentColor; }
.reaper-ghost .pit { fill: var(--ink); }
.reaper-ghost .crown { fill: var(--gold); }
@keyframes reaper-tremble {
  0%, 100% { transform: var(--pos) rotate(0deg); }
  25%      { transform: var(--pos) rotate(-1.6deg); }
  75%      { transform: var(--pos) rotate(1.6deg); }
}
.reaper-ghost.fell { animation: reaper-fell 0.5s cubic-bezier(0.4, 0.05, 0.7, 1) forwards; }
@keyframes reaper-fell {
  0%   { transform: var(--pos) rotate(0deg) scale(1); opacity: 1; filter: none; }
  55%  { opacity: 1; }
  100% { transform: var(--pos) rotate(76deg) translateY(12%) scale(0.82); opacity: 0; filter: brightness(0.5) hue-rotate(-40deg); }
}
/* 屍がその場に沈み込むように現れる */
.piece.reaper-rise { animation: reaper-rise 0.5s ease-out; }
@keyframes reaper-rise {
  0%   { opacity: 0; transform: var(--pos) scale(0.78); }
  55%  { opacity: 1; }
  100% { opacity: 0.92; transform: var(--pos) scale(1); }
}

/* 特殊勝利の解説モーダル */
.special-body { width: min(90vw, 360px); text-align: center; padding: 24px 20px 18px; }
.special-body .sp-eyebrow { font-family: var(--f-num); font-size: 10px; letter-spacing: 0.4em; color: var(--soul); }
.special-body .sp-title {
  font-family: var(--f-display); font-weight: 800; font-size: 21px; color: var(--bone);
  letter-spacing: 0.12em; margin: 4px 0 14px;
}
.special-body .sp-title-bat { display: inline-block; width: 24px; height: 15px; margin-right: 8px; color: var(--soul); vertical-align: -1px; }
.special-body .sp-title-bat svg { width: 100%; height: 100%; }
.special-body .sp-chars { display: flex; justify-content: center; gap: 22px; margin-bottom: 14px; }
.special-body .sp-char { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.special-body .sp-icon { width: 52px; height: 52px; color: var(--soul); }
.special-body .sp-icon svg { width: 100%; height: 100%; filter: drop-shadow(0 0 8px rgba(157, 123, 255, 0.6)); }
.special-body .sp-lbl { font-size: 11px; color: var(--bone-dim); letter-spacing: 0.08em; }
.special-body .sp-text { font-size: 12.5px; line-height: 1.85; color: var(--bone-dim); text-align: left; margin-bottom: 14px; }
.special-body .sp-text b { color: var(--bone); }
.special-body .sp-count { color: var(--soul); font-weight: 700; }

/* ヘルプ */
.help-body { width: min(92vw, 420px); }
.help-scroll { overflow-y: auto; max-height: 58dvh; font-size: 12.5px; line-height: 1.9; color: var(--bone-dim); padding-right: 6px; }
.help-scroll h4 {
  font-family: var(--f-display); font-size: 14.5px; color: var(--soul);
  letter-spacing: 0.2em; margin: 16px 0 6px;
  border-bottom: 1px solid var(--line); padding-bottom: 3px;
}
.help-scroll h4:first-child { margin-top: 0; }
.help-scroll b { color: var(--bone); }
.help-scroll .rule-important { color: var(--blood); font-weight: 700; }
.help-scroll table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 4px 0; }
.help-scroll td, .help-scroll th { border: 1px solid var(--line); padding: 4px 6px; text-align: left; }
.help-scroll th { color: var(--bone); font-weight: 700; background: rgba(46, 35, 72, 0.4); }

/* トースト */
#toast {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%);
  z-index: 200;
  background: rgba(20, 10, 16, 0.95);
  border: 1px solid var(--blood);
  color: var(--bone);
  font-size: 12.5px; letter-spacing: 0.06em;
  padding: 10px 18px;
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(224, 71, 95, 0.35);
  animation: toast-in 0.25s ease-out;
  max-width: 84vw; text-align: center;
}
#toast.info { border-color: var(--soul); box-shadow: 0 0 20px rgba(157, 123, 255, 0.35); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* ── 進行方向の矢印（初心者ガイド） ─────────── */

.piece .dir {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--cell) * 0.115);
  height: calc(var(--cell) * 0.1);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  background: currentColor;
  opacity: 0.42;
  pointer-events: none;
  transform: translate(-50%, -50%)
    translate(calc(var(--dx) * var(--cell) * 0.395), calc(var(--dy) * var(--cell) * 0.395))
    rotate(var(--ang));
}
.piece .dir.far {
  opacity: 0.26;
  width: calc(var(--cell) * 0.09);
  transform: translate(-50%, -50%)
    translate(calc(var(--dx) * var(--cell) * 0.485), calc(var(--dy) * var(--cell) * 0.485))
    rotate(var(--ang));
}
.piece.selected .dir, .piece.card-target .dir { opacity: 0.85; }
/* 屍の可動矢印は「蘇生後の予告」。倒れた眷属の可動域が読み取れる程度に表示 */
.piece.corpse .dir { opacity: 0.42; }
.piece.corpse.selected .dir, .piece.corpse.card-target .dir { opacity: 0.75; }

/* ── 公開済みの屍 ───────────────────────── */

.p-known {
  position: absolute;
  right: -6%; top: -8%;
  width: 46%; height: 46%;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #2a1f4d, #140e26 78%);
  border: 1px solid var(--soul-deep);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.p-known svg { width: 72%; height: 72%; opacity: 0.9; }
.piece .p-disc { position: relative; }
.piece .p-name.known { color: var(--soul); }

/* ── 王手（チェック）演出 ─────────────────── */

@keyframes check-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(224, 71, 95, 0.55), 0 0 18px var(--blood-glow); }
  50% { box-shadow: 0 0 0 5px rgba(224, 71, 95, 0.25), 0 0 34px var(--blood-glow); }
}
.piece.in-check .p-disc {
  border-color: var(--blood);
  animation: check-pulse 0.9s ease-in-out infinite;
}
.piece.threat .p-disc {
  border-color: var(--blood);
  box-shadow: 0 0 0 2px rgba(224, 71, 95, 0.4), 0 0 16px var(--blood-glow);
}
.piece.threat::before {
  content: '⚔';
  position: absolute; top: 2%; left: 8%;
  font-size: calc(var(--cell) * 0.16);
  color: var(--blood);
  text-shadow: 0 0 8px var(--blood-glow);
  z-index: 3;
}
@keyframes danger-breathe {
  0%, 100% { box-shadow: 0 0 0 1px #000, 0 14px 40px rgba(0, 0, 0, 0.6), inset 0 0 34px rgba(224, 71, 95, 0.18); }
  50% { box-shadow: 0 0 0 1px #300, 0 14px 40px rgba(0, 0, 0, 0.6), inset 0 0 52px rgba(224, 71, 95, 0.34), 0 0 26px rgba(224, 71, 95, 0.22); }
}
.board-frame.danger {
  border-color: var(--blood-deep);
  animation: danger-breathe 1.4s ease-in-out infinite;
}
#context-bar .ctx-hint.danger { color: var(--blood); text-shadow: 0 0 12px var(--blood-glow); font-weight: 700; }
#context-bar .ctx-hint.gold { color: var(--gold); }

/* 敵王を討てるマス（決着の一手） */
@keyframes kingcap-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}
.cell.hl-capture-king { border-color: var(--gold); box-shadow: inset 0 0 22px rgba(216, 178, 90, 0.4), 0 0 18px rgba(224, 71, 95, 0.35); }
.cell.hl-capture-king .hl::before {
  content: '☠';
  width: auto; height: auto;
  border: none; outline: none;
  font-size: calc(var(--cell) * 0.42);
  color: var(--gold);
  text-shadow: 0 0 14px var(--blood), 0 0 26px var(--gold);
  animation: kingcap-pulse 0.8s ease-in-out infinite;
}

/* ── 直前の手のマーカー ───────────────────── */

.cell.last-from { box-shadow: inset 0 0 0 2px rgba(216, 178, 90, 0.22); }
.cell.last-to { box-shadow: inset 0 0 0 2px rgba(216, 178, 90, 0.5), inset 0 0 16px rgba(216, 178, 90, 0.16); }
.cell.last-to::before {
  content: '';
  position: absolute; top: 3px; right: 3px;
  width: 7px; height: 7px;
  background: var(--gold);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  opacity: 0.85;
}

/* ── バフ付与エフェクト ───────────────────── */

@keyframes buff-ring {
  0% { box-shadow: 0 0 0 0 rgba(216, 178, 90, 0.85); }
  100% { box-shadow: 0 0 0 calc(var(--cell) * 0.42) rgba(216, 178, 90, 0); }
}
.piece.buff-flash .p-disc { animation: buff-ring 0.9s ease-out 2; }

/* ── カード使用フラッシュ演出 ─────────────── */

#card-flash {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  pointer-events: none;
  background: radial-gradient(60vw 60vh at 50% 46%, rgba(20, 8, 34, 0.72), rgba(4, 2, 10, 0.25) 70%, transparent);
}
#card-flash .cf-inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: cf-pop 1.7s ease-in-out both;
}
@keyframes cf-pop {
  0% { opacity: 0; transform: translateY(20px) scale(0.82); }
  12% { opacity: 1; transform: translateY(0) scale(1.02); }
  18% { transform: scale(1); }
  82% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.96); }
}
#card-flash .cf-label {
  font-family: var(--f-display);
  font-size: 16px; font-weight: 700; letter-spacing: 0.24em;
  color: var(--blood);
  text-shadow: 0 0 16px var(--blood-glow), 0 2px 4px #000;
}
#card-flash .zoom-card { width: 190px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.8), 0 0 34px rgba(157, 123, 255, 0.3); }
#card-flash .zoom-card .z-name { font-size: 21px; }
#card-flash .zoom-card .z-art svg { width: 64px; height: 64px; }
#card-flash .zoom-card .z-text { font-size: 11.5px; }

/* ── グローバルメニュー（ハンバーガー） ───────── */

.global-menu-btn {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 60;
  width: 44px; height: 44px;
  font-size: 20px; color: var(--bone-dim);
  border: 1px solid var(--line-lit); border-radius: 6px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 0 0 1px #000, 0 6px 16px rgba(0, 0, 0, 0.5);
  transition: color 0.2s, border-color 0.2s;
}
.global-menu-btn:hover { color: var(--soul); border-color: var(--soul); }

/* ── カスタマイズ設定 ─────────────────────── */

.custom-scroll {
  overflow-y: auto; max-height: 38dvh;
  display: flex; flex-direction: column; gap: 8px;
  padding-right: 6px;
}
.cf-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12.5px; color: var(--bone);
  border-bottom: 1px solid var(--line);
  padding: 6px 2px;
}
.cf-row .cf-label { letter-spacing: 0.06em; }
.cf-row .cf-note { font-size: 10px; color: var(--bone-dim); }
.cf-num {
  display: flex; align-items: center; gap: 8px;
}
.cf-num button {
  width: 30px; height: 30px;
  font-size: 16px; color: var(--bone);
  border: 1px solid var(--line-lit); border-radius: 4px;
  background: var(--panel);
}
.cf-num button:active { border-color: var(--soul); }
.cf-num b { font-family: var(--f-num); font-size: 15px; min-width: 28px; text-align: center; }
.cf-section {
  font-family: var(--f-display); font-size: 12.5px; color: var(--soul);
  letter-spacing: 0.2em; margin-top: 6px;
}

.custom-save-row { display: flex; gap: 8px; }
.custom-save-row input, .acc-form input {
  flex: 1; min-width: 0;
  font-family: var(--f-body); font-size: 14px; color: var(--bone);
  background: var(--panel); border: 1px solid var(--line-lit); border-radius: 4px;
  padding: 10px 12px; outline: none;
}
.custom-save-row input:focus, .acc-form input:focus { border-color: var(--soul); }
.custom-btn { width: auto; padding: 8px 14px; flex: none; }

/* セグメント選択（時間設定など・固定の少数選択肢） */
.cf-seg-row { flex-wrap: wrap; gap: 8px; }
.cf-seg { display: flex; gap: 6px; }
.seg-btn {
  min-width: 52px; padding: 7px 10px;
  font-family: var(--f-num); font-size: 13px; color: var(--bone-dim);
  background: var(--panel); border: 1px solid var(--line-lit); border-radius: 5px;
}
.seg-btn.on {
  color: var(--ink); background: var(--soul);
  border-color: var(--soul); box-shadow: 0 0 12px var(--soul-glow);
}

/* テーマに合わせたプルダウン（select） */
.app-select, .deck-select {
  font-family: var(--f-body); font-size: 14px; color: var(--bone);
  background: var(--panel); border: 1px solid var(--line-lit); border-radius: 5px;
  padding: 10px 34px 10px 12px; outline: none; width: 100%;
  appearance: none; -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--soul) 50%),
    linear-gradient(135deg, var(--soul) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.app-select:focus, .deck-select:focus { border-color: var(--soul); box-shadow: 0 0 12px var(--soul-glow); }
.app-select option, .deck-select option { background: var(--bg-deep, #14101f); color: var(--bone); }

/* 並び替え行（カード一覧） */
.sort-row { display: flex; align-items: center; gap: 10px; }
.sort-label { font-size: 11.5px; letter-spacing: 0.1em; color: var(--bone-dim); flex: none; }

/* カード種別の色（魔法＝血の赤。他は既存の move/revive/tutor を踏襲） */
.mini-card.kind-sorcery { color: var(--blood); }
.card.kind-sorcery { --card-hue: var(--blood); }
.zoom-card.kind-sorcery { --card-hue: var(--blood); }
.pick-card.kind-sorcery { --card-hue: var(--blood); }

/* カード種別チップ（移動／蘇生／魔法／補助） */
.kind-chip {
  display: inline-block; flex: none;
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--ink); border-radius: 3px; padding: 1px 6px;
  background: var(--soul);
}
.kind-chip.kind-move { background: var(--venom); }
.kind-chip.kind-revive { background: var(--soul); }
.kind-chip.kind-tutor { background: var(--gold); }
.kind-chip.kind-sorcery { background: var(--blood); }

/* ── デッキ編集の行（アイコン＋名前＋種別チップ＋説明＋枚数） ── */
.deck-edit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid transparent; border-bottom-color: var(--line);
  border-radius: 6px;
  padding: 8px 8px 8px 6px;
  opacity: 0.5; transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.deck-edit-row.kind-move { --row-hue: var(--venom); }
.deck-edit-row.kind-revive { --row-hue: var(--soul); }
.deck-edit-row.kind-tutor { --row-hue: var(--gold); }
.deck-edit-row.kind-sorcery { --row-hue: var(--blood); }
/* 採用中（1枚以上）: くっきり点灯させて選んだカードが一目で分かるように */
.deck-edit-row.has {
  opacity: 1;
  border-color: color-mix(in srgb, var(--row-hue) 45%, transparent);
  border-left: 3px solid var(--row-hue);
  padding-left: 6px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--row-hue) 12%, transparent), transparent 70%);
}
.deck-edit-row.has .der-name { color: #fff; }
.deck-edit-row.has .cf-num b { color: var(--row-hue); }
.der-info { display: flex; align-items: flex-start; gap: 9px; min-width: 0; flex: 1; }
.der-icon {
  flex: none; width: 30px; height: 30px; margin-top: 1px;
  display: grid; place-items: center;
  color: var(--card-hue, var(--soul));
}
.der-icon.kind-move { --card-hue: var(--venom); }
.der-icon.kind-revive { --card-hue: var(--soul); }
.der-icon.kind-tutor { --card-hue: var(--gold); }
.der-icon.kind-sorcery { --card-hue: var(--blood); }
.der-icon svg { width: 26px; height: 26px; filter: drop-shadow(0 0 5px currentColor); }
.der-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.der-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.der-name {
  font-family: var(--f-display); font-size: 13px; font-weight: 700;
  letter-spacing: 0.05em; color: var(--bone);
}
.der-text { font-size: 10px; line-height: 1.45; color: var(--bone-dim); }
.custom-btn .btn-main { font-size: 13px; }

/* ── デッキ管理カード（かんばん風・タイトルは折り返して全文表示） ── */
.deck-list { gap: 10px !important; }
.deck-card {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--line-lit); border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  padding: 10px 12px;
}
.dc-head { display: flex; flex-direction: column; gap: 3px; }
.dc-title {
  font-family: var(--f-display); font-size: 14.5px; font-weight: 700;
  letter-spacing: 0.04em; color: var(--bone);
  overflow-wrap: anywhere; line-height: 1.3;
}
.dc-meta { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--bone-dim); }
.dc-owner::before { content: '👤 '; }
.dc-count { color: var(--gold); }
.dc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.dc-btn {
  font-size: 11px; letter-spacing: 0.06em; color: var(--bone-dim);
  border: 1px solid var(--line-lit); border-radius: 4px;
  padding: 6px 12px; background: transparent;
}
.dc-btn:hover { color: var(--bone); border-color: var(--bone-dim); }
.dc-btn.apply { color: var(--venom); border-color: var(--venom-deep); }
.dc-btn.danger { color: var(--blood); border-color: var(--blood-deep); }

/* ── メニューの「タイトルへ」退出ボタン（対局へ戻ると明確に差別化） ── */
.btn-exit {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 13px 18px 12px;
  color: var(--blood);
  background: color-mix(in srgb, var(--blood) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--blood) 45%, transparent);
  border-radius: 4px; letter-spacing: 0.1em;
}

/* 対局中メニュー・終了確認: 縦並びボタンの幅とフォントを統一（テキスト長で横幅がバラつくのを防ぐ） */
#modal-menu .modal-actions.column > button,
#modal-confirm-quit .modal-actions.column > button {
  width: min(80vw, 300px); min-width: 0;
}
#modal-menu .modal-actions.column .btn-main,
#modal-confirm-quit .modal-actions.column .btn-main {
  font-family: var(--f-display); font-weight: 700; font-size: 17px; letter-spacing: 0.14em;
}

/* 終了確認モーダル */
.confirm-body { align-items: center; text-align: center; padding: 26px 22px 20px; }
.confirm-text { font-family: var(--f-display); font-size: 16.5px; color: var(--bone); letter-spacing: 0.06em; line-height: 1.6; }
.confirm-sub { font-size: 12px; color: var(--bone-dim); margin: 6px 0 18px; letter-spacing: 0.08em; }
/* チャレンジ限定の補足（クリア済みステージから再開できる旨）。上の「対局は終了します。」に寄せる */
.confirm-note { margin-top: -12px; color: var(--soul); }
.confirm-note.hidden { display: none; }
.btn-exit:hover { color: #fff; background: color-mix(in srgb, var(--blood) 22%, transparent); }
.btn-exit .btn-exit-ico { font-size: 15px; line-height: 1; }
.btn-exit .btn-main { font-size: 13px; }

/* 終了確認: OK / キャンセルを同じ大きさで横並び（左=OK・赤枠 / 右=キャンセル） */
/* grid の 1fr×2 で両ボタンを完全に同サイズにする（テキスト長に左右されない） */
#modal-confirm-quit .confirm-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  width: 100%; max-width: 320px; margin: 0 auto;
}
#modal-confirm-quit .confirm-actions > button {
  width: auto; min-width: 0; max-width: none; align-items: center; justify-content: center;
}
#modal-confirm-quit .confirm-actions .btn-main {
  font-family: var(--f-display); font-weight: 700; font-size: 16px; letter-spacing: 0.12em;
}

/* ── ドラフトの左上「戻る（☰）」 ── */
.pg-back {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 34px); left: 16px; z-index: 5;
  width: 40px; height: 40px; font-size: 20px; line-height: 1;
  color: var(--bone); background: rgba(10, 7, 18, 0.6);
  border: 1px solid var(--line-lit); border-radius: 6px;
  display: grid; place-items: center;
}
.pg-back:hover { color: var(--soul); border-color: var(--soul); }

.custom-presets { display: flex; flex-direction: column; gap: 6px; }
.preset-row {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 10px;
  font-size: 12.5px;
}
.preset-row.active { border-color: var(--gold); box-shadow: 0 0 10px rgba(216, 178, 90, 0.25); }
.preset-row .preset-name { flex: 1; color: var(--bone); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-row button {
  font-size: 11px; letter-spacing: 0.08em; color: var(--bone-dim);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 4px 10px;
}
.preset-row button.apply { color: var(--venom); border-color: var(--venom-deep); }
.preset-row button:hover { color: var(--bone); }

/* ── マイページ ───────────────────────────── */

.acc-form { display: flex; gap: 8px; margin: 8px 0; }
.acc-divider { font-size: 11px; color: var(--bone-dim); text-align: center; margin: 14px 0 2px; letter-spacing: 0.1em; }
.acc-skip { text-align: center; margin-top: 14px; }
.acc-skip button { font-size: 11.5px; color: var(--bone-dim); text-decoration: underline; }
.acc-name {
  font-family: var(--f-display); font-size: 22px; font-weight: 700;
  text-align: center; letter-spacing: 0.14em;
  color: var(--soul); text-shadow: 0 0 14px var(--soul-glow);
  margin-bottom: 12px;
}
.acc-stats { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 14px; }
.acc-stats th, .acc-stats td { border: 1px solid var(--line); padding: 7px 6px; text-align: center; }
.acc-stats th { color: var(--bone-dim); font-weight: 700; background: rgba(46, 35, 72, 0.4); }
.acc-stats td { font-family: var(--f-num); font-size: 15px; color: var(--bone); }

/* ── 屍ドラフト（開始前セレモニー） ─────────── */

#pregame {
  position: fixed; inset: 0; z-index: 96;
  display: grid; place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background:
    radial-gradient(80vw 70vh at 50% 40%, #1a1030 0%, #0c0718 55%, #06040e 100%);
}
.pg-inner {
  width: min(94vw, 440px);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center;
}
.pg-eyebrow { font-family: var(--f-num); font-size: 10px; letter-spacing: 0.42em; color: var(--bone-dim); }
.pg-title {
  font-family: var(--f-display); font-weight: 800;
  font-size: 34px; letter-spacing: 0.24em; padding-left: 0.24em;
  color: var(--soul); text-shadow: 0 0 24px var(--soul-glow);
  margin: 2px 0 4px;
}
.pg-sub { font-size: 12px; line-height: 1.9; color: var(--bone-dim); letter-spacing: 0.06em; margin-bottom: 14px; }
.pg-sub b { color: var(--gold); }

.pg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  margin-bottom: 16px;
}
.pg-grid.dimmed { opacity: 0.4; pointer-events: none; }

.pg-tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 7px;
  border: 1px solid var(--line-lit);
  background:
    linear-gradient(168deg, rgba(234, 225, 205, 0.06), transparent 45%),
    linear-gradient(180deg, #1d1536, #120c24);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  display: grid; place-items: center;
  color: var(--soul-deep);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.5s ease;
}
.pg-tile .pg-grave { width: 58%; height: 58%; display: grid; place-items: center; }
.pg-tile .pg-grave svg { width: 100%; height: 100%; }
.pg-tile .pg-glyph {
  position: absolute; bottom: 5px; right: 7px;
  font-family: var(--f-num); font-size: 12px; color: var(--soul-deep); opacity: 0.7;
}
.pg-tile:hover { transform: translateY(-3px); border-color: var(--soul); }
.pg-tile.sel {
  transform: translateY(-5px) scale(1.04);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6), 0 0 20px rgba(216, 178, 90, 0.5);
}
.pg-tile.sel::after {
  content: '✦';
  position: absolute; top: 4px; left: 6px;
  font-size: 11px; color: var(--gold);
}
.pg-tile.fade { opacity: 0.12; transform: translateY(6px) scale(0.94); }

.pg-foot { display: flex; align-items: center; gap: 16px; }
.pg-count { font-family: var(--f-num); font-size: 15px; letter-spacing: 0.14em; color: var(--bone-dim); }
.pg-ok { width: auto; min-width: 140px; }
.pg-timer {
  min-width: 40px;
  font-family: var(--f-num); font-size: 17px; letter-spacing: 0.06em;
  color: var(--soul);
  border: 1px solid var(--line-lit); border-radius: 20px;
  padding: 4px 12px;
  text-align: center;
}
.pg-timer.low { color: var(--blood); border-color: var(--blood-deep); animation: timer-pulse 0.8s ease-in-out infinite; }

/* ── ドラフト戦（共有プールから交互に1枚ずつ取る） ── */
#draft {
  position: fixed; inset: 0; z-index: 96;
  display: flex; justify-content: center; align-items: flex-start;
  overflow-y: auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  background:
    radial-gradient(80vw 70vh at 50% 30%, #1a1030 0%, #0c0718 55%, #06040e 100%);
}
.draft-inner {
  width: min(96vw, 760px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center;
}
.draft-head {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 2px 0 6px;
}
.draft-turn {
  font-size: 14px; letter-spacing: 0.06em; color: var(--bone-dim);
}
.draft-turn.mine { color: var(--gold); }
.draft-turn b { color: var(--soul); }
.draft-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: 100%;
}
@media (min-width: 620px) {
  .draft-cols { grid-template-columns: 1.4fr 1fr; align-items: start; }
}
.draft-sub {
  font-family: var(--f-num); font-size: 11px; letter-spacing: 0.14em;
  color: var(--bone-dim); text-align: left; margin: 6px 0 4px;
}
.draft-sub span { color: var(--gold); }
.draft-pool, .draft-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  width: 100%;
}
.draft-pool.dimmed { opacity: 0.5; pointer-events: none; }
.draft-card { position: relative; }
.draft-card.pickable { cursor: pointer; }
.draft-card.pickable:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6), 0 0 18px rgba(216, 178, 90, 0.4);
}
.draft-card .deck-count {
  position: absolute; bottom: 4px; right: 6px;
  font-family: var(--f-num); font-size: 12px; color: var(--gold);
}
.draft-empty { font-size: 12px; color: var(--bone-dim); opacity: 0.7; }
.draft-hidden-note { color: var(--bone-dim); opacity: 0.65; font-size: 10px; margin-left: 4px; }

/* チュートリアル時のガイド吹き出し */
.pg-guide {
  max-width: min(88vw, 380px);
  font-size: 13px; line-height: 1.8; color: var(--bone);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--soul);
  border-radius: 10px;
  box-shadow: 0 0 0 1px #000, 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 24px rgba(157, 123, 255, 0.25);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.pg-guide b { color: var(--gold); }

/* 時間切れの自動選択 */
.pg-tile.auto { border-color: var(--soul); box-shadow: 0 0 16px var(--soul-glow); }
.pg-wait {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; letter-spacing: 0.12em; color: var(--soul);
  margin-top: 8px;
}
.pg-wait .summon-ring { width: 26px; height: 26px; }

/* 配置演出: 墓から起き上がるように出現 */
.piece.pre-hidden { opacity: 0; pointer-events: none; }
@keyframes grave-rise {
  0% { transform: var(--pos) translateY(-26%) scale(0.4); opacity: 0; filter: brightness(2.6); }
  55% { transform: var(--pos) translateY(3%) scale(1.12); opacity: 1; }
  100% { transform: var(--pos) translateY(0) scale(1); opacity: 1; filter: brightness(1); }
}
.piece.placing { animation: grave-rise 0.6s cubic-bezier(0.22, 1.2, 0.36, 1); z-index: 6; }

/* ── 先攻・後攻の抽選演出 ─────────────────── */

#order-flash {
  position: fixed; inset: 0; z-index: 95;
  display: grid; place-items: center;
  pointer-events: none;
  background: radial-gradient(70vw 70vh at 50% 46%, rgba(14, 6, 26, 0.88), rgba(4, 2, 10, 0.55) 70%, rgba(4, 2, 10, 0.3));
  opacity: 1;
  transition: opacity 0.5s ease;
}
#order-flash.out { opacity: 0; }
.of-inner { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.of-title {
  font-family: var(--f-display); font-size: 14px; font-weight: 700;
  letter-spacing: 0.34em; color: var(--bone-dim);
}
.of-cards { display: flex; gap: 26px; perspective: 700px; }
.of-card {
  position: relative;
  width: 92px; height: 128px;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.65s;
}
.of-face {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line-lit);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.of-back {
  background:
    radial-gradient(circle at 50% 42%, #241a44, #130d26 75%);
  color: var(--soul-deep);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), inset 0 0 0 4px rgba(74, 58, 116, 0.35);
}
.of-skull { width: 58px; height: 58px; filter: drop-shadow(0 0 8px rgba(107, 79, 192, 0.5)); }
.of-skull .cranium { fill: currentColor; }
.of-skull .eye { fill: #130d26; }
.of-skull .teeth { fill: none; stroke: #130d26; stroke-width: 2.2; stroke-linecap: round; }
.of-front {
  transform: rotateY(180deg);
  font-family: var(--f-display); font-weight: 800;
  font-size: 26px; letter-spacing: 0.2em; padding-left: 0.2em;
  background: linear-gradient(180deg, #231a42, #140e28);
}
.of-front.first { color: var(--venom); box-shadow: 0 0 26px var(--venom-glow), inset 0 0 0 2px rgba(140, 235, 90, 0.4); }
.of-front.second { color: var(--soul); box-shadow: 0 0 22px var(--soul-glow), inset 0 0 0 2px rgba(157, 123, 255, 0.35); }

/* シャッフル（左右のカードが交差して入れ替わる） */
@keyframes of-swap-a {
  0%, 100% { transform: translateX(0) rotate(0deg); z-index: 2; }
  25% { transform: translateX(calc(100% + 26px)) translateY(-14px) rotate(6deg); }
  50% { transform: translateX(0) rotate(0deg); }
  75% { transform: translateX(calc(100% + 26px)) translateY(10px) rotate(-5deg); }
}
@keyframes of-swap-b {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(calc(-100% - 26px)) translateY(12px) rotate(-6deg); }
  50% { transform: translateX(0) rotate(0deg); }
  75% { transform: translateX(calc(-100% - 26px)) translateY(-12px) rotate(5deg); }
}
#order-flash.shuffling .of-a { animation: of-swap-a 1.4s ease-in-out; }
#order-flash.shuffling .of-b { animation: of-swap-b 1.4s ease-in-out; }

/* めくり（自分の札＝左を強調）
   ※ opacity は .of-card 自体に掛けない（preserve-3d が平坦化され裏面が見えてしまう） */
#order-flash.revealed .of-a { transform: rotateY(180deg) scale(1.18); }
#order-flash.revealed .of-b { transform: rotateY(180deg) scale(0.86); }
#order-flash.revealed .of-b .of-face { opacity: 0.4; }

.of-label {
  min-height: 26px;
  font-family: var(--f-display); font-weight: 800;
  font-size: 21px; letter-spacing: 0.24em;
}
.of-label.first { color: var(--venom); text-shadow: 0 0 18px var(--venom-glow); }
.of-label.second { color: var(--soul); text-shadow: 0 0 18px var(--soul-glow); }

/* ── チュートリアル案内 ─────────────────── */

#tut {
  position: fixed; inset: 0; z-index: 101; /* カード等のモーダル(100)より前面。案内リングを「使用する」ボタンにも重ねる */
  pointer-events: none; /* 盤面・モーダルへのタップを通す。吹き出しとボタンだけ受ける */
}

.tut-ring {
  position: fixed;
  display: none;
  border: 2.5px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5), 0 0 22px rgba(216, 178, 90, 0.7), inset 0 0 14px rgba(216, 178, 90, 0.25);
  pointer-events: none;
  transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
  animation: tut-ring-pulse 1.2s ease-in-out infinite;
}
@keyframes tut-ring-pulse {
  50% { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5), 0 0 34px rgba(216, 178, 90, 0.9), inset 0 0 14px rgba(216, 178, 90, 0.3); }
}
.tut-finger {
  position: fixed;
  display: none;
  transform: translate(-50%, 0);
  color: var(--venom);
  pointer-events: none;
  filter: drop-shadow(0 2px 4px #000) drop-shadow(0 0 6px var(--venom-glow));
  animation: tut-finger-bob 0.9s ease-in-out infinite;
}
.tut-finger svg { width: 26px; height: 26px; display: block; }
@keyframes tut-finger-bob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -7px); }
}

.tut-bubble {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(90vw, 400px);
  pointer-events: auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--soul);
  border-radius: 10px;
  box-shadow: 0 0 0 1px #000, 0 18px 46px rgba(0, 0, 0, 0.7), 0 0 30px rgba(157, 123, 255, 0.28);
  padding: 16px 16px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.tut-bubble.pos-bottom { bottom: calc(148px + env(safe-area-inset-bottom)); }
.tut-bubble.pos-top { top: calc(72px + env(safe-area-inset-top)); }
.tut-bubble.shake { animation: tut-shake 0.32s ease; }
@keyframes tut-shake {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 7px)); }
  75% { transform: translateX(calc(-50% + 7px)); }
}
.tut-text {
  font-family: var(--f-body);
  font-size: 13.5px; line-height: 1.85; color: var(--bone);
  letter-spacing: 0.02em;
}
.tut-text b { color: var(--gold); font-weight: 700; }
.tut-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tut-count { font-family: var(--f-num); font-size: 11px; color: var(--bone-dim); letter-spacing: 0.1em; }
.tut-btns { display: flex; gap: 8px; }
.tut-btn {
  font-family: var(--f-display); font-weight: 700;
  font-size: 13px; letter-spacing: 0.12em;
  padding: 9px 20px; border-radius: 4px;
  border: 1px solid var(--line-lit);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--bone);
}
.tut-btn.primary { border-color: var(--soul); color: var(--soul); box-shadow: 0 0 14px rgba(157, 123, 255, 0.3); }
.tut-btn.ghost { color: var(--bone-dim); }
.tut-close {
  position: absolute; top: 6px; right: 8px;
  width: 26px; height: 26px;
  font-size: 18px; line-height: 1; color: var(--bone-dim);
  border-radius: 4px;
}
.tut-close:hover { color: var(--bone); }
.tut-toast {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: rgba(20, 10, 16, 0.96);
  border: 1px solid var(--gold);
  color: var(--bone);
  font-size: 13px; letter-spacing: 0.05em;
  padding: 11px 18px; border-radius: 5px;
  box-shadow: 0 0 22px rgba(216, 178, 90, 0.4);
  max-width: 80vw; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.tut-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ── カード・眷属一覧 ─────────────────── */

/* タブ（カード / 眷属） */
.cat-tabs { display: flex; gap: 6px; }
.cat-tab {
  flex: 1; padding: 9px 0;
  font-family: var(--f-display); font-size: 13px; letter-spacing: 0.14em;
  color: var(--bone-dim); background: transparent;
  border: 1px solid var(--line-lit); border-radius: 6px;
}
.cat-tab.active {
  color: var(--ink); background: var(--soul);
  border-color: var(--soul); box-shadow: 0 0 14px var(--soul-glow);
}

.card-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  overflow-y: auto;
  max-height: 56dvh;
  padding: 4px 6px 4px 2px;
}

/* 眷属一覧 */
.minion-gallery {
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; max-height: 56dvh;
  padding: 4px 6px 4px 2px;
}
.minion-card {
  display: flex; align-items: center; gap: 11px;
  border: 1px solid var(--line); border-left: 3px solid var(--mc-hue, var(--soul));
  border-radius: 7px; padding: 9px 11px;
  background: color-mix(in srgb, var(--panel) 60%, transparent);
}
.minion-card.tag-base { --mc-hue: var(--venom); }
.minion-card.tag-summon { --mc-hue: var(--blood); }
.minion-card.tag-king { --mc-hue: var(--gold); }
.mc-art { flex: none; width: 40px; height: 40px; display: grid; place-items: center; color: var(--mc-hue); }
.mc-art svg { width: 38px; height: 38px; filter: drop-shadow(0 0 6px currentColor); }
.mc-art .bone { fill: currentColor; } .mc-art .pit { fill: var(--ink); } .mc-art .crown { fill: var(--gold); }
.mc-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mc-head { display: flex; align-items: center; gap: 8px; }
.mc-name { font-family: var(--f-display); font-size: 14px; font-weight: 700; letter-spacing: 0.04em; color: var(--bone); }
.mc-tag {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--ink); background: var(--mc-hue); border-radius: 3px; padding: 1px 6px;
}
.mc-text { font-size: 10.5px; line-height: 1.5; color: var(--bone-dim); }
.zoom-card.small { width: auto; padding: 10px 10px 12px; gap: 6px; border-radius: 8px; }
.zoom-card.small .z-name { font-size: 17px; }
.zoom-card.small .z-art { padding: 2px 0; }
.zoom-card.small .z-art svg { width: 44px; height: 44px; }
.zoom-card.small .z-text { font-size: 10.5px; line-height: 1.6; }

/* 自分のデッキ構成（対局中メニュー）: カードごとの枚数バッジ・タップで詳細 */
.mydeck-hint { font-size: 11px; color: var(--bone-dim); margin: -2px 0 8px; letter-spacing: 0.04em; }
.mydeck-gallery .deck-entry {
  position: relative; cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.mydeck-gallery .deck-entry:hover { border-color: var(--card-hue, var(--soul)); }
.mydeck-gallery .deck-entry:active { transform: scale(0.97); }
.mydeck-gallery .deck-count {
  position: absolute; top: 8px; right: 8px;
  font-family: var(--f-num); font-weight: 700; font-size: 15px;
  color: var(--bone);
  background: rgba(4, 2, 10, 0.72);
  border: 1px solid var(--card-hue, var(--soul));
  border-radius: 5px; padding: 1px 7px; line-height: 1.35;
}
.gallery-note {
  grid-column: 1 / -1;
  font-size: 11px; color: var(--blood);
  text-align: center; line-height: 1.6;
  padding-top: 2px;
}

/* デッキ確認ビュー: 名前＋アイコンのみの3列グリッド（一覧性重視） */
.deckview-gallery {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  overflow-y: auto; max-height: 56dvh; padding: 4px 4px 4px 2px;
}
.dv-entry {
  position: relative; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 1px solid var(--line-lit); border-radius: 8px;
  background: linear-gradient(180deg, #221a3e, #140e26);
  padding: 11px 6px 9px;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.dv-entry:hover { border-color: var(--card-hue, var(--soul)); }
.dv-entry:active { transform: scale(0.97); }
.dv-entry .dv-art { color: var(--card-hue, var(--soul)); line-height: 0; }
.dv-entry .dv-art svg { width: 34px; height: 34px; filter: drop-shadow(0 0 8px currentColor); }
.dv-entry .dv-name { font-family: var(--f-display); font-size: 12px; font-weight: 700; text-align: center; line-height: 1.15; color: var(--bone); }
.dv-entry .dv-count {
  position: absolute; top: 4px; right: 4px;
  font-family: var(--f-num); font-weight: 700; font-size: 12px; color: var(--bone);
  background: rgba(4, 2, 10, 0.72); border: 1px solid var(--card-hue, var(--soul));
  border-radius: 5px; padding: 0 5px; line-height: 1.4;
}
.dv-entry.kind-move { --card-hue: var(--venom); }
.dv-entry.kind-revive { --card-hue: var(--soul); }
.dv-entry.kind-tutor { --card-hue: var(--gold); }
.dv-entry.kind-sorcery, .dv-entry.kind-special { --card-hue: var(--blood); }

/* 初期デッキ・ドラフト（2-pick）: 2枚を左右に並べ、各カードの「これを選ぶ」で1枚選択 */
.chal-draft-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
.chal-draft-card { display: flex; flex-direction: column; gap: 6px; }
.chal-draft-card .z-text { flex: 1; }
.chal-draft-card .chal-draft-pick { margin-top: 4px; width: 100%; }
/* ドラフト中の「これまでに選んだカード」ストリップ */
.chal-draft-picked-wrap { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.chal-draft-picked-head { font-size: 11px; color: var(--bone-dim); letter-spacing: 0.06em; text-align: center; margin-bottom: 8px; }
.chal-draft-picked { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chal-draft-empty { font-size: 11px; color: var(--bone-dim); }
.chal-draft-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--card-hue, var(--soul)); border-radius: 6px;
  background: rgba(20, 14, 38, 0.6); color: var(--bone);
  padding: 3px 7px 3px 5px; font-size: 11px; cursor: pointer;
  transition: transform 0.1s ease;
}
.chal-draft-chip:active { transform: scale(0.95); }
.chal-draft-chip .cdc-art { color: var(--card-hue, var(--soul)); line-height: 0; }
.chal-draft-chip .cdc-art svg { width: 16px; height: 16px; filter: drop-shadow(0 0 5px currentColor); }
.chal-draft-chip .cdc-name { font-family: var(--f-display); font-weight: 700; white-space: nowrap; }
.chal-draft-chip .cdc-count { font-family: var(--f-num); color: var(--card-hue, var(--soul)); }
.chal-draft-chip.kind-move { --card-hue: var(--venom); }
.chal-draft-chip.kind-revive { --card-hue: var(--soul); }
.chal-draft-chip.kind-tutor { --card-hue: var(--gold); }
.chal-draft-chip.kind-sorcery, .chal-draft-chip.kind-special { --card-hue: var(--blood); }
/* デッキ確認: 編集アイコン（右上） */
.deckview-edit {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  width: 34px; height: 34px; display: grid; place-items: center;
  color: var(--gold); background: rgba(20, 14, 38, 0.7);
  border: 1px solid var(--soul-deep); border-radius: 8px; cursor: pointer;
}
.deckview-edit:hover { border-color: var(--gold); }
.deckview-edit svg { width: 20px; height: 20px; }
.deckview-sub { font-size: 11px; color: var(--bone-dim); margin-left: 6px; }
/* 他デッキから選ぶ: 選択項目 */
.deckpick-item {
  width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line-lit); border-radius: 8px;
  background: linear-gradient(180deg, #201839, #140e26);
  padding: 12px 14px; margin-bottom: 8px; color: var(--bone);
}
.deckpick-item:hover { border-color: var(--soul); }

/* 小さい端末 */
@media (max-height: 750px) {
  :root { --cell: min(22vw, 88px); }
  #hand { height: 116px; }
  .card { width: 82px; height: 110px; }
}
@media (max-width: 430px) {
  .card { width: 80px; height: 112px; margin: 0 -9px; }
  #hand { height: 120px; }
  .pile { padding: 3px 6px; }
  .hud-me .pl-badge.me { display: none; }
}
@media (min-width: 700px) {
  :root { --cell: 96px; }
}

/* ── チャレンジ 登場演出 ── */
/* チャレンジ 敵登場: バン！とズームで全画面に迫り、少し見せてからズームアウトで開始 */
.chal-fx { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center;
  overflow: hidden;
  animation: chalFxIn .16s ease both, chalFxShake .44s .24s cubic-bezier(.36,.07,.19,.97) both; }
.chal-fx.out { animation: chalFxOut .5s cubic-bezier(.5,0,.55,1) both; }

.chal-fx-bg { position: absolute; inset: 0; background:
  radial-gradient(125% 95% at 50% 42%, color-mix(in srgb, var(--chal-accent) 26%, #05030b) 0%, #05030b 72%);
  animation: chalFxBg .55s ease both; }
@keyframes chalFxBg { from { opacity: 0; transform: scale(1.14); } to { opacity: 1; transform: none; } }

/* 背後でゆっくり回る放射光 */
.chal-fx-rays { position: absolute; left: 50%; top: 43%; width: 170vmax; height: 170vmax;
  transform: translate(-50%, -50%); opacity: 0; mix-blend-mode: screen; pointer-events: none;
  background: repeating-conic-gradient(from 0deg,
    color-mix(in srgb, var(--chal-accent) 24%, transparent) 0deg 5deg, transparent 5deg 15deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 10%, transparent 60%);
          mask-image: radial-gradient(closest-side, #000 10%, transparent 60%);
  animation: chalFxRaysIn .6s .12s ease both, chalFxRaysSpin 15s linear infinite; }
@keyframes chalFxRaysIn { to { opacity: .48; } }
@keyframes chalFxRaysSpin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* 着地(バン)の瞬間に外へ弾ける衝撃波 */
.chal-fx-shock { position: absolute; left: 50%; top: 43%; width: 42vmin; height: 42vmin;
  transform: translate(-50%, -50%) scale(0); border-radius: 50%; opacity: 0; pointer-events: none;
  border: 3px solid color-mix(in srgb, var(--chal-accent) 82%, #fff);
  box-shadow: 0 0 46px var(--chal-accent), inset 0 0 34px var(--chal-accent);
  animation: chalFxShock .62s .2s cubic-bezier(.12,.62,.28,1) both; }
@keyframes chalFxShock {
  0% { transform: translate(-50%, -50%) scale(0.12); opacity: .95; }
  100% { transform: translate(-50%, -50%) scale(3.6); opacity: 0; } }

/* 舞台（図像＋文字）を一括でズームイン → ズームアウト */
.chal-fx-stage { position: relative; width: 100%; height: 100%; display: grid; place-items: center;
  animation: chalFxZoomIn .56s cubic-bezier(.16,1,.3,1) both; }
.chal-fx.out .chal-fx-stage { animation: chalFxZoomOut .5s cubic-bezier(.5,0,.55,1) both; }
@keyframes chalFxZoomIn {
  0%   { opacity: 0; transform: scale(.24); filter: blur(7px); }
  46%  { opacity: 1; filter: blur(0); }
  64%  { transform: scale(1.07); }   /* バン: 行き過ぎてから */
  80%  { transform: scale(.985); }
  100% { transform: scale(1); } }
@keyframes chalFxZoomOut {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.5); } }

/* 全画面に迫る挑戦者のシルエット（画面を大きく占めつつ、縦横どちらでも見切れないように収める）。
   幅 = 高さ×0.75。117vw で頭打ちにすると幅≈88vw に収まり、ズームの行き過ぎ(×1.07)でも画面内。 */
.chal-fx-figure { position: relative; height: min(66vh, 117vw, 560px); width: auto;
  filter: drop-shadow(0 0 30px var(--chal-accent)) drop-shadow(0 0 8px var(--chal-accent));
  animation: chalFxBreath 2.6s .6s ease-in-out infinite; }
.chal-fx-figure svg { height: 100%; width: auto; fill: currentColor; opacity: .94; }
@keyframes chalFxBreath {
  0%, 100% { transform: scale(1) translateY(0); filter: drop-shadow(0 0 26px var(--chal-accent)); }
  50%      { transform: scale(1.018) translateY(-0.6%); filter: drop-shadow(0 0 40px var(--chal-accent)); } }

.chal-fx-text { position: absolute; bottom: 13vh; width: 100%; text-align: center; }
.chal-fx-title { font-family: 'Shippori Mincho B1', serif; font-weight: 800; font-size: clamp(30px, 9.5vw, 60px);
  color: #f4ecff; text-shadow: 0 0 20px var(--chal-accent), 0 2px 10px #000;
  animation: chalFxSlam .42s .34s cubic-bezier(.16,1.1,.3,1) both; }
.chal-fx-sub { font-size: clamp(12px, 3.4vw, 18px); color: color-mix(in srgb, var(--chal-accent) 72%, #fff); letter-spacing: .12em;
  text-shadow: 0 1px 6px #000; animation: chalFxSlam .42s .46s cubic-bezier(.16,1.1,.3,1) both; }
.chal-fx-cry { margin-top: .45em; font-family: 'Shippori Mincho B1', serif; font-weight: 700;
  font-size: clamp(19px, 5.6vw, 32px); color: #ff5a6e; text-shadow: 0 0 16px #ff2b45, 0 2px 8px #000;
  animation: chalFxSlamCry .5s .58s cubic-bezier(.14,1.25,.32,1) both; }
@keyframes chalFxSlam {
  0% { opacity: 0; transform: translateY(16px) scale(1.35); }
  60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes chalFxSlamCry {
  0% { opacity: 0; transform: scale(1.9); letter-spacing: .2em; }
  55% { opacity: 1; } 100% { opacity: 1; transform: none; letter-spacing: .02em; } }

@keyframes chalFxIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes chalFxOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes chalFxShake {
  0%, 100% { transform: translate(0, 0); }
  16% { transform: translate(-9px, 6px); }
  32% { transform: translate(8px, -7px); }
  48% { transform: translate(-6px, 5px); }
  64% { transform: translate(5px, -4px); }
  82% { transform: translate(-2px, 2px); } }
/* ※ 挑戦者登場は「バン！と動く」ことが演出の要点なので、prefers-reduced-motion でも
   演出を止めない（静止・見切れの原因になっていたフェード差し替えを廃止）。
   ごく短い一度きりの登場演出のため、動きをそのまま見せる方針。 */

/* ── チャレンジ ステージクリア/記録 ── */
.chal-clear-stage { font-family: 'Shippori Mincho B1', serif; font-weight: 800; font-size: clamp(22px, 6.4vw, 34px); color: #f4ecff; text-align: center; }
.chal-clear-enemy { text-align: center; color: #b9a8d8; margin-top: .2em; }
.chal-stats { display: flex; justify-content: center; gap: 18px; margin: 18px 0; }
.chal-stat { display: grid; place-items: center; min-width: 74px; padding: 10px 6px; border: 1px solid #3a2c58; border-radius: 12px; background: #150e26; }
.chal-stat b { font-size: 26px; color: #7dffb0; }
.chal-stat span { font-size: 11px; color: #a99cc4; margin-top: 2px; }
.chal-records { max-height: 40vh; overflow-y: auto; margin: 10px 0; }
.chal-rec { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-bottom: 1px solid #2a2040; font-size: 13px; }
.chal-rec-stage { font-weight: 700; color: #9d7bff; min-width: 28px; }
.chal-rec-enemy { flex: 1; color: #e7dcff; }
.chal-rec-nums { color: #a99cc4; font-size: 12px; }
.chal-rules-list { margin: 8px 0 0; padding-left: 1.1em; }
.chal-rules-list li { margin: 4px 0; }

/* ── チャレンジ デッキ調整 ── */
.chal-deck-total { margin-left: 6px; font-weight: 700; color: #b9a8d8; }
.chal-deck-total.over { color: var(--blood); }
.chal-deck-panels { display: flex; flex-direction: column; gap: 10px; }
.chal-panel-head { width: 100%; text-align: left; padding: 10px 12px; border: 1px solid #3a2c58; border-radius: 10px;
  background: #150e26; color: #e7dcff; font-weight: 700; font-size: 13px; }
.chal-panel-grid { margin-top: 8px; }
.chal-scout { position: relative; cursor: pointer; }
.chal-scout.scouted { outline: 2px solid #7dffb0; box-shadow: 0 0 12px rgba(125,255,176,.4); }
.chal-badge { position: absolute; top: 4px; right: 4px; font-size: 10px; padding: 2px 6px; border-radius: 8px;
  background: #0f3b28; color: #7dffb0; }
.chal-mine-ctr { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 4px; }
.chal-mine-count { font-size: 16px; color: #f4ecff; min-width: 1.2em; text-align: center; }
.chal-minus { width: 26px; height: 26px; border-radius: 50%; border: 1px solid #6a2c3c; background: #2a0f18; color: #ff9fb0; font-size: 16px; line-height: 1; }
.chal-minus:disabled { opacity: .3; }
/* ＋: 除去の取り消し（毒光緑） */
.chal-plus { width: 26px; height: 26px; border-radius: 50%; border: 1px solid #2c6a45; background: #0f2a1a; color: #7dffb0; font-size: 16px; line-height: 1; }
.chal-plus.hidden { display: none; }
.dv-entry.chal-mine.emptied { opacity: .55; }
.chal-removed-tag { display: block; margin-top: 3px; font-size: 10px; color: #ff9fb0; }
/* 制覇・敗北の文字は中央に大きく */
.chal-clear-body, .chal-over-body { text-align: center; align-items: center; }
/* 敗北の確認モード: 結果モーダルへ戻るフローティングボタン */
.chal-review-back { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 2500; padding: 11px 22px; border-radius: 999px; font-weight: 700;
  border: 1px solid var(--blood); background: rgba(30,8,14,.92); color: #ffd7de;
  box-shadow: 0 4px 18px rgba(0,0,0,.5); }
.chal-review-back.hidden { display: none; }

/* ── チャレンジ レア補充 ── */
.chal-rare-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chal-rare-card { cursor: pointer; }
.chal-rare-card:active { transform: scale(.97); }
