/* Transparent icon artwork; no white bitmap rectangles. */
.mi-board-icon{padding:0!important;border:0!important;background:transparent!important;box-shadow:none!important;min-width:0!important;line-height:1!important;cursor:pointer;object-fit:contain}
.mi-board-icon>img{display:block;width:100%!important;height:100%!important;object-fit:contain;pointer-events:none}
.mi-board-host{background:none!important}
.mi-reset-icon{padding:0!important;border:0!important;background:transparent!important;box-shadow:none!important;cursor:pointer;object-fit:contain}
.mi-reset-icon>img{width:100%!important;height:100%!important;object-fit:contain;display:block;pointer-events:none}
.mi-reset-icon:before,.mi-reset-icon:after{content:none!important;display:none!important}
.mi-app-exit{display:inline-flex!important;align-items:center;justify-content:center;width:32px;height:40px;padding:0!important;border:0!important;background:transparent!important;color:#ff690b!important;font:42px/1 Arial,sans-serif!important;text-decoration:none!important;box-shadow:none!important;flex-shrink:0;cursor:pointer}
.mi-app-exit:focus:not(:focus-visible){outline:none!important}
.mi-mobile-toggle{background:transparent!important;color:#666!important;border:0!important;box-shadow:none!important;min-width:0!important}
[data-mobile-app] select:focus,[data-mobile-app] select:active,[data-mobile-app] summary:focus:not(:focus-visible){outline:none!important;box-shadow:none!important;border-color:transparent!important}
[data-math-app] :is(#trash,#card-trash,#remove,#computer-trash,#computer-trash-open){mix-blend-mode:multiply;z-index:0!important;background:transparent!important}
[data-math-app] :is(#trash,#card-trash,#remove)>img{width:100%;height:100%;object-fit:contain;pointer-events:none}
@media(max-width:600px) and (orientation:portrait){.mi-stage-reset{position:absolute!important;left:9px!important;bottom:9px!important;top:auto!important;right:auto!important;width:40px!important;height:40px!important;z-index:6!important;margin:0!important;touch-action:manipulation}}
.math-whiteboard-open .mi-stage-reset,.board-open .mi-stage-reset,.leggi-whiteboard-open .mi-stage-reset{pointer-events:none!important;opacity:.3}
@media(max-width:600px) and (orientation:portrait){
 .mi-app-exit{width:25px;height:34px;font-size:34px!important}
 .mi-reset-relocated{display:none!important}
 [data-mobile-menu].mi-mobile-menu,#counter-top #menu[data-mobile-menu].mi-mobile-menu{display:none!important;inset:70px 8px auto 8px!important;width:calc(100vw - 16px)!important;max-width:420px;padding:14px!important;grid-template-columns:repeat(7,minmax(0,1fr))!important;grid-auto-rows:40px;grid-template-rows:none!important;gap:10px!important;align-items:center!important;justify-items:center}
 [data-mobile-menu].mi-menu-open,#counter-top #menu[data-mobile-menu].mi-menu-open{display:grid!important}
 [data-mobile-menu]>* ,#counter-top #menu[data-mobile-menu]>li{grid-area:auto!important;position:relative!important;margin:0!important;align-self:center!important;max-width:100%;min-width:0}
 [data-mobile-menu]>[data-mi-wide]{grid-column:span 2!important;width:100%!important}
 [data-mobile-menu]>[data-mi-wide] select{max-width:100%!important;width:100%!important}
 [data-mobile-menu] .mi-reset-icon{margin-right:7px!important}
 [data-mobile-menu] .mi-board-icon,#counter-top #whiteboard a.mi-board-icon{width:36px!important;height:36px!important;background:transparent!important}
 [data-mobile-menu].mi-board-active.mi-mobile-menu,#counter-top #menu.mi-board-active.mi-mobile-menu{display:flex!important;left:auto!important;right:8px!important;width:64px!important;overflow:visible}
 [data-mobile-menu].mi-board-active>:not([data-mobile-board-item]){display:none!important}
 #counter-top #menu[data-mobile-menu]>li.counter-notation{width:100%!important}
 #counter-top #counter-notation{width:100%!important}
 #menu #range-summary{width:100%!important;font-size:15px!important;padding:0 4px;gap:3px}
 #menu .range-slot{grid-column:span 3!important;width:100%!important;max-width:none}
 #range-panel{position:fixed!important;top:125px!important;left:12px!important;width:calc(100vw - 24px)!important;transform:none!important;z-index:5200!important}
 [data-mobile-legacy] [data-mobile-popup].mi-popup{z-index:5200!important;min-width:140px!important}
 [data-mobile-legacy] [data-mobile-popup].mi-popup img{width:120px!important;height:48px!important;max-width:none!important}
 [data-mobile-app=block] .reset-control{margin-right:6px!important}
 body[data-math-app=block] .block-palette :is(.plus,.minus){display:none!important}
 body[data-math-app=block] .block-palette .card-body{padding-inline:3px!important}
 /* The stage fills the available height; palette rows have reserved space. */
 body[data-math-app=touchandthink] #app{height:100dvh;min-height:0;gap:7px;padding-bottom:8px}
 body[data-math-app=touchandthink] #workspace{flex:1!important;height:auto!important;max-height:none!important;min-height:0!important;grid-template-rows:minmax(0,1fr)!important;width:100%!important}
 body[data-math-app=touchandthink] #stage{height:100%!important;max-height:none!important;min-height:0!important}
 body[data-math-app=touchandthink] #app>footer{height:48px;min-height:48px;flex:none}
 body[data-math-app=cartellini]{height:100dvh;min-height:0;display:flex;overflow:hidden;box-sizing:border-box;padding-bottom:5px}
 body[data-math-app=cartellini] #card-game{flex:1!important;min-height:0!important;height:auto!important;width:96%;margin:0 auto!important;padding-block:0;gap:5px}
 body[data-math-app=cartellini] #card-table{flex:1!important;min-height:0!important;height:auto!important;max-height:none!important}
 body[data-math-app=cartellini] #card-challenge{min-height:96px;height:96px}
 body[data-math-app=cartellini] #card-challenge[hidden]{display:none!important}
 body[data-math-app=cartellini] #card-palette{height:94px;min-height:94px;max-height:94px;flex:none;align-content:center;box-sizing:border-box;gap:4px;padding:4px 6px;overflow:hidden}
 body[data-math-app=touchandthink] #category .chevron{width:21px!important;height:13px!important;bottom:-12px!important}
 body[data-math-app=tabelline] #object-picker .object-chevron{width:23px!important;height:14px!important;top:34px!important;left:7px!important}
 body[data-math-app=tabelline]{padding-bottom:19px!important;box-sizing:border-box}
 body[data-math-app=tabelline] footer{min-height:39px}
 body[data-math-app=tabelline] .math-app-credit,body[data-math-app=componi] .math-app-credit{display:block!important;position:fixed;left:7px;bottom:2px;font:9px/12px Arial;color:#777;pointer-events:none;white-space:nowrap}
 body[data-math-app=componi]{padding-bottom:18px!important;box-sizing:border-box}
}

body[data-math-app=touchandthink] #trash.active>img,body[data-math-app=euro] #trash.open>img{content:url('/shared/trashbred.jpg')}

@media(max-width:600px) and (orientation:portrait){
 #counter-top #menu[data-mobile-menu]>li:is(#fullscreen_,#counter-language-slot){grid-area:auto!important}
 #counter-top #menu[data-mobile-menu]>li[data-mi-wide]{width:100%!important}
 [data-mobile-menu]>.game-options{grid-column:1/-1!important;width:100%!important;justify-content:center}
}

/* Euro uses the same board tools and canvas engine as Leggi. */
body[data-math-app=euro] #whiteboard-panel{position:fixed;inset:0;z-index:1000;display:flex;flex-direction:column;padding:70px 8px 6px;background:#ffffff20}
body[data-math-app=euro] #whiteboard-panel[hidden]{display:none}
body[data-math-app=euro].leggi-whiteboard-open header{position:relative;z-index:1001}
body[data-math-app=euro] #whiteboard-surface{flex:1;min-height:0}
body[data-math-app=euro] .whiteboard-tools{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:6px;align-self:center;padding:6px;border:1px solid #bbb;border-radius:12px;background:white;box-shadow:0 3px 10px #0002}
body[data-math-app=euro] .whiteboard-tools button,body[data-math-app=euro] .whiteboard-tools summary{display:grid;place-items:center;width:36px;height:36px;min-width:36px;padding:7px;border:0;border-radius:50%;background:#00b9ce;color:white;font:bold 22px Arial;cursor:pointer;list-style:none}
body[data-math-app=euro] .whiteboard-tools button[data-tool=delete]{background:#ff1717}
body[data-math-app=euro] .whiteboard-tools button[aria-pressed=true]{background:#ff690b;box-shadow:none}
body[data-math-app=euro] .whiteboard-tools svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
body[data-math-app=euro] #whiteboard-color{position:relative}
body[data-math-app=euro] #whiteboard-color summary::-webkit-details-marker{display:none}
body[data-math-app=euro] #whiteboard-color .color-dot{width:18px;height:18px;border-radius:50%;background:var(--active-color)}
body[data-math-app=euro] #whiteboard-color:not([open])>.color-swatches{display:none}
body[data-math-app=euro] .color-swatches{position:absolute;bottom:44px;left:50%;transform:translateX(-50%);display:flex;gap:5px;padding:7px;border:1px solid #ddd;background:white;border-radius:20px}
body[data-math-app=euro] .whiteboard-tools .color-swatches button{background:var(--swatch);width:23px;height:23px;min-width:23px;padding:0}
body[data-math-app=euro] #trash{background:transparent;padding:0;pointer-events:none}

body[data-math-app=componi] .math-app-credit{position:fixed;left:7px;bottom:2px;font:11px/13px Arial;color:#777;pointer-events:none}
.mi-app-exit{opacity:1!important}
.mi-mobile-toggle{font:30px/1 Arial,sans-serif!important;width:36px!important;height:36px!important;padding:0!important}
@media(max-width:600px) and (orientation:portrait){
 [data-math-app] :is(#trash,#card-trash,#remove,#computer-trash,#computer-trash-open){position:absolute!important;right:8px!important;bottom:8px!important;left:auto!important;top:auto!important;width:45px!important;height:60px!important;margin:0!important;padding:0!important;object-fit:contain}
 body[data-math-app=touchandthink] .computer-mode #trash{bottom:165px!important}
}

/* One compact confirmation style, for both legacy and native board dialogs. */
#canvasReset{margin-top:0!important;z-index:2147483500!important}
#canvasReset .modal-dialog{position:relative;display:flex;align-items:center;width:240px!important;min-width:0!important;max-width:calc(100vw - 32px)!important;min-height:calc(100vh - 32px);min-height:calc(100dvh - 32px);margin:16px auto!important}
#canvasReset .modal-content{width:100%;border-radius:10px}
#canvasReset .modal-header[hidden]{display:none!important}
#canvasReset .modal-body{padding:16px 12px 8px;text-align:center;font:20px/1.3 Arial,sans-serif}
#canvasReset .modal-footer{display:flex;justify-content:center;gap:10px;border:0;padding:6px 12px 16px}
#canvasReset .modal-footer .btn{width:58px;min-width:58px;height:34px;min-height:34px;margin:0;padding:4px;font:600 15px/24px Arial,sans-serif;border:0;border-radius:6px;color:white;box-shadow:none;cursor:pointer}
#canvasReset .modal-footer .reset-yes,.mi-canvas-reset .mi-reset-yes{background:#ff690b!important}
#canvasReset .modal-footer .reset-no,.mi-canvas-reset .mi-reset-no{background:#239d50!important}
.mi-canvas-reset{box-sizing:border-box;width:240px;max-width:calc(100vw - 32px);height:fit-content!important;min-height:0!important;max-height:calc(100dvh - 32px);inset:0;margin:auto;flex:none;padding:16px 12px;border:1px solid #bbb;border-radius:10px;background:white;color:#222;box-shadow:0 5px 20px #0003;font-family:Arial,sans-serif;overflow:auto}
.mi-canvas-reset::backdrop{background:#0005}
.mi-canvas-reset p{margin:0 0 12px;text-align:center;font:20px/1.3 Arial,sans-serif}
.mi-reset-actions{display:flex;justify-content:center;gap:10px}
.mi-canvas-reset button{display:block;width:58px;min-width:58px;height:34px;min-height:34px;padding:4px;margin:0;border:0;border-radius:6px;color:white;font:600 15px/24px Arial,sans-serif;cursor:pointer;box-shadow:none;transform:none}
.mi-canvas-reset button:focus-visible{outline:2px solid #245ba5;outline-offset:3px}
.mi-reset-backdrop{position:fixed;inset:0;z-index:2147483600;background:#0005;display:flex;align-items:center;justify-content:center}

/* Reserve a separate bottom strip for Touch and Think's copyright. */
body[data-math-app=touchandthink] #app{padding-bottom:calc(22px + env(safe-area-inset-bottom, 0px))!important;box-sizing:border-box}
body[data-math-app=touchandthink]>.math-app-credit{position:fixed;left:8px;bottom:calc(3px + env(safe-area-inset-bottom, 0px));font:10px/12px Arial,sans-serif;color:#777;white-space:nowrap;pointer-events:none}

/* Phone-only corrections; no changes to desktop or tablet layouts. */
@media(max-width:600px),(max-width:950px) and (max-height:500px) and (pointer:coarse){
 /* Match before JavaScript adds menu classes or body identifiers. */
 [data-mobile-menu][data-mobile-app=leggi]:not(.mi-menu-open),
 [data-mobile-menu][data-mobile-app=euro]:not(.mi-menu-open){display:none!important}
 #counter-top{position:relative!important}
 #counter-top .mi-mobile-toggle{position:absolute!important;left:auto!important;right:48px!important;top:15px!important;margin:0!important;z-index:1005;width:32px;height:34px;line-height:1}
 .counting-layout{display:flex!important;flex-direction:column!important;height:100vh!important;height:100dvh!important;min-height:0!important;padding-bottom:0!important}
 .counting-layout>.row:first-child{flex:0 0 88px!important;min-height:88px!important}
 .counting-layout>.counting-play-area{flex:1 1 0!important;min-height:0!important;display:flex!important;margin-top:10px!important;margin-bottom:12px!important}
 .counting-play-area>.row{flex:1;min-height:0!important;width:100%;height:100%!important;align-items:stretch!important}
 .counting-play-area>.row>div{height:100%!important;min-height:0!important;align-items:stretch!important}
 #gameAreaContainer,#gameArena{height:100%!important;min-height:0!important}
 body:has(#menu[data-mobile-app=componi]) #number-work{padding-top:clamp(35px,7dvh,65px);box-sizing:border-box}
 body:has(#menu[data-mobile-app=componi]) #composition{flex-basis:48%;min-height:115px}
}
@media(max-width:950px) and (max-height:500px) and (pointer:coarse) and (orientation:landscape){
 .counting-layout>.row:first-child{flex-basis:70px!important;min-height:70px!important}
 body:has(#menu[data-mobile-app=componi]) #number-work{padding-top:24px}
}

@media(max-width:600px),(max-width:950px) and (max-height:500px) and (pointer:coarse){
 #counter-top>a.close-icon{position:absolute!important;right:8px!important;left:auto!important;top:12px!important;bottom:auto!important;margin:0!important;transform:none!important;grid-column:auto!important;width:32px!important;height:40px!important;z-index:1006}
 #counter-top .mi-mobile-toggle{right:52px!important;left:auto!important}
}

@media(max-width:600px),(max-width:950px) and (max-height:500px) and (pointer:coarse){
 /* Counter already scales its content; prevent its unscaled layout box from scrolling. */
 html:has(#counter-top),body:has(#counter-top){width:100%!important;max-width:100%!important;min-width:0!important;overflow-x:hidden!important}
 #counter-top,#counter-viewport{box-sizing:border-box!important;width:100%!important;max-width:100%!important;min-width:0!important}
 #counter-viewport{overflow-x:hidden!important}
}
