/* Formation-first setup. Scoped to body.setup-before-play; live match styles remain untouched. */
.setup-flow[hidden],.setup-screen[hidden]{display:none!important}
.setup-flow{margin:9px 0 13px;display:block;color:#2c2d24}
.setup-screen{background:linear-gradient(145deg,#f8f4e9,#efe5d3);border:1px solid #ceb99a;border-radius:15px;padding:13px 12px 14px;box-shadow:0 4px 16px #45351b1c}
.setup-title{margin:0;font-weight:900;font-size:clamp(15px,4.2vw,21px);color:#244e38;line-height:1.4}
.setup-description{margin:7px 0 0;font-size:clamp(11px,2.9vw,13px);line-height:1.65;color:#3d4238}
.setup-explanation{margin:10px 0 12px;border-left:3px solid #6d876d;padding:5px 9px;font-size:11px;line-height:1.55;background:#fffcf5;color:#696050}
.setup-action-row{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin:9px 0 13px}
.setup-flow button{font:inherit;touch-action:manipulation}
.setup-action-row button{border-radius:10px;border:1px solid #acaf96;min-height:43px;font-size:13px;font-weight:800;color:#304b38;background:#fffdf7}
.setup-action-row button:disabled{opacity:.55}
.setup-saved-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:5px 0 7px}
.setup-saved-head strong,.setup-formation-head strong{font-size:13px;color:#273a2d}
.setup-saved-head small,.setup-formation-head small{font-size:11px;color:#776c5c}
.setup-saved-strip{display:flex;gap:9px;max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;padding:3px 1px 10px;scroll-snap-type:x mandatory;scrollbar-width:thin}
.setup-saved-empty{min-width:100%;border:1px dashed #cbbba5;border-radius:8px;padding:12px 8px;color:#776954;font-size:11px;text-align:center}
.setup-saved-card{scroll-snap-align:start;flex:0 0 142px;width:142px;min-width:0;background:#fffaf1;border:2px solid #d4c5ac;border-radius:9px;padding:6px 5px 5px;display:flex;flex-direction:column;gap:5px}
.setup-saved-card.active{border-color:#2c7652;box-shadow:0 0 0 1px #2c7652}
.setup-saved-pick{border:none;background:transparent;text-align:center;padding:0;color:#3c4437;font-size:11px;font-weight:800;min-width:0}
.setup-saved-time{display:block;white-space:nowrap;margin-bottom:5px;font-variant-numeric:tabular-nums}
.setup-saved-remove{align-self:flex-end;border:none;background:#efe5d5;color:#694a40;border-radius:5px;font-size:10px;padding:3px 9px;min-height:23px}
.setup-formation-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:10px 0 7px}
.setup-board-card{border-radius:9px;background:#c18b56;border:2px solid #936238;box-shadow:inset 0 2px 3px #61452250,0 3px 7px #44352321;padding:7px 7px 8px}
.setup-board-files{display:grid;grid-template-columns:repeat(9,minmax(0,1fr));text-align:center;font-size:10px;color:#4c3219;font-weight:850;margin-bottom:2px}
.setup-board-grid{display:grid;grid-template-columns:repeat(9,minmax(0,1fr));grid-template-rows:repeat(3,minmax(0,1fr));aspect-ratio:3 / 1.13;border-top:1px solid #815e3b;border-left:1px solid #815e3b;background:#dbab72 url('/assets/materials/board-wood-v6.svg') center/100% 300% no-repeat}
.setup-board-cell{display:grid;place-items:center;min-width:0;min-height:0;border-right:1px solid #815e3baf;border-bottom:1px solid #815e3baf;overflow:hidden}
.setup-board-cell .piece{display:block;width:96%;height:96%;max-height:100%;max-width:100%;object-fit:contain;filter:drop-shadow(0 1px 1px #42291650)}
.setup-board-cell .piece.enemy{transform:none}
.setup-board-grid.mini{aspect-ratio:3 / 1.18}
.setup-board-grid.mini .piece{width:100%;height:100%;max-width:100%;max-height:100%}
.setup-board-grid.mini .setup-board-cell{border-width:.6px}
.setup-confirm,.setup-choice{border:1px solid #2f6348;background:linear-gradient(145deg,#32694e,#20523a);color:#fff!important;font-weight:850;border-radius:11px;min-height:49px;padding:10px;font-size:14px;box-shadow:0 3px 8px #2541272a}
.setup-confirm{display:block;width:100%;margin:11px 0 1px}
.setup-choice.secondary{color:#315443!important;background:#fffaf1;border-color:#b8bcab;box-shadow:none}
.setup-mode-head{margin-bottom:9px}
.setup-mode-summary{background:#fffcf5;border:1px solid #d7c4a6;border-radius:10px;padding:8px 10px;margin:8px 0 12px}
.setup-mode-summary .setup-board-grid{width:100%;margin:0}
.setup-mode-summary .setup-board-card{width:100%;margin:0}
.setup-mode-options{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px;align-items:stretch}
.setup-mode-options button{min-height:52px;border:1px solid #809d85;border-radius:10px;padding:8px 5px;background:#fffbf1;color:#245139;font-size:13px;font-weight:850}
.setup-mode-options button.setup-choice{background:linear-gradient(145deg,#32694e,#20523a);color:#fff}
.setup-mode-foot{font-size:11px;color:#655a49;margin:10px 0 0;line-height:1.55}
.setup-wait-heading{font-size:17px;font-weight:850;color:#30523e;margin:0 0 8px}
.setup-wait-msg{font-size:12px;line-height:1.6;color:#635b4d;margin:0 0 12px}
body.setup-before-play .menu,
body.setup-before-play .hint,
body.setup-before-play #previewPanel,
body.setup-before-play .match-alert-bar,
body.setup-before-play .opponent-name,
body.setup-before-play .opponent-row,
body.setup-before-play .boardwrap,
body.setup-before-play .self-row,
body.setup-before-play .self-name,
body.setup-before-play .replay-panel,
body.setup-before-play .footnote{display:none!important}
body.setup-before-play .setup-flow{display:block}
body:not(.setup-before-play) .setup-flow{display:none}
.menu button#galleryBtn{min-height:52px;align-self:stretch}
@media(max-width:430px){.setup-screen{padding:11px 9px}.setup-saved-card{flex-basis:134px;width:134px}.setup-mode-options button{min-height:46px}.menu button#galleryBtn{min-height:41px}}
@media(max-width:360px){.setup-description{font-size:11px}.setup-board-card{padding:5px}.setup-saved-card{flex-basis:128px;width:128px}}

/* Preserve the same wood, ink and square geometry when moving to mode selection. */
.setup-description,.setup-explanation,.setup-mode-foot{font-family:system-ui,-apple-system,BlinkMacSystemFont,'Hiragino Kaku Gothic ProN','Yu Gothic',Meiryo,sans-serif;font-weight:650;letter-spacing:.005em;color:#343c32}
.setup-description{font-size:clamp(13px,3.35vw,15px);line-height:1.7}
.setup-explanation{font-size:13px;line-height:1.65;font-weight:700;color:#43513d}
.setup-title{font-family:system-ui,-apple-system,BlinkMacSystemFont,'Hiragino Kaku Gothic ProN','Yu Gothic',Meiryo,sans-serif;font-weight:850}
body.setup-before-play #newBtn{display:none!important}
.setup-mode-summary{background:transparent;border:0;padding:0}
.setup-mode-summary .setup-board-card{background:#c18b56}

/* Match the approved setup-piece shadow during live play without changing the SVG artwork. */
.board .square > .piece{filter:drop-shadow(0 1px 1px #42291650)}

/* Three approved instructions are shown as bold, distinct bullets. */
.setup-description-list{list-style:disc;padding-left:1.35em;margin:10px 0 12px;display:grid;gap:5px}
.setup-description-list li{padding-left:1px;margin:0;line-height:1.6}
.setup-description-list strong{font-weight:800}

/* Three equally sized mode buttons on one row, including narrow phones. */
.setup-mode-options > .setup-choice{
 width:100%;min-width:0;min-height:52px;display:grid;place-items:center;
 padding:7px 3px;text-align:center;white-space:normal;overflow-wrap:normal;
 font-family:system-ui,-apple-system,BlinkMacSystemFont,"Hiragino Kaku Gothic ProN","Yu Gothic",Meiryo,sans-serif;
 font-size:clamp(10px,2.8vw,13px);font-weight:850;line-height:1.3;
}
#setupBackBtn.setup-back{
 font-family:system-ui,-apple-system,BlinkMacSystemFont,"Hiragino Kaku Gothic ProN","Yu Gothic",Meiryo,sans-serif;
 font-weight:850;font-size:clamp(13px,3.3vw,15px);letter-spacing:0;line-height:1.45;
}

/* The live legacy navigation also honors the approved 3-button mode layout.
 * "獲得した運" remains exclusively in the top-right header. */
body:not(.setup-before-play) .menu{grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}
body:not(.setup-before-play) .menu .online-choice{display:contents}
body:not(.setup-before-play) .menu button{
 width:100%;min-width:0;min-height:48px;
 font:800 clamp(11px,2.8vw,13px)/1.3 system-ui,-apple-system,BlinkMacSystemFont,"Hiragino Kaku Gothic ProN","Yu Gothic",Meiryo,sans-serif;
 padding:8px 3px;white-space:normal;letter-spacing:0
}

/* The name itself is editable. The mini-board remains the load target. */
.setup-saved-name{
 display:block;box-sizing:border-box;width:100%;min-width:0;min-height:26px;padding:3px 2px;
 border:0;border-radius:5px;background:transparent;color:#2b4c36;
 font:850 12px/1.35 "Yu Gothic","Hiragino Kaku Gothic ProN",system-ui,sans-serif;
 overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0 0 2px;text-align:center;cursor:text;
}
.setup-saved-name::after,.saved-name-edit::after{content:" ✎";font-size:15px;font-weight:900;color:#416c54;vertical-align:-1px}
.setup-saved-name:focus-visible,.saved-name-edit:focus-visible{outline:2px solid #2c7652;outline-offset:1px}
.setup-saved-name-input,.saved-name-input{
 box-sizing:border-box;width:100%;min-width:0;min-height:28px;padding:3px 5px;
 border:1px solid #2c7652;border-radius:5px;background:#fff;color:#234b38;
 font:800 13px/1.3 "Yu Gothic","Hiragino Kaku Gothic ProN",system-ui,sans-serif;
}
.setup-saved-time{font-size:10px;color:#796b58;margin-bottom:5px}
.setup-saved-pick{display:block;width:100%}
.setup-saved-actions{display:flex;align-items:center;justify-content:flex-end;gap:4px}
.setup-saved-remove{
 flex:none;min-width:49px;min-height:26px;padding:4px 9px;
 font:800 10px/1.2 "Yu Gothic","Hiragino Kaku Gothic ProN",system-ui,sans-serif;
 border:1px solid #d3c0a5;border-radius:5px;background:#efe7d8;color:#554536;
}
.saved-name-edit{
 flex:none;max-width:32%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
 padding:5px;border:0;background:transparent;color:#2b4c36;
 font:800 12px/1.3 "Yu Gothic","Hiragino Kaku Gothic ProN",system-ui,sans-serif;cursor:text;
}
.saved-name-input{flex:none;max-width:32%}
