/* 本物を見抜け — 王城の夜。濃紺と深紅、金の縁取り、羊皮紙の文字盤 */
:root {
  --ink: #1a1420;
  --night: #120f1a;
  --panel: rgba(22, 17, 30, .86);
  --panel-solid: #1d1726;
  --line: #5c4a2c;
  --gold: #d9b25f;
  --gold-hi: #f3d996;
  --crimson: #7a1f2b;
  --paper: #efe3c6;
  --paper-ink: #3a2a18;
  --text: #efe6d2;
  --muted: #a99e88;
  --ok: #7fd38a;
  --danger: #d0574e;
  --mincho: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --gothic: "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", "Meiryo", sans-serif;
  --c-A: #c0392b; --c-B: #2f6fb5; --c-C: #2e8b57; --c-D: #7d4fb0; --c-E: #c9a227;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--text); font: 15px/1.7 var(--gothic); }
body { overflow-x: hidden; }
button, input, textarea { font: inherit; color: inherit; }
#app { min-height: 100%; }

/* ---------- 共通部品 ---------- */
.screen { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; animation: screen-in .6s ease both; }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }
.bg { position: fixed; inset: 0; z-index: -1; background-size: cover; background-position: center; animation: kenburns 40s ease-in-out infinite alternate; }
.bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(10, 8, 16, .25), rgba(10, 8, 16, .82)); }
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.1) translate(-1%, -1%); } }
.bg-title { background-image: url(img/bg/title.jpg), linear-gradient(160deg, #3a1f2e, #121022 60%); }
.bg-lobby { background-image: url(img/bg/lobby.jpg), linear-gradient(160deg, #3b2a1c, #141018 60%); }
.bg-hall::after { background: radial-gradient(ellipse at center, rgba(10, 8, 16, .5), rgba(10, 8, 16, .88)) !important; }
.bg-hall { background-image: url(img/bg/hall.jpg), linear-gradient(160deg, #2c2238, #120f1a 60%); }
.bg-throne { background-image: url(img/bg/throne.jpg), linear-gradient(160deg, #401c26, #120f1a 60%); }
.bg-night { background-image: url(img/bg/night.jpg), linear-gradient(160deg, #1c2448, #120f1a 60%); }
.bg-result { background-image: url(img/bg/result.jpg), linear-gradient(160deg, #3a4a6a, #141a2a 60%); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(217, 178, 95, .08); backdrop-filter: blur(4px); }
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 22px; border-radius: 8px; border: 1px solid var(--line); background: #2a2233; cursor: pointer; transition: transform .12s, background .2s, border-color .2s, box-shadow .2s; user-select: none; }
.btn:hover:not(:disabled) { border-color: var(--gold); background: #33293f; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.gold { background: linear-gradient(180deg, #8a6420, #5e4214); border-color: var(--gold); color: #fff6dc; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.btn.gold:hover:not(:disabled) { background: linear-gradient(180deg, #a07628, #6e4e18); box-shadow: 0 0 18px rgba(217, 178, 95, .35); }
.btn.gold:not(:disabled)::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(110deg, transparent 30%, rgba(255, 240, 200, .35) 50%, transparent 70%); background-size: 250% 100%; animation: shine 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes shine { 0%, 60% { background-position: 150% 0; } 100% { background-position: -100% 0; } }
.btn.red { background: linear-gradient(180deg, #8f2a33, #5a161d); border-color: #c4565e; color: #fff; font-weight: 600; }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.field { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: rgba(10, 8, 16, .6); outline: none; transition: border-color .2s, box-shadow .2s; }
.field:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 178, 95, .18); }
textarea.field { resize: none; line-height: 1.6; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.muted { color: var(--muted); }
.gold-text { color: var(--gold-hi); }
.mincho { font-family: var(--mincho); }
.counter { font-size: 12px; color: var(--muted); text-align: right; transition: color .2s; }
.counter.over { color: var(--danger); font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; }
.dots::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.pop-in { animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.rise-in { animation: rise-in .5s ease both; }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; pointer-events: none; display: flex; flex-direction: column; gap: 6px; align-items: center; }
#toast div { background: #3a1d24; border: 1px solid #c4565e; color: #fff; padding: 8px 18px; border-radius: 8px; animation: toast 3.2s ease both; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

#sound-btn { position: fixed; left: 10px; bottom: 10px; z-index: 70; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: rgba(22, 17, 30, .85); cursor: pointer; font-size: 17px; line-height: 1; transition: transform .15s, border-color .2s; }
#sound-btn:hover { transform: scale(1.08); border-color: var(--gold); }
#offline { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 120; padding: 6px 18px; border-radius: 999px; background: #3a1d24; border: 1px solid #c4565e; font-size: 13px; animation: rise-in .3s both; }
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(6, 4, 10, .7); display: flex; align-items: center; justify-content: center; padding: 16px; animation: screen-in .25s ease both; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 24px; animation: pop-in .35s cubic-bezier(.2, 1.3, .4, 1) both; }
.modal h2 { margin: 0 0 10px; font: 600 20px var(--mincho); color: var(--gold-hi); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- タイトル ---------- */
.title-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 26px; }
.logo { text-align: center; }
.logo h1 { margin: 0; font: 700 clamp(46px, 11vw, 92px)/1.1 var(--mincho); letter-spacing: .12em; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .7)); animation: logo-in 1.6s cubic-bezier(.2, .8, .2, 1) both; }
.logo h1 span { display: inline-block; background: linear-gradient(180deg, #fff3cf 0%, #e8c46e 45%, #9a6d22 100%); -webkit-background-clip: text; background-clip: text; color: transparent; animation: letter 1.2s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes letter { from { opacity: 0; transform: translateY(-30px) rotateX(80deg); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes logo-in { from { letter-spacing: .5em; } to { letter-spacing: .12em; } }
.logo p { margin: 8px 0 0; font-family: var(--mincho); color: var(--gold); letter-spacing: .3em; animation: rise-in 1s .9s ease both; }
.title-card { width: min(420px, 100%); padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; animation: rise-in .8s 1.1s ease both; }
.title-card .row .field { flex: 1; }
.room-input { letter-spacing: .4em; text-align: center; font-size: 20px; font-family: Consolas, monospace; }
.title-foot { position: fixed; right: 12px; bottom: 8px; font-size: 12px; color: var(--muted); }
.title-foot b { font-family: Consolas, monospace; letter-spacing: 1px; color: var(--text); font-weight: normal; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.help-link { align-self: center; font-size: 13px; color: var(--muted); background: none; border: 0; cursor: pointer; text-decoration: underline dotted; }
.rules h3 { margin: 14px 0 4px; font: 600 15px var(--mincho); color: var(--gold); }
.rules p, .rules li { margin: 0; font-size: 14px; }
.rules ul { padding-left: 1.2em; margin: 0; }

/* ---------- 待合室 ---------- */
.lobby { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.lobby .panel { width: min(640px, 100%); padding: 22px 24px; }
.room-no { text-align: center; margin-bottom: 16px; }
.room-no small { display: block; color: var(--muted); letter-spacing: .2em; }
.room-no #lb-copy { margin-left: 10px; vertical-align: 10px; }
.room-no b { font: 700 46px/1.1 var(--mincho); letter-spacing: .25em; color: var(--gold-hi); text-shadow: 0 0 20px rgba(217, 178, 95, .35); }
.seats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 16px; }
.seat { position: relative; min-height: 64px; border-radius: 10px; border: 1px dashed #4a3f2c; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--muted); font-size: 13px; transition: border-color .3s, background .3s; }
.seat.filled { border-style: solid; border-color: var(--line); background: rgba(217, 178, 95, .06); color: var(--text); font-size: 15px; animation: seat-in .5s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes seat-in { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.seat .crown { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); color: var(--gold); font-size: 16px; text-shadow: 0 0 8px rgba(217, 178, 95, .6); }
.seat .st { font-size: 11px; color: var(--ok); }
.seat .st.off { color: var(--danger); }
.seat .kick { position: absolute; top: 2px; right: 4px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.seat .kick:hover { color: var(--danger); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.settings .val { font-size: 18px; font-family: var(--mincho); color: var(--gold-hi); }
.lobby-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- 役職カード ---------- */
.roles { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 16px 40px; gap: 18px; perspective: 1400px; overflow: hidden; }
.roles .hint { font-family: var(--mincho); font-size: 18px; color: var(--gold-hi); min-height: 1.7em; text-align: center; text-shadow: 0 2px 8px #000; }
.table-area { position: relative; width: min(560px, 100%); height: 420px; }
.table-area .deck .card-back { border-radius: 7px; }
.deck { position: absolute; left: 50%; top: 10px; width: 110px; height: 165px; margin-left: -55px; cursor: pointer; transition: transform .3s; }
.deck:hover { transform: translateY(-4px); }
.deck.idle { animation: deck-pulse 2s ease-in-out infinite; }
@keyframes deck-pulse { 0%, 100% { filter: drop-shadow(0 0 0 rgba(243, 217, 150, 0)); } 50% { filter: drop-shadow(0 0 16px rgba(243, 217, 150, .7)); } }
.deck .card-back { position: absolute; inset: 0; }
.deck .card-back:nth-child(1) { transform: translate(6px, 6px) rotate(3deg); }
.deck .card-back:nth-child(2) { transform: translate(3px, 3px) rotate(-2deg); }
.deck .card-back:nth-child(3) { transform: translate(1px, 1px) rotate(1deg); }
.deck.done { opacity: .5; cursor: default; animation: none; transform: scale(.8) translateY(-20px); transition: transform .6s, opacity .6s; }
.flyer { position: absolute; left: 50%; top: 10px; width: 210px; height: 315px; margin-left: -105px; transform-style: preserve-3d; transform-origin: 50% 0; transform: scale(.524); z-index: 5; }
.flyer.to-hand { animation: to-hand 1s cubic-bezier(.3, .1, .2, 1) forwards; }
@keyframes to-hand {
  0% { transform: translate(0, 0) scale(.524); }
  45% { transform: translate(0, 40px) scale(.75) rotate(-6deg); }
  100% { transform: translate(0, 90px) scale(1); }
}
.flyer.in-hand { transform: translate(0, 90px) scale(1); }
.card3d { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.4, .1, .2, 1); }
.card3d.r180 { transform: rotateY(180deg); }
.card3d.r360 { transform: rotateY(360deg); transition-duration: 1.1s; }
.card3d .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card3d .face.front { transform: rotateY(180deg); }
.card3d.shake { animation: card-shake .7s ease-in-out; }
@keyframes card-shake { 0%, 100% { translate: 0; } 20% { translate: -4px 0; } 40% { translate: 4px 0; } 60% { translate: -3px 0; } 80% { translate: 3px 0; } }

.card-back { border-radius: 9px; border: 2px solid #c9a04e; background:
  radial-gradient(circle at 50% 50%, rgba(243, 217, 150, .25) 0 18%, transparent 19%),
  repeating-conic-gradient(from 0deg at 50% 50%, rgba(217, 178, 95, .16) 0 10deg, transparent 10deg 20deg),
  linear-gradient(160deg, #6e1a28, #3a0c16);
  box-shadow: inset 0 0 0 5px #3a0c16, inset 0 0 0 6px rgba(217, 178, 95, .6), 0 6px 16px rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; }
.card-back svg { width: 46%; filter: drop-shadow(0 0 6px rgba(243, 217, 150, .5)); }

.role-card { width: 100%; height: 100%; border-radius: 10px; overflow: hidden; position: relative; border: 2px solid var(--gold); box-shadow: 0 0 0 1px #2a1d0c, 0 10px 30px rgba(0, 0, 0, .65); font-family: var(--mincho); }
.role-card::before { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(243, 217, 150, .55); border-radius: 7px; pointer-events: none; z-index: 3; }
.role-card .art { position: absolute; inset: 10px 10px 50px; border-radius: 5px; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .5), inset 0 0 24px rgba(0, 0, 0, .45); }
.role-card .art::before { content: ""; position: absolute; inset: -10px; background-size: cover; background-position: center; filter: blur(3px) saturate(.9); opacity: .55; }
.role-card .art::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; box-shadow: inset 0 0 22px rgba(0, 0, 0, .55); }
.role-card .art img { width: 100%; height: 100%; padding-top: 10px; object-fit: cover; object-position: 50% 0; position: relative; z-index: 1; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .55)); }
.role-card .art .kanji { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 110px; color: rgba(255, 255, 255, .22); }
.role-card .corner { position: absolute; z-index: 4; width: 18px; height: 18px; border: 2px solid var(--gold-hi); pointer-events: none; }
.role-card .corner.tl { top: 6px; left: 6px; border-right: 0; border-bottom: 0; border-top-left-radius: 6px; }
.role-card .corner.tr { top: 6px; right: 6px; border-left: 0; border-bottom: 0; border-top-right-radius: 6px; }
.role-card .corner.bl { bottom: 6px; left: 6px; border-right: 0; border-top: 0; border-bottom-left-radius: 6px; }
.role-card .corner.br { bottom: 6px; right: 6px; border-left: 0; border-top: 0; border-bottom-right-radius: 6px; }
.role-card .plate { white-space: nowrap; position: absolute; left: 10px; right: 10px; bottom: 10px; height: 34px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; letter-spacing: .6em; text-indent: .6em; box-shadow: 0 2px 6px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .35); z-index: 3; }
.role-card .plate::before, .role-card .plate::after { content: "◆"; font-size: 9px; letter-spacing: 0; text-indent: 0; opacity: .7; margin: 0 6px; }
.role-card.chancellor { background: linear-gradient(160deg, #1f2c55, #0d1430); }
.role-card.chancellor .art { background: radial-gradient(ellipse at 50% 30%, #4a66b0, #142046 75%); }
.role-card.chancellor .art::before { background-image: url(img/bg/throne.jpg); mix-blend-mode: luminosity; }
.role-card.chancellor .plate { background: linear-gradient(180deg, #f0d27e, #a47a2c); color: #1a1430; }
.role-card.citizen { background: linear-gradient(160deg, #4a3d30, #241c14); border-color: #a59272; }
.role-card.citizen::before { border-color: rgba(207, 192, 160, .5); }
.role-card.citizen .corner { border-color: #cfc0a0; }
.role-card.citizen .art { background: radial-gradient(ellipse at 50% 30%, #9a8a70, #3a2f22 75%); }
.role-card.citizen .art::before { background-image: url(img/bg/hall.jpg); mix-blend-mode: multiply; }
.role-card.citizen .plate { background: linear-gradient(180deg, #d8caa8, #8b7a5c); color: #2a2014; }
.role-card.descendant { background: linear-gradient(160deg, #fff4d4, #d8b260); border-color: #fff0b8; box-shadow: 0 0 0 1px #6a4a10, 0 0 30px rgba(255, 230, 150, .6), 0 10px 30px rgba(0, 0, 0, .6); }
.role-card.descendant::before { border-color: rgba(122, 31, 43, .55); }
.role-card.descendant .corner { border-color: #7a1f2b; }
.role-card.descendant .art { background: radial-gradient(ellipse at 50% 35%, #fffbe8, #f0cf7a 60%, #a77a26); }
.role-card.descendant .art::before { background: repeating-conic-gradient(from 0deg at 50% 40%, rgba(255, 255, 255, .5) 0 6deg, transparent 6deg 18deg); filter: none; opacity: .6; animation: rays 20s linear infinite; inset: -60%; }
@keyframes rays { to { transform: rotate(360deg); } }
.role-card.descendant .plate { background: linear-gradient(180deg, #8f2a36, #4a0f18); color: #ffe9a8; }
.role-card.descendant::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .55) 50%, transparent 65%); background-size: 250% 100%; animation: shine 2.6s ease-in-out infinite; pointer-events: none; }
.burst { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; pointer-events: none; z-index: 4; }
.burst i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--gold-hi); box-shadow: 0 0 10px #fff2c0; animation: spark 1.3s ease-out forwards; }
@keyframes spark { from { transform: translate(0, 0) scale(1); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.halo { position: absolute; left: 50%; top: 50%; width: 520px; height: 520px; margin: -260px 0 0 -260px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 236, 170, .55), transparent 60%); pointer-events: none; animation: halo 2s ease-out forwards; z-index: 0; }
@keyframes halo { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.puff { position: absolute; left: 50%; top: 50%; width: 300px; height: 300px; margin: -150px 0 0 -150px; border-radius: 50%; background: radial-gradient(circle, rgba(180, 170, 150, .35), transparent 65%); pointer-events: none; animation: halo 1.4s ease-out forwards; }
.role-info { width: min(520px, 100%); padding: 16px 20px; text-align: center; }
.role-info h2 { margin: 0 0 6px; font: 700 24px var(--mincho); letter-spacing: .2em; }
.role-info p { margin: 0 0 12px; }

/* ---------- 紙芝居 ---------- */
.ks { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; align-items: center; justify-content: center; animation: screen-in .6s ease both; }
.ks-stage { position: relative; width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; max-height: 100vh; overflow: hidden; background: #0b0910; cursor: pointer; }
.ks-bg { position: absolute; inset: -3%; background-size: cover; background-position: center; opacity: 0; transition: opacity 1.2s ease; }
.ks-bg.show { opacity: 1; animation: kenburns 24s ease-in-out infinite alternate; }
.ks-bg.corridor { background-image: url(img/bg/corridor.jpg), linear-gradient(180deg, #1b1a33, #0b0910); }
.ks-bg.night { background-image: url(img/bg/night.jpg), linear-gradient(180deg, #1b1a33, #0b0910); }
.ks-bg.hall { background-image: url(img/bg/hall.jpg), linear-gradient(180deg, #3b2c22, #0b0910); }
.ks-vignette { position: absolute; inset: 0; z-index: 1; background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, .65)); pointer-events: none; }
.actor { position: absolute; bottom: 0; height: 84%; z-index: 1; transition: filter .4s, transform .4s; filter: brightness(.6) saturate(.8); }
.actor img { height: 100%; display: block; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .6)); }
.actor.speaking { filter: none; transform: translateY(-1.5%); }
.actor.left { left: 1%; }
.actor.right { right: 1%; }
.actor.right img { transform: scaleX(-1); }
.actor.run-in { animation: run-in .9s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes run-in { 0% { transform: translateX(-120%); } 70% { transform: translateX(4%); } 100% { transform: none; } }
.actor.run-out { animation: run-out .8s ease-in both; }
@keyframes run-out { to { transform: translateX(-140%); opacity: 0; } }
.actor.fade-in { animation: actor-fade 1s ease both; }
@keyframes actor-fade { from { opacity: 0; transform: translateX(6%); } to { opacity: 1; transform: none; } }
.actor.bounce { animation: bounce .45s ease; }
@keyframes bounce { 0%, 100% { translate: 0 0; } 40% { translate: 0 -5%; } }
.actor.sweat::after { content: "💧"; position: absolute; top: 6%; left: 18%; font-size: clamp(14px, 3vw, 30px); animation: sweat 1.4s ease-in infinite; }
@keyframes sweat { 0% { opacity: 0; transform: translateY(-6px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(18px); } }
.heirs-line { position: absolute; left: 21%; right: 28%; bottom: 27%; height: 50%; display: flex; justify-content: center; align-items: flex-end; gap: 0; }
.heirs-line .heir { height: 100%; margin: 0 -3%; animation: heir-in .6s cubic-bezier(.2, 1.3, .4, 1) both; filter: brightness(.75); }
.heirs-line .heir img { height: 100%; display: block; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .6)); }
.heirs-line.shake .heir { animation: heir-shake .5s ease-in-out; }
@keyframes heir-in { from { opacity: 0; transform: translateY(20%) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes heir-shake { 0%, 100% { transform: none; } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
.ks-box { position: absolute; z-index: 2; left: 4%; right: 4%; bottom: 4%; min-height: 24%; padding: 2.2% 3% 2%; border-radius: 10px; background: linear-gradient(180deg, rgba(20, 14, 26, .92), rgba(12, 8, 16, .95)); border: 1px solid var(--gold); box-shadow: 0 0 0 4px rgba(0, 0, 0, .4), inset 0 0 30px rgba(217, 178, 95, .08); font: clamp(13px, 2.1vw, 22px)/1.7 var(--mincho); transition: opacity .3s, transform .3s; }
.ks-box.hide { opacity: 0; transform: translateY(12px); }
.ks-name { position: absolute; top: 0; left: 3%; transform: translateY(-60%); padding: 2px 18px; border-radius: 6px; background: linear-gradient(180deg, #8a6420, #5e4214); border: 1px solid var(--gold-hi); color: #fff6dc; font-size: clamp(12px, 1.7vw, 18px); letter-spacing: .15em; }
.ks-text em { font-style: normal; color: var(--gold-hi); }
.ks-next { position: absolute; right: 2.5%; bottom: 8%; color: var(--gold); animation: next-blink 1s ease-in-out infinite; font-size: .8em; }
@keyframes next-blink { 0%, 100% { opacity: .2; transform: translateY(0); } 50% { opacity: 1; transform: translateY(3px); } }
.ks-skip { position: absolute; top: 2.5%; right: 2%; z-index: 3; }
.ks-interlude { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #000; font: clamp(18px, 3.4vw, 36px) var(--mincho); color: var(--paper); letter-spacing: .3em; opacity: 0; transition: opacity .9s; z-index: 2; }
.ks-interlude.show { opacity: 1; }
.ks-interlude span { animation: rise-in 1.2s ease both; }
.ks-start { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 2; pointer-events: none; }
.ks-start b { font: 700 clamp(30px, 7vw, 80px) var(--mincho); letter-spacing: .3em; color: var(--gold-hi); text-shadow: 0 0 30px rgba(217, 178, 95, .8), 0 4px 10px #000; animation: start-in 1.6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes start-in { 0% { opacity: 0; transform: scale(2.2); filter: blur(10px); } 40% { opacity: 1; transform: scale(1); filter: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.96); } }
.ks-fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .8s; z-index: 2; }
.ks-fade.show { opacity: 1; }

/* ---------- ゲーム画面 ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px; background: linear-gradient(180deg, rgba(10, 8, 16, .92), rgba(10, 8, 16, .6)); border-bottom: 1px solid var(--line); font-size: 14px; position: sticky; top: 0; z-index: 10; }
.topbar .t-game { font-family: var(--mincho); color: var(--gold-hi); font-size: 16px; }
.topbar .t-name em { font-style: normal; color: var(--gold-hi); font-family: var(--mincho); font-size: 16px; }
.topbar .spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; }
.chip.chancellor { border-color: #6f8ad8; color: #c8d4ff; background: rgba(60, 80, 160, .25); }
.chip.descendant { border-color: var(--gold); color: var(--gold-hi); background: rgba(217, 178, 95, .15); }
.chip.fake { border-color: #a59272; color: #e6d8bb; background: rgba(120, 100, 70, .25); }
.chip.spectator { color: var(--muted); }
.rounds { display: inline-flex; gap: 4px; vertical-align: middle; }
.rounds i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--gold); transition: background .4s; }
.rounds i.done { background: var(--gold); }
.rounds i.now { background: transparent; box-shadow: 0 0 8px var(--gold); animation: deck-pulse 1.6s infinite; }

.stage { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 16px 12px 8px; gap: 14px; }
.chancellor-seat { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.chancellor-seat img { width: 54px; height: 54px; object-fit: cover; object-position: top; border-radius: 50%; border: 2px solid #6f8ad8; background: #1f2c55; }
.chancellor-seat b { color: #c8d4ff; font-weight: normal; font-family: var(--mincho); font-size: 16px; }
.chancellor-seat .off { color: var(--danger); }
.scroll { position: relative; width: min(720px, 100%); min-height: 64px; padding: 14px 28px; border-radius: 6px; background: linear-gradient(180deg, #f3e8cc, #e2d1a8); color: var(--paper-ink); font: 600 clamp(16px, 2.4vw, 22px)/1.6 var(--mincho); text-align: center; box-shadow: 0 8px 26px rgba(0, 0, 0, .5), inset 0 0 30px rgba(120, 80, 30, .25); white-space: pre-wrap; word-break: break-word; }
.scroll::before, .scroll::after { content: ""; position: absolute; top: -6px; bottom: -6px; width: 14px; border-radius: 7px; background: linear-gradient(90deg, #6b4a22, #b48a4c, #6b4a22); }
.scroll::before { left: -7px; } .scroll::after { right: -7px; }
.scroll .q-label { display: block; font-size: 12px; font-weight: normal; color: #7a6040; letter-spacing: .3em; }
.scroll.empty { background: linear-gradient(180deg, rgba(243, 232, 204, .25), rgba(226, 209, 168, .2)); color: var(--paper); font-weight: normal; font-size: 15px; }
.scroll.unroll { animation: unroll .7s cubic-bezier(.3, .8, .3, 1) both; }
@keyframes unroll { from { clip-path: inset(0 50% 0 50%); } to { clip-path: inset(0 0 0 0); } }

.heirs { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; width: 100%; max-width: 1000px; }
.heir-card { position: relative; width: 160px; display: flex; flex-direction: column; align-items: center; transition: transform .25s, filter .5s, opacity .5s; }
.heir-card .bubble { position: relative; width: 100%; min-height: 0; margin-bottom: 8px; padding: 8px 10px; border-radius: 10px; background: var(--paper); color: var(--paper-ink); font: 600 14px/1.5 var(--mincho); text-align: center; white-space: pre-wrap; word-break: break-word; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); animation: bubble-in .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.heir-card .bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: var(--paper); }
.heir-card .bubble.blank { color: #8a7a60; font-weight: normal; font-style: italic; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(.7); } to { opacity: 1; transform: none; } }
.heir-fig { position: relative; width: 120px; height: 150px; border-radius: 10px 10px 4px 4px; overflow: hidden; background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--hc) 45%, #2a2233), #120f1a 80%); border: 2px solid color-mix(in srgb, var(--hc) 70%, #000); box-shadow: 0 6px 18px rgba(0, 0, 0, .45); }
.heir-fig img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; object-position: center 12%; }
.heir-fig .sil { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 56px; color: color-mix(in srgb, var(--hc) 60%, #fff); opacity: .5; font-family: var(--mincho); }
.heir-card.idle .heir-fig { animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.heir-name { margin-top: -12px; position: relative; z-index: 2; padding: 1px 14px; border-radius: 5px; background: color-mix(in srgb, var(--hc) 60%, #1a1420); border: 1px solid color-mix(in srgb, var(--hc) 80%, #fff); font: 600 14px var(--mincho); letter-spacing: .1em; color: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.heir-card .me-tag { position: absolute; top: -8px; right: 6px; z-index: 3; padding: 0 8px; border-radius: 999px; background: var(--gold); color: #1a1420; font-size: 11px; font-weight: 700; }
.heir-card .stamp { position: absolute; top: 46px; left: 50%; z-index: 3; transform: translateX(-50%) rotate(-12deg); padding: 2px 10px; border: 3px double var(--ok); border-radius: 6px; color: var(--ok); font: 700 15px var(--mincho); background: rgba(10, 30, 14, .7); animation: stamp .45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes stamp { from { opacity: 0; transform: translateX(-50%) rotate(-12deg) scale(2.4); } to { opacity: 1; transform: translateX(-50%) rotate(-12deg) scale(1); } }
.heir-card .off-tag { margin-top: 4px; font-size: 11px; color: var(--danger); }
.heir-card.out { filter: grayscale(1) brightness(.45); opacity: .7; }
.heir-card.out .heir-fig::after { content: "退場"; position: absolute; inset: auto 0 40% 0; text-align: center; transform: rotate(-14deg); font: 700 24px var(--mincho); color: #e55; text-shadow: 0 0 6px #000; letter-spacing: .2em; }
.heir-card.falling { animation: falling 1.2s ease-in both; }
@keyframes falling { 0% { transform: none; } 20% { transform: translateY(-8px) rotate(-3deg); } 100% { transform: translateY(16px) rotate(4deg); filter: grayscale(1) brightness(.45); opacity: .7; } }
.heir-card.pickable { cursor: pointer; }
.heir-card.pickable:hover { transform: translateY(-4px); }
.heir-card.pickable:hover .heir-fig { box-shadow: 0 0 0 3px rgba(208, 87, 78, .5), 0 8px 22px rgba(0, 0, 0, .5); }
.heir-card.selected { transform: translateY(-6px) scale(1.04); }
.heir-card.selected .heir-fig { box-shadow: 0 0 0 3px var(--danger), 0 0 26px rgba(208, 87, 78, .7); animation: pick 1.2s ease-in-out infinite; }
@keyframes pick { 0%, 100% { box-shadow: 0 0 0 3px var(--danger), 0 0 16px rgba(208, 87, 78, .5); } 50% { box-shadow: 0 0 0 3px var(--danger), 0 0 32px rgba(208, 87, 78, .9); } }
.heir-card.revealed .heir-fig { animation: fig-flip .9s var(--d, 0s) cubic-bezier(.4, .1, .2, 1) both; }
@keyframes fig-flip { 0% { transform: rotateY(0); } 50% { transform: rotateY(90deg); filter: brightness(2); } 100% { transform: rotateY(0); } }
.heir-card.revealed.is-real { filter: none; opacity: 1; }
.heir-card.revealed.is-real .heir-fig { border-color: var(--gold-hi); box-shadow: 0 0 0 2px var(--gold), 0 0 30px rgba(243, 217, 150, .7); }
.heir-card.revealed.is-real.out .heir-fig::after { content: "退場"; }
.heir-card .reveal { margin-top: 6px; text-align: center; font-size: 13px; animation: rise-in .5s ease both; }
.heir-card .reveal b { display: block; font: 600 15px var(--mincho); }
.heir-card .reveal .real { color: var(--gold-hi); }
.heir-card .reveal .fake { color: var(--muted); }

.action { width: 100%; padding: 12px 16px 18px; display: flex; justify-content: center; position: sticky; bottom: 0; z-index: 9; background: linear-gradient(0deg, rgba(10, 8, 16, .95), rgba(10, 8, 16, .75) 70%, transparent); }
.action .panel { width: min(720px, 100%); padding: 14px 18px; animation: rise-in .4s ease both; }
.action .lead { margin: 0 0 8px; font-family: var(--mincho); color: var(--gold-hi); }
.action .sub { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.action .form { display: flex; gap: 10px; align-items: flex-end; }
.action .form .grow { flex: 1; }
.waiting { display: flex; align-items: center; gap: 12px; justify-content: center; color: var(--muted); font-family: var(--mincho); }
.quill { display: inline-block; animation: quill 1.2s ease-in-out infinite; transform-origin: bottom left; }
@keyframes quill { 0%, 100% { transform: rotate(-8deg) translateX(0); } 50% { transform: rotate(8deg) translateX(6px); } }
.progress { display: inline-flex; gap: 4px; }
.progress i { width: 9px; height: 9px; border-radius: 50%; background: #3a3244; transition: background .3s, transform .3s; }
.progress i.on { background: var(--ok); transform: scale(1.2); }

.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(380px, 92vw); z-index: 50; padding: 16px; overflow: auto; background: var(--panel-solid); border-right: 1px solid var(--line); box-shadow: 10px 0 40px rgba(0, 0, 0, .6); transform: translateX(-104%); transition: transform .35s cubic-bezier(.3, .8, .3, 1); }
.drawer.open { transform: none; }
.drawer h2 { margin: 0 0 10px; font: 600 18px var(--mincho); color: var(--gold-hi); }
.hist { margin-bottom: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .02); }
.hist .q { font-family: var(--mincho); color: var(--paper); margin-bottom: 6px; }
.hist .a { display: flex; gap: 8px; font-size: 14px; padding: 2px 0; }
.hist .a .lb { flex: none; width: 52px; color: var(--hc); font-weight: 600; }
.hist .a.out { color: var(--danger); }
.hist .a.out .lb::after { content: " ✕"; }

.banner { position: fixed; left: 0; right: 0; top: 40%; z-index: 40; pointer-events: none; display: flex; justify-content: center; }
.banner b { padding: 10px 50px; font: 700 clamp(20px, 4vw, 34px) var(--mincho); letter-spacing: .2em; color: #fff; background: linear-gradient(90deg, transparent, rgba(122, 31, 43, .92) 15%, rgba(122, 31, 43, .92) 85%, transparent); text-shadow: 0 2px 8px #000; animation: banner 2.2s ease both; }
.banner.gold b { background: linear-gradient(90deg, transparent, rgba(110, 80, 20, .92) 15%, rgba(110, 80, 20, .92) 85%, transparent); color: var(--gold-hi); }
@keyframes banner { 0% { opacity: 0; transform: scaleX(.2); } 15% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

.wait-box { position: fixed; inset: 0; z-index: 45; background: rgba(6, 4, 10, .65); display: flex; align-items: center; justify-content: center; padding: 16px; animation: screen-in .3s both; }
.wait-box .panel { width: min(440px, 100%); padding: 20px 24px; text-align: center; }
.wait-box .count { font: 700 42px var(--mincho); color: var(--gold-hi); }

/* 結果 */
.result { width: min(820px, 100%); padding: 20px 22px; margin: 0 auto; }
.result h2 { margin: 0 0 4px; text-align: center; font: 700 clamp(22px, 4vw, 30px) var(--mincho); letter-spacing: .15em; color: var(--gold-hi); animation: rise-in .6s both; }
.result .verdict { text-align: center; margin: 0 0 14px; color: var(--muted); animation: rise-in .6s .3s both; }
.pts { width: 100%; border-collapse: collapse; }
.pts td, .pts th { padding: 6px 8px; border-bottom: 1px solid #2f2838; text-align: left; }
.pts th { font-weight: normal; color: var(--muted); font-size: 13px; }
.pts tr { animation: rise-in .45s both; }
.pts td.num { text-align: right; font: 600 18px var(--mincho); color: var(--gold-hi); }
.pts tr.me td { background: rgba(217, 178, 95, .08); }
.pts .rank { font: 700 20px var(--mincho); width: 48px; }
.pts .rank.r1 { color: #ffd76a; } .pts .rank.r2 { color: #d8dde6; } .pts .rank.r3 { color: #d09a62; }
.result .actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.final { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.crown-big { text-align: center; font-size: 46px; animation: crown 1.4s cubic-bezier(.2, 1.4, .4, 1) both; filter: drop-shadow(0 0 16px rgba(243, 217, 150, .7)); }
@keyframes crown { from { opacity: 0; transform: translateY(-40px) rotate(-20deg) scale(.4); } to { opacity: 1; transform: none; } }

/* スマホ */
@media (max-width: 600px) {
  .heir-card { width: calc(50% - 10px); max-width: 170px; }
  .heir-fig { width: 100px; height: 124px; }
  .seats { grid-template-columns: repeat(2, 1fr); }
  .settings { grid-template-columns: 1fr; }
  .action .form { flex-direction: column; align-items: stretch; }
  .topbar { font-size: 13px; padding: 8px 12px; }
}
/* 背の低い画面では、操作欄を下に固定しない（質問や子孫が隠れないように） */
@media (max-height: 640px) {
  .action { position: static; }
  .topbar { position: static; }
}
/* 縦長の画面では紙芝居を全画面にする（人物は上、台詞は下） */
@media (orientation: portrait) {
  .ks-stage { width: 100vw; height: 100vh; height: 100dvh; aspect-ratio: auto; max-height: none; }
  .actor { bottom: 30%; height: 46%; }
  .actor.left { left: -4%; } .actor.right { right: -4%; }
  .heirs-line { left: 8%; right: 8%; bottom: 36%; height: 30%; }
  .ks-box { min-height: 26%; font-size: 16px; padding: 22px 18px 16px; }
  .ks-name { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
