*{box-sizing:border-box}
body{margin:0;background:#fff;color:#2a2328;font:14px -apple-system,BlinkMacSystemFont,"Hiragino Sans","Noto Sans JP",sans-serif}
main{max-width:450px;margin:auto;padding:6px 12px max(16px,env(safe-area-inset-bottom))}
button,select{font:inherit;color:inherit;touch-action:manipulation}
button{min-height:44px;border:0;border-radius:8px;background:#f3f4f6;padding:8px 12px;cursor:pointer}
button:focus-visible,select:focus-visible{outline:2px solid #95536b;outline-offset:2px}
button[aria-pressed=true]{background:#eef0f3;box-shadow:inset 0 0 0 2px #956277}
select{min-height:44px;max-width:100%;border:0;background:transparent;font-weight:600}
label{display:flex;gap:4px;align-items:center}
.toolbar{display:flex;align-items:center;gap:6px;margin-bottom:6px}
.toolbar label{margin-right:auto;min-width:0}
.toolbar select{max-width:145px}
#stage{background:#e4edf2;border-radius:12px;overflow:hidden}
.brief{padding:4px 12px}
.brief p{font-size:12px;margin:0;color:#574d55;min-height:32px}
.scene{display:flex;align-items:flex-end;justify-content:center;height:clamp(230px,35svh,330px);padding:0 6px 10px;position:relative;background:radial-gradient(ellipse at 50% 100%,#fff9 0%,transparent 75%)}
.figure{width:50%;max-width:205px;display:flex;flex-direction:column;align-items:center;height:100%;justify-content:flex-end}
.figure svg{display:block;width:100%;height:calc(100% - 23px)}
.figure span{font-size:12px;background:#ffffffb8;border-radius:20px;padding:3px 10px}
.partner img{object-fit:contain;width:100%;height:78%}
.speech{margin:0;background:#fffc;padding:10px 12px;min-height:54px;line-height:1.5}
.categories{display:flex;gap:6px;margin:8px 0}
.categories button{flex:1}
.items{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.item{display:flex;align-items:center;text-align:left;gap:8px;min-height:70px;padding:8px}
.item-preview{width:38px;height:48px;flex-shrink:0;pointer-events:none}
.item-preview svg{width:100%;height:100%;display:block}
.item strong{font-size:13px;display:block}
.item small{font-size:12px;color:#6e626a;display:flex;flex-wrap:wrap;gap:2px 4px;margin-top:3px}
.tag.match{color:#2a2328;font-weight:600;text-decoration:underline;text-underline-offset:2px}
.primary{width:100%;margin-top:8px;background:#95536b;color:#fff;font-weight:600}
h2{font-size:18px;margin:12px 0 8px}
#result p{line-height:1.5;margin:8px 0}
#breakdown{display:grid;grid-template-columns:1fr 1fr;list-style:none;padding:0;gap:6px;font-size:12px}
.actions{display:flex;gap:8px}
.actions button{flex:1}
#photo-note,.save-note{font-size:12px;color:#6e626a}
dialog{border:0;border-radius:12px;padding:16px;width:calc(100% - 24px);max-width:426px;max-height:88svh;overflow:auto;color:#2a2328}
dialog::backdrop{background:#2a232877}
.dialog-head{display:flex;align-items:center;justify-content:space-between;gap:8px;position:sticky;top:-16px;z-index:1;background:#fff;margin:-16px -16px 12px;padding:12px 16px}
.dialog-head h2{margin:0}
.dialog-head button{width:44px;flex-shrink:0;font-size:22px}
dialog p{line-height:1.7}
#photos{display:grid;gap:8px}
#photos button{text-align:left;width:100%}
#photos .scene{height:180px;border-radius:8px;margin-bottom:6px;pointer-events:none}
#photo-scene{height:min(340px,48svh);border-radius:8px}
[hidden]{display:none!important}


.operation-guide{display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px;margin:8px 0 0;font-size:12px;color:#6e626a}
.operation-guide strong{color:#2a2328;font-weight:600}


.actions .primary{width:auto;margin:0}


.item:active{background:#e6e8ec}
.item>span:last-child{min-width:0;overflow-wrap:anywhere}
.items{grid-template-columns:repeat(2,minmax(0,1fr))}


/* The toolbar may shrink on narrow phones; touch targets keep their height. */
.toolbar label{flex:1}
.toolbar select{min-width:0;width:100%}
.toolbar>button{flex-shrink:0}

.figure{min-width:0}
.figure span{max-width:100%;text-align:center;overflow-wrap:anywhere;flex-shrink:0}

select:disabled{color:#6e626a;opacity:1}
.save-note{padding:8px;border:1px solid #dedde1;border-radius:8px}

@media(max-height:700px){#stage>.scene{height:190px}
.brief p{min-height:0}
.speech{min-height:44px;padding:8px 12px}
}


.toolbar > .game-cast-control { flex: 1; }
