/* ===== テーマ（見た目の仕上げ）: style.css の上に重ねる ===== */
:root {
  --ink: #070a12; --ink2: #0d1220; --glass: rgba(12, 16, 28, .78); --glass2: rgba(20, 26, 44, .72);
  --gold: #e3c06a; --gold2: #b48a2c; --gold3: #fff1c4; --line: rgba(227, 192, 106, .22); --line2: rgba(227, 192, 106, .45);
  --text: #eef0f6; --muted: #98a0b8; --accent: #f0c75e; --p0: #5cc8ff; --p1: #ff6f6a;
  --cand: #52ffb0; --sel: #ffd257; --danger: #ff4f5a;
  --font: "Zen Kaku Gothic New", "Yu Gothic UI", "Hiragino Sans", "Meiryo", sans-serif;
  --font-title: "Dela Gothic One", "Zen Kaku Gothic New", sans-serif;
  --font-latin: "Cinzel", "Times New Roman", serif;
}
html, body { background: var(--ink); font-family: var(--font); font-feature-settings: "palt"; letter-spacing: .02em; }
::selection { background: rgba(227, 192, 106, .35); }
* { scrollbar-width: thin; scrollbar-color: rgba(227, 192, 106, .35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: rgba(227, 192, 106, .3); border-radius: 4px; } ::-webkit-scrollbar-track { background: transparent; }

/* ----- ボタン ----- */
button {
  position: relative; overflow: hidden; color: var(--text); font-weight: 700; letter-spacing: .05em;
  background: linear-gradient(180deg, #2a3350, #182036); border: 1px solid rgba(160, 175, 220, .28);
  border-radius: 8px; padding: 6px 14px; box-shadow: 0 2px 0 rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: transform .12s, box-shadow .2s, filter .2s, background .2s;
}
button:hover { background: linear-gradient(180deg, #34406a, #1d2844); filter: brightness(1.08); box-shadow: 0 0 0 1px rgba(227, 192, 106, .35), 0 4px 14px rgba(0, 0, 0, .5); }
button:active { transform: translateY(1px) scale(.98); }
button::after { content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .22), transparent); transform: skewX(-20deg); transition: left .5s; pointer-events: none; }
button:hover::after { left: 130%; }
button.primary {
  color: #1d1405; text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  background: linear-gradient(180deg, #ffe7a1 0%, #e9be55 45%, #b8862a 100%); border: 1px solid #ffe3a0;
  box-shadow: 0 2px 0 #6b4a10, 0 0 18px rgba(240, 199, 94, .35), inset 0 1px 0 rgba(255, 255, 255, .6);
}
button.primary:hover { background: linear-gradient(180deg, #fff0bf 0%, #f3cb66 45%, #c8952f 100%); box-shadow: 0 2px 0 #6b4a10, 0 0 26px rgba(240, 199, 94, .6); }
button.danger { background: linear-gradient(180deg, #7a2633, #4a1520); border-color: #c4505f; }
button:disabled { filter: grayscale(.7) brightness(.7); }
select, input[type=text], input:not([type]), input[type=number], textarea {
  background: rgba(6, 9, 18, .8); color: var(--text); border: 1px solid rgba(160, 175, 220, .25); border-radius: 7px; padding: 6px 8px; transition: border-color .2s, box-shadow .2s;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(227, 192, 106, .18); }
input[type=checkbox], input[type=radio] { accent-color: var(--gold); }

.screen { animation: screen-in .45s ease-out; }
@keyframes screen-in { from { opacity: 0; filter: blur(4px); } to { opacity: 1; filter: none; } }

/* ----- タイトル画面 ----- */
#menu { position: relative; overflow: hidden; background: #05070d; }
#menu .menu-bg { position: absolute; inset: -4%; background: url(../assets/title.jpg) center/cover no-repeat, radial-gradient(circle at 50% 30%, #2a3a5e, #070a12); animation: kenburns 40s ease-in-out infinite alternate; filter: saturate(1.08); }
#menu .menu-shade { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, rgba(5, 7, 13, 0) 0%, rgba(5, 7, 13, .35) 55%, rgba(5, 7, 13, .9) 100%), linear-gradient(180deg, rgba(5, 7, 13, .1), rgba(5, 7, 13, .65)); }
#menu canvas.embers { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
@keyframes kenburns { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.08) translate(-1.5%, -1%); } }
.title-wrap { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 22px; width: min(720px, 94vw); }
.logo { text-align: center; animation: logo-in 1.2s cubic-bezier(.2, .8, .2, 1) both; }
.logo .en { font-family: var(--font-latin); font-weight: 700; letter-spacing: .5em; font-size: 14px; color: var(--gold3); opacity: .85; text-shadow: 0 0 10px rgba(255, 220, 140, .6); margin-left: .5em; }
.logo .jp {
  font-family: var(--font-title); font-size: clamp(30px, 5vw, 70px); line-height: 1.1; white-space: nowrap; margin: 6px 0 4px; letter-spacing: .04em;
  background: linear-gradient(180deg, #fff8dc 0%, #ffe08a 38%, #d79a2a 62%, #fff0b8 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #4a2e06) drop-shadow(0 0 24px rgba(255, 190, 80, .45));
}
.logo .sub { color: #d7dcef; letter-spacing: .4em; font-size: 13px; margin-left: .4em; text-shadow: 0 1px 4px #000; }
.logo .line { width: 280px; height: 1px; margin: 10px auto 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
@keyframes logo-in { from { opacity: 0; transform: translateY(-14px) scale(.96); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.menu-box {
  position: relative; background: linear-gradient(180deg, rgba(14, 19, 34, .82), rgba(8, 11, 22, .9)); backdrop-filter: blur(10px);
  border: 1px solid var(--line2); border-radius: 16px; padding: 22px 26px 18px; width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .06), 0 0 0 4px rgba(227, 192, 106, .05);
  animation: rise .9s .25s cubic-bezier(.2, .8, .2, 1) both;
}
.menu-box::before { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(227, 192, 106, .12); border-radius: 12px; pointer-events: none; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.menu-box h1 { display: none; }
.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.mode-cards input { display: none; }
.mode-card {
  position: relative; cursor: pointer; border-radius: 12px; padding: 14px 10px 12px; text-align: center; border: 1px solid rgba(160, 175, 220, .2);
  background: linear-gradient(180deg, rgba(40, 50, 80, .55), rgba(16, 20, 36, .7)); transition: transform .18s, border-color .2s, box-shadow .2s, background .2s;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--line2); }
.mode-card .ic { font-size: 26px; display: block; margin-bottom: 4px; filter: drop-shadow(0 2px 4px #000); }
.mode-card .t { font-weight: 900; font-size: 15px; letter-spacing: .08em; }
.mode-card .d { font-size: 11px; color: var(--muted); margin-top: 3px; }
.mode-cards input:checked + .mode-card { border-color: var(--gold); background: linear-gradient(180deg, rgba(120, 90, 30, .55), rgba(40, 28, 8, .75)); box-shadow: 0 0 0 1px var(--gold), 0 0 24px rgba(227, 192, 106, .35); }
.mode-cards input:checked + .mode-card .t { color: var(--gold3); }
.menu-grid { grid-template-columns: 150px 1fr; gap: 10px 14px; }
.menu-grid > label { color: #c9cfe2; font-weight: 700; font-size: 13px; }
.menu-buttons { margin-top: 18px; gap: 12px; }
.menu-buttons button { padding: 11px 30px; font-size: 16px; border-radius: 10px; }
.menu-buttons #btn-start { padding: 12px 46px; font-size: 18px; letter-spacing: .2em; }
.menu-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); font-size: 12px; }
.help { margin-top: 0; }
.help summary { cursor: pointer; }
.help[open] { max-height: 32vh; overflow: auto; }
.snd-toggle { display: flex; gap: 10px; }
.snd-toggle label { cursor: pointer; }

/* ----- 対戦画面 ----- */
#game { grid-template-columns: 300px 1fr 340px; background: var(--ink); }
#board { background: #06080e; }
#board::before { content: ""; position: absolute; inset: 0; background: url(../assets/mat.jpg) center/cover no-repeat; opacity: .75; filter: saturate(.95) brightness(.85); }
#board::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(3, 5, 10, .75) 100%); z-index: 0; }
#board canvas.embers { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; opacity: .7; }
#plane { position: relative; z-index: 2; background: linear-gradient(180deg, rgba(10, 14, 30, .45), rgba(10, 14, 30, .05) 30%, rgba(10, 14, 30, .05) 70%, rgba(10, 14, 30, .5)); box-shadow: 0 0 80px rgba(0, 0, 0, .6) inset; }
#game.tilt #plane { transform: rotateX(16deg); }

.row { border-radius: 12px; }
.row.field { background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .015)); border: 1px solid rgba(227, 192, 106, .12); box-shadow: inset 0 0 30px rgba(0, 0, 0, .35); }
.row.land { background: linear-gradient(180deg, rgba(150, 110, 40, .1), rgba(90, 60, 20, .06)); border: 1px solid rgba(227, 192, 106, .08); }
.row.hand { background: transparent; }
.row .rlabel { font-family: var(--font); font-weight: 900; letter-spacing: .3em; color: rgba(227, 192, 106, .55); font-size: 10px; text-shadow: 0 1px 2px #000; }

/* カード */
.card { border-radius: 6px; box-shadow: 0 3px 8px rgba(0, 0, 0, .7), 0 0 0 1px rgba(0, 0, 0, .6); transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .2s, filter .2s; }
.card img { border-radius: 6px; }
.row.field .card:hover, .row.land .card:hover { transform: translateY(-4px) scale(1.06); z-index: 5; box-shadow: 0 10px 22px rgba(0, 0, 0, .8), 0 0 0 1px rgba(227, 192, 106, .6); }
.row.hand .card:hover { transform: translateY(-16px) scale(1.25); box-shadow: 0 18px 30px rgba(0, 0, 0, .85), 0 0 0 1px rgba(227, 192, 106, .7); }
.card .back, .fx-ghost .back {
  background: url(../assets/back.jpg) center/cover no-repeat, radial-gradient(circle at 50% 45%, #3a2a6e, #140e2c 70%);
  border: none; box-shadow: inset 0 0 0 2px rgba(227, 192, 106, .75), inset 0 0 0 4px rgba(0, 0, 0, .55), inset 0 0 18px rgba(0, 0, 0, .6);
  color: transparent; font-size: 0; border-radius: 6px;
}
.card.night::after {
  content: "夜"; font-family: var(--font-title); font-size: calc(var(--ch) * .15); color: #fff3c4; align-items: flex-end; padding-bottom: 7%;
  background: url(../assets/night.jpg) center/cover no-repeat, radial-gradient(circle at 30% 25%, #4a4a90, #0d0c26);
  border: none; box-shadow: inset 0 0 0 2px rgba(170, 160, 255, .75), inset 0 0 22px rgba(0, 0, 30, .8);
  text-shadow: 0 0 10px #ffd86b, 0 0 2px #000; border-radius: 6px;
}
.card.sick { filter: saturate(.6) brightness(.85); }
.card.sick::before { content: "待機"; top: -7px; left: -5px; background: linear-gradient(180deg, #6b7290, #3b4058); border: 1px solid rgba(255, 255, 255, .25); font-weight: 700; padding: 0 4px; border-radius: 4px; box-shadow: 0 2px 4px rgba(0, 0, 0, .6); }
.card.swift::before, .card.quick::before { position: absolute; top: -7px; left: -5px; z-index: 3; font-size: 9px; font-weight: 700; padding: 0 4px; border-radius: 4px; color: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .35); }
.card.swift::before { content: "駿足"; background: linear-gradient(180deg, #3fcf7f, #1f7f4a); }
.card.quick::before { content: "待機・早業"; background: linear-gradient(180deg, #6b7290, #3b4058); }
.card.quick { filter: saturate(.75) brightness(.92); }
.card.playable { box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(240, 199, 94, .8), 0 3px 8px rgba(0, 0, 0, .7); animation: glow-gold 1.6s ease-in-out infinite; }
.card.cand { box-shadow: 0 0 0 3px var(--cand), 0 0 18px var(--cand); animation: glow-cand 1.2s ease-in-out infinite; }
.card.sel { box-shadow: 0 0 0 4px var(--sel), 0 0 22px var(--sel); animation: none; transform: translateY(-4px); }
.card.attacking { box-shadow: 0 0 0 3px #ff4f5a, 0 0 22px rgba(255, 60, 70, .9); }
.card.blocking { box-shadow: 0 0 0 3px #5cc8ff, 0 0 22px rgba(80, 190, 255, .9); }
@keyframes glow-gold { 50% { box-shadow: 0 0 0 2px #fff0b8, 0 0 26px rgba(240, 199, 94, 1), 0 3px 8px rgba(0, 0, 0, .7); } }
@keyframes glow-cand { 50% { box-shadow: 0 0 0 3px #b8ffdd, 0 0 28px var(--cand); } }
.card .pt {
  bottom: -6px; right: -6px; padding: 1px 6px; font-size: 13px; font-weight: 900; border-radius: 7px; letter-spacing: 0;
  background: linear-gradient(180deg, #232a44, #0a0d18); border: 1px solid rgba(227, 192, 106, .7); box-shadow: 0 2px 6px rgba(0, 0, 0, .8); color: #fff;
}
.card .pt .up { color: #6dffa0; } .card .pt .down { color: #ff7b7b; }
.card .dmg { background: radial-gradient(circle at 35% 30%, #ff8a8a, #c0101e); border: 1px solid #ffc0c0; box-shadow: 0 0 10px rgba(255, 40, 60, .8); font-weight: 900; }
.card .kwb span { background: rgba(10, 40, 30, .88); border: 1px solid rgba(110, 255, 180, .35); color: #b5ffd6; font-weight: 700; }
.card .ctrs span { background: linear-gradient(180deg, #8a6bff, #4f33c2); border: 1px solid rgba(255, 255, 255, .3); font-weight: 700; }
.card .eqb { background: linear-gradient(180deg, #ffe08a, #b88a1e); font-weight: 700; }
.token-face { background: radial-gradient(circle at 50% 30%, #3a4f78, #141b30); border: 2px solid rgba(160, 200, 255, .55); color: #e6efff; box-shadow: inset 0 0 14px rgba(0, 0, 0, .6); }

/* プレイヤー欄 */
.pinfo {
  position: relative; gap: 12px; padding: 4px 12px 4px 6px; min-height: 38px; border-radius: 12px;
  background: linear-gradient(90deg, rgba(10, 14, 26, .92), rgba(16, 22, 40, .78) 60%, rgba(10, 14, 26, .5)); border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .05); backdrop-filter: blur(6px);
}
.pinfo .pname { font-size: 15px; font-weight: 900; letter-spacing: .08em; text-shadow: 0 0 10px currentColor; }
.pinfo .life {
  display: inline-flex; align-items: center; justify-content: center; min-width: 50px; height: 30px; padding: 0 10px 0 8px; font-size: 21px; font-weight: 900; border-radius: 15px;
  background: radial-gradient(circle at 30% 30%, #4a1018, #1a0508); border: 1px solid rgba(255, 110, 120, .6); box-shadow: 0 0 12px rgba(255, 60, 80, .35), inset 0 0 8px rgba(0, 0, 0, .7);
  font-variant-numeric: tabular-nums;
}
.pinfo .life::before { content: "❤"; font-size: 14px; margin-right: 5px; color: #ff5d6a; text-shadow: 0 0 6px #ff2d4a; }
.pinfo .zc { font-size: 12px; } .pinfo .zc b { font-size: 14px; }
.pinfo button { padding: 2px 9px; font-size: 11px; border-radius: 6px; }
.pinfo.active-turn { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(227, 192, 106, .5), 0 0 24px rgba(227, 192, 106, .35), 0 6px 18px rgba(0, 0, 0, .5); }
.pinfo .prio { color: var(--gold3); text-shadow: 0 0 10px var(--gold); animation: prio 1.2s ease-in-out infinite; }
@keyframes prio { 50% { opacity: .55; } }

/* 中央の帯 */
#midbar {
  position: relative; z-index: 3; justify-content: center; gap: 4px; min-height: 34px; padding: 4px 12px;
  background: linear-gradient(90deg, transparent, rgba(6, 9, 18, .9) 12%, rgba(6, 9, 18, .9) 88%, transparent);
  border: none; box-shadow: 0 1px 0 rgba(227, 192, 106, .35), 0 -1px 0 rgba(227, 192, 106, .35);
}
#midbar .turn { font-family: var(--font); font-weight: 900; letter-spacing: .1em; margin-right: 10px; color: var(--gold3); text-shadow: 0 0 10px rgba(227, 192, 106, .7); }
#midbar .ph { position: relative; padding: 3px 14px 3px 18px; font-weight: 700; font-size: 12px; color: #7d86a3; background: rgba(255, 255, 255, .04); clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%); border-radius: 0; }
#midbar .ph.on { color: #1d1405; background: linear-gradient(180deg, #ffe7a1, #d9a83c); box-shadow: none; text-shadow: 0 1px 0 rgba(255, 255, 255, .4); }
#midbar .combat { margin-left: 12px; color: #ff9b8e; text-shadow: 0 0 8px rgba(255, 80, 60, .6); }

/* 左右のパネル */
#detail, #panel { background: linear-gradient(180deg, rgba(14, 18, 32, .97), rgba(7, 10, 18, .98)); border-color: var(--line); }
#detail { border-right: 1px solid var(--line); box-shadow: 6px 0 24px rgba(0, 0, 0, .5); z-index: 3; }
#panel { border-left: 1px solid var(--line); box-shadow: -6px 0 24px rgba(0, 0, 0, .5); z-index: 3; }
#detail .dhead, .phead { font-family: var(--font-latin); letter-spacing: .3em; font-size: 11px; color: var(--gold); padding: 9px 12px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(227, 192, 106, .1), transparent); }
#detail #preview img { border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(227, 192, 106, .35); animation: pv-in .25s ease-out; }
@keyframes pv-in { from { opacity: .3; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
#preview .ptext .nm { color: var(--gold3); font-weight: 900; text-shadow: 0 0 10px rgba(227, 192, 106, .4); }
#preview .ab { background: rgba(255, 255, 255, .035); border-radius: 7px; }
.pempty { text-align: center; padding-top: 20px !important; line-height: 1.8; }
.pempty::before { content: ""; display: block; width: 62%; aspect-ratio: .716; margin: 10px auto 18px; border-radius: 12px; background: url(../assets/back.jpg) center/cover; opacity: .55; box-shadow: 0 10px 30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(227, 192, 106, .35); }
#topbar { padding: 8px; gap: 10px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, .25); }
#topbar label { color: #c3c9dc; cursor: pointer; }
#prompt { background: linear-gradient(180deg, rgba(40, 32, 12, .55), rgba(16, 14, 8, .4)); border-bottom: 1px solid var(--line); padding: 12px; min-height: 92px; }
#prompt:not(.waiting) { box-shadow: inset 3px 0 0 var(--gold); animation: prompt-in .3s ease-out; }
@keyframes prompt-in { from { background-color: rgba(227, 192, 106, .2); } }
#prompt .who { font-weight: 900; letter-spacing: .06em; }
#prompt .ptitle { font-weight: 700; font-size: 14px; }
#prompt .btns button { padding: 7px 14px; }
#prompt.waiting .ptitle { color: var(--muted); }
#prompt.waiting .ptitle { animation: prio 1.6s ease-in-out infinite; }
#pile { border-bottom: 1px solid var(--line); }
#pile .item { background: linear-gradient(90deg, rgba(40, 48, 78, .7), rgba(20, 24, 40, .5)); border-radius: 8px; border-left-width: 4px; animation: pv-in .25s ease-out; }
#log { font-size: 12px; }
#log .l { border-bottom: 1px solid rgba(255, 255, 255, .04); padding: 1px 0; }
#log .turn { color: var(--gold3); font-weight: 900; margin-top: 10px; padding: 3px 6px; border-radius: 5px; background: linear-gradient(90deg, rgba(227, 192, 106, .15), transparent); }

/* モーダル・メニュー */
#modal { background: rgba(2, 3, 8, .72); backdrop-filter: blur(4px); animation: fade-in .2s ease-out; }
@keyframes fade-in { from { opacity: 0; } }
.mbox { background: linear-gradient(180deg, rgba(20, 26, 44, .97), rgba(9, 12, 22, .98)); border: 1px solid var(--line2); border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .8); animation: pop-in .25s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop-in { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.mbox h3 { color: var(--gold3); font-weight: 900; letter-spacing: .05em; }
.mgrid .mc { transition: transform .15s; } .mgrid .mc:hover { transform: translateY(-4px); }
.mgrid .mc img { border-radius: 8px; box-shadow: 0 6px 14px rgba(0, 0, 0, .7); }
#ctxmenu { background: linear-gradient(180deg, rgba(22, 28, 48, .98), rgba(10, 13, 24, .98)); border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 14px 40px rgba(0, 0, 0, .8); }
#ctxmenu .mi:hover { background: rgba(227, 192, 106, .14); }
#toast { background: linear-gradient(180deg, rgba(20, 24, 40, .95), rgba(8, 10, 20, .95)); border: 1px solid var(--gold); border-radius: 12px; box-shadow: 0 0 30px rgba(227, 192, 106, .35); font-weight: 700; }

/* クリックで詳細を表示中のカード */
.card.inspect { outline: 2px solid #9be7ff; outline-offset: 2px; }
/* ダイアログの詳細欄 */
.mbox.wide { width: min(1240px, 97vw); }
.mbody { display: grid; grid-template-columns: 1fr 300px; gap: 12px; min-height: 0; flex: 1; overflow: hidden; }
.mbody .mgrid { align-content: flex-start; }
.mdetail { overflow: auto; padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: 12px; line-height: 1.5; }
.mdetail img { width: 100%; max-width: 230px; align-self: center; border-radius: 10px; box-shadow: 0 8px 22px rgba(0, 0, 0, .8); animation: pv-in .2s ease-out; }
.mdetail .ptext { white-space: pre-wrap; }
.mdetail .nm { color: var(--gold3); font-weight: 900; font-size: 15px; white-space: normal; }
.mdetail .meta { color: var(--muted); white-space: normal; }
.mdetail .ab { margin-top: 5px; padding: 4px 6px; border-radius: 6px; background: rgba(255, 255, 255, .04); border-left: 3px solid #666; white-space: pre-wrap; }
.mdetail .ab.auto { border-left-color: #3ccf7a; } .mdetail .ab.man { border-left-color: #f0b43c; }
.mdetail .abtag { display: inline-block; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 3px; margin-right: 5px; color: #111; }
.mdetail .ab.auto .abtag { background: #3ccf7a; } .mdetail .ab.man .abtag { background: #f0b43c; }
.mdetail .kwline { color: #bfffd8; } .mdetail .pempty { padding-top: 30px !important; }
.mdetail .pempty::before { display: none; }
.mgrid .mc { position: relative; }
.mgrid .mc .mz { position: absolute; top: 4px; right: 4px; z-index: 3; padding: 0 5px; font-size: 12px; line-height: 20px; border-radius: 6px; opacity: .85; }
.mgrid .mc.look img { outline: 2px solid #9be7ff; outline-offset: 2px; }
#ctxmenu .mi.cancel { color: var(--muted); }
@media (max-width: 900px) { .mbody { grid-template-columns: 1fr; } .mdetail { max-height: 30vh; } }

/* コピー表示 */
.card .cpb { position: absolute; left: -4px; right: -4px; bottom: 30%; text-align: center; font-size: 9px; font-weight: 900; color: #e9f6ff; background: linear-gradient(90deg, rgba(40, 120, 200, .2), rgba(30, 100, 190, .95), rgba(40, 120, 200, .2)); border-top: 1px solid rgba(150, 210, 255, .6); border-bottom: 1px solid rgba(150, 210, 255, .6); z-index: 3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.copybox { margin-top: 10px; padding: 8px; border-radius: 10px; border: 1px solid rgba(120, 190, 255, .45); background: linear-gradient(180deg, rgba(30, 70, 130, .3), rgba(10, 20, 40, .3)); }
.copybox .cph { color: #bfe3ff; margin-bottom: 6px; } .copybox .cph b { color: #fff; } .copybox .cph small { color: #8fb3d6; display: block; }
.copybox .cpimg { width: 46% !important; max-width: 140px; display: block; margin: 4px 0 6px; border-radius: 8px !important; }

/* 結果画面 */
.mbox.result { width: min(560px, 94vw); align-items: center; text-align: center; padding: 26px 28px 20px; gap: 6px; overflow: hidden; position: relative; }
.mbox.result::before { content: ""; position: absolute; inset: -50%; background: conic-gradient(from 0deg, transparent, rgba(255, 210, 120, .12), transparent 25%, rgba(255, 210, 120, .1), transparent 50%, rgba(255, 210, 120, .12), transparent 75%); animation: spin 18s linear infinite; pointer-events: none; }
.mbox.result.lose::before { background: conic-gradient(from 0deg, transparent, rgba(120, 140, 200, .1), transparent 30%, rgba(120, 140, 200, .08), transparent 60%); }
.mbox.result > * { position: relative; }
.rs-big { font-family: var(--font-latin); font-weight: 700; font-size: 54px; letter-spacing: .14em; line-height: 1; background: linear-gradient(180deg, #fffbe6, #ffd76a 45%, #b07a12 70%, #fff0b0); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #4a2e06) drop-shadow(0 0 18px rgba(255, 200, 80, .6)); }
.mbox.result.lose .rs-big { background: linear-gradient(180deg, #e8eefc, #8d9ab8 60%, #4c5878); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 3px 0 #10141f); }
.rs-turn { font-family: var(--font-latin); letter-spacing: .4em; color: var(--muted); font-size: 12px; }
.rs-ps { display: flex; align-items: stretch; gap: 12px; margin: 10px 0 8px; width: 100%; }
.rs-p { flex: 1; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); }
.rs-p.won { border-color: var(--gold); box-shadow: 0 0 20px rgba(227, 192, 106, .3); background: rgba(227, 192, 106, .08); }
.rs-n { font-weight: 900; } .rs-p.p0 .rs-n { color: var(--p0); } .rs-p.p1 .rs-n { color: var(--p1); }
.rs-l { font-family: var(--font-title); font-size: 34px; color: #fff; } .rs-l::before { content: "❤ "; font-size: 18px; color: #ff5d6a; }
.rs-s { font-size: 11px; color: var(--muted); }
.rs-vs { align-self: center; font-family: var(--font-latin); color: var(--gold); font-weight: 700; }
.mbox.result .mbtns { justify-content: center; margin-top: 6px; }
.mbox.result .mbtns button { padding: 9px 18px; }

/* デッキ構築 */
#builder { display: grid; grid-template-columns: 1fr 1fr; background: var(--ink); height: 100vh; }
.bd-deck { display: flex; flex-direction: column; min-height: 0; background: linear-gradient(180deg, rgba(16, 20, 36, .98), rgba(7, 10, 18, .99)); border-right: 1px solid var(--line2); box-shadow: 8px 0 30px rgba(0, 0, 0, .5); z-index: 2; }
.bd-top { display: flex; gap: 8px; padding: 10px 12px 6px; align-items: center; }
.bd-top #b-name { flex: 1; font-size: 16px; font-weight: 900; padding: 7px 10px; }
.bd-top #b-load { max-width: 34%; }
.bd-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 8px; align-items: center; border-bottom: 1px solid var(--line); }
.bd-actions button { padding: 5px 10px; font-size: 12px; }
.bd-view { margin-left: auto; display: flex; gap: 8px; font-size: 12px; color: #c3c9dc; }
.bd-stats { display: flex; gap: 14px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, .2); }
.st-curve { display: flex; align-items: flex-end; gap: 4px; height: 64px; padding-top: 4px; }
.st-curve .bar { position: relative; width: 22px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.st-curve .bar span { display: block; width: 100%; background: linear-gradient(180deg, #ffe08a, #b88a1e); border-radius: 3px 3px 0 0; min-height: 2px; box-shadow: 0 0 8px rgba(227, 192, 106, .35); }
.st-curve .bar b { position: absolute; top: -2px; font-size: 10px; color: #fff; }
.st-curve .bar i { font-style: normal; font-size: 10px; color: var(--muted); margin-top: 2px; }
.st-info { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #c3c9dc; justify-content: center; }
.st-info .tg { display: inline-block; margin-right: 5px; padding: 1px 7px; border-radius: 10px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); }
.st-col .c { display: inline-block; margin-left: 5px; padding: 0 6px; border-radius: 9px; font-weight: 700; color: #111; }
.c.cP, .f-colors .cP { --cc: #f2e6a6; } .c.cM, .f-colors .cM { --cc: #ff9a7a; } .c.cW, .f-colors .cW { --cc: #7ac8ff; } .c.cF, .f-colors .cF { --cc: #7ee08f; } .c.cN, .f-colors .cN { --cc: #b9a8ff; } .c.cA, .f-colors .cA { --cc: #cfd3dc; }
.st-col .c { background: var(--cc); }
#b-errors { padding: 6px 12px; font-size: 12px; color: #ffb36b; border-bottom: 1px solid var(--line); }
#b-errors .ok { color: #7fe0a0; font-weight: 700; }
#b-list { flex: 1; overflow: auto; padding: 6px 12px 12px; }
.bd-sec { margin-bottom: 10px; }
.bd-h { position: sticky; top: -6px; z-index: 3; padding: 6px 4px; color: var(--gold3); font-weight: 900; letter-spacing: .08em; background: linear-gradient(180deg, rgba(16, 20, 36, 1) 70%, rgba(16, 20, 36, 0)); }
.bd-h b { font-size: 18px; }
.bd-type { margin: 8px 0 4px; color: var(--muted); font-size: 12px; font-weight: 700; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.bd-empty { color: var(--muted); font-size: 12px; padding: 8px 4px; }
.bd-cards.img { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.dc { position: relative; cursor: pointer; border-radius: 7px; transition: transform .15s; }
.dc img { width: 100%; display: block; border-radius: 7px; box-shadow: 0 4px 10px rgba(0, 0, 0, .7); }
.dc:hover { transform: translateY(-3px); }
.dc .n { position: absolute; right: 3px; bottom: 3px; background: linear-gradient(180deg, #ffe7a1, #c8952f); color: #1d1405; font-weight: 900; font-size: 13px; padding: 0 6px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, .7); }
.dc .pm { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; opacity: 0; transition: opacity .15s; padding: 3px; }
.dc:hover .pm { opacity: 1; }
.dc .pm button { padding: 0 7px; font-size: 13px; line-height: 20px; border-radius: 6px; }
.dc.sel img, .bc.sel img { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(227, 192, 106, .7); }
.bd-cards.list .dl { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.bd-cards.list .dl:hover, .bd-cards.list .dl.sel { background: rgba(227, 192, 106, .1); }
.dl .cnt { width: 22px; text-align: right; font-weight: 900; color: var(--gold3); }
.dl .cost { width: 20px; height: 20px; border-radius: 50%; background: #222a44; text-align: center; line-height: 20px; font-size: 11px; font-weight: 700; }
.dl .nm { flex: 1; } .dl .cs { color: var(--muted); font-size: 11px; }
.dl button { padding: 0 7px; font-size: 12px; }
#b-preview { flex: none; height: 30vh; min-height: 190px; display: flex; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line2); background: linear-gradient(180deg, rgba(30, 26, 12, .35), rgba(8, 10, 18, .9)); overflow: hidden; }
#b-preview { max-height: none; }
#b-preview img { width: auto; height: 100%; aspect-ratio: .716; border-radius: 10px; box-shadow: 0 8px 22px rgba(0, 0, 0, .8), 0 0 0 1px rgba(227, 192, 106, .35); flex: none; animation: pv-in .25s ease-out; }
#b-preview .ptext { flex: 1; overflow: auto; font-size: 12px; line-height: 1.55; }
#b-preview .nm { color: var(--gold3); font-weight: 900; font-size: 15px; }
#b-preview .meta { color: var(--muted); margin-bottom: 4px; }
#b-preview .ab { margin-top: 5px; padding: 4px 6px; border-radius: 6px; background: rgba(255, 255, 255, .04); border-left: 3px solid #666; white-space: pre-wrap; }
#b-preview .ab.auto { border-left-color: #3ccf7a; } #b-preview .ab.man { border-left-color: #f0b43c; }
#b-preview .abtag { display: inline-block; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 3px; margin-right: 5px; color: #111; }
#b-preview .ab.auto .abtag { background: #3ccf7a; } #b-preview .ab.man .abtag { background: #f0b43c; }
#b-preview .kwline { color: #bfffd8; margin-top: 4px; }
.bp-btns { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.bp-empty { color: var(--muted); margin: auto; }
.bd-pool { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.bd-pool .b-filter { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 10px 12px; background: linear-gradient(180deg, rgba(14, 18, 32, .97), rgba(7, 10, 18, .98)); border-bottom: 1px solid var(--line); }
.bd-pool .b-filter #f-text { flex: 1; min-width: 180px; }
.f-colors { display: flex; gap: 3px; }
.f-colors label { cursor: pointer; padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .15); font-weight: 700; font-size: 12px; color: var(--cc); }
.f-colors label:has(input:checked) { background: var(--cc); color: #111; }
.f-colors input { display: none; }
.f-auto { font-size: 12px; color: #c3c9dc; cursor: pointer; }
#f-count { color: var(--muted); font-size: 12px; margin-left: auto; }
.bd-help { padding: 4px 12px; font-size: 11px; color: var(--muted); background: rgba(0, 0, 0, .25); }
#b-grid { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; padding: 12px; align-content: start; background: radial-gradient(ellipse at 50% 0%, #1a2240, #070a12 70%); }
#b-grid .bc { width: auto; position: relative; cursor: pointer; transition: transform .15s, filter .2s; }
#b-grid .bc img { width: 100%; display: block; border-radius: 8px; box-shadow: 0 6px 14px rgba(0, 0, 0, .7); }
#b-grid .bc:hover { transform: translateY(-4px) scale(1.04); z-index: 2; }
#b-grid .bc.in img { box-shadow: 0 0 0 2px rgba(227, 192, 106, .7), 0 6px 14px rgba(0, 0, 0, .7); }
#b-grid .bc .n { position: absolute; top: 4px; right: 4px; background: linear-gradient(180deg, #ffe7a1, #c8952f); color: #1d1405; font-weight: 900; border-radius: 10px; padding: 0 7px; box-shadow: 0 2px 6px rgba(0, 0, 0, .7); }
#b-grid .bc .auto.part { position: absolute; bottom: 4px; left: 4px; background: #a07a1e; color: #fff; font-size: 10px; border-radius: 3px; padding: 0 4px; }
#b-grid .bc.banned { filter: grayscale(1) brightness(.6); }
#b-grid .bc .ban { position: absolute; top: 40%; left: 0; right: 0; text-align: center; background: rgba(160, 20, 30, .9); color: #fff; font-weight: 900; }

/* ===== 演出の仕上げ ===== */
.fx-banner { min-width: 560px; padding: 18px 80px; border: none; background: linear-gradient(90deg, transparent, rgba(4, 6, 14, .92) 18%, rgba(4, 6, 14, .92) 82%, transparent); }
.fx-banner::before, .fx-banner::after { content: ""; position: absolute; left: 10%; right: 10%; height: 2px; background: linear-gradient(90deg, transparent, currentColor, transparent); }
.fx-banner::before { top: 0; } .fx-banner::after { bottom: 0; }
.fx-banner.p0 { color: var(--p0); } .fx-banner.p1 { color: var(--p1); }
.fx-banner .bm { font-family: var(--font-title); font-size: 42px; font-weight: 400; letter-spacing: .18em; color: #fff; }
.fx-banner.p0 .bm { text-shadow: 0 0 22px var(--p0), 0 0 4px var(--p0), 0 3px 0 #0a2a44; }
.fx-banner.p1 .bm { text-shadow: 0 0 22px var(--p1), 0 0 4px var(--p1), 0 3px 0 #44100e; }
.fx-banner .bs { font-family: var(--font-latin); color: var(--gold3); letter-spacing: .6em; font-size: 15px; margin-top: 4px; }
.fx-phase { font-family: var(--font); font-weight: 900; color: #1d1405; background: linear-gradient(180deg, #ffeab0, #d9a83c); border-radius: 3px; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); padding: 5px 34px; box-shadow: none; filter: drop-shadow(0 0 12px rgba(240, 199, 94, .8)); }
.fx-ghost.cast { box-shadow: 0 0 0 2px #ffe8a8, 0 0 50px rgba(255, 200, 90, .85), 0 30px 60px rgba(0, 0, 0, .9); border-radius: 12px; }
.fx-ghost.cast::before { content: ""; position: absolute; inset: -40%; background: conic-gradient(from 0deg, transparent, rgba(255, 220, 140, .35), transparent 30%, rgba(255, 220, 140, .25), transparent 60%, rgba(255, 220, 140, .35), transparent); border-radius: 50%; animation: spin 3s linear infinite; z-index: -1; filter: blur(6px); }
.fx-ghost.cast::after { content: ""; position: absolute; inset: 0; border-radius: 12px; background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .55) 45%, transparent 60%); background-size: 250% 100%; animation: sheen 1.1s ease-out .15s both; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sheen { from { background-position: 130% 0; } to { background-position: -60% 0; } }
.fx-castlabel { font-family: var(--font); font-weight: 900; background: linear-gradient(180deg, rgba(14, 18, 32, .95), rgba(6, 8, 16, .95)); border: 1px solid var(--gold); padding: 4px 16px; bottom: -36px; box-shadow: 0 6px 16px rgba(0, 0, 0, .7); }
.fx-float { font-family: var(--font-title); font-weight: 400; -webkit-text-stroke: 1px rgba(0, 0, 0, .7); }
.fx-float.big { font-size: 44px; }
.fx-stamp { font-family: var(--font-title); font-weight: 400; color: #9be7ff; border: 3px solid #9be7ff; background: rgba(4, 14, 30, .75); box-shadow: 0 0 30px rgba(80, 200, 255, .6); }
.fx-end { font-family: var(--font-latin); font-weight: 700; font-size: 110px; letter-spacing: .12em; }
.fx-end.win { background: linear-gradient(180deg, #fffbe6, #ffd76a 45%, #b07a12 70%, #fff0b0); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(0 4px 0 #4a2e06) drop-shadow(0 0 30px rgba(255, 200, 80, .8)); }
.fx-end.lose { color: #aab4cc; text-shadow: 0 0 40px #24304c, 0 4px 0 #0a0d18; }
.fx-flash { position: fixed; inset: 0; pointer-events: none; }
.fx-shock { position: fixed; width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .9); box-shadow: 0 0 30px rgba(255, 255, 255, .7), inset 0 0 20px rgba(255, 255, 255, .5); pointer-events: none; }
.fx-slash { position: fixed; height: 5px; margin-top: -2px; transform-origin: 50% 50%; border-radius: 3px; background: linear-gradient(90deg, transparent, #fff 40%, #ffd0a0 60%, transparent); box-shadow: 0 0 16px #ff8a4a, 0 0 4px #fff; pointer-events: none; }
.fx-orb { position: fixed; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, #fff, rgba(255, 220, 140, .9) 40%, rgba(255, 180, 60, 0) 70%); box-shadow: 0 0 18px #ffcf6a; }
.fx-vignette { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 140px rgba(255, 30, 40, .55); }

/* 設定のパネル（右上） */
.opt-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.vol { display: inline-flex; align-items: center; gap: 4px; }
.vol input[type=range] { width: 70px; accent-color: var(--gold); }

@media (max-width: 1250px) { #game { grid-template-columns: 230px 1fr 280px; } }
@media (max-width: 950px) { #game { grid-template-columns: 160px 1fr 230px; } .mode-cards .d { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
