.mg-game [hidden]{display:none!important}.mg-game{max-width:760px!important;padding:clamp(14px,3vw,28px)!important;background:radial-gradient(ellipse at 50% 0%,#22332e 0%,#11191d 55%,#0c1015 100%)!important;box-shadow:0 24px 75px #0008,inset 0 1px #d3ad5240}.mg-game h2{font-size:clamp(30px,5vw,47px);letter-spacing:.02em;color:#f8df9a;margin:8px 0 14px;text-shadow:0 3px 22px #bc7c3255}.mg-game h3{color:#f4d88d}.mg-game p{line-height:1.65}.mg-game #mg-menu-screen,.mg-game #mg-end-screen{position:relative;overflow:hidden;padding:clamp(28px,6vw,58px) 18px;animation:mgReveal .5s ease both}.mg-game #mg-menu-screen:before,.mg-game #mg-end-screen:before{content:'✦';position:absolute;inset:-95px 0 auto;z-index:0;font-size:250px;line-height:1;color:#cfa34a0b;pointer-events:none}.mg-game #mg-menu-screen>* ,.mg-game #mg-end-screen>*{position:relative}.mg-big-best{display:inline-block;margin:22px auto;padding:14px 28px;background:linear-gradient(120deg,#27362e,#172228);border:1px solid #a5814560;border-radius:14px;font-size:19px;color:#b9c9c8}.mg-big-best strong{color:#f6d783;font-size:26px}.mg-button{font-size:15px;padding:14px 29px!important;box-shadow:inset 0 1px #fff7,0 5px 0 #69431b,0 12px 25px #0006;transition:transform .15s,filter .15s,box-shadow .15s}.mg-button:hover{filter:brightness(1.12);transform:translateY(-2px);box-shadow:inset 0 1px #fff7,0 7px 0 #69431b,0 15px 25px #0007}.mg-button:active{transform:translateY(3px);box-shadow:inset 0 1px #fff7,0 2px 0 #69431b}.mg-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:4px auto 18px;max-width:610px}.mg-stats>div{background:linear-gradient(145deg,#263633,#141e23);border:1px solid #94713c85;border-radius:12px;padding:12px 10px;text-align:center;font-size:11px;letter-spacing:1px;color:#b6c7c5;font-weight:800}.mg-stats strong{display:block;margin-top:3px;color:#f8d68c;font-size:clamp(21px,4vw,31px);font-variant-numeric:tabular-nums}.mg-stats .urgent{border-color:#f46d58;box-shadow:0 0 20px #e53b3b33}.mg-stats .urgent strong{color:#ff786d;animation:mgPulse .8s infinite alternate}.mg-board{position:relative;width:min(100%,560px);aspect-ratio:1;margin:0 auto;border:2px solid #b68b49;border-radius:15px;background:radial-gradient(circle at 50% 30%,#20362f,#0c151b 85%);box-shadow:inset 0 0 0 6px #090e13,inset 0 0 40px #0009,0 12px 32px #0008;overflow:hidden;touch-action:none;user-select:none;-webkit-user-select:none}.mg-tile{position:absolute;box-sizing:border-box;width:calc(100% / 7 - 5px);height:calc(100% / 7 - 5px);margin:2.5px;border:1px solid #99713e;border-radius:11px;background:linear-gradient(145deg,#33443f,#18262c 75%);box-shadow:inset 0 1px #ffffff24,0 4px 7px #0008;display:flex;align-items:center;justify-content:center;padding:6px;cursor:grab;touch-action:none;will-change:transform,opacity;transition:box-shadow .18s,filter .18s;transform:translate3d(var(--dx,0px),var(--dy,0px),0)}.mg-tile img{width:100%;height:100%;object-fit:contain;image-rendering:pixelated;pointer-events:none;filter:drop-shadow(0 4px 3px #0009)}.mg-tile:hover{filter:brightness(1.2)}.mg-tile.selected{border-color:#ffe8a1;box-shadow:0 0 0 2px #ffdd80,0 0 22px #e6b65eaa}.mg-tile.dragging{z-index:50;cursor:grabbing;scale:1.1;filter:brightness(1.2);box-shadow:0 0 0 2px #ffe7a1,0 16px 26px #000b,0 0 25px #f2d16e77;transition:none}.mg-tile.hint-neighbor{filter:brightness(1.5);box-shadow:0 0 0 2px #b4e9b1,0 0 16px #a4f5aa77}.mg-tile.vanish{pointer-events:none;animation:mgBurst .29s ease-in forwards!important}.mg-tile.golden{border:2px solid #ffe78c;background:linear-gradient(135deg,#8e612a,#3c3321 65%);box-shadow:inset 0 0 16px #e5b75d70,0 0 14px #efc06e66}.mg-star{position:absolute;top:0;right:3px;color:#fff2a0;font-size:17px;text-shadow:0 0 9px #ffb52a;pointer-events:none}.mg-float{position:absolute;left:50%;top:42%;transform:translate(-50%,-50%);font-size:30px;font-weight:1000;color:#fff1b1;text-shadow:0 3px 3px #000,0 0 20px #edb34d;z-index:90;pointer-events:none;white-space:nowrap;animation:mgFloat 1.2s ease-out forwards}.mg-float.time{color:#a7f7c0}.mg-float.combo{font-size:42px;color:#ffd26d}.mg-status{min-height:28px;color:#e5c276;margin:18px 0 12px;font-weight:700}.mg-note{font-size:12px;color:#a6b0b8;margin-top:20px}.mg-xp-row{max-width:490px;text-align:left;margin:14px auto;padding:13px 15px;border-radius:12px;background:#1d2b2d;border:1px solid #876d3f66}.mg-xp-label{display:flex;justify-content:space-between;gap:8px;color:#e5ebdf}.mg-xp-label strong{color:#f5d27f}.mg-xp-label small{font-size:10px;color:#9cb0aa}.mg-xp-track{height:13px;border-radius:20px;background:#0e181b;border:1px solid #635637;overflow:hidden;margin-top:9px}.mg-xp-fill{height:100%;width:0;background:linear-gradient(90deg,#318b68,#91d9a1,#e7c56b);border-radius:20px;transition:width 1s cubic-bezier(.2,.8,.2,1)}.mg-actions{display:flex;gap:15px;justify-content:center;flex-wrap:wrap;margin-top:26px}@keyframes mgBurst{0%{opacity:1;transform:scale(1);filter:brightness(1)}35%{opacity:1;transform:scale(1.25);filter:brightness(2.4)}100%{opacity:0;transform:scale(.1) rotate(25deg);filter:brightness(3)}}@keyframes mgFloat{0%{opacity:0;transform:translate(-50%,-25%) scale(.6)}25%{opacity:1}100%{opacity:0;transform:translate(-50%,-135%) scale(1.1)}}@keyframes mgReveal{from{opacity:0;transform:translateY(14px) scale(.98)}to{opacity:1;transform:none}}@keyframes mgPulse{to{opacity:.55}}@media(max-width:600px){.mg-board{border-radius:9px}.mg-tile{padding:2px;margin:1px;width:calc(100% / 7 - 2px);height:calc(100% / 7 - 2px);border-radius:6px}.mg-game{padding:12px!important}.mg-stats>div{padding:9px 4px;font-size:9px}.mg-float{font-size:22px}}
/* V4: premium arcade shell, menus and fullscreen */
.mg-game{max-width:920px!important;border:1px solid #aa874e;position:relative;isolation:isolate}.mg-game:before{content:'';position:absolute;inset:0;pointer-events:none;background:radial-gradient(circle at 50% 25%,#a7853217,transparent 48%);z-index:-1}.mg-toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:0 0 12px;margin-bottom:8px;border-bottom:1px solid #b894513d;color:#bca97d;font-size:11px;letter-spacing:.18em;font-weight:800}.mg-fullscreen{border:1px solid #b38e4e;background:linear-gradient(180deg,#314039,#172125);color:#f3d994;padding:9px 14px;border-radius:8px;cursor:pointer;font-size:12px;font-weight:800;letter-spacing:.03em}.mg-fullscreen:hover{background:#384b40;box-shadow:0 0 18px #b58a3855}.mg-game #mg-menu-screen,.mg-game #mg-end-screen{max-width:800px;margin:auto;text-align:center;padding:38px 16px 48px}.mg-game #mg-menu-screen:before,.mg-game #mg-end-screen:before{content:'';inset:0;background:radial-gradient(ellipse at center,#d4a54b14,transparent 68%)}.mg-menu-crest,.mg-results-crest{width:98px;height:98px;border-radius:50%;margin:0 auto 20px;display:grid;place-items:center;font-size:49px;color:#ffe5a4;background:radial-gradient(circle,#6d572e,#1d2b2b 72%);border:2px solid #c7a35b;box-shadow:0 0 0 7px #b9913521,0 0 42px #cfa4473b,inset 0 0 20px #d3b26a25;animation:mgCrest 4s ease-in-out infinite}.mg-game #mg-menu-screen h2,.mg-game #mg-end-screen h2{font-size:clamp(45px,8vw,74px);line-height:.95;font-weight:1000;letter-spacing:.055em;margin:20px 0;color:#fff0c3;text-shadow:0 3px 0 #5a3c19,0 12px 30px #000b}.mg-game h2 em{font-style:normal;color:#e4ac4e;text-shadow:0 2px 0 #593514,0 0 28px #a67a3266}.mg-tagline{font-size:clamp(14px,2.4vw,18px);color:#b6c7be;margin:20px 0 26px!important}.mg-menu-cards,.mg-result-stats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;max-width:600px;margin:25px auto}.mg-menu-card,.mg-result-stats>div{padding:19px 14px;background:linear-gradient(145deg,#304039,#17232a 70%);border:1px solid #b38a4d99;border-radius:14px;box-shadow:inset 0 1px #e9d49c28,0 12px 20px #0004}.mg-menu-card span,.mg-result-stats span{display:block;color:#c3b18a;font-size:11px;font-weight:900;letter-spacing:.13em}.mg-menu-card strong,.mg-result-stats strong{display:block;color:#ffe1a0;font-size:clamp(25px,4vw,37px);line-height:1.2;margin:9px 0;text-shadow:0 0 20px #e0ad4d44}.mg-menu-card small{display:block;color:#9baaa4;font-size:11px}.mg-rules{display:flex;flex-wrap:wrap;justify-content:center;gap:9px;max-width:650px;margin:24px auto 30px}.mg-rules span{padding:8px 12px;border-radius:30px;background:#101d20;border:1px solid #8a75465c;color:#d3d9c5;font-size:12px}.mg-button.mg-primary{font-size:18px;padding:18px 44px!important;letter-spacing:.06em;min-width:min(100%,320px);animation:mgButtonGlow 2.5s ease-in-out infinite}.mg-menu-footer{margin-top:28px;color:#8fa59e;font-size:12px;letter-spacing:.06em}.mg-results-crest{font-size:45px}.mg-results-divider{display:flex;align-items:center;gap:16px;justify-content:center;margin:32px 0 10px;color:#f1d28c;font-weight:900;letter-spacing:.13em}.mg-results-divider:before,.mg-results-divider:after{content:'';height:1px;max-width:100px;flex:1;background:linear-gradient(90deg,transparent,#b88f48)}.mg-results-divider:after{transform:rotate(180deg)}.mg-results-sub{font-size:13px;color:#aebfb5}.mg-xp-row{max-width:630px;padding:18px 19px;margin:13px auto;background:linear-gradient(145deg,#283b35,#132127);border-color:#aa874d80;box-shadow:inset 0 1px #ffffff12,0 9px 18px #0003}.mg-xp-label span{font-weight:900;font-size:17px;color:#f2e4c1}.mg-xp-label strong{font-size:13px}.mg-levels{display:flex;justify-content:space-between;margin-top:14px;color:#b9c8bd;font-size:12px}.mg-levels b{color:#ffe3a2}.mg-xp-track{height:17px;margin-top:9px;border:1px solid #9c824f}.mg-xp-caption{margin-top:8px;font-size:11px;color:#9aa9a3}.mg-no-xp{padding:28px;color:#d2c09a}.mg-game:fullscreen,.mg-game.mg-fullscreen-fallback{width:100vw!important;height:100vh!important;max-width:none!important;overflow:auto;background:radial-gradient(ellipse at 50% 20%,#253a31,#0a1117 72%)!important;border:0;border-radius:0;box-sizing:border-box;padding:clamp(12px,2vh,24px)!important;display:flex;flex-direction:column;justify-content:flex-start}.mg-game:fullscreen .mg-board,.mg-game.mg-fullscreen-fallback .mg-board{width:min(70vh,72vw,680px);max-width:100%}.mg-game:fullscreen #mg-menu-screen,.mg-game:fullscreen #mg-end-screen,.mg-game.mg-fullscreen-fallback #mg-menu-screen,.mg-game.mg-fullscreen-fallback #mg-end-screen{width:min(100%,800px);box-sizing:border-box}.mg-game.mg-fullscreen-fallback{position:fixed;inset:0;z-index:99999}.mg-game:fullscreen .mg-toolbar,.mg-game.mg-fullscreen-fallback .mg-toolbar{width:100%;box-sizing:border-box}.mg-game:fullscreen .mg-stats,.mg-game.mg-fullscreen-fallback .mg-stats{width:min(70vh,72vw,680px)}@keyframes mgCrest{50%{box-shadow:0 0 0 11px #b9913514,0 0 54px #cfa4475c,inset 0 0 24px #d3b26a40;transform:translateY(-3px)}}@keyframes mgButtonGlow{50%{filter:brightness(1.15);box-shadow:inset 0 1px #fff7,0 5px 0 #69431b,0 0 35px #e7b75d55}}@media(max-width:600px){.mg-toolbar{font-size:9px;letter-spacing:.06em}.mg-fullscreen{padding:8px;font-size:11px}.mg-menu-cards,.mg-result-stats{gap:9px}.mg-menu-card,.mg-result-stats>div{padding:14px 8px}.mg-menu-card span,.mg-result-stats span{font-size:9px}.mg-rules span{font-size:10px}.mg-game #mg-menu-screen,.mg-game #mg-end-screen{padding:22px 4px 30px}.mg-menu-crest,.mg-results-crest{width:75px;height:75px;font-size:38px}.mg-xp-label span{font-size:14px}}

.mg-character-label{display:block;margin:22px 0 8px;color:#e7ca7d;font-weight:800;letter-spacing:.12em;font-size:12px}.mg-character-select{display:block;width:min(440px,90%);margin:0 auto;padding:13px 16px;border:1px solid #a77c39;border-radius:10px;background:#171a20;color:#fff;font-size:17px}.mg-character-status{color:#dfb979;font-size:13px;margin:8px}.mg-leaderboard-table{width:100%;border-collapse:collapse;color:#eee}.mg-leaderboard-table th,.mg-leaderboard-table td{padding:13px;border-bottom:1px solid #56452c;text-align:left}.mg-leaderboard-table th{color:#dcb96c}.mg-board-tabs{display:flex;gap:10px;flex-wrap:wrap;margin:20px 0}.mg-board-tabs a{padding:10px 16px;background:#332817;color:#f7db9e;border:1px solid #86632d;border-radius:8px;text-decoration:none}
/* Live 50% swap preview: both resources slide into each other's slots. */
.mg-board .mg-tile.dragging{transition:transform 165ms cubic-bezier(.22,.85,.25,1),box-shadow 165ms ease,filter 165ms ease;}
.mg-board .mg-tile.mg-preview-other{z-index:30;pointer-events:none;filter:brightness(1.18);box-shadow:0 0 0 2px #ffe5a5,0 8px 18px #0009,0 0 20px #f1d27b70;transition:transform 165ms cubic-bezier(.22,.85,.25,1),box-shadow 165ms ease,filter 165ms ease;}
.mg-board .mg-tile.mg-preview-active{z-index:50;box-shadow:0 0 0 2px #ffe5a5,0 12px 24px #000b,0 0 20px #f1d27b80;}

/* Floating combat text: separate notification lanes and compact mobile sizing. */
.mg-board .mg-float{top:calc(42% + var(--float-offset,0px));font-size:clamp(16px,3vw,27px);max-width:94%;text-align:center;line-height:1.12;letter-spacing:.025em;animation:mgFloatSeparated 1.15s ease-out forwards}
.mg-board .mg-float.combo{font-size:clamp(21px,4vw,34px)}
@keyframes mgFloatSeparated{0%{opacity:0;transform:translate(-50%,-35%) scale(.78)}20%{opacity:1;transform:translate(-50%,-50%) scale(1)}75%{opacity:1}100%{opacity:0;transform:translate(-50%,-110%) scale(1.03)}}
.mg-herb-icon{font-size:clamp(20px,4vw,39px);line-height:1;pointer-events:none}
@media(max-width:600px){.mg-board .mg-float{font-size:16px}.mg-board .mg-float.combo{font-size:21px}}

/* Mobile-first fullscreen: use available viewport width; keep all controls scrollable. */
.mg-game,.mg-game *{box-sizing:border-box}
.mg-game{width:100%;min-width:0;max-width:100%;}
.mg-game #mg-game-screen{width:100%;min-width:0;max-width:100%;}
.mg-game .mg-board{width:min(100%,560px);max-width:100%;flex:none;}
.mg-game .mg-stats{width:min(100%,610px);max-width:100%;}
.mg-game .mg-toolbar{min-width:0;flex-wrap:wrap;}
.mg-game .mg-result-stats,.mg-game .mg-menu-cards{max-width:100%;}
.mg-game:fullscreen,.mg-game.mg-fullscreen-fallback{height:100dvh!important;max-height:100dvh!important;overflow-x:hidden!important;overflow-y:auto!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding-bottom:max(16px,env(safe-area-inset-bottom))!important;padding-left:max(8px,env(safe-area-inset-left))!important;padding-right:max(8px,env(safe-area-inset-right))!important;}
.mg-game:fullscreen #mg-game-screen,.mg-game.mg-fullscreen-fallback #mg-game-screen{width:100%;max-width:100%;min-width:0;flex:0 0 auto;}
.mg-game:fullscreen .mg-board,.mg-game.mg-fullscreen-fallback .mg-board{width:min(100%,min(78dvh,680px))!important;max-width:100%!important;}
.mg-game:fullscreen .mg-stats,.mg-game.mg-fullscreen-fallback .mg-stats{width:min(100%,680px)!important;}
@media(max-width:700px){
 .mg-game{padding:clamp(6px,2vw,14px)!important;overflow-x:hidden}
 .mg-game .mg-board{width:100%!important;max-width:min(100%,560px)!important;}
 .mg-game:fullscreen .mg-board,.mg-game.mg-fullscreen-fallback .mg-board{width:min(100%,min(82dvh,680px))!important;max-width:100%!important;}
 .mg-game .mg-stats{gap:5px;margin-bottom:9px;}
 .mg-game .mg-stats>div{min-width:0;padding:7px 3px;letter-spacing:0;font-size:clamp(8px,2.3vw,11px);}
 .mg-game .mg-stats strong{font-size:clamp(17px,5vw,30px);overflow-wrap:anywhere;}
 .mg-game .mg-tile{padding:clamp(1px,.8vw,5px);border-radius:clamp(4px,1.5vw,10px);}
 .mg-game .mg-toolbar{gap:6px;letter-spacing:0;}
 .mg-game .mg-fullscreen{flex-shrink:0;}
 .mg-game .mg-float{max-width:95%;white-space:normal;}
 .mg-game .mg-xp-row{max-width:100%;min-width:0;padding:12px;}
 .mg-game .mg-xp-label{flex-wrap:wrap;}
 .mg-game #mg-menu-screen h2,.mg-game #mg-end-screen h2{font-size:clamp(32px,9vw,64px);overflow-wrap:anywhere;}
}
@media(max-width:360px){.mg-game .mg-result-stats,.mg-game .mg-menu-cards{grid-template-columns:1fr}.mg-game .mg-stats strong{font-size:16px}}

/* Mobile fullscreen start-screen fix: make Enter the Mine accessible. */
.mg-game:fullscreen,.mg-game.mg-fullscreen-fallback{min-height:0!important;justify-content:flex-start!important;align-items:stretch;scrollbar-gutter:stable;}
.mg-game:fullscreen #mg-menu-screen,.mg-game.mg-fullscreen-fallback #mg-menu-screen{flex:0 0 auto!important;min-height:0!important;height:auto!important;max-height:none!important;overflow:visible!important;margin:0 auto!important;padding-bottom:max(24px,env(safe-area-inset-bottom))!important;}
.mg-game:fullscreen #mg-menu-screen .mg-primary,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-primary{position:relative;display:inline-flex;align-items:center;justify-content:center;max-width:100%;white-space:normal;min-height:48px;}
@media (max-width:700px){
 .mg-game:fullscreen,.mg-game.mg-fullscreen-fallback{padding-top:max(6px,env(safe-area-inset-top))!important;}
 .mg-game:fullscreen #mg-menu-screen,.mg-game.mg-fullscreen-fallback #mg-menu-screen{padding:8px 6px max(22px,env(safe-area-inset-bottom))!important;}
 .mg-game:fullscreen #mg-menu-screen .mg-menu-crest,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-menu-crest{width:56px;height:56px;font-size:28px;margin:4px auto 8px;}
 .mg-game:fullscreen #mg-menu-screen h2,.mg-game.mg-fullscreen-fallback #mg-menu-screen h2{font-size:clamp(27px,8vw,43px);line-height:1.04;margin:8px 0;}
 .mg-game:fullscreen #mg-menu-screen .mg-tagline,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-tagline{margin:8px 0 12px!important;font-size:13px;line-height:1.35;}
 .mg-game:fullscreen #mg-menu-screen .mg-menu-cards,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-menu-cards{margin:10px auto;gap:8px;}
 .mg-game:fullscreen #mg-menu-screen .mg-menu-card,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-menu-card{padding:8px 6px;}
 .mg-game:fullscreen #mg-menu-screen .mg-menu-card strong,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-menu-card strong{font-size:clamp(20px,6vw,27px);margin:3px 0;}
 .mg-game:fullscreen #mg-menu-screen .mg-rules,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-rules{margin:10px auto;gap:5px;}
 .mg-game:fullscreen #mg-menu-screen .mg-rules span,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-rules span{padding:5px 8px;font-size:10px;}
 .mg-game:fullscreen #mg-menu-screen .mg-primary,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-primary{padding:12px 16px!important;font-size:16px;}
 .mg-game:fullscreen #mg-menu-screen .mg-menu-footer,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-menu-footer{margin-top:12px;}
}
@media (max-height:650px) and (max-width:900px){.mg-game:fullscreen #mg-menu-screen .mg-rules,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-rules{margin:6px auto;}.mg-game:fullscreen #mg-menu-screen .mg-menu-crest,.mg-game.mg-fullscreen-fallback #mg-menu-screen .mg-menu-crest{width:42px;height:42px;font-size:22px;margin:2px auto 5px;}}

/* Mobile results: scrollable, fully contained and safe-area aware. */
.mg-game #mg-end-screen{box-sizing:border-box;min-width:0;max-width:100%;overflow-wrap:anywhere;}
.mg-game #mg-end-screen .mg-xp-row,.mg-game #mg-end-screen .mg-result-stats,.mg-game #mg-end-screen .mg-actions{box-sizing:border-box;min-width:0;max-width:100%;}
.mg-game #mg-end-screen .mg-xp-label,.mg-game #mg-end-screen .mg-levels{min-width:0;flex-wrap:wrap;gap:5px 10px;}
.mg-game #mg-end-screen .mg-xp-caption{overflow-wrap:anywhere;}
.mg-game:fullscreen,.mg-game.mg-fullscreen-fallback{height:100dvh!important;max-height:100dvh!important;overflow-y:auto!important;overflow-x:hidden!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;}
.mg-game:fullscreen #mg-end-screen,.mg-game.mg-fullscreen-fallback #mg-end-screen{flex:0 0 auto!important;width:min(100%,800px)!important;min-height:0!important;height:auto!important;max-height:none!important;overflow:visible!important;margin:0 auto!important;padding-bottom:max(32px,env(safe-area-inset-bottom))!important;}
@media(max-width:700px){
 .mg-game #mg-end-screen{padding:12px 5px max(28px,env(safe-area-inset-bottom))!important;}
 .mg-game #mg-end-screen .mg-results-crest{width:52px;height:52px;font-size:27px;margin:4px auto 8px;}
 .mg-game #mg-end-screen h2{font-size:clamp(28px,8vw,44px)!important;line-height:1.05;margin:8px 0 12px;}
 .mg-game #mg-end-screen .mg-result-stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;margin:12px auto;}
 .mg-game #mg-end-screen .mg-result-stats>div{min-width:0;padding:10px 5px;}
 .mg-game #mg-end-screen .mg-result-stats strong{font-size:clamp(19px,6vw,29px);overflow-wrap:anywhere;}
 .mg-game #mg-end-screen .mg-results-divider{margin:18px 0 8px;gap:8px;font-size:12px;}
 .mg-game #mg-end-screen .mg-xp-row{margin:8px auto;padding:10px 9px;}
 .mg-game #mg-end-screen .mg-xp-label span{font-size:14px;}
 .mg-game #mg-end-screen .mg-levels{font-size:11px;margin-top:9px;}
 .mg-game #mg-end-screen .mg-xp-track{height:12px;margin-top:7px;}
 .mg-game #mg-end-screen .mg-actions{gap:9px;margin-top:16px;}
 .mg-game #mg-end-screen .mg-actions .mg-button{max-width:100%;min-width:0;white-space:normal;padding:12px 14px!important;}
}
/* Resource Madness Duel Lobby — Phase 1 */
.rm-duel-entry{margin-top:12px;background:linear-gradient(135deg,#3b5c50,#1b302c);border:1px solid #b6a16c;color:#fff2cf}
#rm-duel-lobby{padding:26px;background:radial-gradient(ellipse at 50% 0,#375b48,#142821 70%);color:#f4ead0;min-height:430px}
#rm-duel-lobby[hidden]{display:none}
.rm-duel-heading{text-align:center;font-size:clamp(27px,5vw,46px);color:#f5d58e;margin:4px 0}
.rm-duel-sub{text-align:center;color:#b8cdbd;margin-bottom:22px}
.rm-duel-layout{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.rm-duel-card{border:1px solid #8c815c;border-radius:14px;background:#122a27d9;padding:16px;min-width:0}
.rm-duel-card h3{margin:0 0 12px;color:#eed89c}
.rm-duel-player{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 8px;border-bottom:1px solid #526d58}
.rm-duel-player button,.rm-duel-chat-form button{border:1px solid #cfb878;background:#5d4931;color:#fff2d4;padding:10px 14px;border-radius:8px;cursor:pointer}
#rm-duel-chat{height:210px;overflow-y:auto;overflow-wrap:anywhere}
#rm-duel-chat p{margin:7px 0}
.rm-duel-chat-form{display:flex;gap:8px}.rm-duel-chat-form input{min-width:0;flex:1;padding:11px;border-radius:8px;border:1px solid #718877;background:#1e3732;color:white}
#rm-duel-status{color:#ffe3a2;min-height:25px;text-align:center;margin:14px 0}
@media(max-width:650px){.rm-duel-layout{grid-template-columns:1fr}#rm-duel-lobby{padding:14px}}

/* Live duels */
.rm-live-heading{text-align:center;color:#f6d89b;font-size:1.25rem;font-weight:900;margin:1rem}.rm-live-layout{display:grid;grid-template-columns:1fr 1fr;gap:18px;padding:16px}.rm-live-side{min-width:0;background:linear-gradient(160deg,#173c35,#0c2528);border:2px solid #8c784d;border-radius:16px;padding:12px;color:#e9f4e6}.rm-live-hud{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px;margin-bottom:12px}.rm-live-hud strong{color:#f4d590}.rm-live-board{position:relative;width:100%;aspect-ratio:1/1;background:#1d403a;border:4px solid #8b774c;border-radius:10px;touch-action:none;overflow:hidden}.rm-live-tile{position:absolute;width:14.285714%;height:14.285714%;padding:2px;box-sizing:border-box;background:linear-gradient(140deg,#3e6855,#24473d);border:1px solid #638875;border-radius:5px;display:flex;align-items:center;justify-content:center;cursor:pointer}.rm-live-tile img{width:88%;height:88%;object-fit:contain;pointer-events:none}.rm-live-tile.golden{background:linear-gradient(135deg,#9a7134,#f0c467);border-color:#ffdf92}.rm-live-star{position:absolute;right:1px;top:0;color:#fff1a1;font-size:12px}.rm-live-spectator .rm-live-tile{cursor:default}.rm-tile-arrive{animation:rmArrive .35s ease-out}.rm-live-combo{position:absolute;left:50%;top:45%;transform:translate(-50%,-50%);font-weight:900;color:#ffe7a1;font-size:2rem;pointer-events:none;animation:rmBadge .55s ease-out forwards;text-shadow:0 2px 5px #000;z-index:4}@keyframes rmArrive{from{opacity:.3;transform:translateY(-14px)}to{opacity:1;transform:none}}@keyframes rmBadge{to{opacity:0;transform:translate(-50%,-95%)}}#rm-duel-results{text-align:center;padding:36px 16px;color:#f5e6c4}#rm-duel-results h2{font-size:clamp(2rem,5vw,4rem);color:#f8d487}#rm-duel-result-note{max-width:600px;margin:20px auto;color:#c8d6cf}@media(max-width:680px){.rm-live-layout{grid-template-columns:1fr}.rm-live-side{max-width:540px;width:100%;margin:auto}}

/* Phase 2.1: isolate duel from solo board and keep 7x7 tiles inside each panel. */
#rm-duel-match[hidden],#rm-duel-results[hidden],#mg-game-screen[hidden],#mg-end-screen[hidden],#mg-menu-screen[hidden]{display:none!important}
#rm-duel-match{width:100%;min-width:0;overflow:hidden}
#rm-duel-match .rm-live-layout{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:8px 0}
#rm-duel-match .rm-live-side{min-width:0;padding:9px;overflow:hidden}
#rm-duel-match .rm-live-board{position:relative;width:100%;height:auto;aspect-ratio:1;min-width:0;max-width:100%;overflow:hidden;isolation:isolate}
#rm-duel-match .rm-live-tile{appearance:none;position:absolute;display:flex;align-items:center;justify-content:center;width:14.285714%;height:14.285714%;margin:0;padding:2px;min-width:0;min-height:0;overflow:hidden;touch-action:none;user-select:none;transform:translate(var(--dx,0px),var(--dy,0px));transition:transform .16s ease,filter .16s ease}
#rm-duel-match .rm-live-tile img{display:block;width:90%;height:90%;max-width:100%;max-height:100%;object-fit:contain;pointer-events:none}
#rm-duel-match .rm-live-tile.rm-swap-preview{z-index:3;filter:brightness(1.22);border-color:#ffe4a2}
#rm-duel-match .rm-live-tile.rm-selected{outline:2px solid #f6d37e;outline-offset:-3px}
#rm-duel-match .rm-live-board .rm-live-combo{z-index:10}
@media(max-width:550px){#rm-duel-match .rm-live-layout{grid-template-columns:1fr}#rm-duel-match .rm-live-side{width:100%;max-width:520px;margin:auto}}

/* Duel 2.2: same cascade feedback as solo, isolated from the solo board. */
#rm-duel-match .rm-live-board .rm-duel-float{position:absolute;left:50%;top:calc(43% + var(--lane,0)*35px);z-index:30;pointer-events:none;white-space:nowrap;font-size:clamp(15px,2.7vw,27px);font-weight:1000;color:#fff0af;text-shadow:0 3px 4px #000,0 0 16px #d9a34e;animation:rmDuelFloat 1.15s ease-out forwards}
#rm-duel-match .rm-live-board .rm-duel-float.combo{color:#ffd16d;font-size:clamp(19px,3vw,33px)}
#rm-duel-match .rm-live-board .rm-duel-float.time{color:#a7f7c0}
#rm-duel-match .rm-live-tile.rm-duel-burst{z-index:8;animation:rmDuelBurst .26s ease-in forwards!important;pointer-events:none}
#rm-duel-match .rm-live-tile.rm-tile-arrive{animation:rmDuelFall .34s cubic-bezier(.17,.85,.27,1) both}
@keyframes rmDuelBurst{0%{opacity:1;filter:brightness(1)}40%{opacity:1;transform:scale(1.18);filter:brightness(2.8)}100%{opacity:0;transform:scale(.15) rotate(18deg);filter:brightness(3)}}
@keyframes rmDuelFall{from{opacity:.2;transform:translateY(-30px) scale(.86)}to{opacity:1;transform:translateY(0) scale(1)}}
@keyframes rmDuelFloat{0%{opacity:0;transform:translate(-50%,-15%) scale(.7)}20%{opacity:1}100%{opacity:0;transform:translate(-50%,-135%) scale(1.1)}}
@media(prefers-reduced-motion:reduce){#rm-duel-match .rm-live-tile.rm-tile-arrive,#rm-duel-match .rm-live-tile.rm-duel-burst,#rm-duel-match .rm-live-board .rm-duel-float{animation-duration:.01ms!important}}

/* Duels 2.3: prioritise your interactive board; opponent is a half-size live preview.
   :has() only widens the shell while a duel is actually visible. */
.mg-game:has(#rm-duel-match:not([hidden])){max-width:1120px!important;width:100%;box-sizing:border-box}
#rm-duel-match .rm-live-layout{grid-template-columns:minmax(0,2fr) minmax(0,1fr);align-items:start;gap:18px}
#rm-duel-match .rm-live-side{width:100%;box-sizing:border-box}
#rm-duel-match .rm-live-side:first-child{border-color:#d5ac65;padding:14px}
#rm-duel-match .rm-live-side:last-child{padding:9px;opacity:.93}
#rm-duel-match .rm-live-side:last-child .rm-live-hud{font-size:clamp(10px,1.1vw,13px);gap:5px}
#rm-duel-match .rm-live-side:last-child p{font-size:12px;margin:7px 0 0}
#rm-duel-match .rm-live-side:first-child .rm-live-board{max-width:660px;margin-inline:auto}
#rm-duel-match .rm-live-side:last-child .rm-live-board{max-width:330px;margin-inline:auto}
@media(max-width:650px){
  #rm-duel-match .rm-live-layout{grid-template-columns:minmax(0,1fr);gap:12px}
  #rm-duel-match .rm-live-side:first-child{max-width:620px}
  #rm-duel-match .rm-live-side:last-child{width:min(55%,280px);max-width:280px;margin-inline:auto}
  #rm-duel-match .rm-live-side:last-child .rm-live-hud{font-size:11px}
}

/* Duel 2.4: results screen; isolated from solo mode. */
#rm-duel-results{text-align:center;padding:22px 10px 30px;position:relative;overflow:hidden}
#rm-duel-results .rm-result-panel{position:relative;max-width:760px;margin:0 auto;padding:32px clamp(14px,4vw,45px);background:linear-gradient(145deg,#152f2c,#10201f 70%,#24372a);border:2px solid #9d8050;border-radius:24px;box-shadow:0 18px 50px #0009,inset 0 0 35px #d1a45212;color:#f4e8cf}
#rm-duel-results .rm-result-glow{position:absolute;inset:-120px 10% auto;height:240px;background:radial-gradient(ellipse,#e2b6592c,transparent 70%);pointer-events:none}
#rm-duel-results .rm-result-crest{font-size:58px;margin:14px 0 2px;filter:drop-shadow(0 6px 12px #0009)}
#rm-duel-results h2{font-size:clamp(38px,7vw,64px);color:#f9d48b;text-shadow:0 3px 0 #493522,0 8px 24px #000;margin:5px 0 12px;letter-spacing:3px}
#rm-duel-results[data-outcome=loss] h2{color:#c5d1d4}#rm-duel-results[data-outcome=draw] h2{color:#e5e1bc}
#rm-duel-results .rm-result-sub{min-height:42px;color:#d7c9ab;margin:0 auto 18px;max-width:540px}
#rm-duel-results .rm-result-versus{display:grid;grid-template-columns:minmax(0,1fr) 46px minmax(0,1fr);align-items:center;gap:10px;margin:20px 0}
#rm-duel-results .rm-result-fighter{display:flex;flex-direction:column;gap:6px;min-width:0;padding:18px 8px;border:1px solid #8b754e;border-radius:14px;background:#0c211f}
#rm-duel-results .rm-result-fighter small{font-size:11px;color:#d2bd89;letter-spacing:1px}#rm-duel-results .rm-result-fighter strong{font-size:clamp(23px,4.5vw,39px);color:#f9e5b5}#rm-duel-results .rm-result-fighter span{overflow-wrap:anywhere;color:#e4e4d7}#rm-duel-results .rm-result-vs{font-weight:1000;color:#e0b966}
#rm-duel-results .rm-result-rewards{padding:17px;background:#091d1b;border:1px solid #526b54;border-radius:14px;margin:20px 0 25px;text-align:left}#rm-duel-results .rm-result-reward-row{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:8px 2px;color:#dddbbd}#rm-duel-results .rm-result-reward-row strong{color:#f7d48b;font-size:20px}#rm-duel-results .rm-result-xp-details{display:grid;gap:12px;margin-top:12px}#rm-duel-results .rm-result-skill{background:#17312c;padding:11px;border-radius:9px}#rm-duel-results .rm-result-skill-head{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap}#rm-duel-results .rm-result-skill-head span,#rm-duel-results .rm-result-skill small{color:#c6d7b9}#rm-duel-results .rm-result-track{height:10px;background:#081b18;border-radius:20px;overflow:hidden;margin:9px 0 5px}#rm-duel-results .rm-result-track span{display:block;height:100%;background:linear-gradient(90deg,#55ad75,#b9e08a);border-radius:20px}
@media(max-width:520px){#rm-duel-results .rm-result-versus{gap:5px;grid-template-columns:minmax(0,1fr) 27px minmax(0,1fr)}#rm-duel-results .rm-result-fighter{padding:12px 4px}#rm-duel-results .rm-result-vs{font-size:12px}}

/* Duel 2.5: separate start actions without affecting solo game. */
#mg-menu-screen .rm-start-actions{display:flex;justify-content:center;align-items:center;gap:22px;flex-wrap:wrap;margin:22px auto 0;max-width:100%;}
#mg-menu-screen .rm-start-actions > .mg-button{margin:0!important;flex:0 1 auto;max-width:100%;}
@media(max-width:650px){#mg-menu-screen .rm-start-actions{flex-direction:column;gap:14px;}#mg-menu-screen .rm-start-actions > .mg-button{width:min(100%,340px);}}

/* Duel 2.6: self-contained chat and challenge overlay */
#rm-duel-chat{display:flex;flex-direction:column;gap:9px;padding:12px;background:linear-gradient(160deg,#10251f,#192d2a);border:1px solid #52634b;border-radius:13px;scroll-behavior:smooth}
#rm-duel-chat .rm-chat-message{max-width:92%;padding:9px 12px;border-radius:12px;background:#28443d;border:1px solid #4c685b;box-shadow:0 3px 9px #0003;overflow-wrap:anywhere}
#rm-duel-chat .rm-chat-message.own{align-self:flex-end;background:#53472c;border-color:#967746}
#rm-duel-chat .rm-chat-name{font-weight:800;color:#f4d58d;font-size:12px;margin-bottom:3px}
#rm-duel-chat .rm-chat-body{color:#f5f1df;line-height:1.45;font-size:14px}
#rm-duel-chat .rm-chat-time{color:#b3bdb2;font-size:10px;text-align:right;margin-top:4px}
.rm-invite-overlay[hidden]{display:none!important}
.rm-invite-overlay{position:fixed;inset:0;z-index:2147483640;display:grid;place-items:center;padding:18px;background:#050b0ad9;backdrop-filter:blur(7px)}
.rm-invite-panel{width:min(100%,460px);text-align:center;padding:30px 24px;border-radius:20px;border:2px solid #d5a85c;background:radial-gradient(ellipse at top,#35463b 0%,#13241f 76%);box-shadow:0 0 0 6px #d7ae5324,0 22px 90px #000b;color:#f7ebcf}
.rm-invite-crest{font-size:44px;filter:drop-shadow(0 2px 9px #c78b4b)}
.rm-invite-kicker{font-size:11px;font-weight:800;letter-spacing:2px;color:#dcb76e;margin:8px 0}
.rm-invite-panel h2{font-size:clamp(25px,5vw,37px);line-height:1.15;color:#ffe3a2;margin:8px 0 15px}
.rm-invite-panel p{line-height:1.55}.rm-invite-panel p strong{color:#f9d387}
.rm-invite-countdown{font-size:13px;color:#c2cbbb}
.rm-invite-actions{display:flex;gap:12px;margin-top:22px}
.rm-invite-actions button{flex:1;min-height:49px;padding:10px 12px;border-radius:10px;font-weight:900;cursor:pointer;border:1px solid #9a8261;color:#fff5dd;background:#563b37}
#rm-invite-accept{background:linear-gradient(#eac77e,#b98236);color:#21190f;border-color:#ffe3a2}
.rm-invite-actions button:focus-visible{outline:3px solid white;outline-offset:3px}
@media(max-width:420px){.rm-invite-actions{flex-direction:column}}

/* 2.8: keep opponent preview inside the viewport, including fullscreen mobile. */
#mg-game-shell,#rm-duel-match,#rm-duel-match .rm-live-layout,#rm-duel-match .rm-live-side{min-width:0;max-width:100%;box-sizing:border-box}
#rm-duel-match .rm-live-layout{width:100%;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:clamp(8px,1.5vw,18px);padding:8px 0}
#rm-duel-match .rm-live-side{width:100%;max-width:100%;margin:0;overflow:hidden}
#rm-duel-match .rm-live-board{width:100%;max-width:100%;box-sizing:border-box}
#rm-duel-match .rm-live-hud{min-width:0;overflow-wrap:anywhere}
@media(max-width:760px){
 #rm-duel-match .rm-live-layout{grid-template-columns:minmax(0,1fr);gap:10px;padding:6px 0}
 #rm-duel-match .rm-live-side:first-child{width:100%;max-width:100%;padding:8px}
 #rm-duel-match .rm-live-side:last-child{width:min(50%,260px);max-width:100%;padding:6px;justify-self:center;margin:0}
 #rm-duel-match .rm-live-side:last-child .rm-live-hud{font-size:10px;line-height:1.25;gap:4px}
 #rm-duel-match .rm-live-side:last-child p{font-size:10px}
}
/* Mobile fullscreen: results must reflow, never overflow the screen. */
#mg-game-shell:fullscreen,#mg-game-shell.mg-fullscreen-fallback{min-width:0;max-width:none!important;box-sizing:border-box;overflow-x:hidden!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch}
#mg-game-shell:fullscreen #mg-end-screen,#mg-game-shell:fullscreen #rm-duel-results,#mg-game-shell.mg-fullscreen-fallback #mg-end-screen,#mg-game-shell.mg-fullscreen-fallback #rm-duel-results{width:100%;min-width:0;max-width:100%;box-sizing:border-box;overflow-x:hidden;padding:clamp(10px,3vw,24px)}
#mg-game-shell:fullscreen #rm-duel-results .rm-result-panel,#mg-game-shell.mg-fullscreen-fallback #rm-duel-results .rm-result-panel{width:100%;max-width:100%;min-width:0;box-sizing:border-box;padding:clamp(12px,3vw,28px)}
#mg-game-shell:fullscreen #rm-duel-results .rm-result-versus,#mg-game-shell.mg-fullscreen-fallback #rm-duel-results .rm-result-versus{width:100%;min-width:0;grid-template-columns:minmax(0,1fr) 22px minmax(0,1fr);gap:4px}
#rm-duel-results .rm-result-fighter,#rm-duel-results .rm-result-rewards,#rm-duel-results .rm-result-reward-row,#mg-end-screen .mg-result-stats,#mg-end-screen .mg-actions{min-width:0;max-width:100%;box-sizing:border-box}
#rm-duel-results .rm-result-fighter strong,#rm-duel-results .rm-result-fighter span,#rm-duel-results .rm-result-reward-row strong{overflow-wrap:anywhere;word-break:break-word}
@media(max-width:540px){
 #mg-game-shell:fullscreen,#mg-game-shell.mg-fullscreen-fallback{padding:8px!important}
 #rm-duel-results h2{font-size:clamp(26px,8vw,42px);letter-spacing:1px}
 #rm-duel-results .rm-result-crest{font-size:40px}
 #rm-duel-results .rm-result-fighter{padding:10px 4px}
 #rm-duel-results .rm-result-fighter strong{font-size:clamp(18px,5vw,27px)}
 #rm-duel-results .rm-result-reward-row{flex-wrap:wrap}
 #mg-end-screen .mg-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:10px}
 #mg-end-screen .mg-actions .mg-button{min-width:0;max-width:100%;white-space:normal}
}
.mg-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
.mg-toolbar .rm-install-btn{margin-left:0;white-space:nowrap}
.mg-toolbar .rm-install-btn[hidden]{display:none!important}

/* 3.1 Mobile fullscreen duel: keep both 7x7 boards fully within visible viewport.
   Match grid is stacked on touch devices in portrait AND landscape. */
@media (pointer:coarse), (max-width:820px) {
  #mg-game-shell:fullscreen,
  #mg-game-shell.mg-is-fullscreen,
  #mg-game-shell.mg-fullscreen-fallback {
    width:100%!important; max-width:100%!important;
    height:100dvh; overflow-x:clip!important; overflow-y:auto!important;
    box-sizing:border-box; padding:clamp(4px,1.5vw,12px)!important;
  }
  #rm-duel-match, #rm-duel-match .rm-live-layout {
    width:100%!important; max-width:100%!important; min-width:0!important;
    box-sizing:border-box!important;
  }
  #rm-duel-match .rm-live-layout {
    display:grid!important; grid-template-columns:minmax(0,1fr)!important;
    justify-items:center; gap:10px; padding:4px 0!important;
  }
  #rm-duel-match .rm-live-side:first-child,
  #rm-duel-match .rm-live-side:last-child {
    width:100%!important; max-width:100%!important; min-width:0!important;
    margin:0!important; justify-self:center!important; box-sizing:border-box!important;
  }
  #rm-duel-match .rm-live-side:first-child {padding:clamp(5px,1.5vw,10px)!important;}
  #rm-duel-match .rm-live-side:last-child {
    width:min(52%,280px)!important;
    padding:6px!important;
  }
  #rm-duel-match .rm-live-board {
    display:block; width:100%!important; max-width:100%!important;
    min-width:0!important; height:auto!important; aspect-ratio:1/1;
    box-sizing:border-box!important; margin-inline:auto!important;
  }
  #rm-duel-match .rm-live-hud {min-width:0;max-width:100%;flex-wrap:wrap;overflow-wrap:anywhere;}
}
/* Fallback for iOS/mobile browsers that report a fine pointer. */
@media (max-width:950px) and (max-height:600px) {
  #mg-game-shell:fullscreen #rm-duel-match .rm-live-layout,
  #mg-game-shell.mg-is-fullscreen #rm-duel-match .rm-live-layout {
    grid-template-columns:minmax(0,1fr)!important;
  }
  #mg-game-shell:fullscreen #rm-duel-match .rm-live-side:last-child,
  #mg-game-shell.mg-is-fullscreen #rm-duel-match .rm-live-side:last-child {
    width:min(52%,280px)!important;max-width:100%!important;
  }
}

/* 3.2: viewport-aware duel sizing. Never use overflow clipping as a substitute for sizing. */
html,body{max-width:100%;}
#mg-game-shell:has(#rm-duel-match:not([hidden])){width:100%!important;max-width:100%!important;min-width:0!important;}
#rm-duel-match{width:100%!important;max-width:100%!important;min-width:0!important;overflow:visible!important;}
#rm-duel-match .rm-live-layout{box-sizing:border-box!important;width:100%!important;max-width:100%!important;min-width:0!important;}
#rm-duel-match .rm-live-side{min-width:0!important;max-width:100%!important;box-sizing:border-box!important;}
#rm-duel-match .rm-live-board{box-sizing:border-box!important;aspect-ratio:1!important;min-width:0!important;max-width:100%!important;}
@media (pointer:coarse), (max-width:900px){
 #mg-game-shell:has(#rm-duel-match:not([hidden])){padding:6px!important;}
 #rm-duel-match .rm-live-layout{display:flex!important;flex-direction:column!important;align-items:center!important;gap:10px!important;padding:4px 0!important;}
 #rm-duel-match .rm-live-side:first-child,#rm-duel-match .rm-live-side:last-child{flex:0 0 auto!important;margin:0 auto!important;min-width:0!important;max-width:100%!important;}
 #rm-duel-match .rm-live-side:first-child{width:min(100%,var(--rm-duel-own-width,480px))!important;padding:6px!important;}
 #rm-duel-match .rm-live-side:last-child{width:min(100%,var(--rm-duel-rival-width,240px))!important;padding:5px!important;}
 #rm-duel-match .rm-live-board{width:100%!important;height:auto!important;}
 #rm-duel-match .rm-live-hud{gap:4px!important;margin-bottom:5px!important;font-size:clamp(10px,2.6vw,14px)!important;}
 #rm-duel-match .rm-live-heading{margin:5px 0!important;font-size:clamp(13px,3.5vw,19px)!important;}
}

/* 3.3 - Landscape: size BOTH boards by actual available width and height. */
@media (orientation:landscape) and (max-height:650px) and (pointer:coarse),
       (orientation:landscape) and (max-height:650px) and (max-width:1100px) {
 #mg-game-shell:fullscreen,#mg-game-shell.mg-is-fullscreen,#mg-game-shell.mg-fullscreen-fallback {height:100dvh!important;overflow:auto!important;max-width:100vw!important;}
 #rm-duel-match .rm-live-layout{display:flex!important;flex-direction:row!important;align-items:flex-start!important;justify-content:center!important;gap:8px!important;width:100%!important;}
 #rm-duel-match .rm-live-side:first-child{width:min(var(--rm-duel-own-width,350px),65%)!important;flex:0 1 auto!important;}
 #rm-duel-match .rm-live-side:last-child{width:min(var(--rm-duel-rival-width,180px),32%)!important;flex:0 1 auto!important;}
 #rm-duel-match .rm-live-board{aspect-ratio:1!important;max-width:100%!important;}
}
/* 3.3 - results: fit within mobile portrait AND landscape fullscreen, scroll vertically. */
@media (pointer:coarse), (max-width:950px) {
 #mg-game-shell:fullscreen,#mg-game-shell.mg-is-fullscreen,#mg-game-shell.mg-fullscreen-fallback{overflow-y:auto!important;overflow-x:hidden!important;-webkit-overflow-scrolling:touch!important;}
 #mg-end-screen,#rm-duel-results{width:100%!important;min-width:0!important;max-width:100%!important;box-sizing:border-box!important;overflow:visible!important;padding:8px!important;}
 #rm-duel-results .rm-result-panel{width:100%!important;max-width:100%!important;min-width:0!important;padding:clamp(9px,2vw,20px)!important;box-sizing:border-box!important;}
 #rm-duel-results .rm-result-versus{display:grid!important;grid-template-columns:minmax(0,1fr) 20px minmax(0,1fr)!important;gap:3px!important;width:100%!important;}
 #rm-duel-results .rm-result-fighter{min-width:0!important;padding:8px 3px!important;}
 #rm-duel-results .rm-result-fighter strong{font-size:clamp(15px,4vw,24px)!important;}
 #rm-duel-results .rm-result-rewards{padding:9px!important;margin:10px 0!important;}
 #mg-end-screen .mg-result-stats{display:flex!important;flex-wrap:wrap!important;max-width:100%!important;}
 #mg-end-screen .mg-actions{display:flex!important;flex-wrap:wrap!important;}
}
@media (orientation:landscape) and (max-height:650px) {
 #rm-duel-results .rm-result-crest{font-size:26px!important;margin:0!important;}
 #rm-duel-results h2{font-size:clamp(22px,5vh,34px)!important;margin:3px 0!important;}
 #rm-duel-results .rm-result-versus{margin:7px 0!important;}
 #rm-duel-results .rm-result-sub{min-height:0!important;margin:5px auto!important;}
 #rm-duel-results .rm-result-panel{padding:8px!important;}
 #mg-end-screen,#rm-duel-results{padding:4px!important;}
}
