/* ToT のデザイン: 神秘的で魔法っぽく、できるだけシンプル。夜の藍色に、金と淡い青紫のひかり */
:root {
  --bg: #12152b; --panel: #1b2040; --panel2: #232950; --line: #343a68; --line2: #4b5190;
  --text: #e9e8f6; --muted: #9da6d2; --gold: #e6c97a; --magic: #8fa0ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* #board など display 指定のある要素でも hidden を効かせる */
body { margin: 0; font-family: 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif; color: var(--text); background: radial-gradient(ellipse at 50% -10%, #2a2b63 0%, transparent 55%), radial-gradient(ellipse at 90% 100%, #1d2150 0%, transparent 50%), var(--bg); background-attachment: fixed; }
#status { text-align: center; padding: 1rem; font-size: 1.3rem; }
button { padding: .6rem 1.2rem; font-size: 1rem; cursor: pointer; font-family: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px; }
button:hover:not(:disabled) { border-color: var(--magic); }
button:disabled { opacity: .4; cursor: not-allowed; }

/* ================= カード（フレーム画像 812×1184 に対する割合で配置）================= */
.cardv { position: relative; width: 100%; aspect-ratio: 812 / 1184; container-type: inline-size; cursor: pointer; user-select: none; color: #2a2113; }
.cardv > * { position: absolute; }
.cardv .art-bg { left: 7.5%; top: 14.4%; width: 84.9%; height: 43.7%; background: linear-gradient(#2b2f55, #191c3a); }
.cardv .art { left: 7.5%; top: 14.4%; width: 84.9%; height: 43.7%; object-fit: cover; }
.cardv .frame { left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.cardv .c-name { left: 7.64%; top: 2.8%; width: 64.5%; height: 10.2%; display: flex; align-items: center; justify-content: center; font-weight: 700; white-space: nowrap; overflow: hidden; }
.cardv .c-cost { left: 73.1%; top: 44.8%; width: 19%; height: 13%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 11cqw; color: #1b5e20; }
.cardv .c-desc { left: 7.76%; top: 60.7%; width: 84.4%; height: 34.4%; overflow: hidden; }
.cardv .c-desc-in { padding: 1.4cqw 2.4cqw; line-height: 1.3; font-size: 4.6cqw; color: #222; }
.cardv .c-badge { display: none; left: 73%; top: 3.6%; width: 22%; height: 8.6%; align-items: center; justify-content: center; background: #2e8b3d; color: #fff; border-radius: 1.5cqw; font-size: 4.4cqw; font-weight: 700; }
.cardv.picked .c-badge { display: flex; }
.cardv.restricted::after { content: '運営のみ'; position: absolute; left: 8%; top: 58%; padding: 0 2.4cqw; border-radius: 2cqw; background: #7a2a2a; color: #fff; font-size: 4cqw; font-weight: 700; z-index: 3; pointer-events: none; }
.cardv.picked { filter: drop-shadow(0 0 6px rgba(230, 201, 122, .85)) drop-shadow(0 0 2px #e6c97a); }
.cardv .tag { color: #a85400; font-weight: 700; }
.tag { color: #ffd479; font-weight: bold; }
#zoom { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7rem; cursor: zoom-out; }
#zoom-card { width: min(88vw, 58vh); }
#zoom .hint { color: #bcd; font-size: .85rem; }

/* 山札・捨て札の一覧ウィンドウ */
.row { display: flex; align-items: center; gap: .5rem; background: #1f2547; padding: .4rem .6rem; border-radius: 6px; }
.row .art { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; }
.row .meta { flex: 1; font-size: .85rem; }
.row .meta b { font-size: 1rem; }
.row .meta small { color: #9da6d2; display: block; }
.row .cost { color: #8fb8ff; }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 40; }
#modal .box { background: #12152b; border: 1px solid #454c85; border-radius: 8px; width: min(1100px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
#modal .head { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; border-bottom: 1px solid #343a68; }
#modal-body { overflow-y: auto; padding: .6rem 1rem 1rem; }
#modal-body h4 { margin: .8rem 0 .5rem; color: #a9b8ff; font-size: .95rem; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, 96px); gap: 8px; justify-content: start; } /* かなり小さめ。クリックで拡大 */
.mcell { width: 96px; }
#modal .idx { width: 2rem; text-align: right; color: #9da6d2; }
#modal .empty { text-align: center; color: #9da6d2; padding: 1rem; }

/* ================= 対戦画面 =================
   左: 盤面（上=相手 / 下=自分）。右: ログ + ターン操作 + Time。 */
#board { display: grid; grid-template-columns: 1fr 18.5vw; width: 100vw; height: 100vh; overflow: hidden; font-size: clamp(11px, .95vw, 17px); }
#arena { display: grid; grid-template-rows: 13fr 12fr 33fr 15fr 27fr; min-width: 0; min-height: 0; position: relative; }

/* 山札 / 手札 / 捨て札 の段 */
.zones { display: grid; grid-template-columns: 13% 1fr 13%; align-items: center; padding: 0 2%; min-height: 0; }
.z-deck, .z-discard { display: flex; justify-content: center; }
.z-hand-foe { display: flex; justify-content: center; align-items: center; }

/* 山札・捨て札のスタック */
.stack { position: relative; width: 6.2vw; max-width: 100%; aspect-ratio: 812 / 1184; }
.stack.click { cursor: pointer; }
.stack.click:hover { filter: brightness(1.2); }
.stack .cback, .stack .cardv, .stack .empty-slot { position: absolute; inset: 0; width: 100%; }
.stack .cback.c2 { transform: translate(3px, -3px); }
.stack .cback.c3 { transform: translate(6px, -6px); }
.stack .cnt { position: absolute; right: -.5em; bottom: -.5em; min-width: 2em; padding: .1em .5em; text-align: center; background: #0b0d1e; border: 1px solid #454c85; border-radius: 1em; font-weight: 700; z-index: 2; }
.stack em { position: absolute; left: 0; right: 0; top: -1.6em; text-align: center; font-style: normal; color: #9da6d2; font-size: .85em; }
.stack .cardv { cursor: inherit; }
.empty-slot { border: 2px dashed #343a68; border-radius: 6%; }
.cback { aspect-ratio: 812 / 1184; border: 3px solid #b89a5a; border-radius: 6%; background:
  radial-gradient(circle at 50% 50%, #c9a24a 0 8%, transparent 9%),
  repeating-linear-gradient(45deg, #2a2c5e 0 8px, #212350 8px 16px); box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.foe-hand-backs { display: flex; align-items: center; }
.foe-hand-backs .cback { width: 4.2vw; flex: none; margin-left: -1.6vw; }
.foe-hand-backs .cback:first-child { margin-left: 0; }
.foe-hand-backs .none { color: #7f88b8; }

/* プレイヤー帯（名前 / バフデバフ+HP / トークン・カウント+PP） */
.pbar { position: relative; display: grid; grid-template-columns: 22% 1fr 14%; align-items: center; gap: 1.2%; padding: 0 2%; margin: 0; background: rgba(255,255,255,.04); border-top: 2px solid #4a4f86; border-bottom: 2px solid #4a4f86; transition: background .3s, border-color .3s; }
.pbar.active { background: rgba(120, 200, 255, .10); border-color: #8fb8ff; box-shadow: 0 0 18px rgba(124,196,255,.25) inset; }
.b-name .nm { font-size: 1.9em; font-weight: 700; }
.b-name .sub { margin-top: .3em; color: #9da6d2; font-size: .85em; line-height: 1.5; }
.b-mid { min-width: 0; }
.buffs { min-height: 2.4em; display: flex; flex-wrap: wrap; gap: .4em; margin-bottom: .35em; align-items: flex-end; }
/* バフ・デバフのバッジ（毒・ブラーなど）: 大きめ。赤=悪い効果 / 青緑=良い効果 */
.stb { display: inline-flex; align-items: center; gap: .5em; padding: .25em .4em .25em .8em; border-radius: 1.4em; font-size: 1.15em; border: 2px solid; cursor: help; background: #1d2342; }
.stb b { font-weight: 700; }
.stb i { font-style: normal; font-weight: 800; min-width: 1.6em; text-align: center; padding: .05em .4em; border-radius: 1em; background: rgba(0,0,0,.4); }
.stb.bad { border-color: #d9605a; background: #4a2426; color: #ffd6d2; }
.stb.good { border-color: #4fbfa8; background: #1f4640; color: #d0fff3; }
.stb:hover, .chip.turn:hover { filter: brightness(1.25); }
.hpline { position: relative; display: flex; align-items: center; gap: .6em; }
.hpbar { position: relative; flex: 1; height: 2.3em; background: #3a1f24; border: 2px solid #6b2f38; border-radius: 1.2em; overflow: hidden; }
.hpbar i { display: block; height: 100%; background: linear-gradient(#f06060, #c03a3a); transition: width .4s; }
.hpbar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; text-shadow: 0 1px 2px #000; }
/* ブロック: HPバーの上に、半透明のシールドバーをかぶせる（幅 = ブロック ÷ 最大HP） */
.hpbar .blkbar { position: absolute; left: 0; top: 0; bottom: 0; display: flex; align-items: center; justify-content: flex-start; background: rgba(110, 190, 255, .42) repeating-linear-gradient(135deg, rgba(255,255,255,.14) 0 6px, transparent 6px 12px); border-right: 3px solid rgba(180, 225, 255, .95); box-shadow: inset 0 0 12px rgba(190, 230, 255, .55); transition: width .4s; cursor: help; z-index: 1; }
.hpbar .blkbar em { font-style: normal; font-weight: 700; font-size: .85em; padding-left: .8em; color: #eaf6ff; text-shadow: 0 1px 3px #000; white-space: nowrap; }
.hpbar span { pointer-events: none; z-index: 2; } /* HPの文字はバーの上。ホバーはシールドバーに届くように */
.b-right { position: relative; display: flex; justify-content: center; }
.pbar.foe .tks { bottom: auto; top: 100%; padding: .7em 0 0; flex-wrap: wrap; } /* 相手は鏡写しで帯の下に並べる */
.tks { position: absolute; bottom: 100%; right: 0; width: max-content; max-width: 34vw; display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: .6em; padding-bottom: .7em; } /* PPの丸の上に、左へ広がって並ぶ */
.tkc { position: relative; width: 4.4em; height: 4.4em; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .85em; font-weight: 700; line-height: 1.05; text-align: center; border: 3px solid; cursor: help; background-clip: padding-box; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.tkc .tk-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.tkc .tk-art ~ .tk-name { display: none; } /* 絵が出ているときは名前を隠す（絵が無い/読めないときだけ名前を出す） */
.tkc:hover { transform: scale(1.12); }
.tkc.tk { background: #3d4f22; border-color: #93b44b; border-radius: 14%; } /* トークンは四角（角を少し丸く）、カウントは丸 */
.tkc.tk .tk-art { border-radius: 11%; }
.tkc.ct { background: #1f4c4c; border-color: #58b8b8; }
.tkc b { position: absolute; right: -.55em; top: -.55em; min-width: 1.7em; padding: .05em .35em; background: #0b0d1e; border: 2px solid #aab; border-radius: 1em; font-size: 1em; }
.ppc { width: 6.4em; height: 6.4em; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(#2d5a86, #17304a); border: 3px solid #8fb8ff; }
.ppc small { color: #a9b8ff; font-size: .8em; }
.ppc .ppv { display: flex; align-items: baseline; justify-content: center; line-height: 1; }
.ppc b { font-size: 2.3em; line-height: 1; }
.ppc .ppv span { font-size: 1.25em; font-weight: 700; color: #a9b8ff; margin-left: .1em; }   /* 残り/最大 の「/最大」側は小さめに */
.ppc.long b { font-size: 1.8em; }
.ppc.long .ppv span { font-size: 1.05em; }
.ppc em { font-style: normal; font-size: .7em; color: #a9b8ff; }

/* バフ・デバフ等のチップ */
.chip { display: inline-block; background: #556; border-radius: 1em; padding: .1em .7em; font-size: .85em; cursor: help; white-space: nowrap; }
.chip.lt { background: #7a2a2a; }
.chip.turn { background: #38475a; }

/* 相手側は上に詰めるため一回り小さく */
.foe-zones .stack { width: min(4.2vw, 74px); }
.foe-zones .stack .cnt { font-size: .85em; }
.foe-zones .stack em { top: auto; bottom: -1.6em; } /* 上端で切れないよう、ラベルは下側 */
.pbar.foe { font-size: .88em; }
.pbar.foe .b-name .nm { font-size: 1.6em; }
.foe-hand-backs .cback.hide { visibility: hidden; }

/* 中央: ターン表示 */
#center { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: .8em; min-height: 0; pointer-events: none; }
#back, #wait-back { pointer-events: auto; padding: .8em 2em; font-size: 1.15em; background: #2e6a3a; color: #fff; border: 2px solid #58b06a; border-radius: .5em; }
#wait-back { display: block; margin: 0 auto 1rem; }
#banner.result { font-size: min(7vw, 15vh); font-weight: 900; letter-spacing: .1em; opacity: 1; padding-top: 0; -webkit-text-stroke: .04em #000; paint-order: stroke fill; text-shadow: 0 4px 24px rgba(0,0,0,.85); animation: resultIn .7s cubic-bezier(.2,1.4,.4,1); }
#banner.win { color: #ffd54a; }
#banner.lose { color: #9fb3d1; }
@keyframes resultIn { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
#banner { font-size: 1.25em; font-weight: 700; color: #e3e6ff; text-shadow: 0 2px 6px #000; text-align: center; opacity: .85; padding-top: .4em; } /* カードを出す演出の邪魔にならないよう上寄せ */

/* ダメージ・回復のポップアップ: 大きく、縁取りで見やすく。ぽんと現れてから上へ流れて消える */
.pop { position: absolute; left: 50%; top: 0; font-size: 3.6em; font-weight: 900; line-height: 1; pointer-events: none; animation: pop 1.7s ease-out forwards; z-index: 60; white-space: nowrap; -webkit-text-stroke: .08em #000; paint-order: stroke fill; text-shadow: 0 3px 8px rgba(0,0,0,.7); }
.pop.dmg { color: #ff5a5a; }
.pop.heal { color: #5dff8a; }
@keyframes pop {
  0% { transform: translate(-50%, 0) scale(.4); opacity: 0; }
  12% { transform: translate(-50%, -.3em) scale(1.35); opacity: 1; }
  25% { transform: translate(-50%, -.4em) scale(1); opacity: 1; }
  70% { transform: translate(-50%, -.9em) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -1.6em) scale(1); opacity: 0; }
}
/* 手札（中央）: 枚数が多いと重なる。マウスを乗せると拡大 */
#hand { display: flex; justify-content: center; align-items: flex-end; min-width: 0; height: 100%; --hw: clamp(84px, 6.6vw, 130px); }
#hand .hand-card { width: var(--hw); flex: none; transition: transform .12s; transform-origin: 50% 100%; }
#hand .hand-card:hover { transform: translateY(-14%) scale(1.85); z-index: 50; }
#hand .hand-card.disabled { opacity: .5; cursor: not-allowed; }
#hand.busy .hand-card { cursor: progress; } /* 演出中はカードを使えない */

/* 手札カードにカーソルを合わせたとき、説明文の x の値をカードの上に表示 */
.cardv .c-x { display: none; left: 50%; top: -17%; transform: translateX(-50%); white-space: nowrap; background: #171c3a; border: 2px solid #f0c860; border-radius: 3cqw; padding: 1cqw 4cqw; font-size: 7cqw; font-weight: 800; color: #ffe08a; text-align: center; z-index: 5; }
.cardv .c-x small { display: block; font-size: 4.2cqw; font-weight: 400; color: #cdd; }
.hand-card:hover .c-x { display: block; }

/* 右: ログ / ターン操作 / Time */
#side { display: flex; flex-direction: column; min-height: 0; border-left: 2px solid #4a4f86; background: rgba(0,0,0,.18); }
#side h3 { margin: 0; padding: .6em .8em; font-size: 1.05em; border-bottom: 1px solid #343a68; color: #a9b8ff; }
#log { flex: 1; min-height: 0; overflow-y: auto; padding: .6em .9em; font-size: 1.2em; line-height: 1.65; } /* ログは読みやすい大きさに */
#log div { padding: .05em 0; }
#log .turn { margin-top: .5em; padding-top: .4em; border-top: 1px solid #343a68; color: #e3e6ff; font-weight: 700; }
#log .me { color: #a5e6ff; }
#log .foe { color: #ffb0a5; }
#log .sub { color: #a9bccf; padding-left: 1.1em; font-size: 1em; }
#log .lethal { color: #f0b0b0; padding-bottom: .5em; border-bottom: 1px dashed #644; margin-bottom: .3em; }
#side-buttons { display: flex; gap: .5em; padding: .6em .8em; border-top: 1px solid #343a68; }
#side-buttons button { flex: 1; padding: .7em .4em; font-size: 1em; }
#end-turn { background: #2e6a3a; color: #fff; border: 1px solid #58b06a; }
#surrender { background: #5a2a2a; color: #fdd; border: 1px solid #a05a5a; }
#deck-status { margin: 0 .8em .6em; padding: .7em; font-size: 1em; background: #1f2547; color: #e3e6ff; border: 1px solid #454c85; }
#timebox.low b { color: #ff6b6b; }
#timebox { height: 12%; min-height: 4.5em; border-top: 2px solid #4a4f86; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#timebox span { color: #9da6d2; letter-spacing: .1em; }
#timebox b { font-size: 2.2em; font-variant-numeric: tabular-nums; }

/* ================= 演出: 飛ぶカード ================= */
.anim-hide { visibility: hidden; }
.fly { position: fixed; z-index: 70; pointer-events: none; aspect-ratio: 812 / 1184; transform-origin: 0 0; }
.fly-in { position: absolute; inset: 0; transform-origin: 50% 50%; }
.fly .f-back, .fly .f-face { position: absolute; inset: 0; width: 100%; height: 100%; }
.fly .f-face { display: none; }
.fly.face .f-face { display: block; }
.fly.face .f-back { display: none; }
.fly .cardv { cursor: default; }
.fly.play.you .fly-in { filter: drop-shadow(0 0 14px #6bb6ff); }   /* 中央に出ている間: 自分=青 */
.fly.play.foe .fly-in { filter: drop-shadow(0 0 14px #ff7b7b); }   /* 相手=赤 */
/* ================= 説明ウィンドウ ================= */
#tip { display: none; position: fixed; z-index: 90; max-width: 26em; gap: .8em; padding: .7em .9em; background: #0c0f22; border: 2px solid #8fb8ff; border-radius: .6em; box-shadow: 0 6px 22px rgba(0,0,0,.6); pointer-events: none; font-size: 15px; }
#tip img { width: 4.6em; height: 4.6em; object-fit: cover; border-radius: .4em; flex: none; }
#tip .tip-body b { display: block; font-size: 1.1em; margin-bottom: .25em; color: #ffe08a; }
#tip .tip-body p { margin: 0 0 .3em; line-height: 1.5; color: #e8eef5; }
#tip .tip-body small { color: #9da6d2; }
/* 現在の状況ウィンドウ */
.nowgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .6rem; }
.nowchip { background: #1c2242; border: 1px solid #454c85; border-radius: 8px; padding: .6rem .9rem; display: grid; grid-template-columns: auto 1fr; gap: .1rem .8rem; align-items: baseline; }
.nowchip b { font-size: 1.1rem; color: #ffe08a; }
.nowchip i { font-style: normal; font-size: 1.8rem; font-weight: 800; text-align: right; }
.nowchip small { grid-column: 1 / -1; color: #9da6d2; }
.xnote { color: #9da6d2; font-size: .85rem; margin-bottom: .4rem; }
.xlist { display: grid; gap: .4rem; }
.xrow { display: grid; grid-template-columns: 11rem 7rem 6.5rem 1fr; gap: .6rem; align-items: baseline; background: #1c2242; border-radius: 6px; padding: .4rem .7rem; }
.xrow .xn { color: #e3e6ff; }
.xrow .xk { color: #8fb8ff; font-weight: 700; }
.xrow .xv i { font-style: normal; font-size: 1.3rem; font-weight: 800; color: #ffe08a; }
.xrow small { color: #9da6d2; }

/* 手札を捨てる選択中: 手札の上に案内を出す */
.you-zones { position: relative; }
#discard-prompt { position: absolute; left: 50%; top: 2%; transform: translateX(-50%); z-index: 40; padding: .5em 1.6em; font-size: 1.5em; font-weight: 800; color: #fff; background: rgba(160, 50, 50, .92); border: 3px solid #ff9a9a; border-radius: 2em; white-space: nowrap; box-shadow: 0 4px 18px rgba(0,0,0,.6); animation: promptPulse 1.1s ease-in-out infinite; pointer-events: none; }
@keyframes promptPulse { 0%, 100% { box-shadow: 0 4px 18px rgba(0,0,0,.6), 0 0 0 0 rgba(255,120,120,.6); } 50% { box-shadow: 0 4px 18px rgba(0,0,0,.6), 0 0 0 10px rgba(255,120,120,0); } }
#hand.choosing .hand-card { filter: drop-shadow(0 0 8px #ff8a8a); cursor: pointer; }

/* ターンチェンジの文字（ターン開始・終了の演出）*/
#turn-banner { position: fixed; left: 0; top: 0; width: 81.5vw; height: 100vh; z-index: 75; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: min(7.5vw, 15vh); font-weight: 900; letter-spacing: .12em; color: #fff; -webkit-text-stroke: .04em #000; paint-order: stroke fill; text-shadow: 0 4px 24px rgba(0,0,0,.85);
  background: linear-gradient(90deg, transparent, rgba(8, 16, 30, .72) 25%, rgba(8, 16, 30, .72) 75%, transparent); }
#turn-banner.tc { color: #ffe08a; }
#turn-banner.mine { color: #9fd8ff; }
#turn-banner.foe { color: #ff9c9c; }
.pop.pp { color: #8fd0ff; }

/* ================= タイトル画面 ================= */
#title { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 2rem 1rem 6rem; position: relative; background: radial-gradient(ellipse at 50% 30%, #2b2d6b 0%, #12152b 55%, #0a0c1c 100%); }
.t-main { text-align: center; }
.t-logo { margin: 0; font-size: clamp(2.6rem, 9vw, 5.5rem); letter-spacing: .04em; font-family: Georgia, 'Times New Roman', serif; font-style: italic; background: linear-gradient(#fff, #9cd3ff); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 14px rgba(120, 190, 255, .45)); }
.t-read { margin-top: .3rem; color: #9da6d2; letter-spacing: .3em; font-size: .95rem; }
.t-catch { margin: 2rem 0; line-height: 2; color: #e3e6ff; font-size: 1.05rem; }
#title-form { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
#player-name { padding: .6rem .9rem; font-size: 1.05rem; width: 15rem; background: #1f2547; color: #eee; border: 1px solid #6a8; border-radius: 6px; text-align: center; }
#title-start { padding: .6rem 2rem; font-size: 1.05rem; font-weight: 700; background: #2e8b3d; color: #fff; border: 0; border-radius: 6px; }
#title-start:hover { background: #3aa64c; }
.t-credit { position: absolute; left: 12px; bottom: 8px; margin: 0; font-size: .68rem; line-height: 1.4; color: #8e97c6; display: grid; grid-template-columns: auto auto; gap: 0 .8rem; }
.t-credit dt { color: #7f88b8; }
.t-credit dd { margin: 0 0 .25rem; }
#me-name { color: #a9b8ff; font-weight: 400; font-size: .9rem; margin-left: .6rem; }
/* -0（ブロック・ブラーで防いだ）とアーマー獲得の表示 */
.pop.zero { color: #e3e9f0; }
.pop.blk { color: #7fd4ff; }
.pop .pop-label { display: block; font-size: .32em; text-align: center; letter-spacing: .05em; margin-top: .1em; }
/* ログのカード名: 絵を横に置く。カーソルでカードの説明を出す */
#log .lcard { display: inline-flex; align-items: center; gap: .3em; cursor: zoom-in; border-radius: .3em; padding: 0 .25em 0 0; background: rgba(255,255,255,.07); }
#log .lcard:hover { background: rgba(255,255,255,.18); }
#log .lcard img { width: 2.6em; height: 1.95em; object-fit: cover; border-radius: .25em; vertical-align: middle; }
#log-preview { position: fixed; width: 270px; z-index: 70; pointer-events: none; filter: drop-shadow(0 6px 18px rgba(0,0,0,.7)); }
/* 絞り込み: ボタンで開くパネル（弾・テーマ・条件）。有効な条件はチップで表示 */
.filters #f-toggle.on { background: #2e6b8f; color: #fff; }
#f-panel { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; padding: .6rem .8rem; margin: -.3rem 0 .8rem; background: #1c2242; border: 1px solid #343a68; border-radius: 6px; font-size: .9rem; }
#f-panel select { padding: .3rem; background: #1f2547; color: #eee; border: 1px solid #454c85; border-radius: 4px; }
#f-active { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
#f-active .fchip { background: #2e6b8f; color: #fff; border-radius: 1em; padding: .1em .7em; font-size: .85em; cursor: pointer; }
#f-active .fchip:hover { background: #3a84ae; }
/* カードの説明文の【○○(x)】: カーソルを合わせると説明が出る */
.tag[data-tip-t] { cursor: help; border-bottom: 1px dotted currentColor; }
.tag[data-src] { cursor: help; }
#tip small { display: block; white-space: pre-line; }

.tag[data-src] { border-bottom: 1px dotted currentColor; } /* トークン条件: 説明は出る。入手元カードは、拡大表示中の右クリックで隣に出す */

/* アカウント・デッキの管理 */
#title-user { padding: .55rem 1rem; font-size: 1.1rem; color: #e3e6ff; }
#title-user b { color: #a9b8ff; font-size: 1.25rem; }
#title-sub { margin-top: .8rem; }
.linkbtn { background: none; border: 0; color: #8fb4d8; text-decoration: underline; padding: .2rem .4rem; font-size: .85rem; cursor: pointer; }
.linkbtn:hover { color: #cfe6ff; }
#title-note { margin-top: .6rem; color: #e7c889; font-size: .85rem; min-height: 1.2em; }
#acct-note { color: #e7c889; }
#dm { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 45; }
#dm .box { width: min(640px, 94vw); max-height: 90vh; overflow-y: auto; background: #12152b; border: 2px solid #454c85; border-radius: 10px; padding: 1rem 1.2rem; }
#dm .head { display: flex; align-items: center; gap: .8rem; margin-bottom: .6rem; }
#dm .head b { font-size: 1.2rem; }
#dm-acct { color: #a9b8ff; flex: 1; font-size: .9rem; }
#dm-msg { min-height: 1.4em; margin-bottom: .4rem; color: #9fe3a8; font-size: .9rem; }
#dm-msg.err { color: #ff9a9a; }
.dm-row { display: grid; grid-template-columns: 2em 1fr auto auto auto; gap: .5rem; align-items: center; padding: .4rem .2rem; border-bottom: 1px solid #2b3160; }
.dm-row .no { color: #8e97c6; text-align: center; }
.dm-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-row .nm small { color: #8e97c6; margin-left: .5em; }
.dm-row.empty .nm { color: #7f88b8; }
.dm-row button { padding: .3rem .7rem; font-size: .85rem; }
.dm-row input { width: 100%; padding: .3rem; background: #1f2547; color: #eee; border: 1px solid #6a8; border-radius: 4px; }
.dm-row button.warn { background: #a04545; color: #fff; }
.dm-help { margin-top: .6rem; color: #8e97c6; font-size: .8rem; }
.dm-code { margin-top: .8rem; padding-top: .7rem; border-top: 1px solid #2b3160; }
.dm-code textarea { width: 100%; margin-top: .4rem; padding: .4rem; background: #1f2547; color: #eee; border: 1px solid #444c80; border-radius: 4px; font: inherit; font-size: .85rem; resize: vertical; box-sizing: border-box; }
.dm-code-btns { display: flex; gap: .5rem; margin-top: .4rem; }
.dm-code-btns button { padding: .3rem .7rem; font-size: .85rem; }
/* ================= デッキ構築（新デザイン）================= */
#builder { --card-w: 150px; min-height: 100vh; padding: 0 clamp(10px, 14vw, 300px) 4rem; }
@media (max-width: 900px) { #builder { padding: 0 3vw 3rem; } }
.b-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .8rem 0; background: linear-gradient(var(--bg) 70%, transparent); }
.b-title { display: flex; align-items: baseline; gap: .8rem; }
.b-logo { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 1.5rem; letter-spacing: .04em; color: var(--gold); text-shadow: 0 0 14px rgba(230, 201, 122, .35); }
#me-name { color: var(--muted); font-size: .9rem; margin: 0; }
.b-deck { display: flex; align-items: center; gap: 1rem; }
.b-count { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 0 .3rem; justify-items: start; }
.b-count b { font-size: 1.9rem; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.b-count span { color: var(--muted); }
.b-meter { grid-column: 1 / -1; display: block; width: 8.5rem; height: 5px; margin-top: .3rem; background: var(--line); border-radius: 3px; overflow: hidden; }
.b-meter u { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--magic), var(--gold)); transition: width .25s; }
.b-count small { grid-column: 1 / -1; color: var(--gold); font-size: .78rem; min-height: 1em; }
button.primary, #start { padding: .7rem 2rem; font-size: 1.05rem; font-weight: 700; letter-spacing: .08em; color: #fff4d6; background: linear-gradient(#4b3f9c, #342d78); border: 1px solid var(--gold); border-radius: 999px; box-shadow: 0 0 16px rgba(143, 160, 255, .3); transition: box-shadow .2s, filter .2s; }
#start-cpu { margin-left: .5rem; }
button.primary:hover:not(:disabled), #start:hover:not(:disabled) { box-shadow: 0 0 22px rgba(230, 201, 122, .5); filter: brightness(1.12); }
#pack-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: .2rem 0 .8rem; }
#pack-tabs button { padding: .45rem 1.1rem; font-size: .92rem; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; }
#pack-tabs button:hover { color: var(--text); border-color: var(--line2); }
#pack-tabs button.on { color: #fff4d6; background: rgba(143, 160, 255, .18); border-color: var(--gold); }
.b-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem; margin-bottom: .6rem; }
.b-tools input[type=search] { flex: 1 1 14rem; max-width: 22rem; padding: .5rem .9rem; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; }
.b-tools input[type=search]:focus { outline: none; border-color: var(--magic); box-shadow: 0 0 10px rgba(143, 160, 255, .3); }
.b-tools button { padding: .45rem 1rem; font-size: .9rem; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; }
.b-tools button:hover { border-color: var(--line2); }
.b-tools button.on { border-color: var(--gold); color: var(--gold); }
.b-size { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .85rem; }
.b-size input { width: 8rem; accent-color: #9fa8ff; }
#f-count { color: var(--muted); font-size: .85rem; margin-left: auto; }
.menu { position: relative; }
#deck-pop { position: absolute; z-index: 8; top: calc(100% + .4rem); right: 0; min-width: 14rem; display: flex; flex-direction: column; gap: .3rem; padding: .5rem; background: var(--panel2); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .55); }
#deck-pop button { text-align: left; border-radius: 8px; border-color: transparent; background: transparent; }
#deck-pop button:hover:not(:disabled) { background: rgba(143, 160, 255, .15); }
#deck-pop label { padding: .45rem 1rem; font-size: .88rem; color: var(--text); cursor: pointer; }
#f-panel { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.4rem; padding: .7rem 1rem; margin: 0 0 .6rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; font-size: .9rem; color: var(--muted); }
#f-panel select { padding: .35rem .6rem; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; }
#f-panel button { padding: .35rem .9rem; font-size: .85rem; border-radius: 999px; color: var(--text); background: transparent; border: 1px solid var(--line2); }
#f-active { display: flex; flex-wrap: wrap; gap: .4rem; }
#f-active:not(:empty) { margin-bottom: .6rem; }
#f-active .fchip { background: rgba(143, 160, 255, .2); color: var(--text); border: 1px solid var(--magic); border-radius: 999px; padding: .15em .8em; font-size: .82rem; cursor: pointer; }
#f-active .fchip:hover { background: rgba(143, 160, 255, .35); }
.b-hint { color: var(--muted); font-size: .8rem; margin: 0 0 .4rem; }
#pool h3 { display: flex; align-items: center; gap: .8rem; margin: 1.6rem 0 .8rem; font-weight: 600; font-size: 1.05rem; letter-spacing: .08em; color: var(--gold); }
#pool h3::before, #pool h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line2), transparent); }
#pool h3 small { color: var(--muted); font-weight: 400; letter-spacing: 0; font-size: .8rem; }
#pool .empty { text-align: center; color: var(--muted); padding: 3rem; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, var(--card-w)); gap: calc(var(--card-w) * .09); justify-content: center; }
.cgrid .cardv { transition: transform .15s, filter .15s; }
.cgrid .cardv:hover { transform: translateY(-3px); }
/* 採用ボタン（カードの右上）: 未採用は薄い「＋」、採用中は「✔ 採用」 */
#pool .cardv .c-badge { display: flex; cursor: pointer; opacity: 0; background: rgba(18, 21, 43, .85); color: var(--gold); border: 1px solid var(--gold); transition: opacity .15s; }
#pool .cardv .c-badge::before { content: '＋ '; }
#pool .cardv:hover .c-badge { opacity: .95; }
#pool .cardv.picked .c-badge { opacity: 1; background: #3b8c74; color: #fff; border-color: #aef0d8; }
#pool .cardv.picked .c-badge::before { content: ''; }
.note { margin: 0 0 .6rem; padding: .5rem .9rem; color: #f0d9a0; background: rgba(230, 201, 122, .1); border: 1px solid rgba(230, 201, 122, .35); border-radius: 10px; font-size: .85rem; }
/* ================= タイトル・全体の色（神秘＋魔法）================= */
#title { background:
  radial-gradient(1.5px 1.5px at 12% 22%, #fff8 50%, transparent 51%), radial-gradient(1px 1px at 78% 18%, #fff9 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 30% 70%, #cfd6ff99 50%, transparent 51%), radial-gradient(1px 1px at 88% 64%, #fff8 50%, transparent 51%),
  radial-gradient(1px 1px at 55% 12%, #ffe9b3aa 50%, transparent 51%), radial-gradient(1.5px 1.5px at 66% 82%, #fff7 50%, transparent 51%),
  radial-gradient(1px 1px at 8% 88%, #fff8 50%, transparent 51%), radial-gradient(1px 1px at 93% 38%, #cfd6ff99 50%, transparent 51%),
  radial-gradient(ellipse at 50% 35%, #34357a 0%, #1a1c45 45%, #0c0e22 100%); }
#title::before { content: ''; position: absolute; left: 50%; top: 34%; width: min(70vw, 620px); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; border: 1px solid rgba(230, 201, 122, .22); box-shadow: 0 0 60px rgba(143, 160, 255, .18) inset, 0 0 40px rgba(143, 160, 255, .12); pointer-events: none; animation: sigil 24s linear infinite; }
@keyframes sigil { to { transform: translate(-50%, -50%) rotate(360deg); } }
.t-main { position: relative; z-index: 1; }
.t-logo { font-style: normal; font-weight: 400; letter-spacing: .12em; background: linear-gradient(#fffbe8, #e6c97a 70%, #b79a52); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 18px rgba(230, 201, 122, .4)); }
.t-read { color: var(--muted); }
.t-catch { color: #d7dbf5; letter-spacing: .06em; }
#player-name { color: var(--text); background: rgba(27, 32, 64, .8); border: 1px solid var(--line2); border-radius: 999px; }
#player-name:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 12px rgba(230, 201, 122, .3); }
#title-start { color: #fff4d6; background: linear-gradient(#4b3f9c, #342d78); border: 1px solid var(--gold); border-radius: 999px; box-shadow: 0 0 16px rgba(143, 160, 255, .3); letter-spacing: .1em; }
#title-start:hover { background: linear-gradient(#5a4cb4, #3d3590); box-shadow: 0 0 24px rgba(230, 201, 122, .5); }
.t-credit { z-index: 1; }
/* ================= 対戦成立の演出 ================= */
#intro { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6rem; cursor: default;
  background: radial-gradient(ellipse at 50% 50%, rgba(46, 44, 120, .92) 0%, rgba(12, 14, 34, .97) 70%); animation: inVeil 5.4s ease both; }
@keyframes inVeil { 0% { opacity: 0; } 7% { opacity: 1; } 92% { opacity: 1; } 100% { opacity: 0; } }
.in-ring { position: absolute; left: 50%; top: 50%; width: min(86vmin, 700px); aspect-ratio: 1; margin: calc(min(86vmin, 700px) / -2) 0 0 calc(min(86vmin, 700px) / -2); border-radius: 50%;
  border: 1px solid rgba(230, 201, 122, .45); box-shadow: 0 0 60px rgba(143, 160, 255, .25) inset, 0 0 40px rgba(143, 160, 255, .2); animation: inRing 5.4s ease-out both; }
.in-ring::after { content: ''; position: absolute; inset: 9%; border-radius: 50%; border: 1px dashed rgba(143, 160, 255, .45); }
@keyframes inRing { 0% { transform: scale(.4) rotate(-90deg); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(1) rotate(90deg); opacity: .8; } }
.in-label { position: relative; color: var(--gold); letter-spacing: .5em; font-size: clamp(.9rem, 2vw, 1.2rem); animation: inFade .7s .1s ease both; }
.in-row { position: relative; display: flex; align-items: center; justify-content: center; gap: clamp(1rem, 5vw, 4rem); width: 100%; }
.in-side { display: flex; flex-direction: column; gap: .5rem; min-width: 0; max-width: 34vw; }
.in-side b { font-size: clamp(1.4rem, 4.4vw, 3rem); font-weight: 600; letter-spacing: .06em; color: #fff; text-shadow: 0 0 18px rgba(143, 160, 255, .7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-side small { color: var(--muted); letter-spacing: .3em; font-size: clamp(.75rem, 1.4vw, 1rem); }
.in-side.you { align-items: flex-end; text-align: right; animation: inLeft .8s .5s cubic-bezier(.2, .9, .3, 1) both; }
.in-side.foe { align-items: flex-start; text-align: left; animation: inRight .8s .5s cubic-bezier(.2, .9, .3, 1) both; }
.in-side.foe b { text-shadow: 0 0 18px rgba(255, 140, 140, .6); }
.in-vs { font-family: Georgia, serif; font-style: italic; font-size: clamp(1.8rem, 6vw, 4rem); color: var(--gold); text-shadow: 0 0 24px rgba(230, 201, 122, .7); animation: inVs .6s 1.05s cubic-bezier(.2, 1.6, .4, 1) both; }
.in-go { position: relative; margin-top: .4rem; font-size: clamp(1.6rem, 5vw, 3.4rem); letter-spacing: .4em; padding-left: .4em; color: #fff4d6; text-shadow: 0 0 26px rgba(230, 201, 122, .8); animation: inGo .7s 3.9s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes inFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes inLeft { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }
@keyframes inRight { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
@keyframes inVs { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: scale(1); } }
@keyframes inGo { from { opacity: 0; transform: scale(.6); letter-spacing: 1em; } to { opacity: 1; transform: scale(1); } }
#sound-btn { position: fixed; right: 10px; top: 8px; z-index: 120; width: 2.4rem; height: 2.4rem; padding: 0; font-size: 1.1rem; line-height: 1; border-radius: 50%; background: rgba(27, 32, 64, .8); border: 1px solid var(--line2); opacity: .7; }
#sound-btn:hover { opacity: 1; }
body.in-battle #sound-btn { top: auto; bottom: 10px; right: 10px; width: 2rem; height: 2rem; font-size: .95rem; }

/* 絞り込み: 発動条件・キーワードのチェックボックス */
#f-panel { display: flex; flex-direction: column; align-items: stretch; gap: .8rem; }
#f-panel .f-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.4rem; }
.f-group { margin: 0; padding: .5rem .8rem .7rem; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.f-group legend { padding: 0 .4rem; color: var(--gold); font-size: .85rem; letter-spacing: .05em; }
.f-group .mode { margin-left: .6rem; padding: .1rem .7rem; font-size: .72rem; color: var(--muted); background: transparent; border: 1px solid var(--line2); border-radius: 999px; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem .5rem; }
.checks .ck-grp { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; width: 100%; }
.checks .ck-grp > span { width: 6.5rem; flex: none; color: var(--muted); font-size: .78rem; }
.checks.wide-label .ck-grp > span { width: 13rem; }
.f-group legend small { margin-left: .5rem; color: var(--muted); font-size: .72rem; letter-spacing: 0; }
.ck { position: relative; display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .7rem; font-size: .82rem; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; user-select: none; }
.ck:hover { border-color: var(--line2); }
.ck input { position: absolute; opacity: 0; pointer-events: none; }
.ck small { color: var(--muted); font-size: .72rem; }
.ck:has(input:checked) { color: #fff4d6; background: rgba(143, 160, 255, .25); border-color: var(--gold); }
.ck:has(input:focus-visible) { outline: 2px solid var(--magic); }

/* 説明文の中の生成カード名: クリックでそのカードを開く */
.stlink { cursor: help; border-bottom: 1px dotted currentColor; }
.glink { cursor: help; border-bottom: 1px dotted currentColor; font-weight: 700; }
.glink:hover { filter: brightness(1.25); }

/* 拡大表示: カード説明のリンクで飛ぶとき、元のカード（左）と一回り小さい飛び先カード（右）を並べる */
#zoom-row { display: flex; align-items: center; justify-content: center; gap: 2vw; }
#zoom-arrow { color: var(--gold); font-size: 2rem; opacity: .8; }
#zoom.pair #zoom-card { width: min(40vw, 56vh); }
#zoom-sub { width: min(32vw, 45vh); }
@media (max-width: 760px) {
  #zoom-row { flex-direction: column; gap: 1vh; }
  #zoom-arrow { transform: rotate(90deg); font-size: 1.4rem; }
  #zoom.pair #zoom-card { width: min(62vw, 38vh); }
  #zoom-sub { width: min(50vw, 30vh); }
}

/* 手札: 発動条件【○○(x)】を満たしているカードは、金と青紫のオーラをまとう（満たしていないカードは今までどおり） */
#hand .hand-card.aura { animation: auraGlow 1.7s ease-in-out infinite; }
#hand .hand-card.aura::before { content: ''; position: absolute; inset: -5%; border-radius: 9%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 224, 140, .55), rgba(143, 160, 255, .35) 60%, transparent 100%); filter: blur(5px); animation: auraBreath 1.7s ease-in-out infinite; }
#hand .hand-card.aura::after { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 100%; border-radius: 6%; pointer-events: none; z-index: 4;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 244, 205, .55) 50%, transparent 65%); background-size: 250% 100%; mix-blend-mode: screen; animation: auraSweep 2.8s linear infinite; }
@keyframes auraGlow { 0%, 100% { filter: drop-shadow(0 0 4px rgba(230, 201, 122, .8)) drop-shadow(0 0 9px rgba(143, 160, 255, .5)); } 50% { filter: drop-shadow(0 0 9px rgba(255, 228, 150, 1)) drop-shadow(0 0 20px rgba(143, 160, 255, .85)); } }
@keyframes auraBreath { 0%, 100% { opacity: .55; transform: scale(.98); } 50% { opacity: 1; transform: scale(1.04); } }
@keyframes auraSweep { 0% { background-position: 150% 0; } 60%, 100% { background-position: -50% 0; } }

/* 生成されるカード: フレームも白黒。コストの緑の円が白黒になるので、数字は濃い灰色にする */
.cardv.mono .c-cost { color: #3c3c3c; }
.cardv.mono .tag { color: #5a5a5a; }

/* 対戦成立: 先攻後攻をきめるじゃんけん（見た目だけ。先攻がランダムに手を出し、後攻はそれに負ける手を出す）と、致命カードの表示 */
.in-hand { margin-top: .6rem; font-size: clamp(2.6rem, 8vw, 5rem); line-height: 1; opacity: 0; animation: inFade .4s 1.55s ease both; filter: drop-shadow(0 0 12px rgba(143, 160, 255, .6)); transition: transform .35s cubic-bezier(.2, 1.6, .4, 1), filter .35s, opacity .35s; }
.in-side.you .in-hand { transform-origin: 100% 50%; }
.in-side.foe .in-hand { transform-origin: 0 50%; }
.in-hand.spin { animation: inFade .4s 1.55s ease both, handShake .18s linear infinite 1.9s; }
@keyframes handShake { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-.12em); } }
.in-hand.win { transform: scale(1.35); filter: drop-shadow(0 0 22px rgba(230, 201, 122, .95)); }
.in-hand.lose { transform: scale(.82); opacity: .55; filter: grayscale(.8); }
.in-lethal { margin-top: .5rem; max-width: 34vw; font-size: clamp(.7rem, 1.3vw, .95rem); color: #f0b0b0; opacity: 0; animation: inFade .5s 1.1s ease both; line-height: 1.7; }
.in-side.you .in-lethal { text-align: right; }
.in-lethal b { display: inline; font-size: inherit; letter-spacing: 0; color: #ffd0d0; text-shadow: none; font-weight: 600; white-space: normal; }
.in-lethal .lt { display: inline-block; margin: 0 0 .15rem .3rem; padding: .05em .7em; background: rgba(122, 42, 42, .75); border: 1px solid rgba(255, 140, 140, .5); border-radius: 999px; }

/* 「現在の状況」の生産: 生成カードと同じモノクロの見た目 */
.nowchip.mono { background: #2b2b2e; border-color: #5d5d62; filter: grayscale(1); }
.nowchip.mono b { color: #cfcfd4; }

/* 天啓の枚数（デッキの決まり: 2枚まで）と通知 */
#deck-open { grid-column: 1 / -1; color: var(--muted); font-size: .75rem; }
#deck-open.full { color: var(--gold); }
#toast { position: fixed; left: 50%; bottom: 8vh; transform: translate(-50%, 12px); z-index: 130; max-width: 90vw; padding: .6rem 1.2rem; background: rgba(27, 32, 64, .96); color: var(--text); border: 1px solid var(--gold); border-radius: 999px; box-shadow: 0 6px 22px rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* コストが増減しているカード: コストの数字を金色に */
.cardv.costmod .c-cost { color: #8a5a00; text-shadow: 0 0 .3em rgba(255, 214, 120, .9); }

/* ================= スマホ版（縦画面）=================
   html.phone が付いたときだけ有効（PCの見た目は変えない）。上: いつもの帯、中央: 手札（左右に小さく山札・捨て札）、最下部: ログ */
html.phone, html.phone body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
html.phone * { touch-action: manipulation; }
html.phone .cardv, html.phone .stack, html.phone #log .lcard { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
html.phone #board { display: flex; flex-direction: column; width: 100vw; height: 100vh; height: 100dvh; font-size: 12px; }
html.phone #arena { flex: 1 1 0; min-height: 0; grid-template-rows: auto auto 3.2em auto minmax(0, 1fr); }

/* 山札・手札・捨て札の段 */
html.phone .zones { grid-template-columns: 15% 1fr 15%; padding: 0 1.5%; }
html.phone .stack { width: min(11vw, 100%); }
html.phone .stack .cnt { font-size: .9em; }
html.phone .foe-zones { padding: 8px 2% 6px; grid-template-columns: 15% 1fr 15%; }
html.phone .foe-zones .stack { width: 9vw; }
html.phone .foe-zones .stack em { display: none; }
html.phone .foe-hand-backs .cback { width: 6.4vw; margin-left: -2.6vw; border-width: 2px; }
html.phone .you-zones { padding: 4px 1.5% 6px; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
html.phone .foe-zones { grid-template-rows: auto; }
html.phone .z-deck, html.phone .z-discard { align-items: center; }
html.phone #discard-prompt { font-size: 1.1em; padding: .35em 1em; white-space: normal; text-align: center; width: max-content; max-width: 90%; }

/* 手札: 枠いっぱいに、重ならない大きさで並べる（JS が大きさと列数を決める。2段〜3段になる） */
html.phone #hand { display: grid; justify-content: center; align-content: center; align-items: center; gap: 3px; height: 100%; }
html.phone #hand .hand-card { width: var(--hw); margin-left: 0 !important; transition: none; }
html.phone #hand .hand-card:hover { transform: none; z-index: auto; }
html.phone .hand-card:hover .c-x { display: none; }

/* プレイヤー帯: 1段目に 名前 / HP+バフ / PP、2段目にトークン・カウント */
html.phone .pbar { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "name mid pp" "tks tks tks"; gap: 4px 8px; padding: 6px 8px; font-size: 12px; }
html.phone .pbar.foe { font-size: 12px; }
html.phone .b-name { grid-area: name; max-width: 26vw; min-width: 0; }
html.phone .b-name .nm, html.phone .pbar.foe .b-name .nm { font-size: 1.35em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.phone .b-mid { grid-area: mid; }
html.phone .b-right { display: contents; }
html.phone .buffs { min-height: 0; margin-bottom: .3em; gap: .3em; }
html.phone .stb { font-size: 1em; padding: .15em .3em .15em .6em; }
html.phone .hpbar { height: 1.9em; }
html.phone .ppc { grid-area: pp; width: 4.8em; height: 4.8em; }
html.phone .ppc b { font-size: 1.9em; }
html.phone .ppc.long b { font-size: 1.5em; }
html.phone .tks, html.phone .pbar.foe .tks { grid-area: tks; position: static; width: auto; max-width: none; justify-content: flex-start; flex-wrap: wrap; padding: 0; gap: .5em; }
html.phone .tks:empty { display: none; }
html.phone .tkc { width: 3.6em; height: 3.6em; }
html.phone .tkc:hover { transform: none; }

/* 中央: ターン表示（結果の大きな文字と「戻る」は、画面の真ん中に重ねる） */
html.phone #center { min-height: 0; overflow: visible; gap: 0; }
html.phone #banner { font-size: 1.05em; padding-top: .5em; }
html.phone #banner.result { position: fixed; left: 0; right: 0; top: 30%; z-index: 60; font-size: 13vw; }
html.phone #back { position: fixed; left: 50%; top: 46%; transform: translateX(-50%); z-index: 61; font-size: 1.1em; }
html.phone #wait-back { font-size: 1em; }
html.phone #turn-banner { left: 0; width: 100vw; height: 100vh; height: 100dvh; font-size: 9vw; }

/* 下: 操作ボタン・Time（1段目）とログ（2段目） */
html.phone #side { height: 26vh; height: 26dvh; flex: none; display: grid; grid-template-columns: 1fr auto auto; grid-template-rows: auto minmax(0, 1fr); border-left: 0; border-top: 2px solid #4a4f86; }
html.phone #side h3 { display: none; }
html.phone #side-buttons { grid-column: 1; grid-row: 1; padding: .4em .5em; border-top: 0; }
html.phone #side-buttons button { padding: .6em .3em; font-size: 1.05em; }
html.phone #deck-status { grid-column: 2; grid-row: 1; align-self: center; margin: 0 .3em; padding: .55em .7em; font-size: .95em; }
html.phone #timebox { grid-column: 3; grid-row: 1; height: auto; min-height: 0; border-top: 0; padding: 0 .7em; }
html.phone #timebox b { font-size: 1.7em; }
html.phone #timebox span { font-size: .8em; }
html.phone #log { grid-column: 1 / -1; grid-row: 2; font-size: 1.1em; line-height: 1.5; padding: .4em .7em; border-top: 1px solid #343a68; }

/* デッキ構築・その他 */
html.phone button.primary, html.phone #start { padding: .55rem 1.1rem; font-size: .95rem; letter-spacing: .02em; }
html.phone #start-cpu { margin-left: 0; }
html.phone .b-deck { gap: .5rem; flex-wrap: wrap; }
html.phone .b-meter { width: 5rem; }
html.phone #zoom-card { width: min(84vw, 56vh); }

/* ================= 画像で置き換えた面 =================
   画像の指定はここの変数だけ。差し替えるときは public/img/ui/ のファイルを同じ名前で上書きする（変数を書き換えてもよい）。
   hp-fill / shield-fill は、横長（目安 3200×140）の絵を、バー全体の幅に固定して置き、HPやブロックの分だけ左から切り取って見せる（縮めない） */
:root {
  --img-title-bg: url(img/ui/title-bg.webp);       /* タイトル画面の背景 */
  --img-builder-bg: url(img/ui/builder-bg.webp);   /* デッキ構築の背景（戦闘画面とは別） */
  --img-hp-fill: url(img/ui/hp-fill.png);          /* HPバーの赤い中身 */
  --img-hp-shield: url(img/ui/shield-fill.png);    /* ブロックのシールドバー */
  --img-block-icon: url(img/ui/block-icon.png);    /* ブロックのアイコン */
}
#title { background: linear-gradient(rgba(6, 8, 24, .30), rgba(6, 8, 24, .55)), var(--img-title-bg) center / cover no-repeat, #0c0e22; }
#builder { background: linear-gradient(rgba(8, 10, 28, .58), rgba(8, 10, 28, .80)), var(--img-builder-bg) center / cover fixed no-repeat; }
.b-head { background: linear-gradient(rgba(10, 12, 30, .93) 70%, transparent); }
/* デッキ編成画面: 操作の部分（デッキの枚数・弾のタブ・検索・絞り込み）の裏に、半透明の黒を置く。背景の絵はその裏にそのまま見える */
.b-head { margin: 0; padding: .8rem 1rem; border-radius: 0 0 14px 14px; background: linear-gradient(rgba(0, 0, 0, .80) 72%, rgba(0, 0, 0, 0)); }
.b-controls { margin: 0 0 1.1rem; padding: .8rem 1rem .5rem; background: rgba(0, 0, 0, .62); border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; }
.b-controls #pack-tabs { margin-top: 0; }
.b-controls #f-panel { margin: 0 0 .7rem; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); }
.b-controls .b-hint { margin: .1rem 0 .3rem; }
#deck-pop { background: rgba(6, 8, 22, .95); }
#pool h3 { text-shadow: 0 1px 6px #000, 0 0 14px #000; }
.hpbar { container-type: inline-size; } /* 中身・シールドの絵の大きさを、バー全体の幅（100cqw）に固定するため */
.hpbar i { background: var(--img-hp-fill) left top / 100cqw 100% no-repeat; }
.hpbar .blkbar { background: var(--img-hp-shield) left top / 100cqw 100% no-repeat; }
/* 対戦待ちの人がいるとき、「対戦開始」が少し光る（デッキ編成画面。押せるときだけ） */
#start.has-waiting:not(:disabled) { border-color: #ffeeb8; animation: waitGlow 1.9s ease-in-out infinite; }
@keyframes waitGlow {
  0%, 100% { box-shadow: 0 0 14px rgba(230, 201, 122, .30); filter: brightness(1); }
  50% { box-shadow: 0 0 30px rgba(255, 224, 140, .85), 0 0 8px rgba(255, 240, 190, .75); filter: brightness(1.14); }
}
.hpbar .blkbar em::before, .pop.blk .pop-label::before { content: ''; display: inline-block; width: 1.25em; height: 1.25em; margin-right: .25em; vertical-align: -.28em; background: var(--img-block-icon) center / contain no-repeat; }
/* 遊び方（タイトルの右上。右上固定の音量ボタンのすぐ左） */
#howto-btn { position: absolute; top: 8px; right: 58px; z-index: 5; height: 2.4rem; padding: 0 1.1rem; font-size: .9rem; letter-spacing: .12em; color: #fff4d6; background: rgba(27, 32, 64, .8); border: 1px solid var(--line2); border-radius: 999px; opacity: .85; }
#howto-btn:hover { opacity: 1; border-color: var(--gold); box-shadow: 0 0 14px rgba(230, 201, 122, .3); }
#howto { position: fixed; inset: 0; z-index: 130; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .65); }
#howto .box { width: min(620px, 94vw); max-height: 88vh; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 0 40px rgba(143, 160, 255, .2); }
#howto .head { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; border-bottom: 1px solid var(--line); }
#howto .head b { color: var(--gold); font-size: 1.1rem; letter-spacing: .15em; }
#howto-body { overflow-y: auto; padding: .4rem 1.2rem 1.2rem; line-height: 1.85; font-size: .95rem; color: var(--text); }
#howto-body h4 { margin: 1.1rem 0 .3rem; padding-bottom: .2rem; color: var(--gold); font-size: 1rem; letter-spacing: .1em; border-bottom: 1px solid var(--line); }
#howto-body p { margin: .3rem 0; }
#howto-body ul, #howto-body ol { margin: .3rem 0; padding-left: 1.4rem; }
#howto-body li { margin: .2rem 0; }
