:root{--ink:#24354a;--muted:#687487;--orange:#ed8924;--gold:#ffd152;--line:#dce2ea;--tile:clamp(29px,8.15vw,47px)}
*{box-sizing:border-box}html{background:#d8e7eb}body{margin:0;color:var(--ink);font-family:system-ui,-apple-system,"Hiragino Kaku Gothic ProN","Yu Gothic",sans-serif}
button{cursor:pointer;touch-action:manipulation;font:inherit}button:disabled{opacity:.46;cursor:default}button:focus-visible,a:focus-visible{outline:3px solid #f3a322;outline-offset:3px}
[hidden]{display:none!important}
.tower-online{width:min(740px,100%);min-height:100dvh;margin:auto;padding:10px 10px calc(30px + env(safe-area-inset-bottom,0px));background:linear-gradient(#f9fcffdf,#fff9ecf2),url("../../kyokasho_tower_background.png") center/cover fixed}
.top-nav{margin-bottom:4px}.brand{height:clamp(68px,12dvh,105px);text-align:center;margin-bottom:7px}.brand img{display:block;width:min(345px,78%);height:calc(100% - 17px);object-fit:contain;margin:auto;filter:drop-shadow(0 3px 5px #68432251)}.brand span{font-size:10px;font-weight:950;letter-spacing:.12em;color:#9c611c}
.panel{background:rgba(255,255,255,.96);border:1px solid var(--line);border-radius:17px;margin-bottom:9px;padding:14px 13px;box-shadow:0 6px 18px #30475b1b}
.panel h1{font-size:clamp(20px,5vw,27px);margin:4px 0 10px;text-align:center}.panel h2{font-size:17px;margin:0 0 9px}.panel p{line-height:1.5}.muted{color:var(--muted)}.hint{font-size:12px;font-weight:750;color:var(--muted)}.center{text-align:center}
.btn{width:100%;display:block;min-height:44px;padding:10px;border:1px solid #d3dce9;border-radius:13px;background:#f6f8fb;color:#283d52;font-weight:950}.btn.primary{background:linear-gradient(#ffdf75,#f5b747);color:#543714;border-color:#e4a83b}.btn.danger{background:#fff5f5;color:#a0484e;border-color:#f0c7c7}.btn.outline{background:#fff;color:#bb6b1e;border-color:#e6b982}
.actions{display:grid;gap:8px;margin-top:12px}.two{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.top-stats{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;color:#98601f;font-size:12px;font-weight:950;margin-bottom:8px}
.scores{display:flex;gap:5px;overflow-x:auto;padding:2px 0 8px;scrollbar-width:thin}.score-chip{flex:0 0 auto;padding:6px 9px;border:1px solid #e9d9bd;border-radius:99px;background:#fff7e8;color:#624926;font-size:11px;font-weight:900}.score-chip.current{background:#ffdf9a;color:#51350e;border-color:#e8a64b}
.board-panel{position:sticky;top:6px;z-index:3;padding:9px 7px 10px;box-shadow:0 8px 16px #30475b29}
.board-head{display:flex;align-items:center;justify-content:space-between;gap:7px;padding:3px 6px 7px;color:#5e6d7b;font-size:12px;font-weight:950}
.tower-board{display:grid;gap:1px;justify-items:center;max-height:min(52dvh,380px);overflow:auto hidden;min-height:var(--tile)}
.tower-row{display:flex;align-items:center;justify-content:center;gap:1px;min-height:var(--tile)}.tower-cell{width:var(--tile);height:var(--tile);display:grid;place-items:center;flex:0 0 var(--tile);border-radius:4px}
.tower-cell.book img{width:99%;height:99%;object-fit:contain;filter:drop-shadow(0 2px 2px #56442b51)}
.tower-empty{border:1px dashed #ccd3dd;background:#f1f2f4aa;width:85%;height:85%;border-radius:5px}
.slot{display:grid;place-items:center;width:100%;height:100%;border-radius:8px;border:2px dashed #e89624;background:#fff2b9;color:#ae671b;font-size:23px;font-weight:1000;animation:glow 1.6s infinite alternate}
.slot.preview{background:#ffe49c;border:3px solid #ea8b13;animation:none;position:relative}.slot.preview img{width:91%;height:91%;object-fit:contain}.slot.preview::after{content:'ここ';position:absolute;bottom:-5px;right:-5px;background:#f08a24;color:#fff;font-size:10px;border-radius:5px;padding:1px 3px}
@keyframes glow{from{box-shadow:0 0 0 0 #ecb56340}to{box-shadow:0 0 9px 3px #ecb56380}}
.notice{padding:9px 10px;border-radius:11px;background:#fff2dc;border:1px solid #edd1a4;font-weight:900;color:#925c21;font-size:12px;text-align:center}
.turn-banner{background:linear-gradient(100deg,#fff4dc,#ffe7b3);border:1px solid #ebca81;border-radius:13px;padding:12px 10px;text-align:center;font-weight:950;color:#77501f;margin:0 0 9px}
.turn-banner strong{display:block;font-size:18px;margin-top:3px}.turn-banner.wait{background:#f0f5fd;border-color:#cbdcf0;color:#465d79}
.hand-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.hand-book{position:relative;display:grid;justify-items:center;align-content:center;gap:3px;padding:6px 2px;border:1px solid #ced8e3;border-radius:10px;background:#fff;min-height:93px;color:#45546a;font-size:11px;font-weight:900}
.hand-book img{height:46px;max-width:100%;object-fit:contain}.hand-book b{position:absolute;right:2px;top:2px;min-width:21px;min-height:21px;border-radius:30px;background:#f1d18b;color:#6d4813;display:grid;place-items:center;font-size:11px}
.hand-book.playable{border:2px solid #d7a34e;background:#fffaf0}.hand-book.selected{border:3px solid #ec8428;background:#ffe3a5;color:#684318}
.hand-book:disabled{opacity:.47}.hand-label{font-size:12px;font-weight:950;margin:0 0 8px}
.place-confirm{position:sticky;bottom:8px;z-index:4;background:#fffdf4;border:2px solid #eead45;border-radius:13px;padding:9px;box-shadow:0 7px 20px #63451544}
.place-confirm p{margin:0 0 8px;text-align:center;font-weight:950;font-size:12px}
.member-list{display:grid;gap:6px}.member{display:flex;align-items:center;justify-content:space-between;gap:7px;padding:9px;border:1px solid #e4e9ee;border-radius:11px;background:#f9fbfd;font-size:13px}.member.current{background:#fff2d5;border-color:#eac77f}.member b{font-size:13px}.member small{color:#77848c;font-size:11px}
.result-grid{display:grid;gap:7px}.result-row{display:grid;grid-template-columns:minmax(0,1fr) 72px 64px;gap:5px;align-items:center;border:1px solid #e4e7ec;border-radius:11px;background:#fff;padding:10px 8px;font-weight:900;font-size:13px}.result-row strong{text-align:right;color:#cb7020}.result-row em{font-style:normal;text-align:right;color:#516174}
.ranking{display:grid;gap:7px}.rank-row{display:flex;align-items:center;justify-content:space-between;border:1px solid #e8e0ce;border-radius:12px;padding:10px;background:#fffaf2;font-weight:900}.winner{text-align:center;background:linear-gradient(120deg,#ffedbb,#fff7df);border:1px solid #f0d18a;border-radius:14px;padding:15px;margin-bottom:12px;font-size:22px;font-weight:1000;color:#975915}
.rules{font-size:13px;line-height:1.8;padding-left:22px}.rules strong{color:#9e5d19}
@media(max-width:365px){:root{--tile:clamp(27px,8vw,34px)}.panel{padding:11px 8px}.hand-grid{gap:4px}.hand-book{min-height:82px}.hand-book img{height:40px}.score-chip{padding:6px}.tower-board{max-height:49dvh}}
@media(min-width:650px){:root{--tile:44px}.panel{padding:16px}.board-panel{top:8px}.hand-book img{height:57px}}


/* Online tower mobile play: hand + board + active player in ONE viewport.
   Compact solo/offline-style paper surfaces, with secondary info in a disclosure. */
.tower-online[data-stage="playing"]{
 width:min(100%,900px);height:100dvh;min-height:320px;
 padding:max(4px,env(safe-area-inset-top)) max(7px,env(safe-area-inset-right))
         max(6px,env(safe-area-inset-bottom)) max(7px,env(safe-area-inset-left));
 display:flex;flex-direction:column;gap:4px;overflow:hidden;
 background:linear-gradient(160deg,rgba(249,252,255,.91),rgba(255,247,230,.88)),
 url("../../kyokasho_tower_background.png") center/cover no-repeat;
}
.tower-online[data-stage="playing"] .top-nav{
 flex:0 0 auto;margin:0;min-height:35px;
 display:flex;align-items:center;gap:5px;flex-wrap:nowrap;
}
.tower-online[data-stage="playing"] .top-nav>a:nth-of-type(2){display:none}
.tower-online[data-stage="playing"] .top-nav .hk-online-link{
 flex:1 1 auto;min-width:0;min-height:34px;
 padding:6px 4px;font-size:clamp(10px,2.6vw,13px);
}
.tower-online[data-stage="playing"] .top-nav .hk-online-connection{
 flex:0 0 auto;padding:6px 4px;font-size:clamp(10px,2.5vw,12px);
}
.tower-online[data-stage="playing"] .top-nav .hk-exit-button{
 flex:0 0 auto;min-width:40px;min-height:33px;padding:5px 8px;font-size:11px;
}
.tower-online[data-stage="playing"] .brand{
 flex:0 0 auto;height:clamp(32px,5.6dvh,48px);
 margin:0;text-align:center;
}
.tower-online[data-stage="playing"] .brand img{
 width:min(225px,56vw);height:100%;
 filter:drop-shadow(0 2px 2px #68432251);
}
.tower-online[data-stage="playing"] .brand span{display:none}
.tower-online[data-stage="playing"] #game-root{
 flex:1 1 auto;min-height:0;min-width:0;overflow:hidden;
 display:flex;flex-direction:column;
}
.tower-online[data-stage="playing"] .hk-online-notice:not([hidden]){
 position:absolute;top:45px;left:9px;right:9px;z-index:50;
 margin:0;padding:7px 8px;min-height:0;
 font-size:11px;box-shadow:0 4px 11px #0002;
}
.tower-play-screen{
 flex:1 1 auto;width:100%;min-height:0;min-width:0;
 display:grid;grid-template-rows:auto minmax(0,1fr) auto;
 gap:clamp(5px,1dvh,9px);overflow:hidden;
}
.tower-play-head{
 position:relative;z-index:5;min-height:51px;
 padding:6px 10px;
 border:1px solid #e6ce9e;border-radius:15px;
 background:linear-gradient(120deg,#fff8e8,#ffe9b9);
 display:flex;gap:5px;align-items:center;justify-content:space-between;
 box-shadow:0 3px 9px #754d2512;
}
.tower-round-label{
 min-width:0;display:flex;flex-direction:column;
 align-items:flex-start;justify-content:center;
 gap:0;line-height:1.25;color:#67491f;
}
.tower-round-label small{font-size:10px;font-weight:950;color:#966125}
.tower-round-label strong{
 font-size:clamp(14px,3.6vw,18px);font-weight:1000;
 text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:100%;
}
.tower-round-label span{font-size:10px;font-weight:850;color:#896c47}
.tower-more{flex:0 0 auto;position:relative}
.tower-more summary{
 min-height:33px;display:flex;align-items:center;justify-content:center;
 cursor:pointer;padding:6px 10px;white-space:nowrap;
 background:#fff;border:1px solid #e5b967;color:#97581f;
 border-radius:9px;font-size:11px;font-weight:950;list-style:none;
}
.tower-more summary::-webkit-details-marker{display:none}
.tower-more summary::after{content:" ▾";margin-left:3px}
.tower-more[open] summary::after{content:" ▴"}
.tower-more-popover{
 position:absolute;z-index:30;right:-1px;top:calc(100% + 6px);
 width:min(340px,calc(100vw - 36px));
 max-height:min(52dvh,420px);overflow-y:auto;
 padding:11px 9px;border:1px solid #d8ba7e;border-radius:13px;
 background:#fffffc;box-shadow:0 15px 35px #29384d56;
}
.tower-more-popover h3{margin:0 0 8px;font-size:14px}
.tower-more-popover .member-list{gap:4px}
.tower-more-popover .member{padding:6px}
.tower-more-popover .notice{margin-top:8px;font-size:11px}
.tower-more-popover .top-stats{margin:7px 0 0;font-size:10px}
.tower-online[data-stage="playing"] .panel{
 min-width:0;min-height:0;margin:0;border-radius:16px;
 box-shadow:0 3px 12px #30475b20;
}
.tower-play-screen .board-panel{
 position:relative;z-index:1;
 display:grid;grid-template-rows:auto minmax(0,1fr);
 height:100%;min-height:0;padding:6px 5px 8px;
 border-color:#e4e7ea;overflow:hidden;
}
.tower-play-screen .board-head{
 display:flex;align-items:center;justify-content:space-between;
 gap:5px;padding:2px 7px 5px;min-height:22px;
 font-size:clamp(10px,2.6vw,13px);line-height:1.2;
 color:#5c6876;
}
.tower-play-screen .board-head strong{font-weight:1000;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.tower-play-screen .board-head span{flex:0 0 auto;font-size:10px}
.tower-play-screen .tower-board{
 --tile:29px;
 width:100%;height:100%;min-height:0;max-height:none;
 overflow:hidden;
 display:flex;align-items:center;justify-content:flex-end;
 flex-direction:column;
 padding:1px 0 2px;gap:0;
}
.tower-stack{
 width:calc(var(--tower-columns) * var(--tile));
 max-width:100%;
 height:calc(var(--tower-rows) * var(--tile));
 flex:0 0 auto;min-height:0;
 display:flex;flex-direction:column;
 align-items:stretch;justify-content:flex-end;
}
.tower-row{
 position:relative;
 display:block;flex:0 0 var(--tile);
 width:100%;height:var(--tile);min-height:var(--tile);
 padding:0;margin:0;
}
.tower-cell{
 position:absolute;
 left:calc(var(--offset) * var(--tile));
 top:0;
 width:var(--tile);height:var(--tile);
 display:grid;place-items:center;flex:none;
 border:0;border-radius:0;
}
.tower-cell.book img.tower-book,.tower-cell img.tower-book{
 display:block;
 width:calc(var(--tile) - 2px);
 height:calc(var(--tile) - 2px);
 object-fit:contain;
 filter:drop-shadow(0 1px 1px #56442b50);
}
.tower-cell .tower-empty{
 display:block;width:calc(var(--tile) - 6px);height:calc(var(--tile) - 6px);
 border:1px dashed #c8cfd6;border-radius:6px;
 background:rgba(231,236,243,.42);
}
.tower-cell .slot{
 display:grid;place-items:center;
 width:calc(var(--tile) - 6px);
 height:calc(var(--tile) - 6px);
 padding:0;border:2px dashed #e9a24b;
 background:#fff2c9;
 border-radius:6px;color:#ad6a24;
 font-size:clamp(12px,2.8vw,19px);line-height:1;
 box-shadow:none;
 animation:slotPulse 1.5s ease-in-out infinite alternate;
}
.tower-cell .slot span{line-height:1;font-weight:1000}
.tower-cell .slot.preview{
 border:2px solid #eb8b18;
 background:rgba(255,231,164,.90);
 animation:none;
}
.tower-cell .slot.preview img{
 display:block;width:100%;height:100%;object-fit:contain;
}
.tower-cell .slot.preview span{
 position:absolute;right:-3px;bottom:-4px;
 padding:1px 2px;border-radius:3px;
 background:#ee9028;color:#fff;
 font-size:clamp(7px,1.7vw,9px);line-height:1;
}
.tower-cell .slot.preview::after{display:none}
@keyframes slotPulse{from{border-color:#d7aa6e;background:#fff5d7}to{border-color:#e88e22;background:#fff1b5}}
.tower-play-screen .hand-panel{
 flex:0 0 auto;padding:8px 8px 9px;overflow:hidden;
 border-color:#e4ded0;
}
.tower-play-screen .hand-heading{
 display:flex;align-items:baseline;justify-content:space-between;gap:8px;
 margin:0 0 6px;
}
.tower-play-screen .hand-heading h2{
 margin:0;font-size:clamp(14px,3.6vw,18px);
 font-weight:1000;color:#263951;
}
.tower-play-screen .hand-heading small{
 font-size:clamp(10px,2.6vw,12px);
 color:#9e6429;font-weight:900;white-space:nowrap;
}
.tower-play-screen .hand-grid{
 display:grid;grid-template-columns:repeat(5,minmax(0,1fr));
 gap:clamp(3px,1vw,7px);min-width:0;width:100%;
}
.tower-play-screen .hand-book{
 min-width:0;min-height:0;
 height:clamp(70px,12dvh,97px);
 padding:4px 1px;
 border:1.5px solid #d6ab64;border-radius:12px;
 background:#fffdf8;
 color:#495973;font-size:clamp(9px,2.6vw,12px);
 grid-template-rows:minmax(0,1fr) auto;gap:2px;
}
.tower-play-screen .hand-book img{
 height:min(7.2dvh,49px);width:100%;min-height:0;
 align-self:end;object-fit:contain;
}
.tower-play-screen .hand-book span{font-size:clamp(9px,2.5vw,12px);line-height:1.1}
.tower-play-screen .hand-book b{
 top:1px;right:1px;min-width:19px;min-height:19px;
 font-size:10px;border-radius:99px;
}
.tower-play-screen .hand-book.selected{
 background:linear-gradient(#ffe7b2,#ffdb90);
 border:3px solid #ee902b;color:#654019;
}
.tower-play-screen .hand-book.playable{border-color:#d3a15b}
.tower-play-screen .hand-book:disabled{opacity:.46}
.tower-play-screen .place-confirm{
 position:static;z-index:auto;
 width:100%;padding:6px 0 0;margin:0;
 border:0;box-shadow:none;background:none;
}
.tower-play-screen .place-confirm p{
 font-size:12px;margin:0 0 5px;line-height:1.15;
}
.tower-play-screen .place-confirm .two{gap:6px}
.tower-play-screen .place-confirm .btn{
 min-height:38px;padding:6px 5px;border-radius:10px;
 font-size:clamp(11px,3vw,15px);
}
.tower-wait-footer{
 padding:9px;min-height:50px;
 border:1px solid #dce3ea;border-radius:13px;
 background:rgba(255,255,255,.97);
 font-size:11px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:2px 7px;
}
.tower-wait-footer>strong{font-size:12px}
.tower-wait-footer>span{color:#66778d}
.tower-wait-footer>details{width:100%;position:relative}
.tower-wait-footer summary{cursor:pointer;color:#a46722;font-weight:900}
.tower-wait-footer details .hand-panel{position:absolute;bottom:calc(100% + 7px);left:0;width:100%;z-index:8;box-shadow:0 5px 22px #0003}
body:has(.hog-demo-tools) .tower-online[data-stage="playing"]{
 padding-bottom:calc(59px + env(safe-area-inset-bottom));
}
/* Trial controls stay fixed, small, and never obscure the placement dialog. */
body:has(.tower-online[data-stage="playing"]) .hog-demo-tools{
 width:min(260px,calc(100vw - 16px));
}
@media(max-height:600px){
 .tower-online[data-stage="playing"]{gap:2px}
 .tower-online[data-stage="playing"] .brand{height:29px}
 .tower-play-head{min-height:43px;padding:3px 8px}
 .tower-play-screen{gap:4px}
 .tower-play-screen .hand-book{height:65px}
 .tower-play-screen .hand-book img{height:37px}
 .tower-play-screen .hand-panel{padding:5px 6px}
 .tower-play-screen .hand-heading{margin-bottom:3px}
 .tower-play-screen .place-confirm .btn{min-height:34px}
}
@media(min-width:650px){
 .tower-online[data-stage="playing"]{max-width:820px}
 .tower-play-screen .board-panel{padding:10px}
 .tower-play-screen .hand-panel{padding:10px 12px}
 .tower-play-screen .hand-book{height:clamp(77px,11dvh,108px)}
 .tower-play-screen .hand-book img{height:min(7.7dvh,58px)}
 .tower-play-screen .tower-board{padding-bottom:5px}
}
@media(prefers-reduced-motion:reduce){
 .tower-cell .slot{animation:none}
}

/* Setup uses concise 3-step directions; full rules and roster on demand. */
.tower-setup-panel .tower-quick-rules{
 display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
 gap:5px;margin:12px 0 8px;
}
.tower-quick-rules span{
 display:grid;place-items:center;min-height:48px;
 padding:5px 3px;border:1px solid #e9ce99;
 border-radius:11px;background:#fff5db;color:#835422;
 font-weight:950;font-size:clamp(10px,2.8vw,13px);text-align:center;
}
.tower-rule-details{margin-top:10px}
.tower-rule-details>summary,.tower-intro-hand>summary{
 cursor:pointer;list-style:none;display:flex;justify-content:center;align-items:center;
 min-height:43px;padding:8px 10px;
 border:1px solid #d8bc8a;border-radius:12px;
 background:#fffdf8;color:#905b25;font-size:13px;font-weight:950;
}
.tower-rule-details>summary::-webkit-details-marker,
.tower-intro-hand>summary::-webkit-details-marker{display:none}
.tower-rule-details>summary::after,.tower-intro-hand>summary::after{content:" ▾"}
.tower-rule-details[open]>summary::after,.tower-intro-hand[open]>summary::after{content:" ▴"}
.tower-rule-details .rules{margin:7px 0 0}
.tower-rule-details .member-list{margin-top:9px}
.tower-intro-panel .turn-banner{padding:8px 10px;margin:7px 0}
.tower-intro-panel .turn-banner strong{font-size:16px}
.tower-intro-hand{padding:9px!important}
.tower-intro-hand .hand-panel{margin-top:9px}

/* Both turns share the same one-screen hand layout.
   Non-current players can SEE their personal cards/counts but cannot place. */
.tower-play-screen.is-waiting .hand-book.has-cards:disabled{
 opacity:1;
 cursor:default;
 border-color:#d4b88e;
 background:#fffdf8;
 color:#45546a;
}
.tower-play-screen.is-waiting .hand-book:not(.has-cards):disabled{
 opacity:.48;
}
.tower-play-screen.is-waiting .hand-heading small{
 color:#66788b;
}
