:root{--bg:#14050a;--bg2:#220910;--panel:#2e0d18;--panel2:#3d1322;--ink:#fff4f2;--muted:#e2c6cc;--line:rgba(255,220,220,.16);
 --l0:#ff4f6d;--l1:#ffb547;--l2:#6fd3ff;--l3:#c38bff;--gold:#ffd54a;--perfect:#ffe15e;--great:#ff9ad9;--good:#7fe6ff;--miss:#a59dc2;
 --font:"Hiragino Sans","Hiragino Kaku Gothic ProN","BIZ UDPGothic","Yu Gothic UI","Yu Gothic","Meiryo",system-ui,sans-serif;color-scheme:dark}
*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);font-family:var(--font);-webkit-text-size-adjust:100%}
button,select,input{font:inherit;color:inherit}
button{cursor:pointer}
[hidden]{display:none!important}
.app{display:flex;flex-direction:column;height:100vh;height:100svh;min-height:0;overflow:hidden;background:radial-gradient(120% 80% at 50% 0%,#4a0f20 0%,var(--bg) 62%)}
.topbar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:8px;height:48px;padding:0 max(12px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left));border-bottom:1px solid var(--line);background:rgba(20,5,10,.88)}
.brand{display:flex;align-items:center;gap:10px;color:var(--ink);text-decoration:none;font-weight:800;font-size:17px;letter-spacing:.04em;white-space:nowrap}
.brand small{display:block;font-size:9px;letter-spacing:.2em;color:var(--muted);font-weight:700}
.brand-icon{display:flex;align-items:flex-end;gap:3px;height:26px}
.brand-icon i{display:block;width:5px;border-radius:3px;background:var(--l0);height:60%;box-shadow:0 0 8px currentColor}
.brand-icon i:nth-child(2){background:var(--l1);height:90%}.brand-icon i:nth-child(3){background:var(--l2);height:45%}.brand-icon i:nth-child(4){background:var(--l3);height:75%}
.tools{display:flex;gap:6px}
.tool{display:inline-flex;align-items:center;gap:6px;min-height:36px;padding:0 12px;border-radius:999px;border:1px solid var(--line);background:var(--panel);font-size:14px;font-weight:700;white-space:nowrap}
.tool:hover{background:var(--panel2)}
.tool:focus-visible,.primary:focus-visible,.secondary:focus-visible,.card:focus-within,.diff:focus-visible{outline:3px solid var(--gold);outline-offset:2px}
@media(max-width:420px){.tool span{display:none}.brand{font-size:15px}}
@media(max-width:360px){.brand small{display:none}.brand{gap:7px}.tools{gap:4px}.tool{padding:0 10px}}
.screen{flex:1;min-height:0}
#lobby,#result,#finale{overflow-y:auto;overscroll-behavior:contain}
footer{flex:none;display:flex;flex-wrap:wrap;justify-content:center;gap:4px 16px;padding:6px 12px;font-size:11px;color:var(--muted);border-top:1px solid var(--line)}
.app.is-playing footer{display:none}
@media(max-width:560px){footer{font-size:10px;gap:2px 10px;padding:4px 8px;line-height:1.35}}
.eyebrow{margin:0 0 6px;font-size:12px;font-weight:800;letter-spacing:.14em;color:var(--gold)}
kbd{display:inline-block;min-width:26px;padding:2px 6px;margin:0 2px;border-radius:6px;border:1px solid rgba(255,255,255,.3);border-bottom-width:3px;background:#4a1626;font:700 13px/1.4 var(--font);text-align:center}

/* ── 選曲 */
#lobby{padding:0 16px 24px}
.hero{position:relative;max-width:1100px;margin:0 auto;padding:28px 4px 8px;overflow:hidden}
.hero-light{position:absolute;inset:0;pointer-events:none}
.hero-light i{position:absolute;top:-30%;width:6px;height:40%;border-radius:6px;opacity:.55;filter:blur(1px);animation:fall 3.2s linear infinite}
.hero-light i:nth-child(4n+1){background:linear-gradient(transparent,var(--l0))}.hero-light i:nth-child(4n+2){background:linear-gradient(transparent,var(--l1))}
.hero-light i:nth-child(4n+3){background:linear-gradient(transparent,var(--l2))}.hero-light i:nth-child(4n){background:linear-gradient(transparent,var(--l3))}
.hero-light i:nth-child(1){left:6%;animation-delay:-.4s}.hero-light i:nth-child(2){left:18%;animation-delay:-1.9s}.hero-light i:nth-child(3){left:31%;animation-delay:-2.6s}.hero-light i:nth-child(4){left:45%;animation-delay:-1.1s}
.hero-light i:nth-child(5){left:58%;animation-delay:-2.2s}.hero-light i:nth-child(6){left:71%;animation-delay:-.2s}.hero-light i:nth-child(7){left:84%;animation-delay:-1.5s}.hero-light i:nth-child(8){left:94%;animation-delay:-2.9s}
@keyframes fall{to{transform:translateY(330%)}}
@media(prefers-reduced-motion:reduce){.hero-light i{animation:none;display:none}}
.hero-moon{position:absolute;right:4%;top:14px;width:clamp(70px,14vw,150px);aspect-ratio:1;border-radius:50%;background:radial-gradient(circle at 40% 38%,#ffd0c8 0%,#ff6b6b 38%,#b3122e 72%,rgba(120,0,20,0) 74%);box-shadow:0 0 60px 10px rgba(255,40,70,.35);opacity:.85;pointer-events:none}
.hero-copy{position:relative}
.hero h1 .tentative{display:block;margin-top:4px;font-size:13px;font-weight:700;letter-spacing:.1em;color:var(--muted)}
.hero h1{margin:0 0 10px;font-size:clamp(26px,5vw,46px);line-height:1.2;letter-spacing:.02em}
.hero h1 em{font-style:normal;background:linear-gradient(90deg,#ff4f6d,#ffb547,#ff8fb0);-webkit-background-clip:text;background-clip:text;color:transparent}
.lead{margin:0 0 8px;font-size:clamp(15px,2.2vw,18px);line-height:1.7;font-weight:700}
.story{margin:0;font-size:14px;line-height:1.7;color:var(--muted)}
.selection{max-width:1100px;margin:16px auto 0}
.section-title{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:4px 16px;margin-bottom:10px}
.section-title h2{margin:0;font-size:20px}
.section-title p{margin:0;font-size:13px;color:var(--muted)}
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,300px),1fr));gap:12px}
.bonus{margin-top:26px}
.bonus .section-title p{max-width:640px}
.card{position:relative;display:flex;flex-direction:column;gap:8px;padding:14px;border-radius:18px;border:2px solid var(--line);background:linear-gradient(160deg,var(--panel) 0%,var(--bg2) 100%);cursor:pointer;transition:border-color .15s,transform .15s}
.card:hover{transform:translateY(-2px)}
.card.is-selected{border-color:var(--c);box-shadow:0 0 0 1px var(--c),0 0 26px -6px var(--c)}
.card-head{display:flex;align-items:center;gap:12px}
.card-head .emblem{width:58px;height:58px;flex:none}
.card-who{margin:0;font-size:13px;font-weight:800;color:var(--c)}
.card-title{margin:2px 0 0;font-size:19px;line-height:1.3}
.card-meta{margin:0;font-size:12px;color:var(--muted)}
.card-lead{margin:0;font-size:14px;line-height:1.6}
.diffs{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin-top:auto}
.diff{display:flex;flex-direction:column;align-items:center;gap:1px;min-height:58px;padding:6px 2px;border-radius:12px;border:1px solid var(--line);background:rgba(255,255,255,.04);font-weight:800}
.diff small{font-size:10px;letter-spacing:.08em;color:var(--muted)}
.diff b{font-size:14px}
.diff .best{font-size:11px;color:var(--muted);font-weight:700}
.diff.is-selected{background:var(--c);border-color:var(--c);color:#170f2c}
.diff.is-selected small,.diff.is-selected .best{color:#2a1b45}
.start-panel{position:sticky;bottom:0;z-index:2;max-width:1100px;margin:14px auto 0;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;border-radius:18px;border:1px solid var(--line);background:rgba(46,13,24,.95);backdrop-filter:blur(6px)}
.start-panel>.start-face{flex:none}
.start-face .emblem{width:56px;height:56px}
.start-info{flex:1;min-width:180px}
.start-info h2{margin:0;font-size:20px}
.start-info p{margin:4px 0 0;font-size:13px;color:var(--muted)}
.start-info .eyebrow{color:var(--c,var(--gold));margin:0}
.start-actions{display:flex;flex-direction:column;align-items:flex-end;gap:6px}
@media(max-width:560px){.start-face{display:none}.start-panel{flex-direction:column;align-items:stretch;gap:8px;padding:10px 12px}.start-info h2{font-size:17px}.start-info p{margin-top:2px}.start-actions{align-items:stretch;text-align:center;gap:4px}}
/* ★横に寝かせた電話（高さ500px以下）：開始の帯と下の表記が画面の半分以上を取り、曲のカードが110pxしか見えなかった（2026-11-04 実機 864×307）。
   帯は1行に細くし、下の表記は選曲画面のいちばん下（流れの中）へ移す */
.credit-inline{display:none}
@media(max-height:500px){
 .app>footer{display:none}
 .credit-inline{display:block;margin:18px 0 0;font-size:11px;line-height:1.6;color:var(--muted);text-align:center}
 .start-panel{flex-direction:row;flex-wrap:nowrap;align-items:center;gap:10px;padding:6px 10px;margin-top:10px}
 .start-face{display:none}
 .start-info{min-width:0}
 .start-info h2{font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 .start-info .eyebrow{font-size:11px}
 .start-info #selected-meta{display:none}
 .start-actions{flex-direction:row;align-items:center;gap:8px}
 .start-actions .keys-hint,.start-actions #replay-finale{display:none}
 .start-actions .primary{padding:8px 16px;font-size:15px}
}
@media(hover:none) and (pointer:coarse){.keys-hint,.side-keys{display:none}}
.keys-hint{margin:0;font-size:12px;color:var(--muted)}
.primary{min-height:48px;padding:0 26px;border:0;border-radius:999px;background:var(--gold);color:#1a1030;font-size:17px;font-weight:900;letter-spacing:.04em;box-shadow:0 6px 22px -8px var(--gold)}
.primary:hover{filter:brightness(1.06)}
.secondary{min-height:46px;padding:0 22px;border-radius:999px;border:2px solid rgba(255,255,255,.4);background:transparent;font-size:16px;font-weight:800}
.text-button{border:0;background:none;color:var(--muted);text-decoration:underline;font-size:14px;padding:6px}
.howto{max-width:1100px;margin:18px auto 0;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
@media(max-width:900px){.howto{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:480px){.howto{grid-template-columns:1fr}}
.howto>div{display:flex;gap:10px;padding:12px;border-radius:14px;background:rgba(255,255,255,.04);border:1px solid var(--line)}
.howto b{flex:none;display:grid;place-items:center;width:28px;height:28px;border-radius:50%;background:var(--panel2);color:var(--gold)}
.howto p{margin:0;display:flex;flex-direction:column;gap:2px}
.howto strong{font-size:15px}
.howto span{font-size:13px;line-height:1.6;color:var(--muted)}

/* 人物の札（紅魔郷の7人は顔の丸い札、付喪神は楽器の印）と立ち絵 */
.emblem{position:relative;display:grid;place-items:center;border-radius:50%;background:radial-gradient(circle at 35% 30%,var(--c) 0%,#1a1236 82%);box-shadow:0 0 0 2px var(--c),0 0 24px -4px var(--c)}
.emblem svg{width:66%;height:66%}
.emblem.has-img{background-color:#3a0f1c;background-repeat:no-repeat;overflow:hidden}
/* ★光（drop-shadow）は入れ物に付ける。絵に付けると下のぼかし（mask）が光ごと四角く切り、スマホで絵が四角い板に見えた（2026-11-04 実機） */
.result-face,.side-face{filter:drop-shadow(0 0 18px color-mix(in srgb,var(--c) 55%,transparent))}
/* ★長押しで画像のメニュー・選択・ドラッグを出さない（iPhone の画像メニュー対策） */
.portrait{display:block;max-width:100%;max-height:100%;object-fit:contain;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none;pointer-events:none;
 -webkit-mask-image:linear-gradient(#000 78%,transparent);mask-image:linear-gradient(#000 78%,transparent)}
/* 咲夜だけ足元まで入った全身の絵なので、上の7割を見せて顔の大きさをほかの6人にそろえる */
.portrait.p-sakuya{aspect-ratio:443/460;object-fit:cover;object-position:top}
.emblem.big{width:150px;height:150px}

/* ── 演奏 */
.play{position:relative;display:flex;flex-direction:column}
.stage{position:relative;flex:1;min-height:0;overflow:hidden;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;--hw:100%}
.stage canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
.hud{position:absolute;left:0;right:0;top:0;pointer-events:none}
.hud-top{display:flex;align-items:center;gap:10px;padding:8px max(10px,env(safe-area-inset-right)) 4px max(10px,env(safe-area-inset-left))}
.hud-top .tool{pointer-events:auto;min-width:40px;justify-content:center;background:rgba(33,26,70,.8)}
.hud-song{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.25}
.hud-song b{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-shadow:0 1px 4px #000}
.hud-song span{font-size:11px;font-weight:800;letter-spacing:.08em;color:var(--muted)}
.hud-score{text-align:right;line-height:1.1}
.hud-score small{display:block;font-size:10px;letter-spacing:.16em;color:var(--muted);font-weight:800}
.hud-score b{font-size:22px;font-variant-numeric:tabular-nums;text-shadow:0 1px 6px #000}
.gauge{position:relative;height:12px;margin:2px max(10px,env(safe-area-inset-right)) 0 max(10px,env(safe-area-inset-left));border-radius:6px;background:rgba(255,255,255,.12);overflow:hidden}
.gauge-fill{position:absolute;left:0;top:0;bottom:0;width:30%;background:linear-gradient(90deg,var(--l2),var(--l3));transition:width .12s}
.gauge.is-clear .gauge-fill{background:linear-gradient(90deg,var(--l0),var(--gold))}
.gauge-line{position:absolute;left:70%;top:0;bottom:0;width:2px;background:#fff}
.gauge span{position:absolute;right:6px;top:-1px;font-size:10px;font-weight:900;line-height:14px;text-shadow:0 0 3px #000}
.progress{height:3px;margin:4px max(10px,env(safe-area-inset-right)) 0 max(10px,env(safe-area-inset-left));background:rgba(255,255,255,.08);border-radius:2px;overflow:hidden}
.progress div{height:100%;width:0;background:rgba(255,255,255,.55)}
.side{position:absolute;top:84px;bottom:16px;width:calc((100% - var(--hw)) / 2);display:none;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:0 14px;text-align:center;pointer-events:none}
.stage.has-sides .side{display:flex}
.side-left{left:0}.side-right{right:0}
.side-face{display:flex;align-items:flex-end;justify-content:center;width:100%;height:min(46vh,340px);min-height:0}
.side-face .emblem{width:min(140px,70%);aspect-ratio:1;height:auto}
.side-who{margin:0;font-size:16px;font-weight:900;color:var(--c)}
.side-line{margin:0;font-size:13px;line-height:1.6;color:var(--muted);max-width:220px}
.live-counts{margin:0;display:grid;gap:6px;min-width:150px}
.live-counts div,.result-counts div{display:flex;justify-content:space-between;gap:12px}
.live-counts dt,.result-counts dt{font-size:12px;font-weight:900;letter-spacing:.06em}
.live-counts dd,.result-counts dd{margin:0;font-weight:900;font-variant-numeric:tabular-nums}
.c-perfect{color:var(--perfect)}.c-great{color:var(--great)}.c-good{color:var(--good)}.c-miss{color:var(--miss)}
.side-keys{margin:6px 0 0}
.auto-badge{margin:0;padding:2px 10px;border-radius:6px;background:#5a1a2e;font-weight:900;letter-spacing:.2em}
@media(max-height:460px){.side{top:70px}.side-face{height:44vh}.side .emblem{width:min(90px,60%)}.side-line{display:none}.live-counts{gap:2px}}
.countdown{position:absolute;inset:0;display:grid;place-items:center;font-size:clamp(60px,16vw,140px);font-weight:900;color:#fff;text-shadow:0 0 30px var(--l3);pointer-events:none}
.countdown:empty{display:none}

/* ── 結果 */
#result{padding:16px}
.result-panel{max-width:960px;margin:0 auto;display:grid;grid-template-columns:240px 1fr;gap:20px;padding:20px;border-radius:22px;border:1px solid var(--line);background:linear-gradient(160deg,var(--panel),var(--bg2))}
.result-face{display:flex;align-items:center;justify-content:center;width:100%;height:min(300px,45svh)}
.result-face .emblem.big{width:150px;height:150px}
@media(max-width:700px){.result-panel{grid-template-columns:1fr;padding:16px}.result-face{height:min(190px,22svh)}.result-face .emblem.big{width:110px;height:110px}}
.result-side{display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center}
.result-who{margin:0;font-weight:900;color:var(--c)}
.result-line{margin:0;font-size:15px;line-height:1.7}
.rank-row{display:flex;align-items:center;gap:18px}
.rank{margin:0;font-size:96px;line-height:1;font-weight:900;background:linear-gradient(180deg,#fff 10%,var(--gold) 60%,var(--l0));-webkit-background-clip:text;background-clip:text;color:transparent;filter:drop-shadow(0 0 14px rgba(255,213,74,.45))}
.clear{margin:0;font-size:24px;font-weight:900;letter-spacing:.1em;color:var(--gold)}
.clear.is-failed{color:var(--miss)}
.badges{margin:4px 0 0;display:flex;flex-wrap:wrap;gap:6px}
.badges span{padding:2px 10px;border-radius:999px;font-size:12px;font-weight:900;letter-spacing:.06em;background:#4a1626;border:1px solid var(--l3);color:#fff}
.badges span.fc{border-color:var(--l0);color:#ffd0e6}
.badges span.ap{background:linear-gradient(90deg,#b8860b,#d4a017);color:#1a1030;text-shadow:none}
.score-big{margin:14px 0 8px;display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 12px}
.score-big small{font-size:12px;letter-spacing:.16em;color:var(--muted);font-weight:900}
.score-big b{font-size:40px;font-variant-numeric:tabular-nums}
.score-big span{padding:2px 10px;border-radius:6px;background:var(--gold);color:#1a1030;font-size:12px;font-weight:900;letter-spacing:.1em}
.result-counts{margin:0 0 16px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 22px;max-width:460px}
.result-buttons{display:flex;flex-wrap:wrap;gap:10px}

/* ── フィナーレ */
#finale{position:relative}
.finale-panel{position:relative;min-height:100%;display:grid;place-items:center;padding:24px 16px;overflow:hidden}
#finale-canvas{position:absolute;inset:0;width:100%;height:100%}
.finale-content{position:relative;max-width:760px;padding:22px;border-radius:22px;background:rgba(26,6,12,.76);border:1px solid var(--line);text-align:center;backdrop-filter:blur(3px)}
.finale-content h1{margin:0 0 12px;font-size:clamp(24px,5vw,40px);background:linear-gradient(90deg,#ff4f6d,#ffb547,#ff8fb0);-webkit-background-clip:text;background-clip:text;color:transparent}
.finale-band{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin-bottom:12px}
.finale-band .emblem{width:clamp(54px,11vw,78px);height:auto;aspect-ratio:1;animation:bob 1.1s ease-in-out infinite alternate}
.finale-band .emblem:nth-child(2n){animation-delay:-.35s}.finale-band .emblem:nth-child(3n){animation-delay:-.7s}
@keyframes bob{to{transform:translateY(-8px)}}
.finale-lead{margin:0 0 12px;line-height:1.8;font-weight:700}
.recap{list-style:none;margin:0 0 12px;padding:0;display:grid;gap:6px}
.recap li{display:flex;justify-content:space-between;gap:10px;padding:8px 12px;border-radius:12px;background:rgba(255,255,255,.06);font-size:14px}
.recap b{color:var(--gold)}
.talk{list-style:none;margin:0 0 12px;padding:0;display:grid;gap:6px;text-align:left;font-size:14px;line-height:1.6}
.talk b{color:var(--gold);margin-right:4px}
.finale-next{margin:0 0 14px;font-size:13px;color:var(--muted)}

/* ── ダイアログ */
dialog{max-width:min(440px,calc(100vw - 32px));border:1px solid var(--line);border-radius:20px;background:var(--panel);color:var(--ink);padding:18px}
dialog::backdrop{background:rgba(6,4,14,.7)}
dialog h2{margin:0 0 10px;font-size:19px}
dialog p{line-height:1.7}
#pause-dialog{text-align:center}
#pause-dialog button{display:block;width:100%;margin-top:10px}
.dialog-heading{display:flex;justify-content:space-between;align-items:center}
.field{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px;margin:14px 0 0;font-weight:800}
.field input[type=range]{width:100%;accent-color:var(--gold)}
.field select{width:100%;min-height:42px;border-radius:10px;border:1px solid var(--line);background:var(--bg2);padding:0 8px}
.field output{font-variant-numeric:tabular-nums;color:var(--gold)}
.setting-help{margin:6px 0 0;font-size:12px;color:var(--muted)}
#settings-dialog .primary{width:100%;margin-top:16px}
#toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);padding:10px 16px;border-radius:12px;background:#4a1626;border:1px solid var(--line);font-size:14px;font-weight:700;z-index:9;max-width:calc(100vw - 32px)}

/* WordPress の iframe の中：選曲画面の端まで送ったら、親ページ（下の説明文）へ続けて送れるように */
.is-embed #lobby,.is-embed #result,.is-embed #finale{overscroll-behavior:auto}
/* 埋めこみのわくは低いので、下の表記は選曲画面のいちばん下（流れの中）へ。同じ表記はわくの下の説明文にもある */
.is-embed .app>footer{display:none}
.is-embed .credit-inline{display:block;margin:18px 0 0;font-size:11px;line-height:1.6;color:var(--muted);text-align:center}

/* ★低い画面（埋め込みのわく・横持ち）では結果が1画面に収まらない。ボタンを結果画面の下に貼りつけて、送らなくても押せるように（2026-11-04） */
@media(max-height:760px){
 .result-buttons{position:sticky;bottom:0;z-index:2;margin-bottom:-8px;padding:10px 0 8px;background:linear-gradient(rgba(30,8,16,0),var(--panel) 30%)}
 .result-buttons{flex-wrap:nowrap}.result-buttons>button{flex:1 1 0;min-width:0;padding:0 10px;white-space:nowrap}
}
/* 言葉の途中で折らない（「大成／功！」と折れた・2026-11-04 実機）。横持ちの演奏中は人物名を小さくし、「（◯面ボス）」を外す（「（6面ボ／ス）」と折れ、1行にすると667×375でフランが「…」で切れた） */
.nowrap{white-space:nowrap}
.recap b{white-space:nowrap}
@media(max-height:460px){.side-who{font-size:12px;line-height:1.3;max-width:100%}.side-who .who-extra{display:none}}
