:root {
  color-scheme: light;
  --bg:#e8f4fc; --surface:rgba(255,255,255,.75); --line:rgba(86,117,145,.14);
  --text:#1c1e21; --muted:#607183; --cyan:#50c8ff; --coral:#ff7b89;
  --mono:'Cascadia Mono',Consolas,monospace;
  --board-w:clamp(210px,calc((100svh - 340px)/2),290px);
  font-family:'Segoe UI','Malgun Gothic',sans-serif; color:var(--text); background:var(--bg); font-synthesis:none;
}
*{box-sizing:border-box}body{margin:0;min-height:100vh;background:radial-gradient(ellipse at 5% 28%,#fff9 0,transparent 45%),radial-gradient(ellipse at 96% 65%,#e7defc80 0,transparent 43%),linear-gradient(145deg,#e8f4fc,#d3ebfc);background-attachment:fixed}
button,input,select{font:inherit}button{cursor:pointer;color:var(--text);background:#ffffff90;border:1px solid #fff;border-radius:12px;padding:11px 16px;transition:background .18s,box-shadow .18s,transform .18s}button:hover{background:#fff;box-shadow:0 4px 14px #6a94b01c;transform:translateY(-1px)}button:active{transform:translateY(1px)}button:disabled{opacity:.45;cursor:not-allowed}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #329acd;outline-offset:3px}[hidden]{display:none!important}a{color:inherit;text-decoration:none}kbd{display:inline-block;font:10px var(--mono);padding:3px 5px;border:1px solid #9bafc045;border-bottom-width:2px;border-radius:5px;color:#516170;background:#ffffff80;white-space:nowrap}.muted{color:var(--muted)}
.topbar{height:74px;padding:0 3.2%;display:flex;align-items:center;gap:26px;border-bottom:1px solid #fff9;background:#ffffff45}.brand{display:flex;align-items:center;gap:6px;font-size:30px;font-weight:850;letter-spacing:-1.4px}.brand-slash{margin:0 3px;font-size:25px;font-weight:300;color:#8193a5}.brand-number{font-size:23px;font-weight:500;letter-spacing:-1px}.brand-icon{width:34px;height:33px;display:grid;grid-template:repeat(2,11px)/repeat(3,11px);gap:1px;margin:0 10px 0 0;transform:rotate(-8deg)}.brand-icon i{border:1px solid #fff9;border-radius:3px;background:linear-gradient(#e7d0fe,#c4a5ed);box-shadow:inset 0 1px 1px #fff}.brand-icon i:first-child{grid-column:2}.brand-icon i:nth-child(2){grid-row:2;background:linear-gradient(#c2f3fb,#88e1f2)}.brand-icon i:nth-child(3){grid-row:2}.brand-icon i:last-child{grid-row:2;background:linear-gradient(#ffd3d3,#ffabab)}.edition{font-size:11px;color:#586e80;line-height:1.7}.edition span{display:block;font-size:10px;color:#698093}.top-actions{margin-left:auto;display:flex;align-items:center;gap:8px}.icon-button{font-size:11px;padding:9px 13px}.connection{font:10px var(--mono);color:#556e7c;margin-right:10px;white-space:nowrap}.connection i,.live-dot,.you-dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:#55aa8c;margin-right:7px}.connection.offline i{background:var(--coral)}
main{max-width:1580px;margin:auto;padding:26px 3.2% 0;display:flex;flex-direction:column}.intro{order:0;display:flex;justify-content:space-between;align-items:center;margin:0 0 24px}.eyebrow{font-size:9px;font-weight:650;letter-spacing:1.9px;color:#657f92;margin:0 0 12px}h1{margin:0;font-size:clamp(24px,2.2vw,34px);line-height:1.45;letter-spacing:-1.8px;font-weight:750}h1 em{font-style:normal;color:#536e8c}.intro-copy{font-size:12px;color:var(--muted);margin:10px 0 0}.room-tag{display:grid;grid-template-columns:1fr auto;gap:5px 20px;padding:16px 20px;background:var(--surface);border:1px solid #fff;border-radius:16px;box-shadow:0 6px 22px #8197b00c}.room-tag>span{font-size:10px;color:var(--muted)}.room-tag strong{grid-row:2;font:17px var(--mono);letter-spacing:1.1px}.room-tag button{grid-column:2;grid-row:1/3;align-self:center;font-size:10px;padding:9px 12px;border-color:var(--line);background:transparent}
.statusbar{order:1;display:flex;align-items:center;background:var(--surface);backdrop-filter:blur(16px);border:1px solid #ffffffe6;border-radius:16px;box-shadow:0 6px 22px #829cb50b;padding:14px 6px;margin-bottom:24px}.statusbar>div{padding:0 24px;min-width:130px;border-right:1px solid var(--line)}.small-label{font:9px var(--mono);letter-spacing:1px;color:var(--muted);display:block}.statusbar strong{font:21px var(--mono);display:block;margin-top:6px;letter-spacing:-.5px}.statusbar>div:first-child strong{font:600 12px 'Segoe UI','Malgun Gothic',sans-serif;margin-top:8px;color:#3b665a}.statusbar>div:first-child strong::before{content:'';display:inline-block;width:5px;height:5px;background:#60af95;border-radius:50%;margin-right:6px}.status-note{font-size:11px;color:#5c7185;margin:auto 20px auto auto;line-height:1.6}
.arena{order:3;display:grid;grid-template-columns:minmax(0,1fr) calc(var(--board-w) + 168px) minmax(0,1fr);gap:30px;position:relative;isolation:isolate}#target-beam{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:3}.opponents-panel{min-width:0}.panel-heading{height:36px;display:flex;justify-content:space-between;align-items:center;margin:0 4px 12px}.panel-heading h2{font-size:11px;font-weight:600;margin:0;color:#4d6479}.panel-heading span{font:9px var(--mono);color:#6d8496}.opponents-panel>canvas{display:block;width:100%}.play-panel{min-width:0;position:relative}.player-heading{height:27px;display:flex;align-items:center;justify-content:space-between;margin:0 2px 8px;font-size:11px}.player-heading>div{display:flex;align-items:center;gap:6px;min-width:0}.player-heading strong{max-width:190px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:12px}.you-dot{margin-right:1px;background:#739fc7}.you-tag{font-size:8px;font-weight:700;letter-spacing:.5px;color:#516581;background:#ffffffa0;border:1px solid #fff;border-radius:5px;padding:3px 5px}#my-badges{color:#6b6396;font:14px var(--mono);letter-spacing:2px}
.board-hud{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:26px;margin:0 0 12px}.board-caption{font-size:8px;letter-spacing:1px;color:#647c90}.targeted-badge{font-size:9px;font-weight:650;white-space:nowrap;color:#486981;background:#ffffffa6;border:1px solid #fff;border-radius:20px;padding:6px 9px}.targeted-badge.is-targeted{color:#92505b;background:#fff0f2d9;border-color:#ffc7ce}.targeted-badge.is-danger{color:#832c3f;background:#ffe0e6;border-color:#ffa6b3}.board-layout{display:grid;grid-template-columns:68px minmax(0,1fr) 68px;gap:16px}.board-shell{position:relative;min-width:0}.board-wrap{border:2px solid #202428;border-radius:9px;overflow:hidden;position:relative;box-shadow:0 16px 40px #6c94b330,0 0 0 5px #ffffff6b;isolation:isolate;background:#202428}#board{width:100%;height:auto;aspect-ratio:1/2;display:block}.board-side{padding-top:3px;display:flex;align-items:center;flex-direction:column;min-width:0}.board-side .small-label{font-size:9px;font-weight:600;letter-spacing:1.3px;margin-bottom:10px;color:#4f657a}.board-side kbd{font-size:8px;padding:2px 4px;margin-left:3px}.board-side canvas{width:68px;height:auto;display:block}.side-note{font-size:9px;color:#6d8193;margin-top:8px;white-space:nowrap}.incoming-summary{margin-top:auto;text-align:center;padding:14px 6px 8px}.incoming-label{font:8px var(--mono);color:#9c5a64;letter-spacing:.5px;display:block}#garbage-count{display:block;font:21px var(--mono);color:#b14759;margin-top:7px}
.garbage-track{position:absolute;left:-10px;top:5px;bottom:5px;width:5px;background:#ff7b8918;border-radius:4px;overflow:hidden}#garbage-fill{position:absolute;bottom:0;width:100%;background:linear-gradient(#ffa7b2,#ff7b89);border-radius:4px;transition:height .25s ease-out;box-shadow:0 0 9px #ff7b8933}.board-shell.is-danger .board-wrap{box-shadow:0 0 0 5px #ff7b8926,0 15px 35px #ff7b8920;border-color:#97515b}.combo-stat{margin-top:28px;text-align:center}.combo-stat span,.b2b-label{display:block;font:8px var(--mono);letter-spacing:.8px;color:#667b8e}.combo-stat strong{display:block;font:24px var(--mono);margin-top:7px;color:#7c669d}.b2b-label{margin-top:auto;padding-top:20px;font-size:7px;white-space:nowrap}#b2b{font:21px var(--mono);margin-top:7px;margin-bottom:8px;color:#7c669d}
.board-overlay{position:absolute;inset:0;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;padding:20px;background:linear-gradient(150deg,#f9fdffe8,#e8f2fbd9);backdrop-filter:blur(9px)}.board-overlay strong{font-size:19px;letter-spacing:-.6px;font-weight:750;color:var(--text)}.board-overlay p{font-size:11px;color:#5e7487;line-height:1.9;max-width:180px;word-break:keep-all}.overlay-symbol{width:91px;height:66px;display:grid;grid-template:repeat(2,29px)/repeat(3,29px);gap:2px;margin-bottom:30px;transform:rotate(-9deg);filter:drop-shadow(0 9px 7px #9e8cbd30)}.overlay-symbol i{border-radius:6px;border:1px solid #fff9;background:linear-gradient(145deg,#edd8ff,#d8b4f8 70%);box-shadow:inset 2px 2px 2px #fffc,inset -2px -2px 4px #a98cca50}.overlay-symbol i:first-child{grid-column:2}.overlay-symbol i:nth-child(n+2){grid-row:2}.board-overlay.countdown strong{font-size:86px;font-weight:800;letter-spacing:-5px}.board-overlay.countdown{background:#eff8ffe3}
.combo-popup{position:absolute;right:-45px;top:20px;z-index:4;display:flex;flex-direction:column;align-items:center;min-width:80px;background:#fffffff0;border:1px solid #fff;border-radius:16px;padding:10px 12px;box-shadow:0 7px 25px #6e559625;transform:rotate(7deg)}.combo-popup strong{font:800 40px 'Segoe UI',sans-serif;line-height:1;color:#8360b1;letter-spacing:-2px}.combo-popup span{font-size:9px;letter-spacing:1px;font-weight:800;color:#78638d;margin-top:5px}.combo-popup.pop{animation:combo-pop 1.2s both}@keyframes combo-pop{0%{opacity:0;transform:rotate(0) scale(.6)}16%{opacity:1;transform:rotate(9deg) scale(1.15)}30%,75%{opacity:1;transform:rotate(7deg) scale(1)}100%{opacity:0;transform:rotate(7deg) translateY(-12px)}}
.personal-stats{display:grid;grid-template-columns:repeat(3,1fr);background:#ffffff80;border:1px solid #fff;border-radius:14px;text-align:center;margin-top:16px;padding:12px 0}.personal-stats>div+div{border-left:1px solid var(--line)}.personal-stats span{font:8px var(--mono);letter-spacing:.5px;color:#63788d;display:block}.personal-stats strong{display:block;font:22px var(--mono);letter-spacing:-1px;margin-top:5px}.target-heading{display:flex;justify-content:space-between;font-size:9px;color:#5c7186;margin:16px 2px 8px}.target-heading>span:last-child{font-size:8px;color:#6e8498}.target-buttons{display:flex;gap:6px}.target-buttons button{flex:1;padding:9px 3px;font-size:10px;white-space:nowrap;border-radius:10px;background:#ffffff65;color:#54697f}.target-buttons kbd{border:none;background:transparent;color:inherit;font-size:9px;padding:0 4px 0 0}.target-buttons button.active{background:#26333f;border-color:#26333f;color:#fff;box-shadow:0 4px 10px #536f871a}
.lobby-controls{order:2;background:var(--surface);backdrop-filter:blur(16px);border:1px solid #fff;border-radius:18px;padding:16px 22px;margin-bottom:26px;box-shadow:0 6px 22px #829cb50b}#join-form{display:flex;align-items:end;gap:16px}label{display:block;font-size:11px;color:#50677a;font-weight:500}#join-form label{flex:1}#join-form .room-input{max-width:220px}input:not([type=range]),select{display:block;width:100%;background:#f4f9fcb3;border:1px solid #b5c9d65e;border-radius:10px;padding:12px 13px;color:var(--text);margin-top:7px;font-size:12px}input::placeholder{color:#718797}.primary{background:#26333f;color:#fff;border-color:#26333f;font-size:12px;font-weight:600;padding:13px 24px;border-radius:11px}.primary:hover{background:#384c5c}.primary span{margin-left:32px}.secondary{background:#fff9;border-color:#b9cdda66;font-size:11px}.quiet-button{border-color:transparent;background:transparent;color:#5e7387;font-size:11px}#joined-controls{display:flex;align-items:center;justify-content:space-between;gap:16px}.lobby-caption{font-size:11px}#host-label{display:block;font-size:10px;color:#617c90;margin:7px 0 0 14px}.lobby-buttons{display:flex;gap:8px;align-items:center}
.bottom-row{order:5;display:flex;justify-content:space-between;align-items:center;gap:20px;padding:24px 0 18px;border-bottom:1px solid #9fbad026}.control-guide{display:flex;gap:13px;align-items:center;font-size:9px;color:#566e83}.control-guide .small-label{font-size:8px;margin-right:6px}#event-feed{font-size:10px;color:#5e7184}footer{order:6;display:flex;justify-content:space-between;align-items:center;font-size:10px;color:#5c7487;padding:18px 0 22px}footer>span:first-child{font-weight:700}footer .muted{font-size:8px;font-weight:400;letter-spacing:1px;margin-left:12px}.footer-star{font-size:18px;color:#8095b9;margin-left:7px}
#toast{position:fixed;bottom:26px;left:50%;transform:translate(-50%,12px);background:#fffffff0;backdrop-filter:blur(14px);color:#394e61;border:1px solid #fff;box-shadow:0 10px 35px #6c879633;border-radius:14px;padding:14px 22px;opacity:0;pointer-events:none;transition:.2s;z-index:100;max-width:90vw;font-size:12px;text-align:center}#toast.visible{opacity:1;transform:translate(-50%,0)}
dialog{width:100%;max-width:min(620px,92vw);padding:30px;border:1px solid #fff;border-radius:24px;background:#f7fbfff2;backdrop-filter:blur(24px);color:var(--text);box-shadow:0 25px 100px #45657e33}dialog::backdrop{background:#405b7740;backdrop-filter:blur(9px)}.dialog-heading{display:flex;justify-content:space-between;align-items:start}dialog h2{font-size:28px;letter-spacing:-1px;margin:14px 0}dialog p{font-size:12px;color:#60788c}dialog label{margin:25px 0}dialog output{float:right;font:12px var(--mono);color:#577e9f}input[type=range]{width:100%;display:block;margin:15px 0;accent-color:#789bc8}.settings-note{font-size:10px;line-height:1.8;color:#60788c}dialog .primary{margin-top:10px}.results-table-wrap{max-height:50vh;overflow:auto;margin:25px 0 10px}table{width:100%;border-collapse:collapse;font-size:11px}th{text-align:left;color:#657e90;font-weight:500;position:sticky;top:0;background:#f5faff}td,th{padding:12px 8px;border-bottom:1px solid #b2c7d633}tbody tr:first-child{color:#775592;font-weight:650}tr.me{background:#e6d7f74d}.result-actions{display:flex;justify-content:end;align-items:end;gap:10px}.floating-button{position:fixed;right:25px;bottom:25px;background:#26333f;color:#fff;box-shadow:0 8px 25px #61778933;z-index:5}.touch-controls{display:none}
body[data-phase=playing] .intro,body[data-phase=countdown] .intro{display:none}body[data-phase=playing] .topbar,body[data-phase=countdown] .topbar{height:60px}body[data-phase=playing] main,body[data-phase=countdown] main{padding-top:18px}body[data-phase=playing] .statusbar,body[data-phase=countdown] .statusbar{padding-top:11px;padding-bottom:11px;margin-bottom:18px}
@media(min-width:1700px){:root{--board-w:310px}.arena{gap:40px}}
@media(max-width:1150px){:root{--board-w:clamp(205px,calc((100svh - 360px)/2),270px)}.arena{gap:18px;grid-template-columns:minmax(0,1fr) calc(var(--board-w) + 148px) minmax(0,1fr)}.board-layout{grid-template-columns:60px minmax(0,1fr) 60px;gap:14px}.board-side canvas{width:60px}.edition{display:none}.statusbar>div{min-width:110px;padding:0 18px}.status-note{font-size:10px}.board-caption{font-size:7px;letter-spacing:.5px}.lobby-buttons{flex-wrap:wrap;justify-content:end}.bottom-row{flex-wrap:wrap}.panel-heading h2{font-size:10px}}
@media(max-width:850px){:root{--board-w:250px}.topbar{height:65px;padding:0 18px;gap:10px}.brand{font-size:27px}.brand-icon{margin-right:5px}.brand-number{font-size:21px}.connection{font-size:9px;margin-right:2px}.icon-button{font-size:10px;padding:8px 10px}main{padding:22px 18px 0}.intro{align-items:center;gap:16px}.intro h1{font-size:27px}.intro-copy{max-width:250px;font-size:11px;line-height:1.7}.eyebrow{font-size:8px;letter-spacing:1px}.room-tag{display:block;padding:14px}.room-tag strong{display:block;font-size:14px;margin:6px 0}.room-tag button{font-size:9px;padding:6px 0;border:0}.statusbar{flex-wrap:wrap;row-gap:12px;padding:13px 0}.statusbar>div{min-width:0;flex:1;padding:0 13px}.statusbar>div:nth-child(4){border:0}.statusbar .small-label{font-size:8px}.statusbar strong{font-size:18px}.status-note{width:100%;margin:0 13px;font-size:10px}.arena{grid-template-columns:1fr 1fr;gap:24px 16px}.play-panel{grid-row:1;grid-column:1/3;max-width:430px;width:100%;justify-self:center}.board-layout{grid-template-columns:60px minmax(0,1fr) 60px;gap:14px}.opponents-panel{grid-row:2}.panel-heading{margin-bottom:8px}.board-side canvas{width:60px}.board-hud{margin-bottom:12px}.board-caption{font-size:8px}.lobby-controls{padding:16px;margin-bottom:24px}#joined-controls{flex-direction:column;align-items:stretch}.lobby-buttons{justify-content:start;flex-wrap:wrap}.lobby-buttons button{padding:11px 13px}#join-form{flex-wrap:wrap;gap:12px}#join-form label{min-width:125px}#join-form .room-input{max-width:150px}#join-form .primary{width:100%}.touch-controls{order:4;display:flex;position:fixed;bottom:max(10px,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:calc(100% - 24px);max-width:460px;gap:5px;background:#eff8ffda;backdrop-filter:blur(16px);padding:8px;border:1px solid #fff;border-radius:16px;box-shadow:0 8px 30px #5a768b2b;z-index:10}.touch-controls button{flex:1;padding:13px 3px;font-size:11px;touch-action:none;user-select:none}.touch-controls button[data-action=hard]{background:#26333f;color:#fff}.control-guide{flex-wrap:wrap;gap:10px;line-height:2}.control-guide .small-label{width:100%}footer .muted{display:block;margin:5px 0 0;font-size:7px}footer{font-size:9px}.bottom-row{padding:20px 0}body[data-phase=playing] main{padding-bottom:70px}dialog{padding:24px}.combo-popup{right:-35px;min-width:66px;padding:8px}.combo-popup strong{font-size:33px}}
@media(max-width:450px){.topbar{padding:0 14px}.brand{font-size:25px;gap:3px;letter-spacing:-1.3px}.brand-icon{width:28px;grid-template:repeat(2,9px)/repeat(3,9px);height:24px;margin-right:5px}.brand-number{font-size:19px}.brand-slash{font-size:20px}.top-actions{gap:5px}#sound{font-size:0;width:29px;min-width:29px;padding:8px 3px}#sound::after{content:'♪';font-size:13px}#settings-open{font-size:9px;padding:8px}.connection{font-size:8px}.connection i{width:5px;height:5px;margin-right:4px}main{padding:20px 14px 0}.intro h1{font-size:25px}.intro h1 em{display:block}.intro-copy{max-width:215px;font-size:10px}.intro .eyebrow{font-size:7px}.room-tag{padding:11px;min-width:112px}.room-tag strong{font-size:13px}.statusbar>div{padding:0 9px}.statusbar .small-label{font-size:7px;letter-spacing:.4px}.statusbar>div:first-child strong{font-size:10px}.statusbar strong{font-size:17px}.board-layout{grid-template-columns:49px minmax(0,1fr) 49px;gap:12px}.board-side canvas{width:49px}.board-side .small-label{font-size:8px;letter-spacing:.8px}.board-side kbd{font-size:7px;margin-left:1px}.side-note{font-size:8px}.b2b-label{font-size:6px;letter-spacing:0}.board-caption{font-size:7px;letter-spacing:.4px}.targeted-badge{font-size:8px;padding:5px 7px}.board-overlay{padding:12px}.board-overlay strong{font-size:17px}.board-overlay p{font-size:10px}.overlay-symbol{transform:rotate(-9deg) scale(.85)}.personal-stats span{font-size:7px}.personal-stats strong{font-size:20px}.panel-heading h2{font-size:9px}.panel-heading span{font-size:8px}.combo-popup{right:-28px;min-width:60px;top:12px}.combo-popup strong{font-size:30px}.combo-popup span{font-size:8px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
.combo-popup{right:8px;top:14px;pointer-events:none}
@media(max-width:850px){body[data-phase=playing] .play-panel{max-width:clamp(280px,calc((100svh - 420px)/2 + 122px),430px)}body[data-phase=playing] .personal-stats{display:none}.combo-popup{right:7px;top:12px}}
@media(max-width:850px){#target-beam{display:none}}
body[data-phase=playing] .arena{-webkit-user-select:none;user-select:none}
body[data-phase=playing] .board-wrap,body[data-phase=playing] #board{touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
body[data-phase=playing] .target-buttons button{touch-action:manipulation}

/* Keep the board and touch controls usable on a phone without shrinking the
   opponent boards into six unreadable columns. */
@media(max-width:600px){
  body{background-attachment:scroll}
  .intro{align-items:stretch;flex-direction:column;gap:14px}
  .intro h1 em{display:inline}
  .intro-copy{max-width:none}
  .room-tag{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 10px;min-width:0}
  .room-tag strong{grid-row:2;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .room-tag button{grid-column:2;grid-row:1/3;align-self:center;padding:8px;font-size:10px}
  .room-tag button,#settings-open,#sound{min-height:44px}
  #sound{width:44px;min-width:44px}
  .arena{display:flex;flex-direction:column;gap:26px}
  .play-panel{align-self:center;order:0}
  .opponents-panel{width:100%;order:1}
  body[data-phase=idle] .opponents-panel{display:none}
  #target-beam{display:none}
  .panel-heading h2{font-size:11px}
  #join-form{display:grid;grid-template-columns:minmax(0,1fr)}
  #join-form label{min-width:0}
  #join-form .room-input{max-width:none}
  #join-form .primary{grid-column:1}
  input:not([type=range]),select{font-size:16px;min-height:44px}
  .lobby-buttons button,.target-buttons button{min-height:44px}
  .target-buttons button{font-size:11px}
  .touch-controls{left:6px;right:6px;bottom:max(6px,env(safe-area-inset-bottom));transform:none;width:auto;max-width:none;gap:4px;padding:5px;border-radius:14px;touch-action:none;overscroll-behavior:contain;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
  .touch-controls button{min-width:0;min-height:48px;padding:7px 1px;font-size:11px;font-weight:600;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
  body[data-phase=playing] main{padding-bottom:calc(84px + env(safe-area-inset-bottom))}
  .floating-button{bottom:calc(86px + env(safe-area-inset-bottom));right:12px}
  dialog{max-height:calc(100dvh - 24px);overflow:auto;padding:20px}
  .results-table-wrap{max-height:45dvh}
  .results-table-wrap table{min-width:480px}
}
@media(max-width:360px){
  .topbar{gap:5px}
  .brand{font-size:22px}
  .brand-number{font-size:17px}
  .top-actions{gap:3px}
  #settings-open{font-size:8px;padding:8px 5px}
  .connection{margin-right:0}
  .connection{font-size:0}
  .connection i{width:8px;height:8px;margin-right:0}
  main{padding-left:10px;padding-right:10px}
  .statusbar>div{padding:0 6px}
  .board-layout{grid-template-columns:46px minmax(0,1fr) 46px;gap:10px}
  .board-side canvas{width:46px}
  .play-panel{max-width:100%}
  .touch-controls button{font-size:10px}
}
@media(max-width:600px) and (max-height:700px){
  body[data-phase=playing] .topbar,body[data-phase=countdown] .topbar{height:50px}
  body[data-phase=playing] main,body[data-phase=countdown] main{padding-top:9px}
  body[data-phase=playing] .statusbar,body[data-phase=countdown] .statusbar{margin-bottom:10px;padding-top:8px;padding-bottom:8px;row-gap:5px}
  body[data-phase=playing] .status-note,body[data-phase=countdown] .status-note{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .board-hud{margin-bottom:6px}
  .target-heading{margin-top:10px}
  body[data-phase=playing] .play-panel{max-width:clamp(280px,calc((100svh - 370px)/2 + 122px),430px)}
}
@media(max-width:850px) and (orientation:landscape) and (max-height:500px){
  body[data-phase=playing] .topbar,body[data-phase=countdown] .topbar{height:44px}
  body[data-phase=playing] main,body[data-phase=countdown] main{padding-top:8px}
  body[data-phase=playing] .statusbar,body[data-phase=countdown] .statusbar{padding:7px 0;margin-bottom:8px}
  body[data-phase=playing] .status-note,body[data-phase=countdown] .status-note{display:none}
  body[data-phase=playing] .statusbar strong,body[data-phase=countdown] .statusbar strong{font-size:16px;margin-top:3px}
  .board-hud{margin-bottom:6px}
  .touch-controls{left:auto;right:max(8px,env(safe-area-inset-right));top:50%;bottom:auto;transform:translateY(-50%);width:148px;max-width:none;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;padding:6px}
  .touch-controls button{min-height:44px;padding:7px 2px}
  body[data-phase=playing] main{padding-bottom:12px}
}
@media(max-width:650px) and (orientation:landscape) and (max-height:500px){
  .play-panel{margin-right:120px}
}
/* Two thumb zones: piece actions on the left, direction pad on the right. */
@media(max-width:850px) and (orientation:portrait){
  .touch-controls{display:grid;grid-template-columns:minmax(78px,1.3fr) 8px repeat(3,minmax(0,1fr));grid-template-rows:repeat(2,58px);gap:4px;padding:5px}
  .touch-controls button{min-height:58px;padding:4px;font-size:14px;border-radius:11px}
  .touch-controls [data-action=hold]{grid-column:1;grid-row:1}
  .touch-controls [data-action=hard]{grid-column:1;grid-row:2;font-size:16px}
  .touch-controls [data-action=cw]{grid-column:4;grid-row:1;font-size:12px}
  .touch-controls [data-action=left]{grid-column:3;grid-row:2;font-size:25px}
  .touch-controls [data-action=right]{grid-column:5;grid-row:2;font-size:25px}
  .touch-controls [data-action=soft]{grid-column:4;grid-row:2;font-size:12px}
  body[data-phase=playing] main{padding-bottom:calc(152px + env(safe-area-inset-bottom))}
  body[data-phase=playing] .play-panel{max-width:clamp(280px,calc((100svh - 450px)/2 + 122px),430px)}
  body[data-phase=playing] #toast{top:145px;bottom:auto;max-width:min(90vw,330px);padding:10px 14px;font-size:11px}
}
@media(max-width:600px) and (orientation:portrait){
  body[data-phase=playing] .topbar{height:48px}
  body[data-phase=playing] main{padding-top:4px}
  body[data-phase=playing] .statusbar{padding:5px 0;margin-bottom:5px;row-gap:4px}
  body[data-phase=playing] .status-note{font-size:9px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  body[data-phase=playing] .player-heading{height:22px;margin-bottom:1px}
  body[data-phase=playing] .board-hud{min-height:18px;margin-bottom:4px}
  body[data-phase=playing] .play-panel{max-width:clamp(280px,calc((100svh - 450px)/2 + 137px),365px)}
  body[data-phase=playing] .board-layout{grid-template-columns:42px minmax(0,1fr) 42px;gap:8px}
  body[data-phase=playing] .board-side canvas{width:42px}
  body[data-phase=playing] .side-note{font-size:7px}
  body[data-phase=playing] .target-heading{margin:4px 2px 2px}
}
@media(min-width:601px) and (max-width:850px){body[data-phase=playing] #toast{top:110px;bottom:auto}}
@media(max-width:850px) and (orientation:landscape) and (max-height:500px){
  body[data-phase=playing] #toast{top:104px;bottom:auto;left:calc((100% - 176px)/2);max-width:calc(100vw - 208px);padding:10px 14px}
  .touch-controls{width:176px;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(3,52px);gap:4px}
  .touch-controls button{min-height:52px}
  .touch-controls [data-action=cw]{grid-column:2;grid-row:1;font-size:10px}
  .touch-controls [data-action=left]{grid-column:1;grid-row:2;font-size:19px}
  .touch-controls [data-action=right]{grid-column:3;grid-row:2;font-size:19px}
  .touch-controls [data-action=soft]{grid-column:2;grid-row:2;font-size:10px}
  .touch-controls [data-action=hold]{grid-column:1;grid-row:3}
  .touch-controls [data-action=hard]{grid-column:2/4;grid-row:3}
}
